chore(test): tighten path handling in test utilities#135
Draft
viniciusdc wants to merge 1 commit into
Draft
Conversation
Two small hygiene fixes in test/utils/utils.go: - LoadTestDataFile now constrains its `filename` argument to stay inside test/e2e/testdata/. Previously the path was built by raw string concat — a caller passing a name with `..` would have escaped the testdata directory. Now it uses filepath.Join + filepath.Rel and rejects anything that traverses out. - UncommentCode writes its output file with mode 0600 (was 0644). Test fixtures don't need group/other readability; the existing nolint:gosec suppression was a workaround for the lint rule. Test-utility code only. No operator runtime impact. Build + lint clean; the test/utils package has no test files so there's nothing new to run against.
Docker Images BuiltImages pushed to Quay.io for branch
Test the operator: kubectl apply -k https://github.com/nebari-dev/nebari-operator.git/config/default?ref=chore/test-utils-hardening
kubectl set image deployment/nebari-operator-controller-manager manager=quay.io/nebari/nebari-operator:chore-test-utils-hardening -n nebari-operator-system |
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
Two small hygiene fixes in
test/utils/utils.go. Test-utility code only — no operator runtime impact.LoadTestDataFile'sfilenameto stay insidetest/e2e/testdata/(reject..traversal). Replaces raw string concat withfilepath.Join+filepath.Relcheck.LoadTestDataFile0600instead of0644. Test fixtures don't need group/other readability; the existingnolint:gosecworkaround for the rule comes off.UncommentCodeVerification
go build ./...— passesmake lint— 0 issuestest/utils/has no test files; nothing new to run. E2E tests that import the package still build cleanly.Why now
Routine test-utility hygiene as part of the v0.1.0 readiness pass (#129). File-level independent of #133 (deps) and #134 (manifest) — can land in any order.