> 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 によるセキュリティスキャンを容易にする以外にも、lockfile を使う理由があります:

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

## 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` と同様に扱い、絶対に手動で編集しないでください。


---

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