-
Notifications
You must be signed in to change notification settings - Fork 62
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
Adding .sarif extension for validation. #183
base: main
Are you sure you want to change the base?
Conversation
Could you please approve workflows ?? |
Could you please approve workflow once more ? Had missed to push changes in cli.go file |
is there anything from my side for now ? |
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.
Need to update index.md
, readme.md
, and the CLI to include Sarif validation
Hey folks, Not entirely sure if this is the most optimal way to validate I've spent a couple of days implementing the validation myself. Partially - because I'm neither good, nor decent in Go ): Here's my take. Minimal
Let me know what you think. |
pkg/validator/sarif.go
Outdated
func (SarifValidator) Validate(b []byte) (bool, error) { | ||
_, err := sarif.FromBytes(b) | ||
if err != nil { | ||
return false, err |
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.
Since sarif.FromBytes
does json.Unmarshal
, we can return a custom error from JSON validator, which will explicitly display the precise location in the file where error occurred.
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.
func (SARIFValidator) Validate(b []byte) (bool, error) {
_, err := sarif.FromBytes(b)
if err != nil {
customError := getCustomErr(b, err)
return false, customError
}
Yeah, if return value from sarif.FromBytes
(except for the error) isn't needed, it's possible just to use JSON validator instead.
func (SARIFValidator) Validate(b []byte) (bool, error) {
var output any
err := json.Unmarshal(b, &output)
if err != nil {
customError := getCustomErr(b, err)
return false, customError
}
return true, nil
}
test/fixtures/good.sarif
Outdated
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.
I presume it'll be nice to have not only a "good" .sarif
file, but also a "bad" one.
Potentially a .sArIf
extension would be nice too.
Ok, I will make required changes. |
Please approve the workflows |
I have added validation for .sarif extension.