MSBA-361 · Lesson 5 of 12 · 18 min
Third-party scanning tools and SARIF
▶ Video coming soon A video version of this lesson is on the way.
CodeQL was not the only analysis tool at Skerry. The store firmware team had paid for a commercial static analyzer for C long before anyone mentioned GitHub, because the payment terminal certification body expected it. The platform team ran an open-source scanner over its infrastructure-as-code files, the Terraform and Kubernetes definitions that described Skerry's cloud. And two web teams used a linter with security rules for their front-end code. Each tool had its own dashboard, its own login and its own idea of severity. Seraphine's goal for the fifth session was to bring their results into code scanning, so that developers had one list and security overview had one picture.
Why bring other tools in
Code scanning accepts results from any tool that can write SARIF. Bringing them in has three benefits. Developers see every tool's findings in the same pull request annotations and alert list. The same triage, dismissal, assignment and campaign features work on all of them. And security overview can report across tools instead of the security team exporting spreadsheets from five dashboards.
Choosing between CodeQL and a third-party tool is not always either-or. The GH-500 code security domain asks candidates to understand both options and when each fits.
| Consider | CodeQL | Third-party tool |
|---|---|---|
| Language and framework coverage | Broad for mainstream languages; models for many frameworks | May cover languages, frameworks or file types CodeQL does not, such as infrastructure-as-code |
| Integration with GitHub | Native; default setup, Autofix, campaigns | Through SARIF upload; some partner tools also support Autofix |
| Specialist requirements | General security analysis | May be required by a certification body, regulator or customer |
| Cost | Included with Code Security, free on public repositories | Separate licence in many cases |
| Custom rules | CodeQL queries and packs | The tool's own rule language |
At Skerry the answer was both. CodeQL ran on all in-scope repositories. The commercial C analyzer stayed on the firmware repositories because certification required it, and the infrastructure scanner covered file types CodeQL does not analyze.
What SARIF is
SARIF, the Static Analysis Results Interchange Format, is an OASIS standard for the output of analysis tools. A SARIF file is JSON. GitHub supports a subset of SARIF version 2.1.0. The important parts for code scanning are few.
| SARIF element | What it holds | Why code scanning cares |
|---|---|---|
| run | One execution of one tool | Each run is processed separately; a file can contain several runs |
| tool.driver | The tool's name, version and rules | Shown as the tool on each alert |
| rules | Each rule's ID, description, help and properties | Become the rule, help text and tags on alerts |
| results | Each finding: rule, message, location, level | Each result becomes or updates an alert |
| properties such as security-severity | A numeric score for a rule | Mapped to critical, high, medium or low security severity |
| partialFingerprints | Values that identify a result across commits | Let code scanning recognize the same problem after code moves |
| codeFlows | Step-by-step paths for a result | Shown as the data flow path on the alert |
{
"version": "2.1.0",
"runs": [{
"tool": { "driver": {
"name": "Example IaC Scanner",
"rules": [{
"id": "IAC-014",
"shortDescription": { "text": "Storage bucket allows public read" },
"properties": { "security-severity": "7.5", "tags": ["security"] }
}]
}},
"results": [{
"ruleId": "IAC-014",
"level": "error",
"message": { "text": "Bucket store-photos is readable by anyone." },
"locations": [{ "physicalLocation": {
"artifactLocation": { "uri": "infra/storage.tf" },
"region": { "startLine": 22 }
}}]
}]
}]
}The security-severity property is the part teams most often miss. Code scanning maps a numeric score from 0.1 to 10.0 to security severity: above 9.0 is critical, 7.0 to 8.9 high, 4.0 to 6.9 medium, and 0.1 to 3.9 low. A third-party tool that does not provide this property produces alerts with a severity but no security severity, which means they cannot be filtered or gated in the same way as CodeQL's security alerts. Part of onboarding a tool at Skerry was checking that its SARIF carried security-severity values and tags, and asking the vendor for an update where it did not.
Fingerprints matter as well. If a tool does not provide fingerprints, the upload action computes some from the code. Without stable fingerprints, a result that moves because someone added lines above it can look like a new alert plus a fixed one, which spoils metrics and loses dismissal history.
Uploading SARIF
There are two ways to upload SARIF to code scanning.
| Method | How | Typical use |
|---|---|---|
| upload-sarif action | A step in a GitHub Actions workflow that uploads a file the earlier steps produced | Tools that run in Actions |
| Code scanning REST API | A request that sends the SARIF, compressed and encoded, with the commit and ref | Tools that run in other CI systems or on a vendor's service |
| CodeQL CLI upload command | The CLI's upload-results command | CodeQL running outside Actions, as in lesson 2 |
jobs:
iac-scan:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v5
- name: Run the infrastructure scanner
run: ./tools/run-iac-scan.sh --format sarif --output iac.sarif
- name: Upload results to code scanning
if: always()
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: iac.sarif
category: iacTwo details in that workflow are easy to get wrong. The upload step runs if: always(), so that results are uploaded even when the scanning step exits with a failure code because it found problems; otherwise the alerts would never reach GitHub. And the category distinguishes this tool's results from any other upload for the same repository, just as it does for CodeQL analyses.
Uploads go through the same permission as CodeQL: the workflow token needs security-events write access. For the REST API, a token or GitHub App with permission to write security events for the repository is needed, and the request names the commit and ref the results belong to. Results for a pull request should use the pull request's merge ref, so that the alerts appear on the pull request.
Limits
Code scanning accepts large files but has limits. Some are soft limits, which reduce what is stored and displayed, and some are hard limits, which cause the upload to be rejected. The GH-500 exam expects awareness that limits exist and what happens when they are exceeded, rather than memorizing every value.
| Limit | Value | If exceeded |
|---|---|---|
| Runs per file | 20 | Upload rejected |
| Results per run | 25,000 | Only the top 5,000 results, by severity, are included |
| Rules per run | 25,000 | Upload rejected |
| Locations per result | 1,000 | Only 100 locations are included |
| Thread flow locations per result | 10,000 | Only the top 1,000 are included |
| Tags per rule | 20 | Only 10 tags are included |
| Alerts per repository | 1,000,000 | All analysis uploads can be blocked |
The firmware team hit the first soft limit in its first upload. The commercial analyzer's default configuration reported style issues alongside security issues, and one repository produced 31,000 results. Code scanning kept the top 5,000 by severity, which happened to be the right ones, but the team reconfigured the tool to report only its security rules so that the alert list was complete and meaningful.
Troubleshooting uploads
When third-party results do not appear, the cause is usually one of a short list.
| Symptom | Likely cause | Fix |
|---|---|---|
| Upload step fails with a permission error | Workflow lacks security-events write | Add the permission to the job |
| Results never appear when the scanner finds problems | The scan step failed and stopped the job before upload | Run the upload with if: always() |
| New results replace another tool's alerts | Two uploads share a category | Give each tool its own category |
| Alerts appear and disappear on every push | Unstable fingerprints | Provide partialFingerprints or keep file paths stable |
| Alerts have no security severity | SARIF lacks the security-severity property | Configure or update the tool |
| Upload rejected as invalid | SARIF outside the supported subset, or too large | Validate against the schema; split or reduce the file |
The code scanning settings page for a repository lists each tool and analysis category, when it last uploaded and whether processing succeeded. The tool status page shows the same information with warnings, such as CodeQL failing to extract files for a language. Seraphine made checking tool status part of onboarding any new tool.
Autofix and third-party tools
Since October 2024, GitHub has extended Copilot Autofix to alerts from some partner tools, starting with a JavaScript linter's security rules. Coverage depends on the tool, so teams should not assume every third-party alert will have a suggested fix. The two web teams' linter alerts did get suggestions; the firmware and infrastructure scanners' alerts did not, which was acceptable because both tools came with their own remediation guidance.
Governing which tools upload
Letting any workflow upload results to code scanning can produce clutter: experiments that never get cleaned up, duplicate tools, and alerts nobody owns. Skerry set three rules. A tool could upload to in-scope repositories only after the security team had reviewed it and agreed its category name. Each approved tool had an owning team. And the shared workflows in the platform-workflows repository, which MSBA-360 introduced, provided the standard upload steps, so teams called a reusable workflow instead of writing their own.
Worked problem
Onboarding a tool
The data group wants to upload results from an open-source SQL linter to code scanning for its 32 pipeline repositories. The linter writes SARIF without security-severity properties and flags every SELECT without a WHERE clause. What should Seraphine ask for before approving it?
Show solution
- Decide whether the linter finds security problems or mainly style issues; if mostly style, keep it in the team's own checks rather than code scanning.
- If kept, configure it to report only rules the team will act on.
- Add security-severity and tags in the SARIF, through tool configuration or a post-processing step, so alerts can be filtered and gated.
- Agree a category name and an owning team, and use the shared upload workflow.
Answer: Approve only a security-relevant rule set, with security-severity values, a dedicated category, an owner and the standard upload workflow; leave style rules out of code scanning.
Mapping third-party severity
Every tool has its own idea of severity. One rates a finding as "major", another as 8 out of 10, another as "P1". Code scanning understands two things: the SARIF level, which becomes the alert's severity of error, warning or note, and a security-severity property on the rule, a number from 0.1 to 10 that becomes critical, high, medium or low. A tool that does not set security-severity produces alerts with no security severity, and those do not trigger a ruleset's security alerts threshold.
Skerry's firmware analyzer set levels but not security-severity. Seraphine wrote a small conversion step in the firmware workflow that added security-severity values to the analyzer's rules from a mapping table the firmware team agreed, before upload. The infrastructure scanner already set security-severity, but rated nearly everything high, so for that tool the gate was configured to block only on critical until the platform team had reviewed the mapping.
| Tool | Severity in its own report | security-severity after mapping | Shown as |
|---|---|---|---|
| Firmware analyzer | Category A | 9.1 | Critical |
| Firmware analyzer | Category B | 7.5 | High |
| Firmware analyzer | Category C | 5.0 | Medium |
| Infrastructure scanner | Set by the tool | Unchanged | Mostly high; gate blocks only critical for now |
Paths and fingerprints
Two other details decide whether uploaded results behave well. File paths in the SARIF must be relative to the repository root, or GitHub cannot place the alert on a line, and the alert appears without a code location. And results should carry stable fingerprints, values that identify the same finding from one run to the next, so that an alert stays the same alert as the code moves. The upload-sarif action computes fingerprints when a tool does not provide them, which is one reason to prefer the action over a raw API call.
Common mistakes
MistakeUploading SARIF only when the scanner succeeds.
InsteadRun the upload with if: always() so findings reach code scanning even when the scan exits with an error code.
MistakeReusing one category for several tools.
InsteadGive each tool or analysis its own category.
MistakeIgnoring security-severity in third-party SARIF.
InsteadMake sure security rules carry scores so alerts can be prioritized and gated.
MistakeSending every style warning to code scanning.
InsteadUpload rules the team will act on, so the alert list stays meaningful.
Summary and key terms
- Code scanning accepts results from any tool that writes SARIF 2.1.0, alongside CodeQL.
- One alert list across tools gives developers and security teams the same triage and reporting features.
- SARIF runs, rules, results, security-severity, fingerprints and code flows map to alert features.
- Upload with the upload-sarif action, the REST API or the CodeQL CLI, with security-events write permission.
- Use if: always() and a distinct category for each tool.
- Soft limits truncate results; hard limits reject uploads.
- Govern which tools upload, who owns them and how they are configured.
- SARIF
- Static Analysis Results Interchange Format, an OASIS standard JSON format for analysis results.
- Run
- In SARIF, one execution of one tool, containing its rules and results.
- security-severity
- A SARIF rule property with a score that code scanning maps to critical, high, medium or low.
- partialFingerprints
- SARIF values that identify a result across commits so code scanning can track it.
- upload-sarif
- The GitHub Action step that uploads a SARIF file to code scanning.
- Soft limit
- A limit that reduces what is stored and displayed.
- Hard limit
- A limit that causes an upload to be rejected.
- Tool status page
- The page that shows each code scanning tool's recent uploads and problems.
Practice problems
Work each problem on paper first, then reveal the answer to check.
What security severity does a SARIF security-severity score of 7.5 produce?
Show answer
High (7.0 to 8.9).
What happens when a run contains 30,000 results?
Show answer
Only the top 5,000, prioritized by severity, are included.
Why give the infrastructure scanner its own category?
Show answer
So its results are tracked separately and do not replace other analyses.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.