Repository navigation
Conversation
Composite (and/or/not) LDAP search filters fail BER decoding: the recursive Filter() references embedded in the composite alternatives are created while Filter.componentType is still the empty univ.Choice class default, so pyasn1 snapshots an empty componentType into instance state at creation time and clone() restores that empty snapshot from the read-only initializers. Override Filter.clone() to clone against the final class definition (object side), and repair the frozen creation-time snapshots on the three embedded Filter instances (spec side: the BER decoder performs tag dispatch on the embedded spec's tagMap before cloning it). Fixes #273 Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Covers the issue #273 wire samples (plain equalityMatch control and the failing composite), byte-identical re-encode, production _parseFilter composite round-trips, deeply nested composites, all leaf alternatives, and clone invariants. Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Author
|
Could a maintainer review this recursive LDAP Filter schema fix for composite search filters? Please let me know if the decoding approach needs changing or if additional cases are needed before review. Thanks. |
Author
|
Following up once more on this one. Could a maintainer take a look when time allows, or let me know what the next step should be? Happy to make any changes needed. Thank you. |
Contributor
To be clear, I am not a maintainer of this repo, but usually this is the natural next step when a PR is opened. No need to ping everyone on each and every PR multiple times. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #273.
Composite LDAP search filters (
and/or/not) fail BER decoding: therecursive
Filter()references embedded in the composite alternatives arecreated while
Filter.componentTypeis still the emptyuniv.Choiceclass default, so pyasn1 snapshots an empty
componentTypeinto instancestate at creation time and
clone()restores that empty snapshot from theread-only initializers. Every composite member therefore decodes against
an empty schema.
Two additive changes, both required:
Filter.clone()clones against the final class-levelFilter.componentType(object side:clone()re-applies the snapshotstored in the read-only initializers).
Filter()instances' instance state is repairedafter the assignment (spec side: the BER decoder performs tag dispatch
on the embedded spec's tag map before cloning it). The read-only
initializers are deliberately left untouched: storing the recursive
reference there creates a cyclic object graph that breaks
repr()andNamedTypestag-map computation at import time.Tests
New network-free regression tests in
tests/misc/test_ldap_filter.py(7 tests): the issue's exact wire samples (plain
equalityMatchcontrolplus the failing composite request), byte-identical re-encode of the
issue's composite request, production
_parseFiltercompositeround-trips, deeply nested composites, every leaf alternative, and clone
invariants.
Verified with pyasn1 0.4.8 and 0.6.5:
non-composite controls. With the fix, all 7 pass.
tests/miscunder unittest discovery: 357 tests with one pre-existingWindows-only DPAPI error before; 364 (357 + 7 new) with the same single
pre-existing error after. No existing test outcome changed.
re-encode of the issue's plain
equalityMatchrequest).