-
Notifications
You must be signed in to change notification settings - Fork 365
Validate sarif against schema before uploading #39
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
Conversation
I think this approach is simple and gets us a lot. There is very little else that we could validate at this stage, and it would mostly revolve around generated code and fingerprints (that are "considered" later in the toolchain).
The schema is the correct one. However, on ingestion we are stricter in a few cases. For example, we require all results to have a message. We believe those requirements to be reasonable but we do not have enough data. Therefore, I would prefer to receive valid SARIF that does not satisfy our internal requirements, so that we can keep track of these occurrences and revisit this decision later. Do you by any chance have an example of how a failure/error message would look in the action console? |
e60799b
to
ddee374
Compare
The format of the error mesages is currently not very good, so I'll improve that so it incluced the line number and ideally a more complete message. e.g.
And unfortunately the SARIF from shift-left currently fails the validation. I'll investigate what this is
|
Can someone else check https://github.com/Anthophila/test-electron/runs/699818763?check_suite_focus=true and see if it looks correct? It looks like a false positive to me as the schema for that array is
so it shouldn't be warning about duplicate items. Is this a bug in the validator? |
I think you are right. It is a bug in the validator. I tried the following (If you want some unfounded speculation, I think the validator is just checking if |
Your hunch seems to be correct. Finding the site of the problem and fixing it was reasonably easy so I've opened tdegrunt/jsonschema#301. In the meantime we could wait for that fix to propogate to a published version or we could just remove the |
Also, https://github.com/Anthophila/test-electron/runs/699818763?check_suite_focus=true is an example of what a failure looks like. |
Shiftleft now succeeds: https://github.com/Anthophila/test-electron/actions/runs/112621402 Also I had to add in |
6a1885c
to
8fb9090
Compare
Now rubocop is failing
|
Seems like rubocop may be using 0-based indexing for its
|
@arthurnn, did you write the |
good catch.. i use |
Have released version 0.3.0 for the gem that fixes the issue. |
@chrisgavin can you take on reviewing this PR? I think the only special action that needs to be taken before merge is check who's using rubocop 0.2.0 and if necessary help them upgrade. I can do that if we're happy with the code. As an explanation of what's happening here, the upload would already not succeed if the SARIF if invalid but this would not be clear to the uploader. This check is merely moving the error checking earlier in the process so the uploader can see more easily and fix it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good change to me. It's a share the server-side validation was not enough to catch the RuboCop issue.
Validates files to be uploaded against the SARIF 2.1.0 schema. Should stop invalid files from being uploaded and thus the user will get an error immediately instead of having to wait to see if their upload is processed correctly.
Also makes other code in the upload action easier because we can assume the sarif files are correctly formatted and thus can skip a lot of manual validation code. For example in #38
Do we think this is the right approach for validation within the action? Is this the right schema to use? Will this be strict enough, or too strict? How much testing do we need in this to be confident we've hit a good compromise?
Merge / deployment checklist