Skip to content

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

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
Contributor

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:49

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 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 gitleaks with 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

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

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 has no identified blocking issues in its configuration, execution paths, dependencies, or documentation.

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:19

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 unresolved blocking issues remain, and the earlier Docker configuration concern has been addressed.

No open issues 🎉

Review effort: Balanced

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