> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/docs/docs-ja/kdosukyan/local-code-scanning/pr-gating/github-pr-gating-using-local-scanner.md).

# ローカルスキャナーを使ったGitHubのPRゲーティング

Aikido Local Scanner は、CI パイプライン内でセキュリティゲートを強制するために使用できます。

{% hint style="info" %}
クラウド接続されたワークスペース（GitHub、BitBucket など）でも PR ゲーティングを使用できます。CI の [統合セクションをご覧ください](https://help.aikido.dev/section/ci-integrations/sg3q6UrIf4qE).
{% endhint %}

PR ゲーティングにより、新しいコードがデフォルトブランチにマージされる前にセキュリティ基準を満たしていることを確認できます。これは、プルリクエストで導入された変更のみをスキャンします。スキャンで、設定した重大度しきい値以上に該当する新しい問題が検出された場合、CI パイプラインは失敗します。

これにより、新しい脆弱性の混入を防ぎつつ、既存の検出結果は別途対応できます。

{% hint style="info" %}
また、 [リリースゲート](/docs/docs-ja/kontenaimjisukyan/local-image-scanning/release-gating-for-container-images-using-local-image-scanner.md) リリース時にチェックを強制したいチーム向けのサポートもあります。
{% endhint %}

PR ゲーティングを有効にするには、 `--fail-on <severity>` オプションを追加して、お好みの重大度レベルを選択します。次に、 `--gating-mode pr` オプションを追加して、PR ゲーティングを実行したいことを示します。また、ベース（`--base-commit-id <commit-id>`）とヘッドコミット（`--head-commit-id <commit-id>`）を指定する必要があります。ベースの commit id に対して以前にスキャンが実行されていた場合、スキャン結果はそれと比較されます。そうでない場合は、デフォルトブランチ上の最新のスキャン結果と比較されます。

GitHub環境で Local Scanner をセットアップするための一般的な情報については、こちらをご覧ください [この記事](/docs/docs-ja/kdosukyan/local-code-scanning/github-action-setup-for-local-code-scanning.md).

例 `.github/workflows/aikido-scan.yml` PRゲーティング用:

```yaml
on:
  pull_request:
    branches:
      - main

name: Aikido Scan
jobs:
  aikido-local-scan-repo:
    runs-on: ubuntu-latest
    container:
      image: aikidosecurity/local-scanner:latest
    steps: 
      - uses: actions/checkout@v4 
        with: 
          token: ${{ secrets.GITHUB_TOKEN }} 
          パス: ${{ github.event.repository.name }}
          fetch-depth: 0 # ベースコミットとヘッドコミットがワークフローでアクセス可能になるようにします
      - name: Run scan
        run: aikido-local-scanner scan ${{ github.event.repository.name }} --apikey ${{ secrets.AIKIDO_API_KEY }} --repositoryname ${{ github.event.repository.name }} --branchname ${{ github.event.pull_request.head.ref }} --gating-mode pr --fail-on critical --base-commit-id ${{ github.event.pull_request.base.sha }} --head-commit-id ${{ github.event.pull_request.head.sha }}
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.aikido.dev/docs/docs-ja/kdosukyan/local-code-scanning/pr-gating/github-pr-gating-using-local-scanner.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
