> 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/aikido-device-protection/miscellaneous-aikido-endpoint/enforce-device-protection-package-managers.md).

# パッケージのインストール中に Device Protection を強制する

Aikido Device Protection が有効でないマシンでは、パッケージのインストールをブロックします。これにより、ポリシーだけに頼らず、開発ワークフローの一部として保護を強制できます。

## これを使う理由

サプライチェーン攻撃は、しばしば依存関係経由で侵入します。Device Protection は悪意のあるパッケージをインストール時に遮断しますが、それは実行中である場合に限られます。事前インストールチェックを追加することで、開発者が保護されていないマシンに誤ってパッケージをインストールしてしまうのを防げます。

## 仕組み

ほとんどのパッケージマネージャーは、インストール前に実行されるライフサイクルフックやラッパースクリプトをサポートしています。チェックが非ゼロのコードで終了すると、インストールは中止され、開発者には明確なメッセージが表示されます。

{% tabs %}
{% tab title="macOS" %}
{% code overflow="wrap" %}

```bash
/Applications/Aikido\ Endpoint\ Protection.app/Contents/Resources/scripts/healthy
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}
{% code overflow="wrap" %}

```powershell
& "C:\Program Files\AikidoSecurity\EndpointProtection\scripts\Healthy.ps1"
```

{% endcode %}
{% endtab %}
{% endtabs %}

## パッケージマネージャーの例

{% tabs %}
{% tab title="npm" %}
追加します `preinstall` スクリプトを `package.json`:

```json
{
  "scripts": {
    "preinstall": "/Applications/Aikido\ Endpoint\ Protection.app/Contents/Resources/scripts/healthy"
  }
}
```

{% endtab %}

{% tab title="yarn / pnpm" %}
yarn と pnpm はどちらも `preinstall` 内のスクリプト `package.json`:

```json
{
  "scripts": {
    "preinstall": "/Applications/Aikido\ Endpoint\ Protection.app/Contents/Resources/scripts/healthy"
  }
}
```

{% endtab %}

{% tab title="pip / uv" %}
pip と uv にはネイティブの pre-install フックがありません。〜を使ってください `Makefile` インストールをラップするターゲット:

```makefile
install: check-aikido
	pip install -r requirements.txt

check-aikido:
	/Applications/Aikido\ Endpoint\ Protection.app/Contents/Resources/scripts/healthy
```

実行 `make install` の代わりに `pip install` 直接。次のケースでも同じパターンが使えます。 `uv sync` または `poetry install`.
{% endtab %}

{% tab title="Maven" %}
次を追加します `exec-maven-plugin` 〜に `validate` フェーズに `pom.xml`。これは依存関係が解決される前に実行されます:

```xml
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>3.1.0</version>
  <executions>
    <execution>
      <id>check-aikido</id>
      <phase>validate</phase>
      <goals><goal>exec</goal></goals>
      <configuration>
        <executable>bash</executable>
        <arguments>
          <argument>-c</argument>
          <argument>/Applications/Aikido\ Endpoint\ Protection.app/Contents/Resources/scripts/healthy</argument>
        </arguments>
      </configuration>
    </execution>
  </executions>
</plugin>
```

{% endtab %}

{% tab title="NuGet" %}
追加します `.targets` プロジェクトにファイルを追加します（例: `CheckAikido.targets`）そしてあなたの `.csproj`:

```xml
<!-- CheckAikido.targets -->
<Project>
  <Target Name="CheckAikido" BeforeTargets="Restore">
    <Exec Command="bash -c &quot;/Applications/Aikido\ Endpoint\ Protection.app/Contents/Resources/scripts/healthy&quot;" />
  </Target>
</Project>
```

```xml
<!-- YourProject.csproj -->
<Import Project="CheckAikido.targets" />
```

{% endtab %}
{% endtabs %}

## Gitフック

Git フックはコミットやチェックアウトの前に発火し、パッケージのインストール前ではありません――ただし、保護されていないマシンでのすべての git 操作をブロックしたいチームにとっては、便利な第2の強制手段になります。

チェックを次に追加します `.git/hooks/pre-commit`:

```bash
#!/bin/bash
/Applications/Aikido\ Endpoint\ Protection.app/Contents/Resources/scripts/healthy
```

実行可能にします:

```bash
chmod +x .git/hooks/pre-commit
```

{% hint style="info" %}
`.git/hooks` は git に追跡されません。チームとフックを共有するには、次のようなツールを使用します: [Lefthook](https://github.com/evilmartians/lefthook) または [Husky](https://typicode.github.io/husky/) を使って、リポジトリの一部としてフックを管理し、コミットします。
{% endhint %}


---

# 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/aikido-device-protection/miscellaneous-aikido-endpoint/enforce-device-protection-package-managers.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.
