尝试将 customInfoType 与 hotwordRule 结合使用。配置如下所示(取自nodeJS实现):
自定义信息类型:
const customConfig = [{
    infoType: {
      name: 'CZECH_ID'
    },
    regex: {
      pattern: /[0-9]{2,6}-?[0-9]{2,10}\/[0-9]{4}/
    },
    likelihood: 'POSSIBLE'
  }];
自定义规则集:
const customRuleSet = [{
    infoTypes: [{ name: 'CZECH_ID' }],
    rules: [
      {
        hotwordRule: {
          hotwordRegex: {
            pattern: /^CZID$/
          }
        },
        proximity: {
          windowBefore: 10,
          windowAfter: 0
        }
      }
    ]
  }]
在这里inspectConfig:
const request = {
    parent: `projects/${projectId}/locations/global`,
    inspectConfig: {
      infoTypes: infoTypes,
      customInfoTypes: customConfig,
      ruleSet: customRuleSet,
      minLikelihood: 'POSSIBLE',
      limits: {
        maxFindingsPerRequest: maxFindings,
      },
      includeQuote: true,
    },
    item: item,
  };
运行它时,我得到:
Error: 3 INVALID_ARGUMENT: `window_before` and `window_after` cannot both be 0.
当我customeRuleSet从运行配置中删除它时,它通过了,但没有识别字符串。所以它必须与该proximity部分做一些事情,但不确定是什么问题。