> 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/scanning-practices/java-scala-kotlin-projects-using-gradle-security-scanning-best-practices.md).

# Gradle を使用する Java/Scala/Kotlin プロジェクト: セキュリティスキャンのベストプラクティス

Aikido は、Java の依存関係にある既知の脆弱性（CVE）だけでなく、それらの依存関係で使用されている危険なライセンスも検出できます。

Aikido はそれらの依存関係と、その推移的なサブ依存関係をどのように見つけるのでしょうか？

Aikido は初期状態で、スキャン対象として以下のファイルをサポートしています:

* gradle.lockfile
* pom.xml
* .jar/.war/.ear

build.gradle.\*（Gradle マニフェスト）ファイルには、依存関係の一部について正確なバージョンが含まれていない場合があることに注意してください。これにより、Aikido がアプリケーション内のリスクの全範囲を見つけられなくなる可能性があります。

各依存関係とそのサブ依存関係の正確なバージョンを含む Gradle のロックファイルを使用することをお勧めします。

Aikido によるセキュリティスキャンを容易にする以外にも、ロックファイルを使う理由はあります:

* ロックファイルを使うと、悪意あるパッケージを介したサプライチェーン攻撃から身を守れます。この種の攻撃はますます一般的になっています
* ロックファイルを使用すると、全員がパッケージのまったく同じマイナーバージョンを使うため、ビルドの予測可能性が高まります。「自分の環境では動く」問題が起きにくくなります。
* ビルド時間の短縮: 依存関係の解決が不要になります

## Gradle プロジェクトでロックファイルの使用を始めるには？ <a href="#how-to-start-using-lockfiles-in-your-gradle-project" id="how-to-start-using-lockfiles-in-your-gradle-project"></a>

リポジトリにロックファイルを入れる方法は 2 つあります：

**オプション 1: Aikido に作成させる（推奨）**

リポジトリに `build.gradle` または `build.gradle.kts` がある一方で、対応する `gradle.lockfile`がない場合、Aikido はこれを自動的に検出し、 **プルリクエストを開いて** それを作成できます。 *注:* [*AutoFix*](https://help.aikido.dev/aikido-autofix/overview-aikido-autofix) *このオプションを有効にする必要があります。*

**ステップ 1.** ロックファイルが不足している該当リポジトリに移動します

**ステップ 2.** 上部に表示されるロックファイルの提案を見つけて、クリックします **PR を作成**<br>

<figure><img src="/files/c1d61b3577a8a7e347f2713afb71e5c2cabedcd4" alt=""><figcaption></figcaption></figure>

**手順 3。** PR をレビューしてマージします。あとは Aikido が処理します

マージされると、Aikido はすべての推移的依存関係を含む、依存関係ツリー全体をすぐにスキャンできるようになります。

**オプション 2: 手動で追加する**

Gradle マニフェストファイルに必要な設定を追加します。 [Gradle ロックファイルのドキュメント](https://docs.gradle.org/current/userguide/dependency_locking.html#ex-locking-all-configurations) で、追加すべき正確な行を確認してください。

次に、以下を実行します：

```
gradle dependencies --write-locks
```

生成されたロックファイルをリポジトリにコミットします。 `package-lock.json` Node.js のものと同様に扱い、手動で編集しないでください。


---

# 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/scanning-practices/java-scala-kotlin-projects-using-gradle-security-scanning-best-practices.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.
