このトピックでは、新しい検査テンプレートの作成方法を詳しく説明します。Cloud Data Loss Prevention(DLP)UI を使用して新しい検査テンプレートを作成する方法のチュートリアルについては、クイックスタート: Cloud DLP 検査テンプレートの作成をご覧ください。
テンプレートについて
テンプレートを使用して、Cloud DLP で使用する構成情報を作成し、維持できます。テンプレートは、検査の目的や匿名化の方法などの構成情報をリクエストの実装から分離するのに役立ちます。テンプレートを使用することで構成を再利用でき、ユーザー間、データセット間での一貫性が保たれます。また、テンプレートを更新するたびに、そのテンプレートを使用するすべてのジョブトリガーが更新されます。
Cloud DLP でサポートされるテンプレートには、検査テンプレート(このトピックで説明)と匿名化テンプレート(Cloud DLP 匿名化テンプレートの作成で説明)の 2 種類があります。
Cloud DLP におけるテンプレートのコンセプトについては、テンプレートをご覧ください。
新しい検査テンプレートの作成
新しい Cloud DLP テンプレートを作成する手順は次のとおりです。
Console
Cloud Console で Cloud DLP を開きます。
[作成] メニューで [テンプレート] を選択します。
または、次のボタンをクリックします。
[テンプレートの作成] ページには次のセクションがあります。
テンプレートの定義
[テンプレートの定義] で、検査テンプレートの識別子を入力します。この ID を使って、ジョブの実行時やジョブトリガーの作成時などにテンプレートを参照します。文字、数字、ハイフンを使用できます。必要に応じて、よりわかりやすい表示名と説明を入力して、テンプレートの内容を覚えやすくすることもできます。
検出の構成
次に、infoType などのオプションを選択して、Cloud DLP がコンテンツで検出する対象を構成します。
infoType 検出器は、特定の型の機密データを検出します。たとえば、Cloud DLP の US_SOCIAL_SECURITY_NUMBER
infoType 検出器では、米国社会保障番号が検出されます。組み込みの infoType 検出器に加えて、独自のカスタム infoType 検出器を作成できます。
[InfoType] で、スキャンするデータ型に対応する infoType 検出器を選択します。このフィールドを空白のままにして、デフォルトのすべての infoTypes をスキャン対象にすることもできます。それぞれの検出器の詳細については、InfoType 検出器リファレンスをご覧ください。
また、[カスタム infoType] セクションでカスタム infoType 検出器を追加し、[検査ルールセット] セクションで組み込みとカスタムの両方の infoType 検出器をカスタマイズできます。
カスタム infoType
To add a custom infoType detector:
- Click Add custom infoType.
- Choose the type of custom infoType detector you want to create:
- Words or phrases: Matches on one or more words or phrases that you enter into the field. Use this custom infoType when you have just a few words or phrases to search for. Give your custom infoType a name, and then, under List of words or phrases, type the word or phrase you want Cloud DLP to match on. To search on multiple words or phrases, press Enter after each one. For more information, see Creating a regular custom dictionary detector.
- Dictionary path: Searches your content for items in a list of words and phrases. The list is stored in a text file in Cloud Storage. Use this custom infoType when you have anywhere from a few to several hundred thousand words or phrases to search for. This method is also useful if your list contains sensitive elements and you don't want to store them inside of a job or template. Give your custom infoType a name, and then, under Dictionary location, enter or browse to the Cloud Storage path where the dictionary file is stored. For more information, see Creating a regular custom dictionary detector.
- Regex: Matches content based on a regular expression. Give your custom infoType a name, and then, in the Regex field, enter a regex pattern to match words and phrases. See the supported regex syntax.
- Stored infoType: This option adds a stored custom dictionary detector, which is a kind of dictionary detector that is built from either a large text file stored in Cloud Storage or a single column of a BigQuery table. Use this kind of custom infoType when you have anywhere from several hundred thousand to tens of millions of words or phrases to search for. Be aware that this is the only option in this menu for which you must have already created the stored infoType to use it. Give your custom infoType a name (different from the name you gave the stored infoType), and then, in the Stored infoType field, enter the name of the stored infoType. For more information about creating stored custom dictionaries, see Creating a stored custom dictionary detector.
Click Add custom infoType again to add additional custom infoType detectors.
検査ルールセット
Inspection rulesets allow you to customize both built-in and custom infoType detectors using context rules. The two types of inspection rules are:
- Exclusion rules, which help exclude false or unwanted findings.
- Hotword rules, which help detect additional findings.
To add a new ruleset, first specify one or more built-in or custom infoType detectors in the InfoTypes section. These are the infoType detectors that your rulesets will be modifying. Then, do the following:
- Click in the Choose infoTypes field. The infoType or infoTypes you specified previously appear below the field in a menu, as shown here:
- Choose an infoType from the menu, and then click Add rule. A menu appears with the two options Hotword rule and Exclusion rule.

