rotate: 4 SaaS-token/app-signing drivers + data-separated proof tracking
Add gitlab, cloudflare, ghactions (MOCK-ONLY) and appsecret (LIVE-VM) one-file Rotators, each with a table-driven cutover-proof + leak-check test. gitlab/ cloudflare/ghactions are in-place SaaS-token rolls (self/rotate, value-roll, sealed-secret overwrite) so RevokeOld is a no-op; ghactions seals via nacl/box.SealAnonymous (no new go.mod dep). appsecret regenerates a local app signing secret and rewrites it in place across every target file (atomic, mode- preserving, redacted errors), discoverable via exact-match app-signing key names in env.go. Keep real-rotation code distinct from mock code: how each driver's cutover was validated lives as DATA in internal/rotate/proofs.go (single source of truth) + docs/ROTATION-PROOFS.md, surfaced as a PROOF column in `incredigo rotate` so a MOCK-ONLY driver can never be mistaken for a LIVE-VM one. appsecret proven LIVE-VM against real local files in the sandbox VM. 82 tests green, -race clean on rotate/sink/vault. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -141,6 +141,61 @@ func TestEnvScanner(t *testing.T) {
|
||||
"pgSECRET", "redisSECRET", "weak")
|
||||
}
|
||||
|
||||
// TestEnvScannerAppSecret proves an app SIGNING secret (SECRET_KEY) is tagged
|
||||
// Source="appsecret" with a self-contained blob carrying its value AND file path, so
|
||||
// the local in-place rotator can Detect+Rotate it straight from a .env scan — while a
|
||||
// generic API key in the same file stays a plain env secret.
|
||||
func TestEnvScannerAppSecret(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
t.Chdir(dir)
|
||||
appVal := "django-insecure-0123456789abcdefghijABCDEF"
|
||||
writeFixture(t, filepath.Join(dir, ".env"),
|
||||
"SECRET_KEY="+appVal+"\nSTRIPE_API_KEY=sk_live_keepGenericEnv00\n")
|
||||
|
||||
v := vault.New()
|
||||
defer v.Purge()
|
||||
creds, err := (&envScanner{}).Scan(context.Background(), v)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var app *Credential
|
||||
for i := range creds {
|
||||
if creds[i].Source == "appsecret" {
|
||||
app = &creds[i]
|
||||
}
|
||||
}
|
||||
if app == nil {
|
||||
t.Fatalf("SECRET_KEY not tagged Source=appsecret; got %+v", creds)
|
||||
}
|
||||
if app.Identity != ".env / SECRET_KEY" {
|
||||
t.Errorf("unexpected identity %q", app.Identity)
|
||||
}
|
||||
|
||||
// The blob must round-trip the value AND the file path for the rotator.
|
||||
buf, _ := v.Open(app.Secret)
|
||||
u, err := url.Parse(strings.TrimSpace(string(buf.Bytes())))
|
||||
if err != nil || u.Scheme != "appsecret" {
|
||||
t.Fatalf("appsecret blob malformed: %v (%q)", err, string(buf.Bytes()))
|
||||
}
|
||||
if u.Query().Get("val") != appVal {
|
||||
t.Error("appsecret blob does not carry the signing value")
|
||||
}
|
||||
if got := u.Query().Get("path"); !strings.HasSuffix(got, ".env") {
|
||||
t.Errorf("appsecret blob path missing/wrong: %q", got)
|
||||
}
|
||||
|
||||
// The generic API key in the same file must NOT be tagged appsecret.
|
||||
for _, c := range creds {
|
||||
if c.Source == "appsecret" && strings.Contains(c.Identity, "STRIPE") {
|
||||
t.Error("generic API key wrongly tagged appsecret")
|
||||
}
|
||||
}
|
||||
|
||||
// Leak-check: the signing value must not appear in any non-secret field.
|
||||
assertNoLeak(t, creds, appVal)
|
||||
}
|
||||
|
||||
func TestNetrcScanner(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
|
||||
Reference in New Issue
Block a user