Fixing Static Analysis Findings at Scale: A Remediation Playbook

How to fix static analysis findings from Fortify, Veracode and SonarQube at scale: triage by root cause, fix patterns and prove it with a clean rescan.

By Victor Sanchez

The first scan we received on a long-lived legacy application listed well over a thousand Fortify findings. Fixing static analysis findings at that scale, one by one and in the order the tool printed them, would have taken months and broken calculations along the way.

What worked was treating the report as data, not as a to-do list. Today we use the same playbook for Veracode and SonarQube findings on modern web applications, where findings span the front end, the API and the database.

Why do static analysis findings come in clusters?

A SAST tool applies rules to your source code or binaries and reports every place a rule matches. One bad habit produces dozens or hundreds of findings with the same rule ID. In our experience, a large report is driven by a small number of root causes:

  • A data-access helper that builds SQL with string concatenation, called from hundreds of places.
  • A connection string with a password, copied into several config files and classes.
  • Missing validation on a shared input control or DTO.
  • An old framework version whose defaults trigger weak-crypto or insecure-protocol rules.

Fix the helper and you close every finding it causes. Fix each call site and you touch hundreds of places, and each change is a chance to break something.

How to triage static analysis findings step by step

1. Export and normalize the report

Fortify, Veracode and SonarQube all offer exports or APIs. Load the findings into something you can query: a spreadsheet works, a SQL table works better. Keep each tool's own identifier so you can match findings between scans.

CREATE TABLE Finding (
    FindingId  NVARCHAR(64)  NOT NULL PRIMARY KEY, -- the tool's instance id
    Tool       NVARCHAR(20)  NOT NULL,             -- Fortify / Veracode / Sonar
    RuleId     NVARCHAR(200) NOT NULL,
    Severity   NVARCHAR(20)  NOT NULL,
    FilePath   NVARCHAR(400) NOT NULL,
    LineNumber INT           NULL,
    Sink       NVARCHAR(200) NULL,                 -- method where the tainted data lands
    Triage     NVARCHAR(20)  NOT NULL DEFAULT 'New' -- New / Fix / NotExploitable / Accepted
);

2. Group by rule and by sink

The most useful query is also the simplest one:

SELECT RuleId, Sink,
       COUNT(*)                 AS Findings,
       COUNT(DISTINCT FilePath) AS Files
FROM Finding
WHERE Triage = 'New'
GROUP BY RuleId, Sink
ORDER BY Findings DESC;

On that platform, the top rows told the whole story: the SQL injection findings ended in two data-access methods, and the password findings pointed to the same connection string in a handful of files. Hundreds of findings collapsed into a few dozen root causes.

3. Separate false positives early, with evidence

Some findings are not exploitable: the value comes from a constant, or the tool does not recognize your sanitizer. Mark them, but always write down why. An auditor accepts "not exploitable: the value is an enum converted to int on line 84". Nobody accepts "false positive". Each tool has its own audit or mitigation workflow; use it instead of suppressing the warning in code, so the reasoning travels with the finding.

4. Fix patterns, not lines

For each cluster, design one fix, apply it everywhere and prevent regressions. This is the shape of the helper behind most of our SQL injection findings:

// Vulnerable: called from hundreds of places in the app
public DataTable GetClients(string name)
{
    var sql = "SELECT * FROM Clients WHERE Name LIKE '%" + name + "%'";
    var adapter = new SqlDataAdapter(sql, _connection);
    var table = new DataTable();
    adapter.Fill(table);
    return table;
}

We replaced raw SQL with Entity Framework queries, which send the value as a parameter:

// Fixed: EF generates WHERE Name LIKE @p0, the value travels as a parameter
public List<Client> GetClients(string name)
{
    return _db.Clients
        .AsNoTracking()
        .Where(c => c.Name.Contains(name))
        .ToList();
}

Then block the old pattern so it cannot come back. The Roslyn banned-API analyzer (Microsoft.CodeAnalysis.BannedApiAnalyzers) reads a BannedSymbols.txt file and raises a build warning when someone calls a banned member:

M:Legacy.Data.SqlHelper.ExecuteQuery(System.String);Use the parameterized repository methods

The same approach applies to the other clusters. Hardcoded credentials disappeared when we moved the app to Windows Authentication (more in our post on hardcoded secrets). Validation findings were closed with one shared special-character validator instead of hundreds of ad hoc checks. For the full SQL story, see Stop concatenating SQL.

5. Keep behavior stable while you fix

Security fixes on financial code are only useful if the numbers stay the same. Before changing a shared helper, we capture its current outputs with characterization tests and compare them after the change. Watch for intentional differences too: the concatenated query failed on names like O'Brien and treated % and _ typed by users as wildcards. The parameterized version handles them differently, which is correct but must be noted.

We also upgraded the application to .NET Framework 4.7 during the remediation, which let it rely on the operating system's TLS defaults instead of hardcoded protocol versions. That upgrade shipped in its own release, so any change could be traced to a single cause. If you are planning a bigger jump, see .NET Core vs .NET Framework.

6. Rescan, diff and report

Ship one pull request per root cause, rescan after each batch with the same scan configuration, and compare by finding ID:

StatusMeaningAction
ClosedPresent before, gone nowLink to the PR that closed it
Still openSame ID, same locationCheck that the fix reached that path
NewNot present beforeOften introduced by the fix itself: review first

Common pitfalls when fixing SAST findings

  • Suppressing in code. A #pragma or annotation hides the finding without explaining it. Use the tool's audit workflow.
  • Fixing the flagged line, not the source. Tools often flag the sink. Validate or parameterize where the data enters or where the pattern lives.
  • Using the finding count as the only KPI. Teams start chasing easy, low-severity findings. Report by severity and root cause.

Remediation checklist

  • Findings exported to a queryable table with tool IDs.
  • Findings grouped by rule and sink; root causes listed.
  • Every non-exploitable finding has a written, reviewed justification.
  • One fix per pattern, applied everywhere, with a guard against regressions.
  • Characterization tests around the code you change.
  • Framework upgrades isolated in their own release.
  • Rescan with the same configuration; closed, open and new findings reviewed.

Key takeaways

  • A large report usually has a few root causes. Find them with a GROUP BY.
  • Fix patterns and block them from coming back.
  • Document false positives in the tool, with evidence.
  • Stable behavior is part of the fix, not an afterthought.
  • The rescan is the proof. Diff it by finding ID.

Sources

Need help with a static analysis backlog?

At Santhor we run security audits and remediate existing .NET applications: we triage Fortify, Veracode and SonarQube reports, fix the root causes and keep your behavior stable until the rescan comes back clean. We are based in Costa Rica and work nearshore with teams in the U.S. and Latin America. Tell us about your project.

More articles ยท Contact Santhor