Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for static and dynamic analyzer tools.
https://codechecker.readthedocs.io
Apache License 2.0
2.26k stars 381 forks source link

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

Closed Xazax-hun closed 1 year ago

Xazax-hun commented 6 years ago

CSA just gained the ability to output SARIF: https://github.com/llvm-mirror/clang/commit/962c092aae53360ab4d5b1adac78963694b5963f#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.

Szelethus commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

The current latest SARIF specification v2.10.

See the list of oasis standards

csordasmarton commented 3 years ago

Documentation:

Questions:

Remaining questions:

Further notes:

Useful links:

Xazax-hun commented 2 years ago

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

Xazax-hun commented 2 years ago

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

Trass3r commented 2 years ago

Yeah Github integration in general is based on sarif. https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github

damiencarol commented 1 year ago

Any news on this new feature?

dgutson commented 1 year ago

we will resume work on this soon, @franco0700

LebedevRI commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 https://github.com/Ericsson/codechecker/commit/90a39054d52f91f1acb50620b03beee6d0829e2c is not yet released.

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