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

# .NETプロジェクト：セキュリティスキャンのベストプラクティス

Aikido は、あなたの .NET 依存関係にある既知の脆弱性（CVE）や、それらの依存関係で使用されているマルウェアおよび危険なライセンスを検出できます。

Aikido はどのようにしてそれらの依存関係と、その遷移的なサブ依存関係を見つけるのですか？

標準では、Aikido はスキャン対象として次のファイルをサポートしています:

* \*.csproj
* \*.deps.json
* packages.lock.json
* packages.config
* packages.props
* paket.lock

なお、.csproj ファイルにはサブ依存関係の正確なバージョンが含まれていないことがよくあります。そのため、Aikido がサブ依存関係に対して誤検知の CVE をいくつか見つけることがあります。

## ロックファイルの使用を始めるべき理由 <a href="#why-you-should-start-using-lockfiles" id="why-you-should-start-using-lockfiles"></a>

各 NuGet 依存関係およびサブ依存関係ごとのバージョンとハッシュを含むロックファイルを使用することをおすすめします。

Aikido によるセキュリティスキャンを容易にする以外にも、ロックファイルを使用する理由はあります:

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

### .NET プロジェクトでロックファイルの使用を始めるには？ <a href="#how-to-start-using-lockfiles-in-your-net-project" id="how-to-start-using-lockfiles-in-your-net-project"></a>

ロックファイルを作成するには、次の行を `.csproj` ファイルに追加する必要があります:

```
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <!-- ロックファイルを生成 -->
    <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>

    <!-- ロックファイルに記載されたとおりに正確なパッケージを復元 -->
    <RestoreLockedMode Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</RestoreLockedMode>
  </PropertyGroup>

  <ItemGroup>
    ...
  </ItemGroup>
</Project>
```

これらの行を追加したら、次を実行します

```
dotnet.exe restore
```

これにより、リポジトリにコミットできるロックファイル（packages.lock.json）が生成されます。NodeJS の世界で NPM の package-lock.json ファイルを使うのと同様に、このファイルを手動で編集してはいけません。

既存のロックファイルを使って復元するには、次を実行します

```
dotnet.exe restore --locked-mode
```


---

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