Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #222 with matches_filters method #223

Merged
merged 4 commits into from
Sep 1, 2023

Conversation

Antelox
Copy link
Contributor

@Antelox Antelox commented Aug 16, 2023

Issue reported here: #222

I have just refactored the code in order to keep the matching logic the same and at the same time to take into account the use case that is causing the wrong matching when filters have more negated fields that matches the headers values.

I have also updated the unittest related to the task filters with negation.

In [1]: from karton.core import Task
In [2]: Task({
   ...:     "type": "sample",
   ...:     "kind": "runnable",
   ...:     "platform": "win32",
   ...:     "extension": "msix"
   ...: }).matches_filters([
   ...:         {"type": "sample", "kind": "runnable", "platform": "win*", "extension": "!msi*"},
   ...:         {"type": "sample", "kind": "runnable", "platform": "win*", "extension": "!lnk"},
   ...:         {"type": "sample", "kind": "document", "platform": "win*"}
   ...:     ])
   ...: 
Out[2]: False
$ python -m unittest discover tests/
.............
----------------------------------------------------------------------
Ran 13 tests in 0.040s

OK

Copy link
Member

@psrok1 psrok1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I was thinking about changing matched list of bools into single bool with &= operator but impact on performance is negligible for such short lists.

@psrok1 psrok1 merged commit d63ef1a into CERT-Polska:master Sep 1, 2023
5 of 6 checks passed
@psrok1 psrok1 linked an issue Sep 1, 2023 that may be closed by this pull request
psrok1 added a commit that referenced this pull request Sep 1, 2023
It was missed during code review of #223
psrok1 added a commit that referenced this pull request Sep 1, 2023
It was missed during code review of #223
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unintuitive logic of header filters with negated fields
2 participants