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

## 2. ローカルスキャナーの実行 <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タスクタイプを検索します。](/files/f8fd8ab21e4a463214e7591269ce3823971c9463)

コマンドとして '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**.
  * 選択 **Capability type** > **Executable**.
  * で **Executable label**をクリックし、Aikido Local Scannerなど、実行可能ファイルの名前を入力します。
  * で **Path** フィールドに、エージェントマシン上のaikido-local-scannerバイナリへのパスを指定します。

これで、Aikido Local scannerをPlan内のタスクとして使用できます。まず、コードがスキャン可能な状態であることを確認するために、'Source Code Checkout' タスクがあることを確認してください。その後、次のような 'Command' タスクを追加します:

![ビルド自動化ツール内でコマンド実行オプションを表示しているタスクタイプのメニュー。](/files/a3dab98670915fae94079ea05b2517d8ac26f3e7)

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

```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.
