Bug 47971 - UDM modules simpleLdap.items() has side effect
UDM modules simpleLdap.items() has side effect
Status: NEW
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 5.0
Other Linux
: P5 normal with 2 votes (vote)
: ---
Assigned To: UMC maintainers
UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-10-14 02:40 CEST by Daniel Tröder
Modified: 2021-04-14 10:37 CEST (History)
1 user (show)

See Also:
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:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.