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