Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Static Analysis Results Interchange Format (SARIF) format? #1797

Closed
Xazax-hun opened this issue Nov 1, 2018 · 13 comments · Fixed by #4011
Closed

Support Static Analysis Results Interchange Format (SARIF) format? #1797

Xazax-hun opened this issue Nov 1, 2018 · 13 comments · Fixed by #4011
Labels
analyzer 📈 Related to the analyze commands (analysis driver) discussion 💡 enhancement 🌟

Comments

@Xazax-hun
Copy link
Contributor

CSA just gained the ability to output SARIF: llvm-mirror/clang@962c092#diff-e47bf599aad9618f970aa41d0f09bf4f

Do we want to support this for interop with other tools? (Or prefer over plist at some point?)
Even if we consume plist it would be great to be able to generate both plist and sarif at the same time so both CodeChecker and other tools can consume the same results.

@whisperity whisperity added the analyzer 📈 Related to the analyze commands (analysis driver) label Nov 1, 2018
@Szelethus
Copy link
Contributor

Please note that the Sarif output still needs a great amount of maturing, for example, it can't handle checkers loaded from plugins, which is a particularly great weakness for our use case. Sadly, the elegant solution for this is very non-trivial, but is on the way.

But of course, that shouldn't stop us from considering using it in the future.

@gyorb
Copy link
Contributor

gyorb commented Apr 11, 2019

I do not see any bug id (hash) in the generated report. Maybe it should be added to the output or we should generate the report id in CodeChecker for it.

@gyorb
Copy link
Contributor

gyorb commented Oct 22, 2019

The current latest SARIF specification v2.10.

See the list of oasis standards

@gyorb gyorb changed the title Support Sarif format? Support Static Analysis Results Interchange Format (SARIF) format? Oct 22, 2019
@csordasmarton
Copy link
Contributor

Documentation:

Questions:

Remaining questions:

  • One sarif file for every analysis run with all the results.
  • JSON parsing might get slow with lot of results.
  • This will change the current behavior where we update only a few plist files.

Further notes:

  • Thread flows in code flow object can be used to represent a bug path (thread flow describes a time-ordered sequence of code locations on a single thread of execution). Code flow can have multiple thread flows

Useful links:

@Xazax-hun
Copy link
Contributor Author

@csordasmarton did a really good analysis above. I wanted to provide some updates on tools using/supporting SARIF since then:

@Xazax-hun
Copy link
Contributor Author

It looks like GCC's static analyzer will also have SARIF support in GCC 13.

@Trass3r
Copy link

Trass3r commented Nov 13, 2022

@damiencarol
Copy link

Any news on this new feature?

@dgutson
Copy link

dgutson commented Feb 13, 2023

we will resume work on this soon, @Franco0700

Szelethus pushed a commit to Szelethus/codechecker that referenced this issue Sep 18, 2023
Fixes Ericsson#1797. Based on a PR authored by @csordasmarton.

