← Blog

Penetration Testing and AI-Generated Code: The Report Does Not Say Who Wrote the Line

Marco Masut

A penetration test is an authorised simulated attack on a system, carried out by specialists to find exploitable vulnerabilities before someone else does. The outcome is a report: a list of findings with severity and remediation guidance. It is useful, and no delivery process should go without it. But it is a downstream, sample-based check: it tells you something is vulnerable, not where it came from or who introduced it. When a coding agent proposes part of the code, the gap between "we found the problem" and "we understand how it got there" grows, and the fix slows down exactly where it should be fastest. That is why the final test is worth pairing with a record produced during development: the request, the declared scope, the checks that ran and the signature of whoever approved. The report then attaches to a story instead of staying an isolated list. This piece is written for teams working under European customer and audit expectations.

It does not belittle the pentest and does not claim to replace it. It is about what the pentest lacks upstream.

What does a penetration test do and when is it done?

A pentest looks at the system from outside, or with test credentials, and tries to exploit what it finds. It is usually done before a major release, after significant architecture changes, at a customer's request or under contractual security requirements. It has known limits, which are not flaws but the nature of the tool.

| Characteristic | What it means | What it leaves uncovered | | --- | --- | --- | | Downstream | Acts when the code already exists | The choices made while writing it | | Sample-based | Covers the agreed scope in a given period | Whatever changes after the test date | | On the running system | Shows what is exploitable | Who introduced the line and from which request | | Delivered as a report | Lists issues and severity | The link between issue, change and approval |

Why does finding the flaw not mean understanding how it got there?

The report says, for instance, that a parameter is not validated at a certain point. Fixing it takes one line. But preventing a repeat requires knowing how it happened: an ambiguous request, a scope too wide, a missing check, a change approved without anyone really reading it?

Without a record, the answers are rebuilt from memory, from repository history or from a chat that has since ended. That is slow and often incomplete, and the next pentest will find the same kind of issue elsewhere.

What changes when an agent proposes part of the code?

With a coding agent, the choice is born inside a session that ends and leaves nothing but the code. Whoever reads the report months later finds no ticket with a discussion and no author who remembers why it was written that way. The METR study of 10/07/2025 measured experienced developers using AI tools taking 19% longer while believing they were faster: a feeling of having checked is no substitute for a recorded check.

This is not an argument against agents. It is an argument for making them leave the records a person would leave without noticing: scope, checks, approval. The same logic applies to AI-assisted code review: its value depends on what remains as evidence.

How long passes between the report and the fix?

Time to fix grows for three reasons, all avoidable:

  • it is unclear who owns the affected code;
  • nobody knows which checks already ran on that change;
  • nobody knows whether the same choice was repeated in other modules.

A structured record shortens each of these steps. A bill of materials, see the software bill of materials for AI-generated code, answers the third question for dependencies. The rest depends on what you record about the code written in-house.

What should you keep on record so the report becomes action?

A short list, built for whoever has to answer a customer or an auditor:

  1. the original request and the declared scope for each task;
  2. the list of modified files and the outcome of automated checks, with date and command run;
  3. the name of whoever approved the delivery;
  4. the link between each report finding and the change that introduced it, where it can be reconstructed;
  5. the result of the retest after the fix, archived with the rest.

Detent, the end-to-end delivery line (detent-ai.com), leaves this trail by default: request, checks run by the system and not by the model, a person's signature, all in versioned files. It does not replace a penetration test or certify software security: it is one station on the line, and the test stays downstream. For data on how it compares with other tools, see the benchmark page.