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 and Infographic
An agent reviewing its own output for secrets is like asking the fox to guard the henhouse — the model that generated the secret might not recognize it as one. Push protection is an independent, external control that blocks secret-containing commits at the platform level before they ever enter git history, regardless of what the agent thinks about its own output. The correct answer is B.
Full explanation below image
Full Explanation
GitHub Secret Scanning with push protection evaluates every commit's diff at the time of push against a library of secret patterns (API keys, tokens, 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.
Push protection 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 API 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.
Option A 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.
Option C 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.
Option D is incorrect because Dependabot alerts flag known vulnerable dependencies, not secrets hardcoded in source code. These are different security controls for different threat categories.