refactor(proxy): unify inject target matching with rulesengine#201
Merged
SasSwart merged 2 commits intoMay 12, 2026
Conversation
Replace the custom shouldInjectHeaders domain/path matching with the existing rulesengine engine. Inject targets now use the same "domain=... path=..." syntax and identical matching semantics as --allow rules. Changes: - config: Remove InjectTarget struct and ParseInjectTarget. Change SessionCorrelationConfig.InjectTargets from []InjectTarget to []string (raw rule specs). DefaultInjectTargetFromEnv returns a string. ValidateSessionCorrelation delegates parsing to rulesengine.ParseAllowSpecs. - config: Simplify buildSessionCorrelation to pass raw strings. - proxy: Replace sessionCorrelation field with injectEngine (*rulesengine.Engine). shouldInjectHeaders now delegates to injectEngine.Evaluate instead of hand-rolled matching. - proxy: Add InjectEngine to proxy.Config, built from SessionCorrelation.InjectTargets at construction time. - tests: Update all session correlation tests to use raw rule strings. This resolves the behavioral differences between inject targets and allow rules: case sensitivity, wildcard/subdomain support, path glob semantics, trailing-slash normalization, and input validation are now identical.
This was referenced May 12, 2026
The behavior is already documented on the Config.ForwardTransport field. Addresses review feedback from johnstcn.
Contributor
Author
|
This refactor has simplified the branch that is based on. To streamline review, I'm merging this directly into #198 now. |
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.
PR Map
Addresses review feedback from @evgeniy-scherbina:
--allowand--session-id-inject-targetused different implementations for parsing and matching domains/paths, leading to divergent behavior.This PR replaces the custom
shouldInjectHeadersmatching with the existingrulesengine.Engine. Inject targets now use the samedomain=... path=...syntax and identical matching semantics as--allowrules.Depends on #198.
Changes
config/session_correlation.go: RemoveInjectTargetstruct andParseInjectTarget.SessionCorrelationConfig.InjectTargetsis now[]string(raw rule specs, same syntax as--allow).DefaultInjectTargetFromEnvreturns a rule string.ValidateSessionCorrelationdelegates parsing torulesengine.ParseAllowSpecs.config/config.go: SimplifybuildSessionCorrelationto pass raw strings instead of parsing into structs.proxy/proxy.go: ReplacesessionCorrelationfield withinjectEngine *rulesengine.Engine.shouldInjectHeadersdelegates toinjectEngine.Evaluateinstead of hand-rolled matching. AddInjectEnginetoproxy.Config.proxy/proxy_framework_test.go: Build inject engine from session correlation targets in test setup.proxy/proxy_session_correlation_test.go: Update all tests to use raw rule strings.config/session_correlation_test.go: Update all tests for the new[]stringtype.Behavioral differences resolved
*.example.com*path semanticspath.Match(single segment); allow: greedyNote
This PR was authored by Coder Agents.