AI vulnerability scanners and traditional static analysis tools prove different things. A static analyzer proves that specific code patterns exist in source: a tainted value reaching a sink, a missing bounds check, a known-vulnerable dependency version. An AI scanner proves something weaker and broader: that a model, given the code or runtime context, judges a region suspicious, often with a natural-language explanation and a suggested fix. Neither proves exploitability. Use static analysis for deterministic, reproducible, rule-backed findings you can trace to a line of code, and use AI scanning for triage, coverage of unfamiliar codebases, and catching logic and configuration smells that no rule encodes. Run both, and verify every finding by hand.
The steps below set up a comparison you can run on your own repository so you can see what each tool actually proves on your code, not on a vendor demo. Menu labels and setting names differ slightly by tool version, edition and region, so treat the paths as examples and look for the equivalent section in your build.
What You'll Need
- A repository you are allowed to scan, ideally a small service with a lockfile or package manifest committed.
- One traditional static analysis tool installed and runnable from the command line (for example Semgrep, CodeQL, or a language-native linter such as Bandit, gosec or ESLint with security rules).
- One AI-assisted scanner that accepts a codebase or diff, either a hosted code-review service or a local model with repository access.
- A build that compiles or a test suite that runs, so the static analyzer can resolve dependencies and types.
- A spreadsheet or issue tracker with columns for finding, tool, file and line, rule or prompt, confidence, and whether it was confirmed by hand.
- Permission in writing to send code to any hosted AI service; check your organisation's data-handling policy first.
Step-by-Step
- Pick a baseline. Choose one repository and one commit. Record the commit hash so both tools see identical code. If the repository is large, restrict to one module or service directory.
- Install and configure the static analyzer. Add its config file to the repo so the rule set is versioned. Run it once with the default rules and once with the security-focused ruleset. Save the raw output (SARIF or JSON) to a file.
- Read the static analyzer's output and classify each finding. For each one, note whether the tool can show the exact data flow or only the pattern. A data-flow finding (source to sink) is stronger evidence than a pattern match on a single line.
- Run the AI scanner on the same commit. Give it the same scope. If it accepts a prompt, ask it to report only issues it can point to a file and line for, and to state its confidence. Save the output verbatim.
- Normalise both outputs into your spreadsheet. One row per finding. Keep the tool's own wording in a column so you can quote it later.
- De-duplicate. Match findings that describe the same defect. Note which tool found it first and whether the other tool missed it entirely.
- Verify every finding by hand. Open the file, read the surrounding code, and decide whether the issue is real. For a suspected injection, trace the input path yourself. For a dependency finding, confirm the installed version from the lockfile, not from the manifest.
- Write down what each tool proved. For a static finding, the proof is the rule plus the code path. For an AI finding, the proof is the model's reasoning plus your manual confirmation. Record the difference explicitly.
- Measure the misses. For a sample of confirmed issues, check whether each tool flagged them. Also check what each tool flagged that turned out to be noise. This gives you a false-positive and false-negative picture on your own code.
- Repeat on a diff. Run both tools on a pull request rather than the whole repo. AI scanners tend to do better on small diffs with context; static analyzers tend to be more consistent across runs. Compare the results.
- Decide the gate. Choose which tool blocks a merge and which only comments. Static analyzers with a stable rule set are usually the better gate because their output is reproducible. AI findings usually work better as review prompts.
- Document the workflow. Put the commands, the config files and the triage rules in the repository so the next person gets the same result.
Common Mistakes
- Treating an AI finding as proof of a vulnerability. A model's judgement is evidence, not a demonstration. Confirm it by reading the code or writing a test.
- Treating a clean static analysis run as proof of safety. Static analyzers only prove the absence of the patterns their rules encode. They say nothing about logic flaws, business-rule bypasses or misconfiguration outside their rule set.
- Scanning different commits or different scopes and comparing the counts. Always pin the commit and the directory.
- Letting the AI scanner see the static analyzer's output first. That biases it toward agreeing. Run them independently.
- Ignoring dependency findings because the scanner did not flag them. Check the lockfile directly; neither tool is a substitute for a software bill of materials.
- Sending code to a hosted AI service without checking the data policy. Source code can contain secrets and customer data.
Tips
- Ask the AI scanner for a minimal reproducing input or a test case. If it cannot produce one that you can verify, downgrade the finding.
- Keep the static analyzer's rule set small and reviewed. A noisy gate gets disabled, and a disabled gate proves nothing.
- Use the AI scanner on code you did not write. It is most useful where your team lacks familiarity, because it does not depend on someone having written a rule.
- Log the model or tool version with every run. AI output changes between versions even on identical input; static output should not.
- Prefer SARIF or JSON output from both tools so you can diff runs and track findings over time.
Troubleshooting
If the static analyzer reports nothing at all, check that it actually parsed the files: most tools print a count of analysed files, and a zero or a tiny number usually means the config excluded your source directory or the build failed. Fix the build first, then rerun.
If the static analyzer produces hundreds of findings, do not disable it. Narrow the scope to one module, raise the severity threshold, and triage the remainder by hand before widening again.
If the AI scanner returns vague findings with no file or line, tighten the prompt to require a location and a confidence level, and reduce the scope to a single diff. If it still cannot point to a line, treat the finding as unverifiable.
If the two tools disagree wildly, that is the expected result and the point of the exercise. Check whether the disagreement is about scope, about the rule set, or about what counts as a finding, before concluding either tool is wrong.
If a hosted AI service refuses the request or times out on a large repository, split the scan by directory and run it in batches. Do not paste secrets or credentials into the prompt.
Frequently Asked Questions
Can an AI scanner replace a static analyzer?
No. They prove different things. A static analyzer gives reproducible, rule-backed findings traceable to a code path. An AI scanner gives broader, judgement-based findings that need manual confirmation. Use both.
Does a clean static analysis run mean the code is secure?
No. It means the rules you ran did not match. Logic flaws, authorisation mistakes and misconfiguration often fall outside what rules encode.
Is an AI finding proof of a vulnerability?
No. It is a lead. Confirm it by reading the code, tracing the input, or writing a test that demonstrates the issue.
Which one should block a merge?
Usually the static analyzer, because its output is stable and reproducible. AI findings work better as review comments, since the same input can produce different output on different runs.
Will either tool find vulnerable dependencies?
Some static analyzers include dependency rules, and some AI scanners will comment on manifests, but neither is a reliable substitute for checking the lockfile against an advisory database. Do that separately.
Can I send private source code to an AI scanner?
Only if your organisation's policy allows it and the provider's data-handling terms permit it. Check before you paste anything, and never include secrets or customer data in a prompt.