Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
GitHub Docs

CodeQL CLI SARIF output

You can output SARIF from the CodeQL CLI and share static analysis results with other systems.

Who can use this feature?

CodeQL is available for the following repository types:

About SARIF output

SARIF is designed to represent the output of a broad range of static analysis tools, and there are many features in the SARIF specification that areconsidered "optional". This document details the output produced when using the format typesarifv2.1.0, which corresponds to the SARIF v2.1.0.csd1 specification. For more information on selecting a file format for your analysis results, seedatabase analyze.

SARIF specification and schema

This article is intended to be read alongside the detailed SARIF specification. For more information on the specification and the SARIF schema, see theSARIF specification documentation.

Change notes

Changes between versions

CodeQL versionFormat typeChanges
2.0.0sarifv2.1.0First version of this format.

Future changes to the output

The output produced for a given specific format type (for example,sarifv2.1.0) may change in future CodeQL releases. We will endeavor to maintain backwards compatibility with consumers of the generated SARIF by ensuring that:

  • Fields that are marked as always being generated will never be removed.

  • For fields that are marked as not always being generated, the circumstances under which the fields are generated may change. Consumers of the CodeQL SARIF output should be robust to the presence or absence of these fields.

New output fields may be added in future releases under the same format type–these are not considered to break backwards compatibility, and consumers should be robust to the presence of newly added fields.

New format argument types may be added in future versions of CodeQL—for example, to support new versions of SARIF. These have no guarantee of backwards compatibility, unless explicitly documented.

Generated SARIF objects

This details each SARIF component that may be generated, along with any specific circumstances. We omit any properties that are never generated.

sarifLog object

JSON property nameAlways generated?Notes
$schemaProvides a link to theSARIF schema.
versionThe version of the SARIF used to generate the output.
runsAn array containing a single run object, for one language.

run object

JSON property nameAlways generated?Notes
toolNone
artifactsAn array containing at least one artifact object for every file referenced in a result.
resultsNone
newLineSequencesNone
columnKindNone
propertiesThe properties dictionary will contain thesemmle.formatSpecifier, which identifies the format specifier passed to the CodeQL CLI.

tool object

JSON property nameAlways generated?Notes
driverNone

toolComponent object

JSON property nameAlways generated?Notes
nameSet to "CodeQL command-line toolchain" for output from the CodeQL CLI tools. Note, if the output was generated using a different tool a differentname is reported, and the format may not be as described here.
organizationSet to "GitHub".
versionSet to the CodeQL release version e.g. "2.0.0".
rulesAn array ofreportingDescriptor objects that represent rules. This array will contain, at a minimum, all the rules that were run during this analysis, but may contain rules which were available but not run. For more detail about enabling queries, seedefaultConfiguration.

reportingDescriptor object (for rule)

reportingDescriptor objects may be used in multiple places in the SARIF specification. When areportingDescriptor is included in the rules array of atoolComponent object it has the following properties.

JSON property nameAlways generated?Notes
idWill contain the@id property specified in the query that defines the rule, which is usually of the formatlanguage/rule-name (for examplecpp/unsafe-format-string). If your organization defines the@opaqueid property in the query it will be used instead.
nameWill contain the@id property specified in the query. See theid property above for an example.
shortDescriptionWill contain the@name property specified in the query that defines the rule.
fullDescriptionWill contain the@description property specified in the query that defines the rule.
defaultConfigurationAreportingConfiguration object, with the enabled property set to true or false, and a level property set according to the@severity property specified in the query that defines the rule. Omitted if the@severity property was not specified.

artifact object

JSON property nameAlways generated?Notes
locationAnartifactLocation object.
indexThe index of theartifact object.
contentsIf results are generated using the--sarif-add-file-contents flag, and the source code is available at the time the SARIF file is generated, then thecontents property is populated with anartifactContent object, with thetext property set.

artifactLocation object

JSON property nameAlways generated?Notes
uriNone
indexNone
uriBaseIdIf the file is relative to some known abstract location, such as the root source location on the analysis machine, this will be set.

result object

The composition of the results is dependent on the options provided to CodeQL. By default, the results are grouped by unique message format string and primary location. Thus, two results that occur at the same location with the same underlying message, will appear as a single result in the output. This behavior can be disabled by using the flag--ungroup-results, in which case no results are grouped.

JSON property nameAlways generated?Notes
ruleIdSee the description of theid property inreportingDescriptor object (for rule) .
ruleIndexNone
messageA message describing the problem(s) occurring at this location. This message may be a SARIF "Message with placeholder", containing links that refer to locations in therelatedLocations property.
locationsAn array containing a singlelocation object.
partialFingerprintsA dictionary from named fingerprint types to the fingerprint. This will contain, at a minimum, a value for theprimaryLocationLineHash, which provides a fingerprint based on the context of the primary location.
codeFlowsThis array may be populated with one or morecodeFlow objects if the query that defines the rule for this result is of@kind path-problem.
relatedLocationsThis array will be populated if the query that defines the rule for this result has a message with placeholder options. Each unique location is included once.
suppressionsIf the result is suppressed, then this will contain a singlesuppression object, with the@kind property set toIN_SOURCE. If this result is not suppressed, but there is at least one result that has a suppression, then this will be set to an empty array, otherwise it will not be set.

location object

JSON property nameAlways generated?Notes
physicalLocationNone
idlocation objects that appear in therelatedLocations array of aresult object may contain theid property.
messagelocation objects may contain themessage property if:

- They appear in therelatedLocations array of aresult object may contain themessage property.

- They appear in thethreadFlowLocation.location property.

physicalLocation object

JSON property nameAlways generated?Notes
artifactLocationNone
regionIf the givenphysicalLocation exists in a text file, such as a source code file, then theregion property may be present.
contextRegionMay be present if this location has an associatedsnippet.

region object

There are two types ofregion object produced by CodeQL:

  • Line/column offset regions

  • Character offset and length regions

Any region produced by CodeQL may be specified in either format, and consumers should robustly handle either type.

For line/column offset regions, the following properties will be set:

JSON property nameAlways generated?Notes
startLineNone
startColumnNot included if equal to the default value of 1.
endLineNot included if identical tostartLine.
endColumnNone
snippetNone

For character offset and length regions, the following properties will be set:

JSON property nameAlways generated?Notes
charOffsetProvided ifstartLine,startColumn,endLine, andendColumn are not populated.
charLengthProvided ifstartLine,startColumn,endLine, andendColumn are not populated.
snippetNone

codeFlow object

JSON property nameAlways generated?Notes
threadFlowsNone

threadFlow object

JSON property nameAlways generated?Notes
locationsNone

threadFlowLocation object

JSON property nameAlways generated?Notes
locationNone

[8]ページ先頭

©2009-2025 Movatter.jp