refactor: add PROPERTY_OPERATORS constant for match_property#448
Merged
refactor: add PROPERTY_OPERATORS constant for match_property#448
Conversation
Implement 9 semver comparison operators (semver_eq, semver_neq, semver_gt, semver_gte, semver_lt, semver_lte, semver_tilde, semver_caret, semver_wildcard) for feature flag local evaluation. Uses regex-based parsing that matches the server-side sortableSemver behavior to handle v-prefix, whitespace, pre-release suffixes, and non-standard version formats. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Add input length limit before regex search to prevent polynomial backtracking on adversarial input (CodeQL py/polynomial-redos).
Replace SEMVER_EXTRACT_RE regex with simple string splitting to eliminate nested quantifiers that CodeQL flagged as polynomial-redos.
Extract all operator strings into a single source-of-truth tuple and validate against it early in match_property, replacing the fallthrough at the end of the function.
Contributor
posthog-python Compliance ReportDate: 2026-03-02 21:12:24 UTC ✅ All Tests Passed!29/29 tests passed Capture Tests✅ 29/29 tests passed View Details
|
Break the flat tuple into category-specific tuples (EQUALITY_OPERATORS, STRING_OPERATORS, etc.) that compose into PROPERTY_OPERATORS via concatenation. The semver dispatch code now references SEMVER_OPERATORS and SEMVER_COMPARISON_OPERATORS instead of repeating the full operator lists inline.
5 tasks
gustavohstrassburger
approved these changes
Mar 2, 2026
Resolve conflicts by keeping extracted operator constants (SEMVER_OPERATORS, SEMVER_COMPARISON_OPERATORS) over the inline tuples that landed from the semver targeting PR.
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
PROPERTY_OPERATORStuple as a single source of truth for whatmatch_propertysupportsmatch_propertyinstead of relying on a fallthrough at the endStacked on #447 (semver targeting).
Test plan
test_unknown_operatorstill validates unknown operators are rejected