We've long wanted to support sarif
(https://sarifweb.azurewebsites.net/), and finally, this is the first
real step towards it!
Szelethus pushed a commit to Szelethus/codechecker that referenced this issue Sep 18, 2023
Fixes Ericsson#1797. Based on a commit authored by @csordasmarton. Credit goes
to him!

We've long wanted to support sarif
(https://sarifweb.azurewebsites.net/), and finally, this is the first
real step towards it!

This patch can both parse and and export to sarif.
Szelethus pushed a commit to Szelethus/codechecker that referenced this issue Sep 18, 2023
Fixes Ericsson#1797. Based on a commit authored by @csordasmarton. Credit goes
to him!

We've long wanted to support sarif
(https://sarifweb.azurewebsites.net/), and finally, this is the first
real step towards it!

This patch can both parse and and export to sarif.
Szelethus pushed a commit to Szelethus/codechecker that referenced this issue Sep 18, 2023
Fixes Ericsson#1797. Based on a commit authored by @csordasmarton. Credit goes
to him!

We've long wanted to support sarif
(https://sarifweb.azurewebsites.net/), and finally, this is the first
real step towards it!

This patch can both parse and and export to sarif.
Szelethus pushed a commit to Szelethus/codechecker that referenced this issue Oct 4, 2023
Fixes Ericsson#1797. Based on a commit authored by @csordasmarton. Credit goes
to him!

We've long wanted to support sarif
(https://sarifweb.azurewebsites.net/), and finally, this is the first
real step towards it!

This patch can both parse and export to sarif.

My intent is that the code is self explanatory (because I explained
things in the code!), there are two things I'd like to highlight:

1. I strugged a LOT with mypy, which lead me to express a things things
   in a rather cumbersome manner. I left comments around these parts
2. I copied all example tests from https://github.com/microsoft/sarif-tutorials/
   to tools/report-converter/tests/unit/parser/sarif/sarif_test_files/.
   These examples come with an MIT licence, which I also copied over.
Szelethus pushed a commit to Szelethus/codechecker that referenced this issue Oct 4, 2023
Fixes Ericsson#1797. Based on a commit authored by @csordasmarton. Credit goes
to him!

We've long wanted to support sarif
(https://sarifweb.azurewebsites.net/), and finally, this is the first
real step towards it!

This patch can both parse and export to sarif.

My intent is that the code is self explanatory (because I explained
things in the code!), there are two things I'd like to highlight:

1. I strugged a LOT with mypy, which lead me to express a things things
   in a rather cumbersome manner. I left comments around these parts
2. I copied all example tests from https://github.com/microsoft/sarif-tutorials/
   to tools/report-converter/tests/unit/parser/sarif/sarif_test_files/.
   These examples come with an MIT licence, which I also copied over.
Szelethus pushed a commit to Szelethus/codechecker that referenced this issue Oct 10, 2023
Fixes Ericsson#1797. Based on a commit authored by @csordasmarton. Credit goes
to him!

We've long wanted to support sarif
(https://sarifweb.azurewebsites.net/), and finally, this is the first
real step towards it!

This patch can both parse and export to sarif.

My intent is that the code is self explanatory (because I explained
things in the code!), there are two things I'd like to highlight:

1. I strugged a LOT with mypy, which lead me to express a things things
   in a rather cumbersome manner. I left comments around these parts
2. I copied all example tests from https://github.com/microsoft/sarif-tutorials/
   to tools/report-converter/tests/unit/parser/sarif/sarif_test_files/.
   These examples come with an MIT licence, which I also copied over.
Szelethus added a commit to Szelethus/codechecker that referenced this issue Oct 10, 2023
Fixes Ericsson#1797. Based on a commit authored by @csordasmarton. Credit goes
to him!

We've long wanted to support sarif
(https://sarifweb.azurewebsites.net/), and finally, this is the first
real step towards it!

This patch can both parse and export to sarif.

My intent is that the code is self explanatory (because I explained
things in the code!), there are two things I'd like to highlight:

1. I strugged a LOT with mypy, which lead me to express a things things
   in a rather cumbersome manner. I left comments around these parts
2. I copied all example tests from https://github.com/microsoft/sarif-tutorials/
   to tools/report-converter/tests/unit/parser/sarif/sarif_test_files/.
   These examples come with an MIT licence, which I also copied over.

Co-authored-by: Kristóf Umann <dkszelethus@gmail.com>
@LebedevRI
Copy link
Contributor

LebedevRI commented Oct 10, 2023

Apologies for confusion, but it seems to me that #4011 added support for parsing SARIF into the CodeChecker,
while i (and i suspect many others) was fully expecting that this issues was tracking the exact opposite feature,
exporting CodeChecker results into SARIF format (so e.g. GitHub could visualize them). Am i missing the point?

@dgutson
Copy link

dgutson commented Oct 10, 2023

Apologies for confusion, but it seems to me that #4011 added support for parsing SARIF into the CodeChecker, while i (and i suspect many others) was fully expecting that this issues was tracking the exact opposite feature, exporting CodeChecker results into SARIF format (so e.g. GitHub could visualize them). Am i missing the point?

I actually expected parsing an input SARIF file, so CodeChecker can ingest the output of more linters.

@Szelethus
Copy link
Contributor

Szelethus commented Oct 11, 2023

Apologies for confusion, but it seems to me that #4011 added support for parsing SARIF into the CodeChecker, while i (and i suspect many others) was fully expecting that this issues was tracking the exact opposite feature, exporting CodeChecker results into SARIF format (so e.g. GitHub could visualize them). Am i missing the point?

You can convert existing report to sarif using report-converter:

report-converter -t cppcheck out/double-free_5197372318879967385.plist -e sarif -o cppcheck.sarif

It is true though that results stored on the server cannot be exported just yet. Also, I realize that report-converter to manually postprocess results isn't the most convenient :)

edit: It may have been a little overkill to close this issue straight away, we support only a subset of sarif that we immediately needed to support the gcc static analyzer. Considering that we have a new issue already, I'll leave this closed.

@jiridanek
Copy link

You can convert existing report to sarif using report-converter:

This requires using git-tip of codechecker, as it was implemented in this PR and the commit 90a3905 is not yet released.

I was initially surprised that my report-converter does not recognize -e sarif. So that's the reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) discussion 💡 enhancement 🌟
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants