Repository navigation
fix(secrets): fast, credential-free atmos secret list - #2646
Conversation
Listing secrets now requires no authenticated identity and never decrypts — it only reports whether each secret is set. - Disable per-component auth during secret-list enumeration. - SOPS status reads cleartext key names (no age key, no decrypt). - Rewrite every store Has() to a non-decrypting existence API (SSM WithDecryption=false, ASM DescribeSecret, GCP GetSecretVersion, Azure properties pager, Vault KV metadata, 1Password no-reveal). - Add tri-state status + --verify flag: remote-store status shows "unknown" by default; --verify contacts backends with a read identity. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
Warning Release Documentation RequiredThis PR is labeled
|
1 similar comment
|
Warning Release Documentation RequiredThis PR is labeled
|
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR makes ChangesCredential-Free Secret List with --verify Flag
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as runSecretList
participant Loader as loadServiceForListFn
participant Service as secrets.Service
participant Provider as sopsProvider / storeProvider
participant Backend as Remote Store / SOPS File
User->>CLI: atmos secret list [--verify]
CLI->>Loader: loadServiceForListFn(scope, verify)
alt verify=false (default)
Loader->>Service: build with AuthDisabled=true
CLI->>Service: Status(false)
Service->>Provider: providerStatusIsLocal?
alt local provider (SOPS, Keychain)
Provider->>Backend: scan cleartext keys / native Has
Backend-->>Provider: key present/absent
Provider-->>Service: (bool, nil)
else remote provider
Service-->>Service: st.Unknown = true
end
Service-->>CLI: []Status (remote = Unknown)
else verify=true
Loader->>Service: build with full auth (loadService)
CLI->>Service: Status(true)
Service->>Provider: provider.Status(coord)
Provider->>Backend: DescribeSecret / GetSecretVersion / HasMetadata
Backend-->>Provider: exists / not-found
Provider-->>Service: (bool, nil)
Service-->>CLI: []Status (Initialized/Missing)
end
CLI->>User: table with STATUS column
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/store/keychain_store.go (1)
165-171: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winAdd perf tracking to
KeychainStore.Has.This exported method performs keyring I/O but currently skips the required perf instrumentation wrapper.
As per coding guidelines: “Add
defer perf.Track(atmosConfig, "pkg.FuncName")()+ blank line to all public functions… Exceptions: … pure validation/lookup functions with no I/O.”🤖 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/store/keychain_store.go` around lines 165 - 171, The exported Has method in the KeychainStore struct performs keyring I/O but is missing required perf tracking instrumentation. Add a defer perf.Track call at the start of the Has method with the appropriate function identifier following the pattern defer perf.Track(atmosConfig, "pkg.FunctionName")(), followed by a blank line, to satisfy the coding guidelines for all public functions that perform I/O operations.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.
Inline comments:
In `@pkg/store/aws_ssm_param_store_test.go`:
- Around line 324-335: The test function `absent_returns_false` sets up an
expectation on the `mockSSM` mock object for the GetParameter method but does
not verify that this expectation was actually called. Add an assertion at the
end of the test to verify that all mock expectations were met on the mockSSM
object. This will ensure that if the code under test changes and stops calling
GetParameter, the test will fail and catch the regression.
In `@pkg/store/aws_ssm_param_store.go`:
- Around line 516-519: The error handling in the assumeRole failure path is
using a dynamic error created with fmt.Errorf instead of a static sentinel error
from errors/errors.go. Replace the fmt.Errorf call that wraps the "failed to
assume read role" message with the appropriate static error sentinel from
errors/errors.go, ensuring that downstream code can use errors.Is checks
consistently and follow the coding guideline that all errors must be wrapped
using static errors defined in errors/errors.go.
In `@pkg/store/onepassword_store.go`:
- Around line 231-233: The `Has` method currently falls back to
`s.resolve(reference)` which retrieves and reveals plaintext secret values when
the Exists operation is unavailable, breaking the metadata-only guarantee and
weakening privacy boundaries. Instead of calling resolve, implement a safe
approach that checks existence without retrieving the actual secret value. This
fix should apply to the main `Has` method implementation and the related code
section that also exhibits this fallback pattern, ensuring that existence probes
never expose secret plaintext regardless of whether the underlying SDK supports
Exists operations.
---
Outside diff comments:
In `@pkg/store/keychain_store.go`:
- Around line 165-171: The exported Has method in the KeychainStore struct
performs keyring I/O but is missing required perf tracking instrumentation. Add
a defer perf.Track call at the start of the Has method with the appropriate
function identifier following the pattern defer perf.Track(atmosConfig,
"pkg.FunctionName")(), followed by a blank line, to satisfy the coding
guidelines for all public functions that perform I/O operations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2fedf5fb-53cf-4274-8fae-9da02d6e1b3a
📒 Files selected for processing (32)
cmd/secret/deps.gocmd/secret/enumerate.gocmd/secret/fake_service_test.gocmd/secret/init.gocmd/secret/list.gocmd/secret/list_coverage_test.gocmd/secret/shared.gopkg/secrets/providers/provider.gopkg/secrets/providers/sops.gopkg/secrets/providers/sops_test.gopkg/secrets/providers/store.gopkg/secrets/service.gopkg/secrets/service_coverage_test.gopkg/secrets/service_test.gopkg/secrets/types.gopkg/secrets/validator.gopkg/store/aws_secrets_manager_store.gopkg/store/aws_secrets_manager_store_test.gopkg/store/aws_ssm_param_store.gopkg/store/aws_ssm_param_store_test.gopkg/store/azure_keyvault_store.gopkg/store/azure_keyvault_store_test.gopkg/store/google_secret_manager_store.gopkg/store/google_secret_manager_store_test.gopkg/store/hashicorp_vault_store.gopkg/store/hashicorp_vault_store_test.gopkg/store/keychain_store.gopkg/store/onepassword_store.gopkg/store/onepassword_store_test.gopkg/store/store.gowebsite/blog/2026-06-20-fast-credential-free-secret-list.mdxwebsite/docs/cli/commands/secret/list.mdx
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2646 +/- ##
==========================================
+ Coverage 80.03% 80.05% +0.02%
==========================================
Files 1361 1361
Lines 127262 127449 +187
==========================================
+ Hits 101850 102035 +185
+ Misses 19760 19748 -12
- Partials 5652 5666 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
- pkg/store: add ErrAssumeRole static sentinel and wrap all six assume-role failure paths in aws_ssm_param_store.go (errors.Is-friendly). - pkg/store: assert mock expectations in SSM Has absent_returns_false test. - pkg/store: implement metadata-only Exists on the native SDK and Connect 1Password clients so Has never resolves (reveals) the secret value under --verify; the resolve fallback now only serves clients without Exists. Adds Exists unit tests for both clients. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add unit tests covering the new credential-free `secret list` paths that Codecov flagged on PR #2646 (patch coverage 62%): per-store Has() existence -check error branches, the loadServiceForList credential-free loader, the LocalStatus capability, and SOPS keyExists error handling. All changed functions now sit at >=83% (most 90-100%); no production code changed. Reuses existing fakes/mocks and the writeMinimalAtmosProject fixture. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
pkg/store/onepassword_store_test.go (1)
247-254: ⚡ Quick winAssert malformed-reference failure is pre-client.
This test checks the error, but not the key contract that no
Exists/Resolvecall happens before reference rendering fails. Add call-count assertions to lock that behavior down.Suggested patch
func TestOnePasswordStore_Has_MalformedReference(t *testing.T) { - s := newTestOPStore(newFakeOPClient(nil), "") + fake := newFakeOPClient(nil) + s := newTestOPStore(fake, "") _, err := s.Has("prod", "api", "op://{{ .atmos_stack ") require.Error(t, err) + assert.Equal(t, 0, fake.existsCalls) + assert.Equal(t, 0, fake.resolveCalls) }🤖 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/store/onepassword_store_test.go` around lines 247 - 254, The TestOnePasswordStore_Has_MalformedReference test currently only verifies that an error is returned for a malformed reference, but does not verify the key contract that no client calls are made before the reference rendering fails. Add call-count assertions to the fakeOPClient to verify that the Exists or Resolve methods were never called after the Has method returns an error for the malformed reference string "op://{{ .atmos_stack ". This ensures the behavior is locked down that reference validation and rendering failures occur before any client interaction happens.
🤖 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.
Inline comments:
In `@cmd/secret/list_coverage_test.go`:
- Around line 100-113: The test TestRunSecretList_VerifyWithoutFullScope_Warns
is named to indicate it should verify warning output, but it only asserts that
runSecretSubcommand returns no error without actually capturing and asserting
the warning message. Modify the test to capture the stderr or stdout output from
the runSecretSubcommand call and add an explicit assertion that verifies the
expected warning text is present in that output, ensuring the warning branch
behavior is actually tested rather than just the success condition.
In `@cmd/secret/shared_loaders_test.go`:
- Around line 196-202: The test function TestLoadServiceForListSeam_Error
currently only validates the error case when verify is false. Add an additional
assertion in this test that calls loadServiceForListFn with verify set to true
and also expects an error. This ensures both branches of the seam (verify=true
and verify=false) are covered on the error path, providing comprehensive unit
test coverage as required by the coding guidelines.
---
Nitpick comments:
In `@pkg/store/onepassword_store_test.go`:
- Around line 247-254: The TestOnePasswordStore_Has_MalformedReference test
currently only verifies that an error is returned for a malformed reference, but
does not verify the key contract that no client calls are made before the
reference rendering fails. Add call-count assertions to the fakeOPClient to
verify that the Exists or Resolve methods were never called after the Has method
returns an error for the malformed reference string "op://{{ .atmos_stack ".
This ensures the behavior is locked down that reference validation and rendering
failures occur before any client interaction happens.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 03d61c39-50db-47f9-a6d8-71874498deaa
📒 Files selected for processing (8)
cmd/secret/list_coverage_test.gocmd/secret/shared_loaders_test.gopkg/secrets/providers/sops_test.gopkg/secrets/providers/store_test.gopkg/store/aws_ssm_param_store_test.gopkg/store/google_secret_manager_store_test.gopkg/store/keychain_store_test.gopkg/store/onepassword_store_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
- pkg/store/google_secret_manager_store_test.go
- pkg/secrets/providers/sops_test.go
Address review feedback on PR #2646: - Assert the `--verify`-without-full-scope warning is actually emitted (capture the UI channel via a new setupIOCapture helper), not just that the command succeeds. - Cover the verify=true error branch of the loadServiceForList seam too. Reclassify as a patch (enhancement to an unreleased feature): remove the changelog blog post and its shipped roadmap milestone. The `--verify` flag docs in secret/list.mdx remain. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏 |
Resolves conflicts from the SOPS refactor in #2643 (main), which moved pkg/secrets/providers/sops.go into the new pkg/secrets/providers/sops subpackage and added cloud-KMS auth via Atmos identity. - pkg/secrets/providers/store_test.go: kept this branch's localFakeStore + TestStoreProvider_LocalStatusCheck (testing storeProvider.LocalStatusCheck); dropped TestNewSops_FromSection/TestNewSops_NotFound, which main moved to the sops subpackage (newSopsProvider no longer lives in package providers). - pkg/secrets/providers/sops/sops_test.go: qualified this branch's added tests' references to LocalStatus and Coordinate with the providers package now that the file lives in package sops. The auto-merged sops/sops.go retains both main's cloud-KMS auth (sopsauth, keyservice, authResolver) and this branch's credential-free existence check (keyExists/branchHasKey/LocalStatusCheck). go build ./..., go vet ./..., and the full secret suite (pkg/secrets/..., pkg/store/..., cmd/secret/...) pass.
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
These changes were released in v1.222.0-rc.6. |
…2652) In processComponentEntry, per-component authentication ran before the stack and component filters and was never memoized. Any auth-enabled ExecuteDescribeStacks caller (atmos describe stacks, list values/instances, terraform --all/--query) authenticated every component in every stack before discarding the out-of-scope ones, and re-authenticated each same-identity component from scratch. On a large multi-stack repo, `atmos describe stacks -s <stack>` authenticates components in stacks other than the one requested and effectively hangs. #2646 sidestepped this for `atmos secret list` by disabling per-component auth there; this fixes the root cause in the shared processor for every other caller. - Move the stack and component filters above resolveComponentAuthManager so only in-scope components authenticate. Auth still precedes its consumers (BuildTerraformWorkspace, template and YAML-function processing). - Add a pass-scoped cache keyed by the parent chain plus a deterministic JSON fingerprint of the component auth section, so components sharing an auth section reuse one authenticated manager instead of re-running the full auth cycle (credential writes, file locks, keyring rebuilds). - Add regression tests (out-of-scope skip + cache reuse). Measured with the identical command (`describe stacks -s <stack> --logs-level Debug`, 45s budget, only the atmos binary varies): the latest release (v1.221.1) and current main both fail to complete within 45s, authenticating mostly out-of-scope components, while this change completes in ~18s (43 auths; in-scope processor-path auth reduced to 2). Related to #2639.
…secret list (#2657) `atmos secret list -s <stack>` (and `secret list -s <stack> -c <component>` without `--verify`) resolve stack/component config with authentication disabled to avoid one auth cycle per component, but still evaluated `!terraform.state`, `!terraform.output`, and `!store`. With auth disabled, those reads fall back to the default AWS credential chain and ultimately the unreachable EC2 IMDS endpoint, so listing aborts with an assume-role/credentials error even when the user is authenticated. Listing only needs the static `secrets.vars` declarations (secrets.ExtractDeclarations), which never require a resolved value. Add credentialFreeSkip() and use it in enumerateSecretScopes and loadServiceForList (non-verify) so the credentialed read functions are skipped; a skipped function leaves its raw string in place, which the extractor ignores. Authenticated paths (loadServiceAndConfig, `secret list --verify`) keep skipping only `!secret`. Write-up: docs/fixes/2026-06-23-secret-list-credential-free-skip.md Related to #2639. Follow-up to #2646, which made secret-list enumeration credential-free but left the credentialed function evaluation in place. Co-authored-by: Andriy Knysh <[email protected]>
what
atmos secret listrequire no authenticated identity and never decrypt — it only reports whether each secret is set. On a 72-component stack, listing drops from ~21–34s (it previously authenticated every component and decrypted every secret) to effectively instant.Has) to a non-decrypting metadata API: SSMGetParameterwithWithDecryption=false, Secrets ManagerDescribeSecret, GCPGetSecretVersion, Azure Key Vault properties pager, Vault KV metadata read, and a no-reveal 1Password check.STATUS(initialized/missing/unknown) plus a new--verifyflag: remote-store status showsunknownby default;--verifycontacts backends with a read/describe identity (never a decrypt identity) on a fully-scoped target.why
kms:Decrypt-style permissions).secret listslow (and prone to hanging) on real-world stacks and unusable without cloud credentials.unknown(credential-free) and opt into a real check via--verify, while local backends (SOPS) always show accurate status for free.references
atmos secret listworkload is fully addressed here); follows fix(stacks): scope per-component auth to requested stack/components #2642.website/docs/cli/commands/secret/list.mdx; changelog:fast-credential-free-secret-list.