> For the complete documentation index, see [llms.txt](https://coky-t.gitbook.io/owasp-devsecops-guideline-ja/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coky-t.gitbook.io/owasp-devsecops-guideline-ja/v0.3/2-purosesu-process/22-kai-fa-develop/2-2-1-komitto-pre-commit/2-2-1-4-repository-hardening.md).

# 2-2-1-4-リポジトリ堅牢化 (Repository-Hardening)

コードリポジトリを保護するには、さまざまなプラクティスとテクニックを導入して、認可されていないアクセス、データ侵害、その他のセキュリティ脅威から保護します。そうすることで、コードとそれに関連するリソースの完全性、機密性、可用性を確保できます。

## 目的

* **認可されていないアクセスの防止:** 認可された担当者のみがリポジトリにアクセスして変更できるようにします。
* **機密情報の保護:** シークレット、パスワード、その他の機密データを保護します。
* **コード完全性の維持:** コードが改竄や破損しないことを確保します。
* **コンプライアンス:** コードセキュリティに関する規制および業界標準に準拠します。

## キーコンセプト

* **アクセス制御:** 誰がリポジトリにアクセスでき、どのようなアクションを実行できるかを管理します。
* **シークレット管理:** API キーやパスワードなどの機密データを安全に処理します。
* **監査と監視:** リポジトリのアクティビティを追跡し続け、セキュリティインシデントを検出して対応します。
* **コード品質とセキュリティ:** コードベースに脆弱性がないこと、およびセキュリティベストプラクティスに準拠していることを確保します。
* **バックアップとリカバリ:** データをバックアップし、障害や侵害の場合に復元できることを確保します。

## リポジトリ堅牢化のベストプラクティス

1. **アクセス制御**
   * **最小権限の原則:** ユーザーに必要最小限のパーミッションを付与します。
   * **ロールベースのアクセス制御 (RBAC):** 特定の権限を持つロールを定義し、これらの役割にユーザーを割り当てます。
   * **多要素認証 (MFA):** リポジトリへのアクセスに MFA を要求し、セキュリティの拡張レイヤを追加します。
   * **SSH キーとトークン管理:** 認証にはパスワードではなく SSH キーまたは個人アクセストークンを使用します。
2. **シークレット管理**
   * **環境変数:** 環境変数を使用して、CI/CD パイプラインのシークレットを管理します。
   * **シークレット管理ツール:** HashiCorp Vault, AWS Secrets Manager, Azure Key Vault などのツールを使用して、シークレットを安全に保存および管理します。
   * **シークレットのスキャン:** GitSecrets, TruffleHog, Talisman などのツールを使用して、リポジトリをスキャンし、誤ってコミットされたシークレットを探します。
3. **監査と監視**
   * **監査ログ:** 監査ログを有効にして定期的にレビューし、リポジトリへのアクセスと変更を監視します。
   * **アクティビティアラート:** ログイン試行の失敗や予期しないリポジトリの変更など、疑わしいアクティビティに関するアラートを設定します。
   * **リポジトリスキャン:** SonarQube や CodeQL などのツールを使用して、リポジトリの脆弱性を定期的にスキャンします。
4. **コード品質とセキュリティ**
   * **静的コード解析:** 静的解析ツールを統合して、セキュリティ脆弱性とコード品質の問題を検出します。
   * **コードレビュー:** 必須のコードレビュープロセスを導入して、すべてのコード変更が同僚によってレビューされるようにします。
   * **依存関係管理:** 依存関係を定期的に更新し、Dependabot や Snyk などのツールを使用して、サードパーティライブラリの脆弱性を検出します。
5. **バックアップとリカバリ**
   * **定期的なバックアップ:** リポジトリデータが定期的にバックアップされ、安全に保存されるようにします。
   * **災害復旧計画:** 災害復旧計画を策定しテストして、侵害や障害の場合にリポジトリデータを復元します。

***

### リンク

* [GitHub Security Best Practices](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure)
* [GitLab Security Guide](https://docs.gitlab.com/ee/user/application_security/)
* [HashiCorp Vault Documentation](https://www.vaultproject.io/docs)
* [OWASP Secure Coding Practices](https://owasp.org/www-project-secure-coding-practices-quick-reference-guide/)
* [SonarQube Documentation](https://docs.sonarqube.org/latest/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://coky-t.gitbook.io/owasp-devsecops-guideline-ja/v0.3/2-purosesu-process/22-kai-fa-develop/2-2-1-komitto-pre-commit/2-2-1-4-repository-hardening.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
