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