> 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/gitlab-self-managed-setup-for-local-code-scanning.md).

# ローカルコードスキャン用のGitLabセルフマネージド設定

**目次：**

* [Local Scanning の設定方法](#how-to-set-up-local-scanning)
* [1. 認証トークンを取得する](#1-get-your-authentication-token)
* [2. ローカルスキャナーを実行する](#2-running-the-local-scanner)
  * [Docker を使用する](#using-docker)
* [3. スキャン結果を確認する](#3-check-your-scanning-results)

## ローカルコードスキャンのための GitLab Self-Managed セットアップ

Aikido Security Local Scanner は、あなたの環境内で Aikido Security のスキャンを実行できるツールで、コードが社外に出ることはありません。スキャンはローカルで実行され、その結果は Aikido Security プラットフォームにアップロードされます。このセットアップにより、レポート目的で Local Scanner を GitLab プロジェクトに簡単に統合できます。

### Local Scanning の設定方法 <a href="#how-to-set-up-local-scanning" id="how-to-set-up-local-scanning"></a>

**前提条件**：Local Scanning を利用できるアカウントが作成済みであることを確認してください。 [Local Scanning アカウントの作成に関する詳細情報](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. へ移動してください [Local Scanner の設定ページ](https://app.aikido.dev/settings/integrations/localscan).
2. 認証トークンを生成してコピーします。このトークンは 1 回しか表示できないので注意してください。
3. 認証トークンを GitLab の CI/CD 変数に追加して、パイプラインで使用できるようにします。\
   これを行うには、グループの Settings ページに移動し、次に **CI/CD** サブページへ移動します。

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

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

### 2. ローカルスキャナーを実行する <a href="#id-2-running-the-local-scanner" id="id-2-running-the-local-scanner"></a>

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

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

GitLab パイプラインでローカルスキャナーを使う最も簡単な方法は、Docker イメージを使うことです。\
​\
例 `.gitlab-ci.yml`:

```yaml
既定値:
  image:
    name: aikidosecurity/local-scanner:latest
    entrypoint: [""]

run_aikido_selfscanner:
  script:
  - aikido-local-scanner scan ./ --apikey $AIKIDO_LOCAL_SCANNER_TOKEN --repositoryname $CI_PROJECT_NAME --branchname main
  rules:
    - if: $CI_COMMIT_BRANCH == "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 Feed で結果を確認できます。指定した名前のリポジトリが作成され、スキャン結果のすべてが含まれています。


---

# 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/gitlab-self-managed-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.
