Using hotword rules, you can further extend built-in and custom infoType detectors with powerful context rules. A hotword rule instructs Sensitive Data Protection to adjust the likelihood of a finding, depending on whether a hotword occurs near that finding. A hotword rule is a kind of inspection rule, which is specified in rule sets. Each rule is applied to a set of built-in or custom infoTypes.
Anatomy of a hotword rule
An infoType detector can have zero or more hotword rules. In your
inspection configuration, you
define each HotwordRule
object inside the rules array, as follows:
"rules":[
{
"hotwordRule":{
"hotwordRegex":{
"pattern":"REGEX_PATTERN"
},
"proximity":{
"windowAfter":"NUM_CHARS_TO_CONSIDER_AFTER_FINDING",
"windowBefore":"NUM_CHARS_TO_CONSIDER_BEFORE_FINDING"
}
"likelihoodAdjustment":{
"fixedLikelihood":"LIKELIHOOD_VALUE"
-- OR --
"relativeLikelihood":"LIKELIHOOD_ADJUSTMENT"
},
}
},
...
]
Replace the following:
- REGEX_PATTERN: a regular expression
(
Regexobject) that defines what qualifies as a hotword. - NUM_CHARS_TO_CONSIDER_AFTER_FINDING: a range of characters after the finding. Sensitive Data Protection analyzes this range to determine whether a hotword occurs near the finding.
NUM_CHARS_TO_CONSIDER_BEFORE_FINDING: a range of characters before the finding. Sensitive Data Protection analyzes this range to determine whether a hotword occurs near the finding.
LIKELIHOOD_VALUE: a fixed
Likelihoodlevel to set the finding to.LIKELIHOOD_ADJUSTMENT: a number that indicates how much Sensitive Data Protection must increase or decrease the likelihood of the finding. A positive integer increases the likelihood level, and a negative integer decreases it. For example, if a finding would be
POSSIBLEwithout the detection rule andrelativeLikelihoodis 1, then the finding is upgraded toLIKELY. IfrelativeLikelihoodis -1, then the finding is downgraded toUNLIKELY. Likelihood can never drop lower thanVERY_UNLIKELYor exceedVERY_LIKELY. In these cases, the likelihood level remains the same. For example, if the base likelihood isVERY_LIKELYand therelativeLikelihoodis 1, the final likelihood remains to beVERY_LIKELY.
Hotword example: Match medical record numbers
Suppose you want to detect a custom infoType such as a medical record number (MRN) in the form "###-#-#####". Also, you want Sensitive Data Protection to increase the match likelihood of each finding that follows the hotword "MRN".
Example values:
- 123-4-56789 would match as
POSSIBLE. - MRN 123-4-56789 would match as
VERY_LIKELY.
The following JSON example and code snippets show you how to configure the hotword rule. This example uses a custom regular expression detector.
In this example, note the following:
- The request defines the
C_MRNcustom infoType, which is a detector for any string that matches the regular expression[0-9]{3}-[0-9]{1}-[0-9]{5}. - The regular expression
(?i)(mrn|medical)(?-i)defines the hotword. Sensitive Data Protection searches for this hotword within the range of characters defined in theproximityfield. - For each
C_MRNfinding that has a hotword within the setproximity, Sensitive Data Protection sets the likelihood level toVERY_LIKELY.
C#
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.