feat(sandbox): add L7 query parameter matchers#617
Open
johntmyers wants to merge 2 commits intomainfrom
Open
Conversation
Signed-off-by: John Myers <9696606+johntmyers@users.noreply.github.com>
|
Three improvements from PR #617 review: 1. Decode + as space in query string values per the application/x-www-form-urlencoded convention. This matches Python's urllib.parse, JavaScript's URLSearchParams, Go's url.ParseQuery, and most HTTP frameworks. Literal + should be sent as %2B. 2. Add glob pattern syntax validation (warnings) for query matchers. Checks for unclosed brackets and braces in glob/any patterns. These are warnings (not errors) because OPA's glob.match is forgiving, but they surface likely typos during policy loading. 3. Add missing test cases: empty query values, keys without values, unicode after percent-decoding, empty query strings, and literal + via %2B encoding.
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
Add L7 query parameter matching for REST allow rules with glob and any-of matchers. This enables explicit filtering of query keys and values (including duplicate keys) while preserving current behavior when no query matcher is defined.
Related Issue
Closes #615
Changes
L7Allow.queryandL7QueryMatcher(globorany).openshell-policyfor both query matcher shapes.Testing
mise run pre-commitpassesExecuted:
mise run pre-commit(fails due pre-existing missing SPDX headers inarchitecture/plans/567-policy-l4.yaml,architecture/plans/567-policy-workaround.yaml,architecture/plans/567-policy.yaml,architecture/plans/567-test-server.py)PYTHONPATH=python .venv/bin/pytest -q e2e/python/test_sandbox_policy.py -k 'l7_query_matchers_enforced or l7_rule_without_query_matcher_allows_any_query_params'(blocked by local environment: openshell-server persistence not initialized)Checklist