Google cloud platform 如何在数据泄漏预防中使用自定义信息类型';s(谷歌云平台)反识别模板?
我正在开发使用数据泄漏预防(GCP)的PII de识别应用程序。我正在使用取消标识模板来取消标识规则 问题:我无法理解如何在身份验证模板中使用自定义信息类型 以下是一个示例身份验证模板:Google cloud platform 如何在数据泄漏预防中使用自定义信息类型';s(谷歌云平台)反识别模板?,google-cloud-platform,google-cloud-dlp,Google Cloud Platform,Google Cloud Dlp,我正在开发使用数据泄漏预防(GCP)的PII de识别应用程序。我正在使用取消标识模板来取消标识规则 问题:我无法理解如何在身份验证模板中使用自定义信息类型 以下是一个示例身份验证模板: { "deidentifyTemplate":{ "displayName":"Email and id masker", "description":"De-identifies emails and
{
"deidentifyTemplate":{
"displayName":"Email and id masker",
"description":"De-identifies emails and ids with a series of asterisks.",
"deidentifyConfig":{
"infoTypeTransformations":{
"transformations":[
{
"infoTypes":[
{
"name":"EMAIL_ADDRESS"
}
],
"primitiveTransformation":{
"characterMaskConfig":{
"maskingCharacter":"*"
}
}
}
]
}
}
}
}
在上面的示例中,它是一个bultin信息类型(电子邮件),文档中的自定义信息类型片段如下所示:
"inspect_config":{
"custom_info_types":[
{
"info_type":{
"name":"CUSTOM_ID"
},
"regex":{
"pattern":"[1-9]{2}-[1-9]{4}"
},
"likelihood":"POSSIBLE"
}
]
}
在deidentification template的rest文档中没有有效的inspect\u config
对象定义,它仅在inspection template中有效
是否可以在反标识模板(infoTypeTransformations
)中使用自定义信息类型
这是rest文档的示例。是的,可以使用自定义信息类型。需要做的是创建一个取消标识模板和一个检查模板 然后在调用API时,将两个模板作为参数发送进来。 对于使用dlp客户机库的python,下面是一些示例伪代码
from google.cloud import dlp_v2
dlp_client = dlp_v2.DlpServiceClient()
dlp_client.deidentify_content(
request={
inspect_template_name = "projects/<project>/locations/global/inspectTemplates/<templateId>,
deidentify_template_name = "projects/<project>/locations/global/deidentifyTemplates/<templateId>,
parent = <parent>,
item = <item>
}
)
从google.cloud导入dlp_v2
dlp_client=dlp_v2.DlpServiceClient()
dlp_client.deIdentity_内容(
请求={
检查\u template\u name=“项目//locations/global/inspectTemplates/,
deIdentity\u template\u name=“项目//位置/global/deIdentityTemplates/,
父项=,
项目=
}
)
我们可以在标识中使用
我们可以使用API调用创建存储的
信息类型,并且存储的
信息类型可以像内置信息类型一样被引用
创建存储信息类型
- 很少有全局变量和依赖项
- 进行api调用
如何引用存储的信息类型
- 使用deidentification template中的
存储的信息类型id
进行操作:
你的问题没有什么细节。你能分享一下你已经尝试过的东西吗?这样社区就可以从那里开始帮助你了?“这是一段关于如何提出好的堆栈溢出问题的视频。”JudithGuzman根据请求添加。请告诉我你的想法。嘿,我很高兴看到你的评论,就像我在一次家庭旅行中看到的一样。谢谢你编辑你的问题,现在你的问题更清楚了,我知道你是从哪里来的。有一个问题,您是否尝试将自定义信息类型用于?它似乎接受自定义信息类型。另外,您是否先试用了API?@JudithGuzmán似乎代理信息类型是特定于加密的。我的用例是:假设我有大量的文本文件,我想屏蔽IP
地址。为此,我需要能够找到定制模式(使用regex)并应用掩蔽转换。IP不是内置类型。除了IP,它还可以是其他任何东西。使用检查
模板很简单,我们有文档示例,但问题是取消标识
添加了听起来很有趣的内容,但我们需要维护两个模板。我找到了一个更简单的方法。创建存储的信息类型。目前正在探索。如果成功的话,我会写下答案,否则在更糟的情况下,我会尝试你的答案。我也喜欢你的方法,向上投票。了解单一解决方案的多种方法很好。如果你觉得我也很有趣,请告诉我
import google.cloud.dlp
import os
dlp = google.cloud.dlp_v2.DlpServiceClient()
default_project = os.environ['GOOGLE_PROJECT'] # project id
parent = f"projects/{default_project}"
# details of custom info types
custom_info_id = "<unique-id>" # example: IP_ADDRESS
custom_info_id_pattern = r"<regex pattern>"
info_config = {
"display_name": custom_info_id,
"description": custom_info_id,
"regex":
{
"pattern": custom_info_id_pattern
}
}
response = dlp.create_stored_info_type(request={
"parent": parent,
"config": info_config,
"stored_info_type_id": custom_info_id
})
{
"info_types":[
{
"name":"IP_ADDRESS" # this is defined stored_info_type_id
}
],
"primitive_transformation":{
"character_mask_config":{
"characters_to_ignore":[
{
"characters_to_skip":"."
}
],
"masking_character":"*"
}
}
},