Bug 55037 - Behavior change when searching for "anything=*" via UDM in UCS 5.0
Behavior change when searching for "anything=*" via UDM in UCS 5.0
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 5.0
Other Linux
: P5 normal (vote)
: UCS 5.0-2-errata
Assigned To: Florian Best
Philipp Hahn
https://git.knut.univention.de/univen...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2022-07-27 13:08 CEST by Florian Best
Modified: 2022-09-08 11:43 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): API change, Regression
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2022-07-27 13:08:37 CEST
git:da06afda8d4c64db2c1ce2fea6b78ac4fb51ac80 introduced an `=*` operator for univention.admin.filter.expression.

So `univention.admin.filter.parse('foo=*')` results in `expression('foo', '', '=*')` instead of `expression('foo', '*', '=')`.

This change had side effects on the UDM filter generation.

Now dead code:
> modules/univention/admin/handlers/users/user.py:                        elif filter.value == u'*'
> modules/univention/admin/handlers/__init__.py:          if filter.value == '*' and property_ and issubclass(property_.syntax if inspect.isclass(property_.syntax) else type(property_.syntax), (univention.admin.syntax.IStates, univention.admin.syntax.boolean)):

Probably affected (no substring search is done anymore, so no search result is found anymore):
> modules/univention/admin/handlers/dhcp/pool.py:                 filter.value = '%s %s' % (filter.value.strip('*'), cls.permits_udm2dhcp[filter.variable])

Maybe affected:
> modules/univention/admin/handlers/users/user.py:                                userexpiry_filter = filter_format(u'(|(shadowExpire=%s)(krb5ValidEnd=%s)(sambaKickoffTime=%s))', [filter.value or '*', filter.value or '*', filter.value or '*'])

And also general different behavior:

`udm policies/registry list --filter 'registry=*'` creates `(&(objectClass=univentionPolicyRegistry)(registry=*[['']]))`  instead of `(&(objectClass=univentionPolicyRegistry)(registry=[['*']]))` - yes, both is broken but that's a different bug. There are probably also cases with valid output.

1. we have to ensure consistent behavior.
`univention.admin.filter.parse('foo=*')`, `expression('foo', '', '=*')` and `expression('foo', '*', '=')` should result in the same expression.

2. we have to fix the broken searches due to this change.
Comment 1 Florian Best univentionstaff 2022-08-25 13:38:22 CEST
Broken search filter generation has been fixed as well as consistency of presence filters is ensured.

univention-directory-manager-modules.yaml
8052b5c2c8a2 | YAML Bug #55037

univention-directory-manager-modules (15.0.13-4)
9a85531a1a64 | Bug #55037: add unittest for UDM filters
f238444de5ce | Bug #55037: add special handling for =* presence operator
ae392792af9f | Bug #55037: fix comparision with presence operator
ac696a45cc20 | Bug #55037: ensure consistent behavior
Comment 2 Philipp Hahn univentionstaff 2022-08-30 09:31:09 CEST
OK: 8052b5c2c8a2
OK: 9a85531a1a64
OK: f238444de5ce
OK: ae392792af9f
OK: ac696a45cc20
OK: apt install -t apt python-univention-directory-manager python3-univention-directory-manager python3-univention-directory-manager-cli univention-directory-manager-tools
OK: https://jenkins2022.knut.univention.de/job/UCS-5.0/job/UCS-5.0-2/job/AutotestJoin/lastCompletedBuild/testReport/
OK: udm users/user list --filter disabled=1 | grep ^DN
OK: univention-directory-manager-modules.yaml
~OK: errata-announce -V --only univention-directory-manager-modules.yaml
 changes.valid: 15.0.13-3A~5.0.0.202208161105 << 15.0.13-5A~5.0.0.202208291032