feat(govern): redact common credential names such as OPENAI_API_KEY and PGPASSWORD
What does this MR do and why?
Follow-up to !4345 (merged). sensitiveKey decides which names have their values redacted, both for JSON keys in tool arguments and for NAME=value and NAME: value in text. It only matched a bare api_key or secret_key, and needed a - or _ before password, passwd and pwd. So common names were sent as they were.
These now match:
*_API_KEY, such asOPENAI_API_KEYandANTHROPIC_API_KEY*_SECRET_KEY, such asSTRIPE_SECRET_KEY*_PRIVATE_KEY, such asSSH_PRIVATE_KEY*_PWD, such asMYSQL_PWD- names ending in
passwordorpasswd, with or without a separator, such asPGPASSWORD
Names that only contain those words, such as api_key_id, secret_key_name or password_file, are kept. Every name the old pattern matched still matches.
It also fixes the rule for paths. !4345 (merged) never redacted a value in text that started with / or ~, to keep PWD=/home/.... That also kept passwords and base64 secrets that start with /, such as about 1 in 64 AWS secret keys. Now only PWD holding a path is kept, in text and JSON, and PWD in an ODBC connection string (...;PWD=...;) is still redacted.
Known limits:
- Names such as
requirePasswordorhasPasswordnow match, so a JSON value like"true"under them is redacted. Text isn't affected, because a value needs 8 characters and a digit. - A path under another credential name, such as
SSH_PRIVATE_KEY: ~/.ssh/id_ed25519, is redacted. - camelCase names such as
openaiApiKeyandclientSecretstill don't match, as before.
How to validate
go test ./internal/commands/govern/audit/sync/ -run 'TestRedact'Closes #8728