kowainik / stan

🕵️ Haskell STatic ANalyser
https://kowainik.github.io/projects/stan
Mozilla Public License 2.0
562 stars 48 forks source link

Support SARIF output #483

Open mbg opened 1 year ago

mbg commented 1 year ago

Hi there!

Thank you for building this library and a happy holidays! This PR aims to resolve #467 and add support for outputting Stan's observations as SARIF files. To support this, I wrote a new library, sarif, which implements the relevant types to represent SARIF structures and to serialise/deserialise them to/from JSON.

The approach taken by my implementation is as follows:

What's this good for?

SARIF files can be understood by other tools, such as GitHub Code Scanning. For example, I used the changes made in this PR to run Stan on itself and upload the results to Code Scanning, which will then show a list of all observations:

Screenshot 2022-12-22 at 14 47 39

These can be viewed in detail:

Screenshot 2022-12-22 at 14 47 53

How can I do this?

To reproduce this, simply run stan --sarif > stan.sarif and use the upload-sarif action to upload the file as part of a GitHub Actions workflow.

Questions / Points of note

I'd appreciate a review of this and your thoughts on all of the above! Thanks!