Bug 51777 - Searching udm attributes which have complex syntax *and* are multivalue never yields results
Searching udm attributes which have complex syntax *and* are multivalue never...
Status: REOPENED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 5.0-0-errata
Assigned To: UMC maintainers
UMC maintainers
https://git.knut.univention.de/univen...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-08-06 10:39 CEST by Julia Bremer
Modified: 2024-01-04 20:57 CET (History)
6 users (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?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.034
Enterprise Customer affected?: Yes
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:
bremer: Patch_Available+


Attachments
fix filter for complex multivalue attributes (844 bytes, patch)
2020-08-06 10:39 CEST, Julia Bremer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Julia Bremer univentionstaff 2020-08-06 10:39:45 CEST
Created attachment 10451 [details]
fix filter for complex multivalue attributes

In a customer project, we created an attribute, which has a complex syntax class, consisting out of three simple syntaxes. This attribute is also multivalue.

Wenn searching the attribute like this:
udm users/user list --filter complexmultiattribut=*

no result is found even though there are results to be found.

This happens due to the constructed filter by udm looking something like this:
"(&(univentionObjectType=users/user)(!(uidNumber=0))(!(univentionObjectFlag=functional))(complexmultiattribut=['*']))"

instead of:
"(&(univentionObjectType=users/user)(!(uidNumber=0))(!(univentionObjectFlag=functional))(complexmultiattribut=*))"

The attached patch seems to fix this issue. But I am not sure if this is a correct solution.
Comment 1 Florian Best univentionstaff 2020-09-29 13:30:47 CEST
Do we have affected properties in the product?

Extended attributes are a special case here. Regulary the mapping should have transformed it into a ldap-suitable representation:
  1826 »   »   »   filter.value = mapping.mapValueDecoded(key, filter.value)
→ This should have done the trick, but seems not working for extended attributes which don't have a mapping for complex syntaxes?

The following block is also only partly correct:
  1828 »   »   if isinstance(filter.value, (list, tuple)) and filter.value:
  1829 »   »   »   # complex syntax
  1830 »   »   »   filter.value = filter.value[0]
→ multiple values should be considered.

See git:b18bcff310551223ebbf4fc551371eca35e96c72 for the reason why it was introduced.

Maybe we can go with something like this:
                if isinstance(filter.value, (list, tuple)) and filter.value:
+                       if isinstance(filter.value[0], (list, tuple)):
+                               filter.value = [mapping.mapValueDecoded(key, val) for val in filter.value]
                        # complex syntax
-                       filter.value = filter.value[0]
+                       filter.transform_to_conjunction(univention.admin.filter.conjunction(u'&', [univention.admin.filter.expression(filter.variable, val, escape=True) for val in filter.value]))
Comment 3 Jan Luttermann univentionstaff 2020-11-16 12:27:16 CET
Changed module: univention-directory-manager-modules
Comment 4 Florian Best univentionstaff 2020-11-17 10:46:26 CET
(In reply to Jan Luttermann from comment #3)
> Changed module: univention-directory-manager-modules

When you change a bug to RESOLVED FIXED, please:
* write a summary of what you did. Explain the details of the change.
* list the changed commits (e.g. with toolshed:gitlog)


REOPEN: The change backported things from UCS 5 which changes the API of UDM to return unicode instead of str.
This caused some Jenkins Tests to fail:
https://jenkins.knut.univention.de:8181/job/UCS-4.4/job/UCS-4.4-6/job/AutotestUpgrade/lastCompletedBuild/SambaVersion=s4,Systemrolle=master-part-II/testReport/99_end/01_var_log_tracebacks/master071/
https://jenkins.knut.univention.de:8181/job/UCS-4.4/job/UCS-4.4-6/job/AutotestJoin/lastCompletedBuild/SambaVersion=no-samba,Systemrolle=master-part-II/testReport/86_selenium/17_self_service_registration/master090/
https://jenkins.knut.univention.de:8181/job/UCS-4.4/job/UCS-4.4-6/job/AutotestJoin/lastCompletedBuild/SambaVersion=no-samba,Systemrolle=master-part-II/testReport/86_selenium/180_portal_entries/master090/

REOPEN: The YAML description should be a not-too-technical description of the change from an Administrator(customer) point of view. So they should contain complete sentences with correct grammar and avoid terms like "Fixed".
+ * Fixing filter functionality for multivalue
+   attributes.
Comment 5 Florian Best univentionstaff 2020-11-18 13:26:46 CET
I had to revert the complete changes, as this breaks the Portal tests.

udm settings/portal_entry list --filter="portal=cn=domain,cn=portal,cn=univention,$(ucr get ldap/base)"
→ with the patch this yields no entries anymore.

univention-directory-manager-modules (14.0.16-8)
9e5a06923aad | Revert "Bug #51777: fixed filter functionality for multivalue attributes"
Comment 6 Jan Luttermann univentionstaff 2021-01-11 17:19:54 CET
fixed with MR 60 and 59.
added tests for all relevant modules
Comment 9 Florian Best univentionstaff 2022-07-27 09:26:40 CEST
Affected properties (removed duplicates):

>>> import univention.admin.modules
>>> univention.admin.modules.update()
>>> for i in [(name, pname, prop.syntax.name) for name, module in univention.admin.modules.modules.items() for pname, prop in module.property_descriptions.items() if prop.multivalue and isinstance(prop.syntax, univention.admin.syntax.compl
ex)]:
...  print(i)
# module, property, syntax
('settings/udm_syntax', 'messagecatalog', 'Localesubdirname_and_GNUMessageCatalog')
('settings/extended_attribute', 'translationShortDescription', 'translationTupleShortDescription')
('settings/extended_attribute', 'translationLongDescription', 'translationTupleLongDescription')
('settings/extended_attribute', 'translationTabName', 'translationTupleTabName')
('settings/extended_attribute', 'translationGroupName', 'I18N_GroupName')
('settings/udm_hook', 'messagecatalog', 'Localesubdirname_and_GNUMessageCatalog')
('settings/printermodel', 'printmodel', 'printerModel')
('settings/portal_all', 'displayName', 'LocalizedDisplayName')
('settings/udm_module', 'messagecatalog', 'Localesubdirname_and_GNUMessageCatalog')
('settings/udm_module', 'umcmessagecatalog', 'UMCMessageCatalogFilename_and_GNUMessageCatalog')
('settings/extended_options', 'translationShortDescription', 'translationTupleShortDescription')
('settings/extended_options', 'translationLongDescription', 'translationTupleLongDescription')
('settings/umc_operationset', 'operation', 'UMC_CommandPattern')
('dhcp/pool', 'range', 'IPv4_AddressRange')
('dhcp/subnet', 'range', 'IPv4_AddressRange')
('dhcp/sharedsubnet', 'range', 'IPv4_AddressRange')
('users/user', 'homePostalAddress', 'postalAddress')
('users/user', 'umcProperty', 'keyAndValue')
('networks/network', 'ipRange', 'IP_AddressRange')
('saml/serviceprovider', 'LDAPattributes', 'attributeMapping')
('shares/share', 'sambaCustomSettings', 'keyAndValue')
('computers/domaincontroller_slave', 'dnsEntryZoneForward', 'dnsEntry')
('computers/domaincontroller_slave', 'dnsEntryZoneReverse', 'dnsEntryReverse')
('computers/domaincontroller_slave', 'dnsEntryZoneAlias', 'dnsEntryAlias')
('computers/domaincontroller_slave', 'dhcpEntryZone', 'dhcpEntry')
… duplication in various computer modules
('monitoring/alert', 'labels', 'keyAndValue')
('mail/folder', 'sharedFolderUserACL', 'SharedFolderUserACL')
('mail/folder', 'sharedFolderGroupACL', 'SharedFolderGroupACL')
('dns/host_record', 'mx', 'dnsMX')
('dns/srv_record', 'location', 'dnsSRVLocation')
('dns/forward_zone', 'mx', 'dnsMX')
('portals/category', 'displayName', 'LocalizedDisplayName')
('portals/entry', 'description', 'LocalizedDescription')
('portals/entry', 'keywords', 'LocalizedKeywords')
('portals/entry', 'link', 'LocalizedLink')
('policies/nfsmounts', 'nfsMounts', 'nfsMounts')
('policies/registry', 'registry', 'UCR_Variable')
Comment 10 Florian Best univentionstaff 2022-07-27 09:41:47 CEST
See also Bug #40672 git:b18bcff310551223ebbf4fc551371eca35e96c72 which adds a special case for complex syntaxes.
Comment 11 Florian Best univentionstaff 2024-01-04 20:57:12 CET
Draft which I started long time ago: https://git.knut.univention.de/univention/ucs/-/merge_requests/1009