# BreachWatchコマンド

## 概要

BreachWatchは、インターネットやダークウェブ上の漏洩情報とボルト内のレコードを照合し、侵害の疑いがあるアカウントを検知するアドオンです。10億件を超える漏洩データベースを参照しながら、Keeperのゼロ知識方式による安全性を保ちます。詳しくは、[Keeperのドキュメント](/enterprise-guide/jp/breachwatch.md)をご参照ください。

## ユーザー体験

BreachWatchの利用を開始するには、KeeperのウェブボルトまたはモバイルアプリでBreachWatchの画面を開き、案内に従ってください。[Keeper Securityのサイト](https://keepersecurity.com/checkout)から購入することもできます。登録直後には、登録時点でボルトに保存されていたパスワードが端末上でスキャンされます。

SDKでは、以下の4つのコマンドを扱います。

1. [BreachWatchの一覧](#breachwatch-list)
2. [BreachWatchのスキャン](#breachwatch-scan)
3. [BreachWatchのパスワード照合](#breachwatch-password)
4. [BreachWatchのレコード無視](#breachwatch-ignore)

### BreachWatchの一覧 <a href="#breachwatch-list" id="breachwatch-list"></a>

`breachwatch list` は、BreachWatchが検知した内容に基づき、ボルト内のレコードごとのパスワード侵害の有無と状態を一覧表示します。再利用・脆弱・侵害済みなど、リスクの把握に利用できます。

<details>

<summary>DotNet CLI</summary>

**コマンド:** `breachwatch list`

**フラグ:**

* `--numbered` - BreachWatchレコードの通し番号付き表示
* `--owned` - 自分が所有者のレコードのみ表示
* `--all` - 参照可能なすべてのレコードの表示 (共有レコードを含む)

**例:**

```sh
My Vault> breachwatch list --numbered --owned
S.No  Record UID              Title                      Description        
----  ----------------------  -------------------------  -------------------
2     record_uid              DemoRecordForWeakPassword  qsaSF@ASFD.CA      
1     record_uid              breachwatchIgnoreTest3     qwdferq@qwef.afqcew
3     record_uid              DemoBreachWatchRecord      
```

</details>

<details>

<summary>DotNet SDK</summary>

**メソッド:** `BreachWatchRecords()`

ボルトの初期化と同期が済んでいれば、以下のように呼び出せます。

**例:**

```csharp
var records = vault.BreachWatchRecords()
.Where(x => x.Status == BWStatus.Weak || x.Status == BWStatus.Breached)
.Where(x => !BreachWatchIgnore.IsRecordIgnored(vault, x.RecordUid)) 
.Select(x => x)
```

</details>

<details>

<summary>PowerCommander</summary>

**コマンド:** `Get-KeeperBreachWatchList`

**フラグ:**

```
OwnedOnly - 自分が所有者のレコードのみ
All - 参照可能なすべてのレコード
Numbered - 結果に通し番号を表示
```

**例:**

```
PS> Get-KeeperBreachWatchList -OwnedOnly -Numbered

S.No Record UID             Title                     Description
---- ----------             -----                     -----------
   1 record_uid             breachwatchIgnoreTest3    qwdferq@qwef.afqcew
 
```

**コマンド:** `Get-KeeperIgnoredBreachWatchRecords`

**例:**

```
PS> Get-KeeperIgnoredBreachWatchRecords

Record UID             Title Description                        Status
----------             ----- -----------                        ------
2lAzF6Ok4xAfA-DYd6LQVQ Test1 a@gmail.com (at) https://agoda.com Ignored

Total ignored records: 1
```

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `breachwatch list`

**オプション:**

* `-n`, `--numbered` - レコードの番号付き一覧表示
* `-a`, `--all` - 件数制限を解除してすべて表示 (省略時は先頭30件のみ)
* `-o`, `--owned` - 自分が所有者のレコードのみ表示

**例:**

```sh
My Vault> breachwatch list

Detected High-Risk Password(s)

Record UID              Title                       Description
----------------------  --------------------------  ----------------
record_uid              hello new shortcut changed  test@example.com
```

</details>

<details>

<summary>Python SDK</summary>

**機能:** `breach_watch_records`

```python
record_uids = {x.record_uid for x in context.vault.vault_data.breach_watch_records() if x.status in (client_pb2.BWStatus.WEAK, client_pb2.BWStatus.BREACHED)}
records = [x for x in context.vault.vault_data.records() if x.record_uid in record_uids and (x.flags & vault_record.RecordFlags.IsOwner if owned_only else True)]
```

</details>

### BreachWatchのスキャン <a href="#breachwatch-scan" id="breachwatch-scan"></a>

`breachwatch scan` は、ボルト内で新規に作成した、または更新したパスワードをBreachWatchに送り、再利用・脆弱・侵害済みのいずれかを判定します。

パスワード付きレコードを作成または変更した直後に実行します。Keeperの公式アプリ以外 (例: Commander CLI や API 経由のスクリプト) から登録した場合などに特に有効です。

<details>

<summary>DotNet CLI</summary>

**コマンド:** `breachwatch scan`

**例:**

```sh
My Vault> breachwatch scan           
No records found to scan or all eligible records have already been scanned.
```

</details>

<details>

<summary>DotNet SDK</summary>

**メソッド:** `ScanAndStoreRecordStatusAsync`

引数には、スキャン対象レコードの `record UID` を要素とする文字列のリストを渡します。

**例:**

```csharp
await vault.ScanAndStoreRecordStatusAsync(recordUids);
```

</details>

<details>

<summary>PowerCommander</summary>

**コマンド:** 非対応

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `breachwatch scan`

**パラメータ:**

* `-r`, `--records` - スキャン対象のレコード UID

**例:**

```sh
My Vault> breachwatch scan -r <record_uid>
Breachwatch: 1 password(s) to scan
Scan completed for record <record_uid>. Status: WEAK
```

</details>

<details>

<summary>Python SDK</summary>

**機能:** `scan_and_store_record_status`

```python
# スキャン対象レコードの record_key と password を取得する
bw_password = vault.breach_watch_plugin().scan_and_store_record_status(
                record_uid=record_uid,
                record_key=record_key,
                password=password
            )
```

</details>

### BreachWatchのパスワード照合 <a href="#breachwatch-password" id="breachwatch-password"></a>

`breachwatch password` は、入力した文字列が公開されているデータ侵害に含まれるかを、BreachWatchのデータベースと照合して確認します。ゼロ知識方式で解析し、安全度 (例: GOOD / WEAK / BREACHED) を返します。

<details>

<summary>DotNet CLI</summary>

**コマンド:** `breachwatch password`

**例:**

```sh
My Vault> breachwatch password 
Password to Check: *************
Scanning 1 password(s)...
   *************: GOOD
```

</details>

<details>

<summary>DotNet SDK</summary>

**メソッド:** `ScanPasswordsAsync`

**例:**

```csharp
public static async Task<List<(string Password, HashStatus Status)>> ScanPasswordsAsync(
            IEnumerable<(string Password, byte[] Euid)> passwordEntries,
            CancellationToken cancellationToken = default)
```

</details>

<details>

<summary>PowerCommander</summary>

公開されている漏洩データにパスワードが含まれるかを、BreachWatchのデータベースと照合します (複数指定可)。

**コマンド:** `Test-PasswordAgainstBreachWatch`

**別名:** `kbwp`

**構文:**

```
Test-PasswordAgainstBreachWatch [-Passwords <SecureString[]>] [-ShowPassword] [-VaultContextVar <string>] [<CommonParameters>]
```

**パラメータ:**

<table data-header-hidden><thead><tr><th width="196.759765625">パラメータ</th><th>説明</th></tr></thead><tbody><tr><td><code>-Passwords</code></td><td>照合するパスワード (SecureString、複数可)、パイプライン入力可、省略時はプロンプト入力</td></tr><tr><td><code>-ShowPassword</code></td><td>マスクなしで結果にパスワードを表示</td></tr><tr><td><code>-VaultContextVar</code></td><td>ボルトコンテキストを保持する変数名 (既定以外のコンテキスト用)</td></tr></tbody></table>

**コマンド例:**

{% code overflow="wrap" %}

```ps1
# パスワードを入力して照合する
PS> Test-PasswordAgainstBreachWatch

# 特定のパスワードを照合する
PS> $pwd = ConvertTo-SecureString "password123" -AsPlainText -Force
PS> Test-PasswordAgainstBreachWatch -Passwords $pwd

# 複数のパスワードを照合し、結果に表示する
PS> $pwd1 = ConvertTo-SecureString "pass1" -AsPlainText -Force
PS> $pwd2 = ConvertTo-SecureString "pass2" -AsPlainText -Force
PS> Test-PasswordAgainstBreachWatch -Passwords $pwd1,$pwd2 -ShowPassword

# パイプライン入力
PS> Get-KeeperRecord | ForEach-Object { $_.GetPassword() } | ConvertTo-SecureString -AsPlainText -Force | Test-PasswordAgainstBreachWatch
```

{% endcode %}

**出力例:**

```powershell
PS> Test-PasswordAgainstBreachWatch
Password to Check: ************
Scanning 1 password(s)...
Processing 1 result(s)...
    ************: WEAK | Strength: System.Object[] (Score: 0)
```

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `breachwatch password`

**パラメータ:**

* `passwords` - 照合するパスワード (コマンド引数として指定)

**例:**

```sh
My Vault> breachwatch password testpassword
    testpassword: BREACHED
```

</details>

<details>

<summary>Python SDK</summary>

**機能:** `scan_passwords`

```python
breach_watch = vault.breach_watch_plugin().breach_watch.scan_passwords(passwords)
# スキャンするパスワード文字列のリストを渡す
```

</details>

### BreachWatchのレコード無視 <a href="#breachwatch-ignore" id="breachwatch-ignore"></a>

`breachwatch ignore` は、BreachWatchが再利用・脆弱・侵害済みと判定したレコードについて、アラートや警告を表示しないようにします。

対応を後回しにする合理的な理由がある場合に使います。たとえば、以下のような場合です。

* レガシーシステム向けの資格情報
* 重要度が低い、または別経路で保護済み
* 修復作業の途中

<details>

<summary>DotNet CLI</summary>

**コマンド:** `breachwatch ignore`

**例:**

```sh
My Vault> breachwatch ignore record_uid            
Record (UID: record_uid) has been ignored.
```

</details>

<details>

<summary>DotNet SDK</summary>

**メソッド:** `IgnoreRecord`

**例:**

```csharp
await BreachWatchIgnore.IgnoreRecord(vault, recordUid);
```

</details>

<details>

<summary>PowerCommander</summary>

**コマンド:** `Set-KeeperBreachWatchRecordIgnore`

```powershell
PS> Set-KeeperBreachWatchRecordIgnore -RecordUids record_uid                            
System.Threading.Tasks.VoidTaskResult
Record 'breachwatchIgnoreTest3' (UID: record_uid) has been ignored.
```

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `breachwatch ignore`

**パラメータ:**

* `records` - 対象外にするレコードの UID

**例:**

```sh
My Vault> breachwatch ignore record_uid
record_uid: success 
Syncing...
```

</details>

<details>

<summary>Python SDK</summary>

**機能:** 非対応

</details>


---

# Agent Instructions: 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:

```
GET https://docs.keeper.io/keeperpam/jp/commander-sdk/keeper-commander-sdks/sdk-command-reference/breachwatch-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
