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