fix(dynamicpathdetector): include Internal in endpoint merge key#24
Merged
fix(dynamicpathdetector): include Internal in endpoint merge key#24
Conversation
HTTPEndpoint.Equal distinguishes endpoints by (Endpoint, Direction,
Internal), but MergeDuplicateEndpoints was keying only on
(Endpoint, Direction). Three places leaked the bug:
1. getEndpointKey — duplicate-detection at the top of the loop
would collapse two endpoints that differ only in Internal.
2. The wildcard-after-specific sweep — a :0/x Internal=false
wildcard could absorb a previously-recorded :443/x Internal=true
sibling because the sweep only checked path + direction.
3. The wildcardKey lookup for specific-after-wildcard ordering —
same omission, so a specific-port entry could fold into a
wildcard with a different Internal.
Result: profile entries that the runtime semantically considers
distinct (Internal=true vs false) were silently merged into one,
losing the internal/external distinction for that path.
Fix: include Internal in getEndpointKey, the sweep predicate, and
wildcardKey, all keyed identically so the map lookups stay
consistent.
4 new regression tests pin all three spots plus a positive sanity
check that matching-Internal merges still happen. Existing tests
unchanged.
Flagged on upstream review of kubescape#316.
|
Summary:
|
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.
HTTPEndpoint.Equal distinguishes endpoints by (Endpoint, Direction, Internal), but MergeDuplicateEndpoints was keying only on (Endpoint, Direction). Three places leaked the bug:
Result: profile entries that the runtime semantically considers distinct (Internal=true vs false) were silently merged into one, losing the internal/external distinction for that path.
Fix: include Internal in getEndpointKey, the sweep predicate, and wildcardKey, all keyed identically so the map lookups stay consistent.
4 new regression tests pin all three spots plus a positive sanity check that matching-Internal merges still happen. Existing tests unchanged.
Flagged on upstream review of kubescape#316.
Sorry, we do not accept changes directly against this repository. Please see
CONTRIBUTING.md for information on where and how to contribute instead.