Text of docs.github.com › en › code-security › reference › code-scanning › sarif-files › sarif-su… as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

SARIF support for code scanning - GitHub Docs

Skip to main content Skip to content Collapse sidebar Expand sidebar SARIF support for code scanning Ensure your SARIF files from third-party tools comply with GitHub's standards. Who can use this feature? Code scanning is available for the following repository types: Public repositories on GitHub.com Organization-owned repositories on GitHub Team, GitHub Enterprise Cloud, or GitHub Enterprise Server, with GitHub Code Security enabled.

In this article GitHub can parse SARIF files produced by third-party tools to display code scanning alerts in repositories. For more information, see About SARIF files for code scanning . This article highlights key properties of SARIF files to help you upload SARIF files that meet GitHub's requirements and can be converted into useful alerts. If you're using GitHub Actions with the CodeQL analysis workflow or using the CodeQL CLI, then the code scanning results will automatically use the supported subset of SARIF 2.1.0.

Data for preventing duplicated alerts Each time the results of a new code scan are uploaded, the results are processed and alerts are added to the repository. To prevent duplicate alerts for the same problem, code scanning uses fingerprints to match results across various runs so they only appear once in the latest run for the selected branch. This makes it possible to match alerts to the correct line of code when files are edited.

The ruleId for a result has to be the same across analysis. Consistent filepaths The filepath has to be consistent across the runs to enable a computation of a stable fingerprint. If the filepaths differ for the same result, each time there is a new analysis a new alert will be created, and the old one will be closed. This will cause having multiple alerts for the same result. Fingerprint generation GitHub uses the partialFingerprints property in the OASIS standard to detect when two results are logically identical.

For more information, see the partialFingerprints property entry in the OASIS documentation. SARIF files created by the CodeQL analysis workflow, or using the CodeQL CLI include fingerprint data. If you upload a SARIF file using the upload-sarif action and this data is missing, GitHub attempts to populate the partialFingerprints field from the source files. For more information about uploading results, see Uploading a SARIF file to GitHub .

If you upload a SARIF file without fingerprint data using the /code-scanning/sarifs API endpoint, the code scanning alerts will be processed and displayed, but users may see duplicate alerts. To avoid seeing duplicate alerts, you should calculate fingerprint data and populate the partialFingerprints property before you upload the SARIF file. You may find the script that the upload-sarif action uses a helpful starting point: https://github.com/github/codeql-action/blob/main/src/fingerprints.ts .

For more information about the API, see REST API endpoints for code scanning . Rules and results SARIF files support both rules and results. The information stored in these elements is similar but serves different purposes. Rules are an array of reportingDescriptor objects that are included in the toolComponent object. This is where you store details of the rules that are run during analysis. Information in these objects should change infrequently, typically when you update the tool.

Results are stored as a series of result objects under results in the run object. Each result object contains details for one alert in the codebase. Within the results object, you can reference the rule that detected the alert. When you compare SARIF files generated by analyzing different codebases with the same tool and rules, you should see differences in the results of the analyses but not in the rules. Source file locations Specifying source file locations and lines of code ensures code scanning alerts are displayed accurately within the file containing the identified problem, allowing for targeted issue resolution.

This precision enhances the efficiency of code review and resolution processes, streamlining development workflows by enabling developers to address issues directly in the context of their codebase. Code scanning will also display alerts in pull request check results when all the lines of code identified by the alert exist in the pull request diff. For display in a pull request check, an alert must meet all the following conditions: All the lines of code identified by the alert exist in the pull request diff, including the first line of the alert.

The alert must exist in the lines of code added or edited in the pull request, not lines that were deleted. The physicalLocation object in a submitted SARIF file identifies the lines of code for an alert. For more information, see physicalLocation object . Root location for source files Code scanning interprets results that are reported with relative paths as relative to the root of the repository analyzed. If a result contains an absolute URI, the URI is converted to a relative URI.

The relative URI can then be matched against a file committed to the repository. You can provide the source root for conversion from absolute to relative URIs in one of the following ways. checkout_path input to the github/codeql-action/analyze action checkout_uri parameter to the SARIF upload API endpoint. For more information, see REST API endpoints for code scanning . invocations[0].workingDirectory.uri property in the run object in the SARIF file If you provide a source root, any location of an artifact specified using an absolute URI must use the same URI scheme.

If there is a mismatch between the URI scheme for the source root and one or more of the absolute URIs, the upload is rejected. For example, a SARIF file is uploaded using a source root of file:///github/workspace . # Conversion of absolute URIs to relative URIs for location artifacts file:///github/workspace/src/main.go -> src/main.go file:///tmp/go-build/tmp.go -> file:///tmp/go-build/tmp.go The file is successfully uploaded as both absolute URIs use the same URI scheme as the source root.

Symlink resolution If the relative URI for a result is matched against a file defined using a symlink, code scanning is unable to display the result. So you need to resolve any symlinked files, and report any results in those files using the resolved URI. File compatibility You can check a SARIF file is compatible with code scanning by testing it against the GitHub ingestion rules. For more information, visit the Microsoft SARIF validator .

For each gzip-compressed SARIF file, SARIF upload supports a maximum size of 10 MB. Any uploads over this limit will be rejected. If your SARIF file is too large because it contains too many results, you should update the configuration to focus on results for the most important rules or queries. For more information, see SARIF results file is too large . Code scanning supports uploading a maximum number of entries for the data objects in the following table.

If any of these objects exceeds its maximum value the SARIF file is rejected. For some objects, there is also an additional limit on the number of values that will be displayed. Whenever possible the most important values are shown. To get the most out of your analysis when it includes data above the supported limits, try to optimize the analysis configuration (for example, for the CodeQL tool, identify and disable the most noisy queries).

For more information, see SARIF results exceed one or more limits . SARIF data Maximum values Data truncation limits Runs per file 20 None Results per run 25,000 Only the top 5,000 results will be included, prioritized by severity. Rules per run 25,000 None Tool extensions per run 100 None Thread Flow Locations per result 10,000 Only the top 1,000 Thread Flow Locations will be included, using prioritization. Location per result 1,000 Only 100 locations will be included.

Tags per rule 20 Only 10 tags will be included. Alert Limit 1,000,000 N

The rest of this page is on the live site.