> 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/pr-torirsugtingu/cli-for-pr-and-release-gating/aikido-ci-api.md).

# Aikido CI API

**ベースURL** `https://app.aikido.dev`

Aikido CI API を使うと、リポジトリ内の特定ブランチに対して新しいスキャンを開始できます。スキャンの状態をポーリングできるので、CI/CD プラットフォーム内にゲーティング機構を構築できます。

Aikido では、特定のスキャンを自分で管理することもできます。独自の Checkov SARIF やカスタム SBOM を Aikido に直接アップロードして、機能ブランチのスキャンに反映できます。Jenkins や CircleCI などのカスタム CI システムも、同じ API トークンでコードカバレッジレポートをアップロードできます。参照 [コードカバレッジをアップロード](#upload-code-coverage).

## 認証 <a href="#authentication" id="authentication"></a>

1. へ移動 [CI 統合の詳細ページ](https://app.aikido.dev/settings/integrations/continuous-integration).
2. 認証トークンを生成してコピーします。このトークンを表示できるのは 1 回だけです。
3. ヘッダーを追加 `X-AIK-API-SECRET` 各リクエストに、認証トークンを値として付与します。

## 新しい機能ブランチスキャンを開始 <a href="#start-a-new-feature-branch-scan" id="start-a-new-feature-branch-scan"></a>

この非同期 API は、特定のコミットに対して新しい機能ブランチスキャンを開始します。

`POST /api/integrations/continuous_integration/scan/repository`

**本文:**

```
{
    "version": "1.0.5",
    "branch_name": "branch-name",
    "repository_id": "R_kgDOJf6H8g", 
    "base_commit_id": "1c5a7dda074aa19ebc6aa9f25884b5e0b6bb3662",
    "head_commit_id": "b7deb06d8be6bc4c62277e0a28911b2284cab6da",
    "minimum_severity": "HIGH",
    "fail_on_sast_scan": true,
    "fail_on_dependency_scan": true,
    "fail_on_iac_scan": true,
    "fail_on_secrets_scan": true,
    "fail_on_malware_scan": false,
    "pull_request_metadata": {
        "url": "https://github.com/AikidoSec/some-repo/pull/12",
        "title": "checkov"
    },
    "self_managed_scanners": ["checkov", "json-sbom"],
    "expected_amount_json_sboms": 1,
}
```

**必須フィールド:**

* repository\_id: GitHub/Gitlab/Bitbucket/.. の内部リポジトリ ID
* base\_commit\_id: ベースとなるコミット（PR で分岐した元のコミット。PR に関連しない場合は、end\_commit\_id の直前のコミット）
* head\_commit\_id: スキャン対象の最新コミット（ブランチの最後のコミット）
* branch\_name: ブランチ名

**任意フィールド:**

* pull\_request\_metadata.url: プルリクエストの URL
* pull\_request\_metadata.title: プルリクエストのタイトル
* self\_managed\_scanners: カスタムスキャンタイプの配列（対応 `checkov` と `json-sbom`）。デフォルトは空配列 \[] です。
* expected\_amount\_json\_sboms: 待機しているカスタム json-sbom アップロード数の整数。
* fail\_on\_dependency\_scan（デフォルト `true`）: Aikido が新しい依存関係の問題（CVE）でブロックすべきかどうかを決定します
* fail\_on\_sast\_scan（デフォルト `false`）: Aikido が新しい SAST 問題でブロックすべきかどうかを決定します
* fail\_on\_iac\_scan（デフォルト: `false`）: Aikido が新しい IaC スキャンでブロックすべきかどうかを決定します
* fail\_on\_secrets\_scan（デフォルト `false`）: Aikido が新しい漏えいシークレットの問題でブロックすべきかどうかを決定します
* fail\_on\_malware\_scan（デフォルト `false`）: Aikido が新しいマルウェアの問題でブロックすべきかどうかを決定します。
  * **注:** この機能は全員が利用できるわけではありません。有効化したい場合は Aikido にお問い合わせください。
* minimum\_severity（デフォルト `重大`）: Aikido がどの（最小）深刻度で `FAILED`。この値は次のいずれかです `低`, `中`, `高`, `重大`.

**応答:**

```
{
    "scan_id": 22
}
```

## 機能ブランチスキャンのステータスをポーリング <a href="#poll-for-feature-branch-scan-status" id="poll-for-feature-branch-scan-status"></a>

スキャンの現在の状態を取得します。ポーリング機構（例: 5 秒ごと）を使って、CI/CD のゲーティングを実装してください。

`GET /api/integrations/continuous_integration/scan/repository?scan_id=1`

**パラメータ:**

* scan\_id（int）

**応答:**

機能ブランチの例 *スキャン進行中*

```
{
    "all_scans_completed": false,
    "dependency_scan_completed": true,
    "sast_scan_completed": false,
    "iac_scan_completed": false,
    "secrets_scan_completed": false,
    "malware_scan_completed": false,
    "code_quality_scan_completed": false,
    "sbom_scan_completed": false // if 'json-sbom' in self_managed_scanners
}
```

機能ブランチスキャン完了の例

```
{
    "all_scans_completed": true,
    "dependency_scan_completed": true,
    "sast_scan_completed": true,
    "iac_scan_completed": true,
    "secrets_scan_completed": true,
    "malware_scan_completed": true,
    "sbom_scan_completed": true, // if 'json-sbom' in self_managed_scanners
    "code_quality_scan_completed": false,
    "issues_outside_sla": 0,
    "new_issues_found": 1,
    "new_dependency_issues_found": 1,
    "new_sast_issues_found": 0,
    "new_iac_issues_found": 0,
    "new_leaked_secret_issues_found": 0,
    "new_malware_issues_found": 0,
    "new_license_issues_found": 0,
    "code_quality_issues_found": 0,
    "diff_url": "https://app.aikido.dev/featurebranch/scan/1?groupId=1",
    "gate_passed": false,
    "issue_breakdown": {
        "sast": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "sca": { "critical": 1, "high": 0, "medium": 0, "low": 0 },
        "iac": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "secrets": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "malware": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "license": { "critical": 0, "high": 0, "medium": 0, "low": 0 }
    }
}
```

d の例*efault ブランチのスキャン完了*

```
{
    "all_scans_completed": false,
    "dependency_scan_completed": true,
    "sast_scan_completed": false,
    "iac_scan_completed": false,
    "secrets_scan_completed": false,
    "malware_scan_completed": false,
    "open_issues_found": 2,
    "issue_links": [
        "https://app.aikido.dev/queue?sidebarIssue=1",
        "https://app.aikido.dev/queue?sidebarIssue=2",
    ],
    "gate_passed": false,
    "issue_breakdown": {
        "sast": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "sca": { "critical": 1, "high": 0, "medium": 0, "low": 0 },
        "iac": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "secrets": { "critical": 1, "high": 0, "medium": 0, "low": 0 },
        "malware": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "license": { "critical": 0, "high": 0, "medium": 0, "low": 0 }
    }
}
```

```
{
    "all_scans_completed": false,
    "dependency_scan_completed": true,
    "sast_scan_completed": false,
    "iac_scan_completed": false,
    "secrets_scan_completed": false,
    "malware_scan_completed": false,
    "open_issues_found": 2,
    "issue_links": [
        "https://app.aikido.dev/queue?sidebarIssue=1",
        "https://app.aikido.dev/queue?sidebarIssue=2",
    ],
    "gate_passed": false,
    "issue_breakdown": {
        "sast": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "sca": { "critical": 1, "high": 0, "medium": 0, "low": 0 },
        "iac": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "secrets": { "critical": 1, "high": 0, "medium": 0, "low": 0 },
        "malware": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "license": { "critical": 0, "high": 0, "medium": 0, "low": 0 }
    }
}
```

```
{
    "all_scans_completed": false,
    "dependency_scan_completed": true,
    "sast_scan_completed": false,
    "iac_scan_completed": false,
    "secrets_scan_completed": false,
    "malware_scan_completed": false,
    "open_issues_found": 2,
    "issue_links": [
        "https://app.aikido.dev/queue?sidebarIssue=1",
        "https://app.aikido.dev/queue?sidebarIssue=2",
    ],
    "gate_passed": false,
    "issue_breakdown": {
        "sast": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "sca": { "critical": 1, "high": 0, "medium": 0, "low": 0 },
        "iac": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "secrets": { "critical": 1, "high": 0, "medium": 0, "low": 0 },
        "malware": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
        "license": { "critical": 0, "high": 0, "medium": 0, "low": 0 }
    }
}
```

## カスタムスキャン結果をアップロード <a href="#upload-custom-scan-results" id="upload-custom-scan-results"></a>

この API を使用すると、Syft で生成した独自の Checkov SARIF やカスタム SBOM をアップロードできます。Syft SBOM を生成する場合は JSON 形式を使用してください。

`POST /api/integrations/continuous_integration/scan/custom`

**本文:**

例: *Checkov*

```
{
    "scan_id": 22, // optional
    "repository_id": 12,
    "payload_type": "checkov",
    "payload": <checkov_sarif_response>
}
```

例: *Syft SBOM*

```
{
    "scan_id": 22, // optional
    "repository_id": 12,
    "container_image_name": "image-name",
    "payload_type": "json-sbom",
    "payload": <syft_json_sbom_response>
}
```

**必須フィールド:**

* container\_image\_name: json-sbom に必要です。これにはイメージタグを含めず、イメージの一意な名前のみを含めてください。
* payload\_type
* payload

**任意フィールド:**

* scan\_id: （次から取得 *スキャンを開始*）。ペイロードを Aikido のライブフィードに送りたい場合は、これを設定しないでください。
* repository\_id: GitHub/Gitlab/Bitbucket/.. の内部リポジトリ ID（scan\_id が設定されていない場合のみ必須）

**応答:**

```
{
    "success": 1
}
```

## コードカバレッジをアップロード <a href="#upload-code-coverage" id="upload-code-coverage"></a>

Jenkins や CircleCI などのカスタム CI は、次をアップロードできます [LCOV](https://github.com/linux-test-project/lcov) または [Cobertura](https://cobertura.github.io/cobertura/) 同じトークンでのカバレッジレポート `X-AIK-API-SECRET` トークン。

次を使用してください: [Aikido CI API クライアント](https://www.npmjs.com/package/@aikidosec/ci-api-client) `upload-coverage` コマンド。テストがレポートを書き出した後、チェックアウト済みのリポジトリから実行してください。クライアントはカバレッジファイルとソースメタデータを読み取り、それらを Aikido に送信します。参照 [コードカバレッジ](/docs/docs-ja/kdo/code-coverage.md) Aikido でアップロードがどのように表示されるか

```sh
$ aikido-api-client upload-coverage \
    --apikey <your-api-key> \
    --repo-name <owner/repo> \
    --commit-sha <commit_sha> \
    --branch-name <branch_name> \
    --repository-id <repository_id> \
    --file-paths coverage/lcov.info
```

`repository_id` Git プロバイダのリポジトリ ID で、このページの他のエンドポイントでも使用されるのと同じ ID です。複数のパスを `--file-paths` に渡して、別々のパッケージやジョブの LCOV と Cobertura レポートを結合します。

各アップロードは、そのリポジトリとブランチのカバレッジを置き換えます。モノレポでは、各実行ごとに各アプリのレポートをすべて渡してください。変更のないアプリを省略する場合は、その最新レポートを同じコマンドに含めてください。参照 [変更されたパスのみをテストするモノレポ](/docs/docs-ja/kdo/code-coverage/monorepos-that-test-only-changed-paths.md).


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.aikido.dev/docs/docs-ja/pr-torirsugtingu/cli-for-pr-and-release-gating/aikido-ci-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
