An AI code-generation agent is creating feature branches and committing code directly. A security engineer is concerned the agent might accidentally include hardcoded secrets in its generated code. Which control provides the strongest protection against agent-generated code containing secrets reaching the repository?
Select an answer to reveal the explanation.
Short Explanation
You need an external gate that stops secrets before they enter git history. GitHub Secret Scanning with push protection blocks commits containing recognized secret patterns at push time, so the agent can't sneak a key into the repo. Self-review or human review won't give you that independent, always-on check.
Full Explanation
GitHub Secret Scanning with push protection evaluates every commit's diff at the time of push against a library of secret patterns (keys, tokens, and credentials for hundreds of services) maintained and updated by GitHub. If a recognized secret pattern is detected, the push is blocked and the committer, or in this case the agent's workflow, receives an error identifying the file and line containing the suspected secret.
This is the correct control for this threat because it is independent of the agent. The agent may not recognize that a value it generated is a secret. It may have fabricated a realistic-looking key as a placeholder, or it may have included a secret it retrieved from context in its output. An independent scanner with up-to-date secret patterns provides a check that does not rely on the agent's self-awareness.
The historical git record is particularly important to protect: a secret that enters git history is retrievable even after the secret is removed in a later commit, because git preserves all commit history. Push protection prevents the secret from ever entering the history, which is the only truly safe outcome.
The training developers to review agent commits before they are pushed option is incorrect because human review at scale is impractical for agent-generated commits and introduces human error. Developers cannot review every agent commit in real time, and subtle generated secrets may not be recognizable to a human reviewer.
The agent-run grep option is incorrect because the agent's self-review uses the same model that may have generated the secret. The model may not recognize its own output as a secret, and its pattern library is limited to what was in its training data. It cannot check against the comprehensive, regularly updated pattern library that GitHub Secret Scanning maintains.
The Dependabot alerts option is incorrect because Dependabot alerts flag known vulnerable dependencies, not secrets hardcoded in source code. These are different security controls for different threat categories.