> 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/python-projects-security-scanning-best-practices.md).

# Python プロジェクト: セキュリティスキャンのベストプラクティス

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

これを正確に行うために、Aikidoは、各依存関係の正確なバージョン、およびそれらのパッケージが依存しているものも含めて、すべての依存関係へのアクセスが必要です。

## Aikidoはどのように依存関係とサブ依存関係を見つけるのですか？

Aikidoは標準で、依存関係スキャン用に次のファイルをサポートしています：

* `uv.lock`
* `Pipfile.lock`
* `poetry.lock`
* `pdm.lock`
* `requirements.txt` *（ロックファイルが存在しない場合のみフォールバック）*
* `requirements.yml` *（ロックファイルが存在しない場合のみフォールバック）*

プロジェクトに `requirements.txt`しか含まれていない場合、Aikidoは完全な依存関係ツリーを検出できないことがあります。

これは、pipがサブ依存関係の正確なバージョンを記録しないため、結果が不完全または古くなる可能性があるからです。

完全で信頼できるスキャンのために、ロックファイルを生成する最新のPythonパッケージマネージャーであるuvの使用を推奨します。

## なぜロックファイルを使うのですか？

* **正確なセキュリティスキャン**：ロックファイルには、解決済みの各依存関係が正確なバージョン付きで含まれているため、Aikidoはリスクの全体像を把握できます。
* **サプライチェーン攻撃からの保護**：固定することで、悪意のあるパッケージを導入しうる不要なバージョン変更を防げます。
* **予測可能なビルド**：すべての環境で同じバージョンがインストールされます。「自分の環境では動く」問題が減ります。
* **より高速なインストール**：依存関係が固定されると、ロックファイルによって重い解決処理を省略できます。

## プロジェクトでロックファイルを使い始める方法

### UV

まずは、 [uvをインストールし、](mailto:undefined) および [pyproject.tomlでプロジェクトをセットアップします](https://docs.astral.sh/uv/guides/projects/#creating-a-new-project) 。まだない場合は。

そこから、 [依存関係を定義し、uvにuv.lockファイルを生成させます](mailto:undefined) 。これにより、すべての依存関係とサブ依存関係について正確なバージョンが固定されます。

pyproject.tomlとuv.lockの両方をリポジトリにコミットし、ロックファイルを手動で編集しないようにしてください。

現在プロジェクトでrequirements.txtを使っている場合、 [uvはそれらの依存関係を直接取り込み、ロックファイルを作成できます](mailto:undefined)。これにより、Aikidoは完全なバージョン精度で依存関係ツリー全体を検出できます。

プロジェクトのセットアップ、依存関係の管理、移行の詳細な手順は、 [uvのドキュメント](https://help.aikido.dev/docs/docs-ja/).

### Poetry

まずは、 [Poetryをインストールし、pyproject.tomlでプロジェクトをセットアップします ](https://python-poetry.org/docs/)。まだない場合は。

そこから、 [依存関係を定義し、Poetryにpoetry.lockファイルを生成させます](https://python-poetry.org/docs/managing-dependencies/) 。これにより、すべての依存関係と、それらが依存するパッケージについて正確なバージョンが固定されます。

pyproject.tomlとpoetry.lockの両方をリポジトリにコミットし、ロックファイルを手動で編集しないようにしてください。

プロジェクトのセットアップ、依存関係の管理、移行の詳細な手順は、 [Poetryのドキュメント](https://python-poetry.org/).


---

# 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/python-projects-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.
