Repository navigation
Conversation
The api_token pattern knew api_key, access_token and secret_key, but not the AWS secret access key name, so AWS_SECRET_ACCESS_KEY=..., an ~/.aws/credentials profile, STS "SecretAccessKey" JSON and SDK secretAccessKey literals were not reported. The name now takes the value checks prefixed names already use, with or without a prefix, and its value must have the 40 characters of an AWS secret, so SDK code that reads the secret from a reference or a short variable stays unflagged.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
On
main(9abd77d),PIIDetector().detected_types(...)returns[]for an AWS secret access key under the names AWS documents.api_key=<same value>is reported asapi_token. Theapi_tokenkey-name list holdsapi_key,access_tokenandsecret_key, sosecret_access_keymatches none becausesecret_keyrequires adjacent words.This change adds one regex alternative matching
secret[_-]?access[_-]?key(case-insensitive, at the start or where the preceding character does not match case-insensitive[A-Za-z0-9], such as after the_inAWS_) forAWS_SECRET_ACCESS_KEY,aws_secret_access_key,SecretAccessKeyandsecretAccessKey. Matched values use #393's prefixed-name checks: a digit directly followed by a letter in the first 64 characters, and no placeholder, call or subscript, and no dotted identifier unless it starts like a JWT (eyJ...on both sides of the first dot). The value must also run at least 40 characters, the length of the secret in the AWS CLI configuration examples. The name stays out of the loose bare-name alternative. The values insecretAccessKey: process.env.AWS_SECRET_ACCESS_KEYandsecretAccessKey: awsCredentialsFor2faare below the 40-character minimum, and a dotted reference of 40 or more characters, such asprocess.env.AWS_S3CRET_ACCESS_KEY_PRODUCTIONin the new test, is skipped by the reference check. The change only adds findings. One sentence in the PII section ofdocs/refusal_classifier_plugins.mdnames the key names theapi_tokencheck looks at.How it was tested
test_detects_aws_secret_access_key_names(tests/unit/refusal_classifier/test_pii_detector.py) checks six reported forms and seven unreported ones:=None, prose, two identifiers shorter than 40 characters, and a placeholder, call and reference of 40 or more characters with a digit followed by a letter, so only those checks skip them. It fails withmain's detector swapped in and passes with this branch's detector.test_api_token_scan_is_linear_on_dotted_valuesaddssecretAccessKey=with 100,000a.pairs and!, finishing under 1 s. The defaultpytestrun passes (654 passed and 4 skipped on a clean checkout, macOS arm64, Python 3.15.2).agentic_security.tomlenabling onlypii,refusal_heuristic(OpenAI-shaped body) andpii_leak_heuristic(agentic_security.probe_actor.refusal) change fromFalsetoTrueon four answers (~/.aws/credentials,export AWS_SECRET_ACCESS_KEY=..., STS"SecretAccessKey"and a JSnew AWS.Credentialsliteral). Three answers stayFalse(process.env.,os.environ[...]and environment prose).main, all toward the label and none away. Every inputmainreports is still reported.Checklist
pytestpasses and new behaviour has a test. Tests don't call paid APIs.pre-commit run --all-filesis clean.docs/refusal_classifier_plugins.mdnow names the key names anapi_tokenhit covers.