このドキュメントでは、リポジトリのセキュリティ監視体制を構築する手順を説明します。
-
リポジトリの
Settings→Security & analysisへ移動
または直接 URL: https://github.com/Yucco-K/react-native-todo-app/settings/security_and_analysis -
以下の機能を有効化:
- ✅ Dependency graph (依存関係の可視化)
- ✅ Dependabot alerts (脆弱性アラート)
- ✅ Dependabot security updates (自動セキュリティアップデート)
- ✅ Secret scanning (機密情報の検出)
- ✅ Push protection (プッシュ前のブロック)
-
リポジトリの
Securityタブ →Code scanningへ移動 -
Set up→Defaultを選択(推奨)- CodeQL が自動的に設定されます
- または
Advancedで.github/workflows/codeql.ymlをカスタマイズ
-
設定完了後、次回のプッシュから自動スキャンが実行されます
-
Settings→Notifications→Security alerts -
以下を有効化:
- ✅ Email notifications for security alerts
- ✅ Web notifications
.github/workflows/ci.yml が追加されました。以下のチェックが自動実行されます:
- Security Scan: gitleaks による機密情報検出
- Dependency Audit: npm audit による脆弱性チェック
- Lint Check: Biome によるコード品質チェック
- Test: Jest によるユニットテスト
- Build Check: TypeScript コンパイルと Expo Doctor
次回のプッシュまたはプルリクエスト作成時に自動実行されます。
# 手動でワークフローをトリガー(オプション)
git push origin main実行結果は Actions タブで確認できます:
https://github.com/Yucco-K/react-native-todo-app/actions
Python がインストールされていることを確認:
python3 --version# pip を使用してインストール
pip3 install pre-commit
# または Homebrew(macOS)
brew install pre-commitプロジェクトルートで以下を実行:
cd /Users/yukig/dev/react-native-todo-app
pre-commit install成功すると以下のメッセージが表示されます:
pre-commit installed at .git/hooks/pre-commit
既存のファイルに対して手動実行:
pre-commit run --all-filesこれで、次回のコミット時に自動的にチェックが実行されます。
# 緊急時のみ使用(推奨しません)
git commit --no-verify -m "commit message"-
Dependabot アラート
https://github.com/Yucco-K/react-native-todo-app/security/dependabot -
Secret scanning アラート
https://github.com/Yucco-K/react-native-todo-app/security/secret-scanning -
Code scanning アラート
https://github.com/Yucco-K/react-native-todo-app/security/code-scanning
-
依存関係の更新
npm outdated npm update
-
Dependabot PR のレビュー
自動作成された PR を確認してマージ -
セキュリティアドバイザリの確認
https://github.com/advisories
- アラートの詳細を確認
- 推奨バージョンへアップデート
- テスト実行後にマージ
- 即座に対応(最優先)
- 該当のシークレットを無効化/変更
- 必要に応じて Git 履歴から削除(
git filter-repo) - 環境変数として再設定
- 重大度を確認(Critical > High > Medium > Low)
- 修正方法を確認
- コードを修正してプッシュ
# フックが正しくインストールされているか確認
ls -la .git/hooks/pre-commit
# 再インストール
pre-commit uninstall
pre-commit install.gitleaks.toml の [allowlist] セクションに除外ルールを追加:
[allowlist]
regexes = [
'''your-false-positive-pattern''',
]Actionsタブでログを確認- エラーメッセージに従って修正
- 必要に応じて
.github/workflows/ci.ymlを調整
セットアップ完了後、以下を確認してください:
- GitHub Secret Scanning を有効化
- Dependabot alerts を有効化
- Code Scanning (CodeQL) を有効化
- CI ワークフロー (
.github/workflows/ci.yml) が動作 - pre-commit フックをインストール
- 通知設定を確認
- 定期的な監視スケジュールを設定
重要: このセキュリティ監視体制は、継続的な運用が必要です。アラートが発生した場合は速やかに対応してください。