@@ -45,6 +45,8 @@ var outputPIIPublicIPPattern = regexp.MustCompile(`\b\d{1,3}(?:\.\d{1,3}){3}\b`)
4545var outputPIINamePattern = regexp .MustCompile (`\b[A-Z][a-z]+ [A-Z][a-z]+\b` )
4646var outputPIISecretAssignmentPattern = regexp .MustCompile (`(?i)\b(?:api[_\-]?key|token|secret|password)\b\s*[:=]\s*\S{8,}` )
4747var outputPIISecretPrefixPattern = regexp .MustCompile (`\b(?:AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{36}|gho_[A-Za-z0-9]{36}|github_pat_[A-Za-z0-9_]{59}|sk-ant-[A-Za-z0-9\-_]{90,}|sk-[A-Za-z0-9]{20,}|hf_[A-Za-z0-9]{37}|npm_[A-Za-z0-9]{36}|AIza[0-9A-Za-z\-_]{35}|sk_live_[A-Za-z0-9]{24,}|pk_live_[A-Za-z0-9]{24,}|xox[baprs]-[0-9A-Za-z\-]{10,48})\b` )
48+ var outputPIIAzureSASPattern = regexp .MustCompile (`(?i)\bsig=[a-zA-Z0-9%]{40,}\b` )
49+ var outputPIIAWSSecretPattern = regexp .MustCompile (`\b[0-9a-zA-Z/+]{40}\b` )
4850
4951var outputPIISSNContextWords = []string {"ssn" , "social security" , "social sec" }
5052var outputPIIPhoneContextWords = []string {"phone" , "call" , "mobile" , "cell" , "tel" , "contact" }
@@ -299,9 +301,30 @@ func redactPIIText(text string, details []piiMatch) string {
299301func redactOutputSecrets (text string ) string {
300302 out := outputPIISecretAssignmentPattern .ReplaceAllString (text , "[REDACTED-KEY]" )
301303 out = outputPIISecretPrefixPattern .ReplaceAllString (out , "[REDACTED-KEY]" )
304+ out = outputPIIAzureSASPattern .ReplaceAllString (out , "sig=[REDACTED-SAS]" )
305+ out = redactAWSSecretKeys (out )
302306 return out
303307}
304308
309+ // redactAWSSecretKeys redacts 40-char base64-like tokens that appear in AWS secret context.
310+ func redactAWSSecretKeys (text string ) string {
311+ contextPattern := regexp .MustCompile (`(?i)\b(?:aws|secret)\b` )
312+ for _ , loc := range outputPIIAWSSecretPattern .FindAllStringIndex (text , - 1 ) {
313+ start := loc [0 ] - 50
314+ if start < 0 {
315+ start = 0
316+ }
317+ end := loc [1 ] + 50
318+ if end > len (text ) {
319+ end = len (text )
320+ }
321+ if contextPattern .FindStringIndex (text [start :end ]) != nil {
322+ text = text [:loc [0 ]] + "[REDACTED-AWS-SECRET]" + text [loc [1 ]:]
323+ }
324+ }
325+ return text
326+ }
327+
305328// piiRedactionTag returns the canonical replacement tag for a detected PII type.
306329func piiRedactionTag (t string ) string {
307330 switch t {
0 commit comments