fix(apps): exclude env-var overrides from app secrets export (#36186)#36187
Conversation
PR #35860 made getSecrets() overlay env-var tiers onto resolved AppSecrets. The export path built the file from getSecrets(), so a defined env override either corrupted the export (locked tier-1 secrets have a null stored value) or leaked the env value into the file. collectSecretsForExport now reads the persisted blob directly via readStoredSecrets(), so env values never enter an export; a stored value masked by an env override still exports its real stored value. Apps provisioned purely from env (no stored blob) are skipped — appKeysByHost() lists env-backed apps — and the existing empty-result guard still errors when nothing remains to export. Adds integration tests for the success (masked stored value round-trips, nothing fromEnv) and failure (env-only app -> IllegalArgumentException) paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🤖 Bedrock Review —
|
|
Claude finished @wezell's task in 1m 14s —— View job Rollback Safety Analysis
Result: ✅ Safe To RollbackLabel applied: AnalysisThe diff touches exactly two files:
Checked against every category in the rollback-unsafe reference:
The change is purely a runtime read-path fix inside |
|
Thanks for the review. Evaluated both findings: [🟠 High] [🟡 Medium] Test mutates global |
|
Re the re-run's [🟡 Medium] on |
Summary
Fixes #36186.
PR #35860 (#35859) made
AppsAPIImpl.getSecrets()overlay env-var tiers onto resolvedAppSecrets. The export path built the file fromgetSecrets(), so a defined env-var override either corrupted the export (a locked tier-1 secret has its value inenvVarValuewith anullstoredvalue) or leaked the env value into the export file.Fix
collectSecretsForExportnow reads the persisted secrets blob directly viareadStoredSecrets()instead ofgetSecrets():appKeysByHost()lists env-backed apps) are skipped, so export-all keeps working in env-provisioned deployments; the existing empty-result guard still errors when nothing remains.Admin + license are already enforced at the
exportSecrets()entry point, so bypassinggetSecrets()does not weaken access control.Tests (integration —
AppsAPIImplTest, inMainSuite3a)Test_Export_Excludes_Env_Overridden_Secret(success): storedp1masked by a host env override → export succeeds; round-trip restores the stored value (not the env value); nothing restored isfromEnv.Test_Export_Env_Only_App_Has_Nothing_To_Export(failure): app provisioned only from env →exportSecretsthrowsIllegalArgumentExceptioninstead of leaking the env value.Verification
Core installs; integration module test-compiles.
🤖 Generated with Claude Code
This PR fixes: #36186