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

# ローカルコードスキャン用のBamboo設定

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

## ローカルスキャンの設定方法 <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. 認証トークンを生成してコピーします。このトークンは一度しか表示できないことに注意してください。
3. 認証トークンを Bitbucket の Plan 変数に追加して、plan 内で使用できるようにします。これを行うには、plan の設定 > Variables に移動します。そこで、認証トークンを次のように追加できます。 `AIKIDO_API_KEY` をキーとして、コピーしたトークンの内容を値として設定します。変数を Project または Global レベルで定義することもできます（参照 [こちら](https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html)).

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

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

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

エージェントで Docker を実行できる場合は、Aikido Local Scanner の Docker イメージを使ってスキャンを実行できます。まず、コードをスキャンできる状態にするために、「Source Code Checkout」タスクがあることを確認してください。その後、次のような「Docker」タスクを追加します。

![Atlassian 統合のタスク選択ウィンドウで Docker タスクタイプを検索します。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-adcb9285152ad13977a3de4fb453934a2a294180%2Fucarecdn-5d3adf06-608c-4533-97c2-921d2059ac5e.png?alt=media)

コマンドとして「Run a Docker container」を選択します。イメージは次の場所で見つかります。 [Docker Hub](https://hub.docker.com/r/aikidosecurity/local-scanner) または [AWS Elastic Container Registry](https://gallery.ecr.aws/z1o3v2w5/aikidosecurity/local-scanner).

コンテナコマンド欄に次のように入力します。 `scan . --apikey ${bamboo.AIKIDO_API_KEY} --repositoryname ${bamboo.planRepository.1.name} --branchname ${bamboo.planRepository.1.branch}`

## バイナリを使用する <a href="#using-the-binary" id="using-the-binary"></a>

エージェントで Docker を実行できない場合は、Aikido Local Scanner のバイナリを直接使用できます。これを行うには、正しいバイナリを次の場所からダウンロードしてください。 [Local Scanner Setup ページ](https://app.aikido.dev/settings/integrations/localscan)。\
次に、これをエージェントの機能として追加する必要があります。

* **対象のエージェントに移動します：**
  * Bamboo で、 **Build Resources** > **Agents**.
  * 機能を追加したいエージェントを選択します。
* **実行可能な機能を追加します：**
  * 次の **エージェント固有の機能** セクションで、 **Add capability**.
  * 選択 **機能タイプ** > **Executable**.
  * 次の **実行可能ファイルのラベル**に、Aikido Local Scanner など実行可能ファイルの名前を入力します。
  * 次の **Path** フィールドで、エージェントマシン上の aikido-local-scanner バイナリへのパスを指定します。

これで、Aikido Local Scanner を Plan の Task として使用できるようになります。まず、スキャン対象のコードが利用可能であることを確認するために、「Source Code Checkout」タスクがあることを確認してください。その後、次のような「Command」タスクを追加します。

![ビルド自動化ツールでコマンド実行オプションを表示しているタスクタイプのメニュー。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-f9f358a8b5fe530520cf3d78b00c3fccf3aaa799%2Fucarecdn-63dfcf44-02c7-46fc-b16b-b549f8df5ecd.png?alt=media)

実行可能ファイルとして「Aikido Local Scanner」を選択し、コマンドパラメータを Argument フィールドに追加します。

```shellscript
scan . --apikey ${bamboo.AIKIDO_API_KEY} --repositoryname ${bamboo.planRepository.1.name} --branchname ${bamboo.planRepository.1.branch}
```

このリポジトリで最初のスキャンの場合、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/bamboo-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.
