Repository navigation
gitleaks による CI とコミット前の機密情報検査を導入する - #154
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
History scans omit merge diffs, and the Docker fallback can fail for users relying on a non-default Docker context.
2 open issues
What changed in this PR
Adds secret scanning to CI and local development using gitleaks, with history checks and an optional pre-commit hook.
Changes:
- Runs full-history scans for pushes and pull requests targeting
main, plus manual workflow runs. - Adds
make gitleakswith native execution, a Docker fallback, and redacted output. - Configures the official pre-commit hook and documents setup.
| File | Description |
|---|---|
uv.lock |
Locks pre-commit and its dependencies. |
README_for_developer.md |
Documents history scans and hook installation. |
pyproject.toml |
Adds pre-commit to development dependencies. |
Makefile |
Adds native and Docker-based history scanning. |
.pre-commit-config.yaml |
Configures the official gitleaks hook. |
.gitleaks.toml |
Enables the default detection rules. |
.github/workflows/gitleaks.yml |
Adds CI scanning with complete Git history. |
Review effort: Balanced
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.

GitHub Actions に gitleaks の履歴検査を追加し、main への push・pull request と手動実行で機密情報の混入を検知します。
fetch-depth: 0で履歴を取得し、--log-opts="-m HEAD"でマージ時の差分も含めて現在のブランチの全履歴を検査します。make gitleaksはインストール済みの gitleaks を利用し、未導入なら公式 Docker イメージ v8.30.1 を実行します。Docker では git worktree の共通 Git ディレクトリを読み取り専用でマウントし、利用者の Docker 設定とコンテキストを引き継ぎます。必要な場合はGITLEAKS_DOCKER_CONFIGで設定ディレクトリを指定できます。検出値は--redact=100でマスクします。DevContainer にも gitleaks v8.30.1 を同梱し、コンテナ内で直接実行できます。既存のコンテナは再ビルドしてください。
公式 pre-commit フック(v8.30.1)、pre-commit の依存、既定ルールを継承する設定ファイル、開発者向けの実行手順を追加しました。
検証: 全履歴の検査はネイティブ版・Docker 版ともに成功。ダミートークンの検出とマスク、マージの競合解消時にだけ追加したトークンの検出、既定以外の Docker コンテキストの継承、明示的な設定切り替えを確認しました。実際の pre-commit フックによる機密情報を含む差分の拒否と通常の差分の通過、Python 3.15.1 での
make format・make lint・既存のローカルテストまたは CLI 起動確認、pre-commit 設定の検証も成功しています。追加検証: DevContainer と同じ Ubuntu 22.04 に公式イメージからバイナリをコピーし、一般ユーザーで v8.30.1 を起動できることを確認しました。