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 SARIF output #1482

Merged
merged 1 commit into from
Apr 2, 2023
Merged

Support SARIF output #1482

merged 1 commit into from
Apr 2, 2023

Conversation

chungyc
Copy link
Contributor

@chungyc chungyc commented Mar 26, 2023

This adds the ability to output into SARIF from HLint. SARIF is an open interchange format for exchanging results for static analyses. In particular, GitHub uses SARIF for reading results from code scanning tools; this would allow HLint to be used as a code scanning tool in GitHub. The output is complete enough such that output uploaded from a test workflow shows up as a code scanning alert.

The changes adds a --sarif flag and a "SARIF" module. E.g., the following will result in the hints being output in SARIF.

$ hlint --sarif data/Test.hs

There are now quite a few output formats that HLint supports. I.e., HLint-native JSON, Code Climate, HTML, Refactor, and now SARIF. I was almost tempted to add a --format=sarif flag instead and put the module in "Format.SARIF", but I didn't in order to maintain consistency with existing practice. However, if you would like such a change made, I would be very happy to make it (obviously, I would keep the existing flags alone).

This change does not use the sarif package. While it would have not added any new dependencies other than itself, I was a little worried by it having an extra module in the "Data.Aeson" namespace. It is not on Stackage, either, so it would have been a little more work to get it working on stack.

This pull request will resolve #1469.


By raising this pull request, I confirm I am licensing my contribution under all licenses that apply to this project and that I have no patents covering my contribution.

@chungyc chungyc marked this pull request as ready for review March 27, 2023 03:39

{- |
Description: Formats hlint ideas in the Statis Analysis Results Interchange Format (SARIF).
License: BSD-3-Clause
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to add a license to just this one file, given the entire project is BSD3 licensed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fill out Haddock module documentation fields out of habit, and the license field was just something that could be filled. Other than the fact that I wrote these lines, there's no reason this file needs special treatment.

@ndmitchell ndmitchell merged commit 944da11 into ndmitchell:master Apr 2, 2023
@ndmitchell
Copy link
Owner

Looks good - thanks for the very well structured pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support SARIF output
2 participants