For hotword rules, choose Hotword rules. Then, do the following:
- In the Hotword field, enter a regular expression that Cloud DLP should look for.
- From the Hotword proximity menu, choose whether the hotword you entered is found before or after the chosen infoType.
- In Hotword distance from infoType, enter the approximate number of characters between the hotword and the chosen infoType.
- In Confidence level adjustment, choose whether to assign matches a fixed likelihood level, or to increase or decrease the default likelihood level by a certain amount.
For exclusion rules, choose Exclusion rules. Then, do the following:
- In the Exclude field, enter a regular expression (regex) that Cloud DLP should look for.
- From the Matching type menu, choose one of the following:
- Full match: The finding must completely match the regex.
- Partial match: A substring of the finding can match the regex.
- Inverse match: The finding doesn't match the regex.
You can add additional hotword or exclusion rules and rulesets to further refine your scan results.
信頼度のしきい値
Cloud DLP で機密データの一致候補が検出されるたびに、可能性の値が「かなり低い」から「かなり高い」までの尺度で割り当てられます。ここで可能性の値を設定すると、Cloud DLP ではその設定に従って、その可能性の値以上のデータの一致のみが検出されます。
「可能性あり」はデフォルト値で、ほとんどの用途に十分対応できます。検出される一致が常に、あまりに広範に及ぶ場合は、スライダーを右に動かしてください。一致が少なすぎる場合は、スライダーを左に動かしてください。
設定が完了したら、[作成] をクリックしてテンプレートを作成します。テンプレートの要約情報のページが表示されます。
Cloud DLP のメインページに戻るには、Cloud Console の [戻る] 矢印をクリックします。
プロトコル
検査テンプレートは、再利用可能な検査構成といくつかのメタデータで構成されます。API の観点では、InspectTemplate
オブジェクトは事実上、InspectConfig
オブジェクトにいくつかのメタデータ(表示名や説明など)のフィールドを追加したものです。したがって、新しい検査テンプレートを作成するための基本的な手順は次のとおりです。
- 最初に
InspectConfig
オブジェクトを作成します。 projects.inspectTemplates
またはorganizations.inspectTemplates
リソースのcreate
メソッドを呼び出すか POST し、そのリクエストに表示名、説明、作成したInspectConfig
オブジェクトを入れたInspectTemplate
オブジェクトを含めます。
返された InspectTemplate
はすぐに使用できます。その name
を使用して、他の呼び出しやジョブでこのテンプレートを参照できます。既存のテンプレートを一覧表示するには、*.inspectTemplates.list
メソッドを呼び出します。特定のテンプレートを表示するには、*.inspectTemplates.get
メソッドを呼び出します。作成できるテンプレート数の上限は 1,000 個です。
過去に Cloud DLP を使用して機密コンテンツのテキスト、画像、構造化コンテンツを検査したことがある場合、InspectConfig
オブジェクトはすでに作成されています。もう 1 つの手順を行うだけで、これを InspectTemplate
オブジェクトに変換できます。
次の JSON は、projects.inspectTemplates.create
メソッドに送信できるものの例です。この JSON は、指定された表示名と説明を含む新しいテンプレートを作成し、infoType PHONE_NUMBER
と US_TOLLFREE_PHONE_NUMBER
に対する一致をスキャンします。スキャン結果には、可能性が POSSIBLE
以上である一致が最大 100 個と、それぞれのコンテキストのスニペットが含まれます。
JSON 入力:
POST https://dlp.googleapis.com/v2/projects/[PROJECT_ID]/inspectTemplates?key={YOUR_API_KEY}
{
"inspectTemplate":{
"displayName":"Phone number inspection",
"description":"Scans for phone numbers",
"inspectConfig":{
"infoTypes":[
{
"name":"PHONE_NUMBER"
},
{
"name":"US_TOLLFREE_PHONE_NUMBER"
}
],
"minLikelihood":"POSSIBLE",
"limits":{
"maxFindingsPerRequest":100
},
"includeQuote":true
}
}
}
JSON 出力:
レスポンスの JSON は次のようになります。
{
"name":"projects/[PROJECT_ID]/inspectTemplates/[JOB_ID]",
"displayName":"Phone number inspection",
"description":"Scans for phone numbers",
"createTime":"2018-11-30T07:26:28.164136Z",
"updateTime":"2018-11-30T07:26:28.164136Z",
"inspectConfig":{
"infoTypes":[
{
"name":"PHONE_NUMBER"
},
{
"name":"US_TOLLFREE_PHONE_NUMBER"
}
],
"minLikelihood":"POSSIBLE",
"limits":{
"maxFindingsPerRequest":100
},
"includeQuote":true
}
}
以下に埋め込まれている API Explorer を使用すれば、これをすぐに試すことができます。JSON を使用して Cloud DLP API にリクエストを送信する方法については、JSON クイックスタートをご覧ください。
Java
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
Node.js
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
Python
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
Go
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
PHP
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
C#
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
検査テンプレートの使用
新しい検査テンプレートを作成したら、それを新しい検査ジョブまたはジョブトリガーの作成時に使用できます。そのテンプレートを更新するたびに、そのテンプレートを使用するすべてのジョブトリガーで更新されます。コードサンプルなどの詳細については、以下をご覧ください。
Console
新しいテンプレートの使用を開始するには、Cloud DLP 検査テンプレートの作成のクイックスタートに記載されている手順に従います。
- [検出の構成] の [テンプレート] セクションで、[テンプレート名] フィールドをクリックし、作成したテンプレートを選択します。
コンテンツのスキャン方法の詳細については、Cloud DLP 検査ジョブの作成とスケジュール設定の「検出の構成」セクションをご覧ください。
プロトコル
次のような inspectTemplateName
が使用可能であればどこでも、テンプレートの作成時に指定したテンプレート ID を使用できます。
projects.content.inspect
: テンプレートを構成として使用して、コンテンツ内の潜在的な機密データを匿名化します。projects.content.deidentify
: テンプレートを構成として使用して、コンテンツ内の機密データを検出して匿名化します。このメソッドでは、検査テンプレートと匿名化テンプレートの両方を使用することに注意してください。InspectJobConfig
オブジェクト内のprojects.dlpJobs.create
: 構成としてテンプレートを含む検査ジョブを作成します。
検査テンプレートの一覧表示
現在のプロジェクトまたは組織で作成されたすべての検査テンプレートを一覧表示する手順は次のとおりです。
Console
Cloud Console で Cloud DLP を開きます。
[テンプレート] タブをクリックします。
現在のプロジェクトにあるすべての検査テンプレートが一覧表示されます。
プロトコル
*.*.list
メソッドのいずれかを使用します。
Java
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
Node.js
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
Python
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
Go
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
PHP
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
C#
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
検査テンプレートの削除
検査テンプレートを削除する手順は次のとおりです。
Console
Cloud Console で Cloud DLP を開きます。
[構成] タブ、[テンプレート] タブの順にクリックします。現在のプロジェクトにあるすべてのテンプレートが一覧表示されます。
削除するテンプレートの [操作] 列で、[その他の操作] メニュー(縦に並んだ 3 つの点)
をクリックし、[削除] をクリックします。
または、テンプレートの一覧から削除対象のテンプレートの名前をクリックし、テンプレートの詳細ページで [削除] をクリックします。
プロトコル
*.*.delete
メソッドのいずれかを使用します。
各 *.*.delete
メソッドには、削除するテンプレートのリソース名を含めます。
Java
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
Node.js
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
Python
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
Go
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
PHP
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。
C#
Cloud DLP 用のクライアント ライブラリをインストールして使用する方法については、Cloud DLP クライアント ライブラリをご覧ください。