本主题详细介绍如何创建新的检查模板。如需快速浏览如何使用敏感数据保护界面创建新的检查模板,请参阅快速入门:创建敏感数据保护检查模板。
模板简介
您可以使用模板创建和保留配置信息,以用于敏感数据保护。模板可用于分离配置信息(如检查的内容和对内容进行去标识化的方式)与请求的实现。模板提供了一种方法,让您能够重复使用配置并在用户和数据集之间实现一致性。此外,每次您更新模板时,系统都会为使用该模板的任何作业触发器更新该模板。
敏感数据保护支持本主题中讨论的检查模板,以及创建敏感数据保护去标识化模板中讨论的去标识化模板。
如需了解敏感数据保护中模板的概念性信息,请参阅模板。
创建新的检查模板
控制台
在 Google Cloud 控制台中,前往创建模板页面。
创建模板页面包含以下部分:
定义模板
在定义模板下,输入检查模板的标识符。在运行作业及创建作业触发器等操作时您可以借此引用模板。标识符可使用字母、数字和连字符。如果需要,您还可以输入更便于理解的显示名以及说明,以便更好地记住模板的用途。
在 Resource location 字段中,选择要存储要检查的数据的区域。您创建的检查模板也会存储在此区域中。如果您希望能够在任何区域中使用新的检查模板,请选择 Global (any region)。
配置检测
接下来,选择 infoType 和其他选项,配置敏感数据保护在内容中检测的内容。
InfoType 检测器会查找特定类型的敏感数据。例如,敏感数据保护 US_SOCIAL_SECURITY_NUMBER
infoType 检测器会查找美国社会保障号。除了内置的 infoType 检测器之外,您还可以创建自己的自定义 infoType 检测器。
在 InfoTypes 部分中,选择与您要扫描以查找的数据类型相对应的 infoType 检测器。我们不建议您将此部分留空。这样做会使敏感数据保护使用一组默认的 infoType 扫描数据,其中可能包括您不需要的 infoType。如需详细了解每种检测器,请参阅 InfoType 检测器参考文档。
如需详细了解如何管理内置和自定义 infoType,请参阅通过 Google Cloud 控制台管理 infoType。
检查规则集
置信度阈值
每当敏感数据保护检测到敏感数据的潜在匹配项时,它就会为其分配一个可能性值,范围从“可能性极小”到“极有可能”。如果您在此处设置可能性值,则表示敏感数据保护仅匹配与该可能性值或更高值相对应的数据。
默认值“可能”(Possible) 足以满足大多数情况。如果您经常获得太过宽泛的匹配项,请调高滑块的值。如果匹配项太少,请调低滑块的值。
完成后,请点击创建以创建模板。您将看到模板的汇总信息页面。
如需返回“敏感数据保护”主页面,请点击 Google Cloud 控制台中的返回箭头。
C#
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Go
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Java
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Node.js
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
PHP
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Python
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
REST
检查模板是一种可重复使用的检查配置,外加一些元数据。在 API 术语中,InspectTemplate
对象其实相当于另外包含几个元数据字段(如显示名和说明)的 InspectConfig
对象。因此,如需创建新的检查模板,可执行下列基础步骤:
- 从
InspectConfig
对象开始。 - 调用或通过 POST 发布
projects.inspectTemplates
或organizations.inspectTemplates
资源的create
方法,在请求中包含一个带显示名、说明和该InspectConfig
对象的InspectTemplate
对象。
返回的 InspectTemplate
立即可供使用。您可以通过其 name
在其他调用或作业中引用它。您可以通过调用 *.inspectTemplates.list
方法列出现有模板。如需查看特定模板,请调用 *.inspectTemplates.get
方法。请注意,可创建的模板数量上限为 1000。
如果您曾使用敏感数据保护检查文本、图片或结构化内容是否包含敏感内容,则表示您已创建 InspectConfig
对象。再执行一步,即可将其转换为 InspectTemplate
对象。
下面的 JSON 示例展示了您可以向 projects.inspectTemplates.create
方法发送哪些内容。此 JSON 会创建一个具有给定显示名和说明的新模板,并依据 infoType PHONE_NUMBER
和 US_TOLLFREE_PHONE_NUMBER
扫描匹配项。其结果中将包含最多 100 个可能性至少为 POSSIBLE
的匹配项,以及每个匹配项的一小段上下文。
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
}
}
如需快速尝试此操作,您可以使用下面嵌入的 APIs Explorer。 如需了解有关如何使用 JSON 将请求发送到 DLP API 的一般信息,请参阅 JSON 快速入门。
使用检查模板
创建新的检查模板后,您可以在创建新的检查作业或作业触发器时使用模板。每次您更新模板时,系统都会为使用该模板的任何作业触发器更新该模板。如需了解详情(包括代码示例),请参阅:
控制台
如需快速开始使用新模板,请按照快速入门:创建敏感数据保护检查模板中提供的说明操作,并做出以下更改:
- 在配置检测 > 模板部分中,点击模板名称字段,然后选择刚创建的模板。
如需更深入地了解如何扫描内容,请参阅创建和安排敏感数据保护检查作业,并特别注意“配置检测”部分。
REST
您可以在任何接受 inspectTemplateName
的位置使用您在创建模板时指定的模板标识符,例如:
projects.content.inspect
:使用模板作为其配置,查找内容中可能的敏感数据。projects.content.deidentify
:使用模板作为其配置,查找内容中可能的敏感数据并对其进行去标识化。请注意,此方法会同时使用检查模板和去标识化模板。InspectJobConfig
对象中的projects.dlpJobs.create
:创建一个将模板作为其配置的检查作业。
列出检查模板
如需列出已在当前项目或组织中创建的所有检查模板,请执行以下操作:
控制台
在 Google Cloud 控制台中,打开“敏感数据保护”。
点击模板标签页。
Console 中显示当前项目的所有检查模板的列表。
C#
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Go
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Java
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Node.js
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
PHP
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Python
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
REST
使用其中一种 *.*.list
方法:
将检查模板复制到 global
区域
在 Google Cloud 控制台中,前往敏感数据保护配置页面。
在工具栏中,点击项目选择器,然后选择您要使用的检查模板所在的项目。
点击模板标签页,然后点击检查子标签页。
点击要使用的模板的 ID。
在 Inspection template details 页面上,点击 Copy。
在创建模板页面的资源位置列表中,选择 Global (any region)。
点击创建。
该模板已复制到 global
区域。
将检查模板复制到其他项目
在 Google Cloud 控制台中,前往敏感数据保护配置页面。
在工具栏中,点击项目选择器,然后选择您要使用的检查模板所在的项目。
点击模板标签页,然后点击检查子标签页。
点击要使用的模板的 ID。
在 Inspection template details 页面上,点击 Copy。
在工具栏中,点击项目选择器,然后选择要将检查模板复制到的项目。
您选择的项目中会重新加载创建模板页面。
点击创建。
模板将在您选择的项目中创建。
删除检查模板
如需删除检查模板,请执行以下操作:
控制台
在 Google Cloud 控制台中,打开“敏感数据保护”。
点击配置标签页,然后点击模板标签页。Console 会显示当前项目的所有模板的列表。
在要删除的模板的操作列中,点击更多操作菜单(显示为纵向排列的三个点)
,然后点击删除。
或者,从模板列表中,点击要删除的模板的名称。在模板的详细信息页面上,点击删除。
C#
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Go
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Java
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Node.js
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
PHP
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
Python
如需了解如何安装和使用用于敏感数据保护的客户端库,请参阅敏感数据保护客户端库。
如需向敏感数据保护服务进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证。
REST
使用其中一种 *.*.delete
方法:
无论使用哪种 *.*.delete
方法,均需添加要删除的模板的资源名称。