fix: harden secret validation and masking - #2872
fix: harden secret validation and masking#2872Mikhail Shirkov (shirkevich) wants to merge 2 commits into
Conversation
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
baae9d2 to
2f2a2ba
Compare
c98e04b to
1dbeaa4
Compare
1dbeaa4 to
100fe74
Compare
100fe74 to
0ad5365
Compare
0ad5365 to
22cf993
Compare
22cf993 to
c1b63f7
Compare
64112b1 to
2be60fd
Compare
c1b63f7 to
39bc2dd
Compare
39bc2dd to
e2883a5
Compare
e2883a5 to
7922d6b
Compare
7922d6b to
0875add
Compare
0875add to
c0ab168
Compare
c0ab168 to
7275e09
Compare
7275e09 to
cce1d55
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## codex/helm-lifecycle-k3s #2872 +/- ##
============================================================
- Coverage 82.79% 82.77% -0.02%
============================================================
Files 1865 1864 -1
Lines 181681 181473 -208
============================================================
- Hits 150424 150223 -201
+ Misses 23395 23391 -4
+ Partials 7862 7859 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
cce1d55 to
40acdd3
Compare
|
CodeRabbit (@coderabbitai) review |
✅ Action performedReview finished.
|
📝 WalkthroughWalkthroughThe change validates secret declarations before mask-only resolution and adds masking for folded and indented YAML multiline literals. Tests cover undeclared secret inspection, backend access, multiline masking, and parameterized secret names. ChangesSecret handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/secrets/resolver_test.go (1)
81-82: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the undeclared-secret diagnostic.
require.ErrorIschecks only the sentinel. The PR objective also requires the error to includeUNDECLARED_KEYandcomponent's secrets.vars. Assert both details so the test cannot pass after the actionable message is removed.The PR objective requires the undeclared name and declaration guidance. As per coding guidelines, new behavior needs comprehensive, behavior-focused unit coverage.
Suggested assertions.
_, err := Resolve(cfg, "!secret UNDECLARED_KEY", "prod", info) require.ErrorIs(t, err, ErrSecretNotDeclared) + assert.Contains(t, err.Error(), "UNDECLARED_KEY") + assert.Contains(t, err.Error(), "component's secrets.vars")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/secrets/resolver_test.go` around lines 81 - 82, Strengthen the undeclared-secret test around Resolve by retaining the ErrSecretNotDeclared check and additionally asserting that the returned error message contains both “UNDECLARED_KEY” and “component's secrets.vars”.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkg/secrets/resolver_test.go`:
- Around line 81-82: Strengthen the undeclared-secret test around Resolve by
retaining the ErrSecretNotDeclared check and additionally asserting that the
returned error message contains both “UNDECLARED_KEY” and “component's
secrets.vars”.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: aed1f583-0698-4261-9d67-7a7f7a99b189
📒 Files selected for processing (5)
internal/exec/describe_stacks_component_processor_test.gopkg/io/masker.gopkg/io/masker_test.gopkg/secrets/resolver.gopkg/secrets/resolver_test.go
40acdd3 to
94c3eee
Compare
what
!secretreference against the component declaration registry before taking the masked-inspection fast path.This is 1 of 2 in a secret-handling follow-up stack based on #2849:
why
Masked inspection previously returned
<MASKED>before checking the declaration registry. A misspelled or malformed secret name therefore appeared valid even though execution would later fail.The masker also searched only for the exact registered literal. Serializers can indent every continuation line of a PEM key or fold a long scalar across lines, so the exact literal no longer appears in the emitted text. That allowed registered secret payload lines to remain visible in command output and CI logs.
behavior and compatibility
<MASKED>without contacting their backend.validation
pkg/ioandpkg/secretstests pass.git diff --checkand a private-name audit pass.references
Summary by CodeRabbit
Bug Fixes
Tests