> 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/zen-firewall/zen-features/playbooks.md).

# プレイブック

Zen がアプリ内で不審な動作を検出した場合、IP を自動的にブロックします。

Playbooks は Zen Firewall の自動化ルールです。各プレイブックはイベントとアクションを組み合わせます。Zen がそのイベントを検知すると、あなたの代わりにそのアクションを実行します。誰かがダッシュボードを監視している必要はありません。

プレイブックは 1 文として読めます： **攻撃の波を検知 → IP を 30 分間ブロック**.

{% hint style="info" %}
Playbooks は早期アクセス機能です。 [サポートに連絡](/docs/docs-ja/miscellaneous-info/contact-support.md) ワークスペースで有効化してもらうためです。
{% endhint %}

## プレイブックを作成

1. Zen Firewall アプリを開いて、 **プレイブック** タブを選択します。
2. クリック： **プレイブックを追加**.
3. 次の下で **有効な場合**、プレイブックを発火させるイベントを選択します。
4. 次の下で **設定**、アクションと継続時間を選択します。
5. クリック： **プレイブックを作成**.

![When トリガーと Configure アクションを備えた「プレイブックを作成」ダイアログ。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-1d4d43c9ef0edb8eb1d2deeed1742faaab6d48a6%2FScreenshot%202026-09-07%20at%2016.55.26.png?alt=media)

プレイブックは作成するとすぐに有効になります。

![攻撃の波の後に IP を 30 分間ブロックする、アクティブなプレイブックを一覧表示する Playbooks タブ。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-95fc1101681f003fad34e319a6f2395152c7e634%2FScreenshot%202026-09-07%20at%2016.55.18.png?alt=media)

## イベント

**攻撃の波を検知しました。** ある IP が体系的にあなたのアプリを探査しています。たとえば、 `.env` ファイルや隠しディレクトリ。詳細は [攻撃波保護](/docs/docs-ja/zen-firewall/zen-features/attack-wave-protection.md) Zen がこれをどのように検知するか。

## アクション

**IP をブロック。** そのイベントを引き起こした IP は、このアプリのブロックリストに追加されます。期間は 30 分、1 時間、24 時間、または永久から選べます。

一時的なブロックは自動的に期限切れになります。ブロックが期限切れになると、Zen はその IP のイベント数もリセットするため、プレイブックは再びゼロから始まります。

Playbooks はあなたの [バイパスリスト](/docs/docs-ja/zen-firewall/zen-features/bypassed-ips.md).

## プレイブックが何をしたかを見る

この **アクティビティ** Playbooks タブの表示では、プレイブックが実行したすべてのアクションが記録されます。いつ発生したか、どのプレイブックが発火したか、対象の IP、そしてブロックの残り時間が表示されます。ドロップダウンでプレイブックごとに絞り込めます。

プレイブックによるブロックも次のように表示されます： **プレイブックのルール** で [この IP はなぜブロックされているのですか？](/docs/docs-ja/zen-firewall/zen-features/why-is-this-ip-blocked.md)

## プレイブックを無効化、編集、または削除する

プレイブック行の右側にあるアクションメニューを使用します：

* **プレイブックを無効化** アクションを実行しなくなります。既存のブロックはそのまま維持されます。
* **プレイブックを編集** イベント、アクション、または期間を変更します。
* **プレイブックを削除** 削除します。

## 自分のコードからのイベントに反応する

{% hint style="info" %}
Playbooks のこの機能はまだ開発中で、利用できません。
{% endhint %}

Zen では、アプリケーションコードから次を使ってイベントを報告できます： `track`そのため、プレイブックはログイン失敗のように、アプリだけが把握している事象に反応できます。

```javascript
const Zen = require("@aikidosec/firewall");

app.post("/login", async (req, res) => {
  const user = await authenticate(req.body.username, req.body.password);

  if (!user) {
    Zen.track("user.login_failed");
    return res.status(401).json({ error: "認証情報が無効です" });
  }

  Zen.setUser({ id: user.id });
  res.json({ token: createToken(user) });
});
```

Zen はリクエストから IP アドレスと現在のユーザーを取得するため、渡すのはイベント名だけで済みます。そこから次のようなプレイブックを作成できます： **`user.login_failed` 5 分間に 3 回 → IP を 1 時間ブロック**。カウントはアプリ全体ではなく、IP ごとに行われます。


---

# 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/zen-firewall/zen-features/playbooks.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.
