Add detect-secrets pre-commit hook and baseline#18
Merged
Conversation
Add Yelp/detect-secrets v1.5.0 to the pre-commit config to prevent new secrets from being committed. Includes a clean baseline file generated with `detect-secrets scan`. https://claude.ai/code/session_01PS6USVBi11LZAmfhotZGHU
This reverts commit 6860318.
Add Yelp/detect-secrets to the generated project's pre-commit config with baseline support. The `just init` task now generates `.secrets.baseline` via `uvx detect-secrets scan` so the hook works out of the box. https://claude.ai/code/session_01PS6USVBi11LZAmfhotZGHU
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
initrecipe unconditionally runsuvx detect-secrets scan > .secrets.baselineand then commits it; consider making this idempotent (e.g., only regenerating/committing when the baseline changes, and guarding the commit with agit statuscheck) so rerunningjust initdoesn’t fail or clobber local updates to the baseline. - Running
detect-secrets scanwithout any path or exclusion flags will scan everything under the repo; you may want to explicitly scope or exclude paths (e.g., build artifacts, virtualenvs) to avoid noise and oversized baselines.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `init` recipe unconditionally runs `uvx detect-secrets scan > .secrets.baseline` and then commits it; consider making this idempotent (e.g., only regenerating/committing when the baseline changes, and guarding the commit with a `git status` check) so rerunning `just init` doesn’t fail or clobber local updates to the baseline.
- Running `detect-secrets scan` without any path or exclusion flags will scan everything under the repo; you may want to explicitly scope or exclude paths (e.g., build artifacts, virtualenvs) to avoid noise and oversized baselines.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Prevents silently baselining real secrets during project init. https://claude.ai/code/session_01PS6USVBi11LZAmfhotZGHU
Replace Python one-liner with the built-in detect-secrets-hook which exits non-zero when secrets are found. Run it before generating the baseline so findings aren't silently allowed. https://claude.ai/code/session_01PS6USVBi11LZAmfhotZGHU
detect-secrets-hook and detect-secrets scan are entry points from the detect-secrets package, so uvx needs --from detect-secrets. https://claude.ai/code/session_01PS6USVBi11LZAmfhotZGHU
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.
Summary
Integrate secret detection into the project's pre-commit hooks and initialization workflow to prevent accidental commits of sensitive credentials.
Key Changes
detect-secretsas a new security hook in the pre-commit configuration.secrets.baselinefiledetect-secrets scanduringjust initto create.secrets.baselineImplementation Details
uvxto run detect-secrets without requiring it as a direct project dependencyhttps://claude.ai/code/session_01PS6USVBi11LZAmfhotZGHU