Skip to content

fix: enforce never-commit secrets on migrated repos, not just fresh ones - #4

Merged
askb merged 1 commit into
mainfrom
fix/enforce-secrets-on-migrated-repos
Jul 12, 2026
Merged

fix: enforce never-commit secrets on migrated repos, not just fresh ones#4
askb merged 1 commit into
mainfrom
fix/enforce-secrets-on-migrated-repos

Conversation

@askb

@askb askb commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Problem

The secret-exclusion guarantee only reached repos the add-on bootstrapped. seed_gitignore() writes its list only when no .gitignore exists, so a repo migrated in with its own .gitignore lacking the entries could leak .google.token (OAuth), *.key, *.pem, etc. (Closes the caveat from #3.)

Fix — enforcement independent of the user's .gitignore

  • write_secret_excludes() — writes the never-commit patterns (secrets, credentials, .storage/, add-on runtime files) to .git/info/exclude on every run, before the stash, so untracked secrets are never swept in. Works whether or not a .gitignore exists.
  • untrack_secrets() — runs after the upstream sync (a staged deletion before the stash would be lost in stash/pop) and untracks any secret a prior run already committed; the removal is captured as drift and goes out through a reviewable PR.
  • Shared pattern list via never_commit_patterns().

Test

Extended the migration self-check: asserts an untracked .google.token stays out of the backup and an already-committed leaked.key gets untracked, while real drift is still backed up. Runs green 3× (no timestamp flakiness); shellcheck clean.

Bumps to 0.2.1.

The exclusion guarantee previously only reached repos the addon
bootstrapped: seed_gitignore writes its list only when no .gitignore
exists, so a repo migrated in with its own .gitignore lacking secret
entries could leak an OAuth token (.google.token), *.key/*.pem, etc.

Generalize enforcement independent of .gitignore:
- write_secret_excludes(): writes the never-commit patterns (secrets,
  credentials, .storage/, addon runtime files) to .git/info/exclude on
  every run, before the stash, so untracked secrets are never swept in.
- untrack_secrets(): runs after the upstream sync (a staged deletion
  before the stash would be lost in stash/pop) and untracks any secret a
  prior run already committed, so the removal is captured as drift and
  goes out through a reviewable PR.

Extends the migration self-check to assert an untracked secret is kept
out AND an already-committed key gets untracked.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
@askb
askb merged commit 3ee5e6f into main Jul 12, 2026
6 checks passed
@askb
askb deleted the fix/enforce-secrets-on-migrated-repos branch July 12, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant