Skip to content

Commit

Permalink
Results must always be present in the SARIF report (#650)
Browse files Browse the repository at this point in the history
* Don't omit empty results

* Add tests
  • Loading branch information
mmorel-35 authored Jun 17, 2021
1 parent 3c230ac commit 731d0d5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
13 changes: 13 additions & 0 deletions report/sarif/sarif_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package sarif_test

import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

func TestRules(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Sarif Formatters Suite")
}
25 changes: 25 additions & 0 deletions report/sarif/sarif_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package sarif_test

import (
"bytes"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/securego/gosec/v2"
"github.com/securego/gosec/v2/report/sarif"
)

var _ = Describe("Sarif Formatter", func() {
BeforeEach(func() {
})
Context("when converting to Sarif issues", func() {
It("sarif formatted report should contain the result", func() {
buf := new(bytes.Buffer)
reportInfo := gosec.NewReportInfo([]*gosec.Issue{}, &gosec.Metrics{}, map[string][]gosec.Error{}).WithVersion("v2.7.0")
err := sarif.WriteReport(buf, reportInfo, []string{})
result := buf.String()
Expect(err).ShouldNot(HaveOccurred())
Expect(result).To(ContainSubstring("\"results\": ["))
})
})
})
2 changes: 1 addition & 1 deletion report/sarif/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 731d0d5

Please sign in to comment.