> 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/github-action-setup-for-local-code-scanning.md).

# ローカルオンプレミスコードスキャン用のGitHub Action設定

## はじめに

Aikido Security Local Scanner を使用すると、GitHub Action 内で直接スキャンを実行できます。さらに、次の場合も利用できます。 **GitHub Enterprise Server (GHES)** 環境。コードが外部に出ることはありません。スキャンはローカルで実行され、結果のみが Aikido Security プラットフォームにアップロードされます。このセットアップにより、Aikido ダッシュボードから脆弱性を管理しながら、最大限のプライバシーを確保できます。

{% hint style="danger" %}
これは **該当しません** 通常のクラウドベースのスキャナーには。これは、ローカルバイナリを使用したオンプレミススキャン専用の GitHub Action セットアップです。
{% endhint %}

### 前提条件 <a href="#how-to-set-up-local-scanning" id="how-to-set-up-local-scanning"></a>

* GitHub Enterprise Server 環境（セルフホストまたはエンタープライズ管理）。
* CI/CD ランナー - GitHub Actions
* Aikido Local Scanning アカウント。
* システム要件:
  * CPU コア 2～4 個
  * RAM 8～16 GB
  * 送信先 HTTPS (443) アクセスが有効

### ローカルオンプレミススキャンのセットアップ方法 <a href="#how-to-set-up-local-scanning" id="how-to-set-up-local-scanning"></a>

**前提条件**: ローカルスキャンを許可するアカウントを作成しておいてください。 [ローカルスキャンアカウントの作成に関する詳細](https://help.aikido.dev/en/articles/9070345-how-to-create-an-account-for-local-scanning-on-aikido).

#### 1. 認証トークンを生成する <a href="#id-1-get-your-authentication-token" id="id-1-get-your-authentication-token"></a>

1. 次へ移動します [ローカルスキャナーのセットアップページ](https://app.aikido.dev/settings/integrations/localscan).
2. 認証トークンを生成してコピーします。 **注記** このトークンは 1 回しか表示できません。
3. このトークンを引数として追加 `--apikey` プロジェクトで Local Scanner を実行する際に使用します。
4. Settings > Secrets and variables > Actions に移動して、このトークンを GitHub Secrets に保存してください。

   ![保存された AIKIDO\_API\_KEY シークレットを表示するリポジトリのシークレット管理インターフェース。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-d03072d0fbe99af3146a86f714a2809ab99f000f%2Fucarecdn-cb1943bf-30c2-4383-95fe-152c356fa5d0.png?alt=media)

#### 2. Local Scanner の実行 <a href="#id-2-running-the-local-scanner" id="id-2-running-the-local-scanner"></a>

あとは、リポジトリでスキャナーを実行するだけです。\
​\
Local scanner は必ずデフォルトブランチでのみトリガーされるようにしてください。Aikido では、デフォルトではリポジトリ内の 1 つのブランチに対して、依存関係とコードの問題をスキャンできます。通常は main または master ブランチです。そのため、Aikido プラットフォーム上でスキャン結果が混在しないように、Local scanner はそのブランチでのみ実行することを推奨します。これをワークフローファイルの 'on' セクションで指定できます。

#### Docker を使用する <a href="#using-docker" id="using-docker"></a>

GitHub Actions で Local Scanner を使う最も簡単な方法は、Docker イメージを使用することです。\
​\
例 `.github/workflows/aikido-scan.yml`:

```yaml
​on:
  push:
    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 }} 
          path: my-repo 
      - name: Run scan
        run: aikido-local-scanner scan my-repo --apikey ${{ secrets.AIKIDO_API_KEY }} --repositoryname MyRepo --branchname main
```

お好みのブランチを指定するには、 `--branchname` をコマンド実行時に使用します。

このリポジトリで最初のスキャンの場合、Aikido は指定した名前でリポジトリを作成し、すべてのスキャン結果をそこに含めます。以降のスキャン結果は、Aikido ではこのリポジトリ名の下に集約されます。

デフォルトではすべてのスキャンタイプが実行されます。選択したスキャンのみ（例: SAST のみ）を実行したい場合は、 `--scan-types` オプション。CLI オプションの詳細は [こちら](https://help.aikido.dev/en/articles/9027526-local-scanner-cli-options).

を指定することで可能です。リリースゲーティングモードや PR ゲーティングモードでもスキャナーを実行できます。リリース前にリポジトリをスキャンする場合、潜在的なリリース前に未解決の問題がないことを確認できるため、リリースゲーティングモードは有用です。リリースゲーティングモードで実行すると、スキャン完了後に選択した重大度以上の未解決の問題が存在する場合、スキャナープロセスは失敗します。PR ゲーティングモードは、PR 内で新たに導入された可能性のある問題をスキャンするために使用できます。

リリースまたは PR ゲーティングモードの詳細は、 [この記事](/docs/docs-ja/kdosukyan/local-code-scanning/pr-gating-for-code-using-local-scanner.md).

#### 3. スキャン結果を確認する <a href="#id-3-check-your-scanning-results" id="id-3-check-your-scanning-results"></a>

最初のスキャン後:

* Aikido に、 `-repositoryname`.
* で指定した名前のリポジトリが表示されます。以降のスキャンは、新しい検出結果で同じリポジトリを更新します。
* スキャンを **release gating** または **PR gating** モードで実行するよう設定すれば、未解決の問題があるデプロイをブロックできます。

### 注意事項と制限事項

* Local Scanner アカウント **には AutoFix は含まれません** UI 上で。AutoFix は [IDE 連携](/docs/docs-ja/aitotsru/ide-plugins-overview.md)
* デフォルトでは、すべてのスキャンタイプが有効です。 `-scan-types` フラグを使用してスキャンを制限できます（例: SAST のみ）。
  * 「[Local Scanner 用 CLI オプション](/docs/docs-ja/kdosukyan/local-code-scanning/cli-options-for-local-scanner.md)」を読んで、ローカルスキャナー実行時に渡せるすべてのオプションを確認してください。
* 結果の混在を避けるため、スキャンするブランチは 1 つだけ（通常は `main` または `master`）にしてください。


---

# 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://help.aikido.dev/docs/docs-ja/kdosukyan/local-code-scanning/github-action-setup-for-local-code-scanning.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.
