> 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/kontenaimjisukyan/local-image-scanning/gitlab-setup-for-local-image-scanning.md).

# ローカルイメージスキャン用の GitLab セットアップ

Aikido Security Local Scanner は、Aikido Security のスキャンをあなたの環境内で実行できるようにするツールで、データが決して外部へ出ないことを保証します。スキャンはローカルで行われ、その結果は Aikido Security プラットフォームにアップロードされます。この設定により、レジストリに送られる前に、自分のマシン上や CI/CD パイプライン内で任意のイメージをローカルにスキャンできます。

## イメージのローカルスキャンを設定する方法 <a href="#how-to-set-up-local-scanning-for-images" id="how-to-set-up-local-scanning-for-images"></a>

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

1. 次へ移動します [Local Scanner のイメージ設定ページ](https://app.aikido.dev/settings/container-image-registry/add/localscan)
2. 認証トークンを生成してコピーします。このトークンは一度しか表示できないので注意してください。
3. このトークンを引数として追加します `--apikey` プロジェクトでローカルスキャナーを実行する際に。
4. 認証トークンを GitLab の CI/CD 変数に追加して、パイプラインで使用できるようにします。\
   そのためには、グループの Settings ページに移動し、次に **CI/CD** サブページ。

   ![変数、ランナー、および Auto DevOps 自動化を管理するための GitLab CI/CD 設定ページ。](/files/6988d31f5c72af34e626093c915ea2d46e36c4e0)

   変数の横にある「Expand」をクリックし、「Add variable」をクリックします。次に、認証トークンを `AIKIDO_LOCAL_SCANNER_TOKEN` をキーとして、コピーしたトークンの内容を値として追加できます。

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

​\
これで、残る作業はイメージに対してスキャナーを実行することだけです。以下のサンプルファイルを参考にできます：

```yaml
の既定値:
  image: docker:cli
  services:
    - docker:dind

run_aikido_selfscanner:
  script:
  - docker build ...
  - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aikidosecurity/local-scanner image-scan your-local-image-name --apikey $AIKIDO_LOCAL_SCANNER_TOKEN
    - if: $CI_COMMIT_BRANCH == "main"
```

これを CI で実行する場合は、本番環境と機能ブランチの結果が Aikido 内で混ざらないよう、機能ブランチを元にしたイメージに対してスキャンを実行しないよう注意してください。

レジストリに push する前にリリースゲート付きスキャンを実行するには、次のようなパイプラインを実行できます：

```yaml
の既定値:
  image: docker:cli
  services:
    - docker:dind

run_aikido_selfscanner:
  script:
  - docker build ...
  - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aikidosecurity/local-scanner image-scan your-local-image-name --apikey $AIKIDO_LOCAL_SCANNER_TOKEN --fail-on critical
  - docker push ...
    - if: $CI_COMMIT_BRANCH == "main"
```

で指定する重大度を調整してください `--fail-on` を、必要に応じて変更してください。

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

最初のスキャンが完了したら、Aikido Feed に移動して結果を確認できます。指定した名前のイメージが Aikido UI に作成され、スキャンのすべての結果が含まれています。


---

# 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/kontenaimjisukyan/local-image-scanning/gitlab-setup-for-local-image-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.
