> 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 を見つける場合があります。

## lockfile を使い始めるべき理由 <a href="#why-you-should-start-using-lockfiles" id="why-you-should-start-using-lockfiles"></a>

各 NuGet 依存関係およびサブ依存関係について、バージョンとハッシュを含む lockfile を使うことをおすすめします。

Aikido によるセキュリティスキャンを容易にする以外にも、lockfile を使う理由はあります：

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

### .NET プロジェクトで lockfile を使い始めるには？ <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
```

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

既存の lockfile を使って復元するには、次を実行します：

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