Repository navigation
chore(security): 🔒 .gitignore とドキュメント追加によるコミット前検知の強化 #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
genzouw
merged 6 commits into
main
from
chore/security-gitignore-leak-prevention-2331861550921072796
May 23, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f2675a4
chore(security): 🔒 .gitignore とドキュメント追加によるコミット前検知の強化
google-labs-jules[bot] 0377463
docs: 🔒 [Code Review] gitleaks未インストール時のスキップ挙動を明記
genzouw 44bbabf
Merge remote-tracking branch 'origin/main' into chore/security-gitign…
genzouw f6a79cb
fix: 🔒 [Code Review] gitleaks CIワークフローを履歴全体スキャンに修正
genzouw 443143f
fix: 🔒 [Code Review] .gitignoreのシークレットパターンを強化
genzouw a84595f
docs: 🔒 .gitignoreの変更内容をleak-prevention.mdに反映
genzouw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # 情報漏洩防止ガイドライン (Leak Prevention) | ||
|
|
||
| 本リポジトリでは、ソースコードや設定ファイルに認証情報(API キー、パスワード、トークン、秘密鍵など)や個人情報が意図せずコミットされ、公開リポジトリを通じて漏洩することを防ぐため、以下の多層的な防御策を導入しています。 | ||
|
|
||
| ## 1. コミット前検知(ローカル防御) | ||
|
|
||
| 開発者が自身のローカル環境で誤って秘密情報をコミットするのを防ぎます。 | ||
|
|
||
| - **`gitleaks` フック**: コミット時に `.husky/pre-commit` フックを通してローカルで `gitleaks` が実行され、秘密情報を検知した場合はコミットをブロックします。 | ||
| - **⚠️ 注意**: `gitleaks` が未インストールの場合、フックはスキャンをスキップします(コミットはブロックされません)。この場合、ローカルでの秘密情報検知は行われません。 | ||
| - **必須**: 開発環境には [gitleaks](https://github.com/gitleaks/gitleaks) をインストールしてください。(例: `brew install gitleaks`)インストールしない場合、ローカル防御は機能しません。 | ||
| - **`.gitignore` による除外**: | ||
| - `.env`, `.env.*` (ただし `.env.example` は除く) | ||
| - `*.pem`, `*.key`, `id_rsa`, `id_ed25519`, `id_ecdsa`, `id_dsa`, `*credentials*.json` 等 | ||
| - AI エージェントの作業跡(`.cursor/`, `.claude/`, `.aider*` 等)はローカル環境特有の秘密情報が含まれるリスクがあるため除外しています。 | ||
|
|
||
| ## 2. CI 検知(リポジトリ防御) | ||
|
|
||
| ローカル環境の防御をすり抜けた場合でも、GitHub へプッシュされた時点で自動スキャンが実行されます。 | ||
|
|
||
| - **Gitleaks ワークフロー (`.github/workflows/gitleaks.yml`)**: | ||
| - 全ての PR と `main` ブランチへのプッシュ時に、対象となるソースコードをスキャンし、secrets の漏洩があれば CI がエラー(赤検知)となります。 | ||
| - **Trivy ワークフロー (`.github/workflows/trivy.yml`)**: | ||
| - パッケージの脆弱性や IaC の設定ミスに加え、シークレットのスキャン (`secret` スキャナ) も実施し、多角的に検知します。 | ||
| - **権限 (Permissions) の最小化**: | ||
| - CI の各ワークフロー (`.github/workflows/*.yml`) では `permissions` が明示されており、GitHub Actions が必要以上にリポジトリを書き換える権限を持たないように設計されています。 | ||
|
|
||
| ## 3. 定期監査(継続的棚卸し) | ||
|
|
||
| 過去の履歴を含めて、見逃しがないかを継続的に監視します。 | ||
|
|
||
| - **週次スケジュールスキャン**: | ||
| - `gitleaks.yml` と `trivy.yml` は cron トリガー (毎週月曜日) が設定されており、Gitコミット履歴全体のスキャン(`--log-opts="--all"` による全コミット対象)および最新の脆弱性情報の取得を自動で行います。 | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| ## 開発者の皆様へお願い | ||
|
|
||
| - 本番のシークレットや接続情報(DB、SaaS)を直接コードにハードコードせず、必ず環境変数を使用してください。 | ||
| - PR 作成時など、誤って秘密情報を含めてしまったことに気づいた場合は、速やかに管理者に連絡し、必要に応じて該当シークレットの無効化(ローテーション)を行ってください。 | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.