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