Skip to main content

Command: Run Static Analysis and export to Sarif file

Symbol: _san_icon_sarif.png

Function: This command starts the static code analysis and saves the result in a SARIF file.

Call: Build → Static Analysis menu

A SARIF file ("Static Analysis Results Interchange Format") is a machine-readable JSON file with the file extension "*.sarif.json" which is created by Static Analysis to store the results in a standardized format. 

SARIF is an OASIS standard. This means that various tools and platforms can use it to exchange and process the analysis results.

Command-line commands

The command can also be executed automatically via CODESYS Scripting. The batch command ["staticanalysis", "runandexportosarif"] accepts the arguments below.

Argument: --sariffile

--sariffile=<path to output>;

Specify the path where the resulting SARIF file should be written. If you do not specify a path, then the file is saved in the folder of the current project.

Argument: --rulesfile

--rulesfile=<patch to CSA file>;

Specify the path to a CSA file which should be used for the static analysis. If you do not specify a path, then the current configuration is used.

Example 14. Example of the call in a Python script
system.commands["staticanalysis", "runandexportosarif"].execute("--sariffile=result.sarif", "--rulesfile=rules.csa")