Bug 47971

Summary: UDM modules simpleLdap.items() has side effect
Product: UCS Reporter: Daniel Tröder <troeder>
Component: UDM (Generic)Assignee: UMC maintainers <umc-maintainers>
Status: NEW --- QA Contact: UMC maintainers <umc-maintainers>
Severity: normal    
Priority: P5 CC: best
Version: UCS 5.0   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
See Also: https://forge.univention.org/bugzilla/show_bug.cgi?id=44944
https://forge.univention.org/bugzilla/show_bug.cgi?id=42787
What kind of report is it?: Bug Report What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: 1: Will affect a very few installed domains How will those affected feel about the bug?: 1: Nuisance – not a big deal but noticeable
User Pain: 0.017 Enterprise Customer affected?:
School Customer affected?: ISV affected?:
Waiting Support: Flags outvoted (downgraded) after PO Review:
Ticket number: Bug group (optional): API change
Max CVSS v3 score:

Description Daniel Tröder univentionstaff 2018-10-14 02:40:19 CEST
When iterating over the properties of a UDM object, they are modified.
simpleLdap.items() uses simpleLdap.__getitem__(), which changes the value to the default if it is unset.

The interface of simpleLdap mimics that of dict.items(), but items() modifying data is unexpected.

Fix could be:

def items(self):
-   return [(key, self[key]) for key in self.keys() if self.has_property(key)]
+   return [(key, self.get(key)) for key in self.keys() if self.has_property(key)]
Comment 1 Daniel Tröder univentionstaff 2019-03-18 08:24:26 CET
I guess iter{items, keys, values}() should also be provided, to allow iteration without data duplication.