fix: enforce never-commit secrets on migrated repos, not just fresh ones - #4
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The secret-exclusion guarantee only reached repos the add-on bootstrapped.
seed_gitignore()writes its list only when no.gitignoreexists, so a repo migrated in with its own.gitignorelacking the entries could leak.google.token(OAuth),*.key,*.pem, etc. (Closes the caveat from #3.)Fix — enforcement independent of the user's
.gitignorewrite_secret_excludes()— writes the never-commit patterns (secrets, credentials,.storage/, add-on runtime files) to.git/info/excludeon every run, before the stash, so untracked secrets are never swept in. Works whether or not a.gitignoreexists.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.never_commit_patterns().Test
Extended the migration self-check: asserts an untracked
.google.tokenstays out of the backup and an already-committedleaked.keygets untracked, while real drift is still backed up. Runs green 3× (no timestamp flakiness); shellcheck clean.Bumps to 0.2.1.