Repository navigation
fix(fixhandler): normalize a padded base path before storing it - #4822
Conversation
NewFixHandler trimmed FixInfo.BasePath for its own checks but stored the padded value, so resourceBasePath compared every resource's source path against the padded string, the containment check failed and the resource fell back to the report-wide root. The value is trimmed once, before it is checked and stored. Resolved kubescape#4816 Signed-off-by: Youssef Omar Bouden <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
matthyx
left a comment
There was a problem hiding this comment.
Reviewed head c1f0a2cc5b86c38861cc92c3e051926b9293d4a1 against master at f30072c676b13c0df4caf16898c2258a2b28d57b (PR remains open and non-draft). The change is needed: the constructor uses a trimmed base path for initial validation but retained the padded value, so resourceBasePath later rejects valid contained source paths and falls back to the report-wide root. Trimming once before storing fixes that mismatch; the regression test covers the padded valid path and preserves the whitespace-only rejection.
History: #2637 established symlink-aware path containment; #4796 added the initial BasePath validation and recorded this direct-constructor edge case as #4816. The bounded PR/issue searches found no duplicate or superseding change (searches are not exhaustive). No blockers found. The reviewed head CI passed, including the cross-platform build/test job, DCO, GitGuardian, CodeRabbit, and secret-validator; run-system-tests was skipped. I did not run tests locally because this workspace has no repository checkout, and I did not execute PR code in the shared environment.
Approve.
|
Thanks for the review and the merge. |
Overview
NewFixHandlertrimmedFixInfo.BasePathfor its own checks but stored the padded value, soresourceBasePathcompared each resource's source path against the padded string, the containment check failed and the resource fell back to the report-wide root. The value is now trimmed once, before it is checked and stored.kubescape fixandKubescape.Fixalready trim it; this covers directNewFixHandlercallers.How to Test
TestNewFixHandler_PaddedBasePathbuilds a directory report under a temp dir, passes that dir padded with whitespace as the base path and checks that a resource below it keeps its own source path. On master the handler returns the report-wide root instead.Related issues/PRs:
Summary by CodeRabbit