Skip to content

gitleaks による CI とコミット前の機密情報検査を導入する - #115

Merged
yuji38kwmt merged 4 commits into
mainfrom
chore/add-gitleaks
Oct 23, 2026
Merged

yuji38kwmt merged 4 commits into
mainfrom
chore/add-gitleaks

Conversation

@yuji38kwmt

@yuji38kwmt yuji38kwmt commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

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 を起動できることを確認しました。

Copilot AI balanced review requested due to automatic review settings October 23, 2026 03:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

History scanning misses merge-only secret additions, and the Docker fallback can lose the caller’s configured daemon context.

2 open issues
What changed in this PR

This PR adds Gitleaks secret scanning to CI and local development, combining Git-history checks with an optional pre-commit hook.

Changes:

  • Adds history scanning for pushes and pull requests targeting main, plus manual runs.
  • Adds make gitleaks with native execution or a Docker fallback and redacted output.
  • Adds pre-commit configuration, dependencies, and developer setup instructions.
File Description
uv.lock Locks pre-commit and its dependencies.
README_for_developer.md Documents history scanning and hook installation.
pyproject.toml Adds pre-commit to development dependencies.
Makefile Adds native and Docker history-scanning commands.
.pre-commit-config.yaml Configures the official Gitleaks hook.
.gitleaks.toml Enables the default Gitleaks rules.
.github/​workflows/​gitleaks.yml Runs history scanning after a full checkout.

Review effort: Balanced

Comment thread Makefile Resolved
Comment thread Makefile Resolved
Copilot AI balanced review requested due to automatic review settings October 23, 2026 03:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused scanning integration is consistent with the stated requirements, and no blocking issues were identified.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 23, 2026 04:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No blocking issues remain, and the Docker fallback preserves the caller’s configuration as requested in the previous review.

No open issues 🎉

Review effort: Balanced

@yuji38kwmt
yuji38kwmt merged commit 826d066 into main Oct 23, 2026
7 checks passed
@yuji38kwmt
yuji38kwmt deleted the chore/add-gitleaks branch October 23, 2026 04:40
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.

2 participants