Skip to content

Commit

Permalink
chore: use the oasis-open endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Rumney authored and owenrumney committed Oct 3, 2023
1 parent dfe6d4c commit 1000f5e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This example is taken directly from the [Microsoft sarif pages](https://github.c
```json
{
"version": "2.1.0",
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
"runs": [
{
"tool": {
Expand Down
2 changes: 1 addition & 1 deletion sarif/sarif.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Version string
const Version210 Version = "2.1.0"

var versions = map[Version]string{
Version210: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
Version210: "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
}

// Report is the encapsulating type representing a Sarif Report
Expand Down
14 changes: 7 additions & 7 deletions test/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ func Test_new_simple_report_with_single_run(t *testing.T) {

given.a_new_report().
with_a_run_added("tfsec", "https://tfsec.dev")
then.report_text_is(`{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[]}]}`)
then.report_text_is(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[]}]}`)
}

func Test_new_report_with_empty_run(t *testing.T) {
given, _, then := newReportTest(t)

given.a_new_report().
with_a_run_with_empty_result_added("tfsec", "https://tfsec.dev")
then.report_text_is(`{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[]}]}`)
then.report_text_is(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[]}]}`)
}

func Test_new_simple_report_with_artifact(t *testing.T) {
Expand All @@ -30,7 +30,7 @@ func Test_new_simple_report_with_artifact(t *testing.T) {
run := given.a_new_report().
with_a_run_added("tfsec", "https://tfsec.dev")
when.an_artifact_is_added_to_the_run(run, "file://broken.go")
then.report_text_is(`{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"artifacts":[{"location":{"uri":"file://broken.go"},"length":-1}],"results":[]}]}`)
then.report_text_is(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"artifacts":[{"location":{"uri":"file://broken.go"},"length":-1}],"results":[]}]}`)
}

func Test_new_simple_report_with_propertybag(t *testing.T) {
Expand All @@ -39,7 +39,7 @@ func Test_new_simple_report_with_propertybag(t *testing.T) {
run := given.a_new_report().
with_a_run_added("tfsec", "https://tfsec.dev")
when.some_properties_are_added_to_the_run(run)
then.report_text_is(`{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[],"properties":{"integer_property":10,"string_property":"this is a string"}}]}`)
then.report_text_is(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[],"properties":{"integer_property":10,"string_property":"this is a string"}}]}`)
}

func Test_new_simple_report_with_duplicate_artifact(t *testing.T) {
Expand All @@ -50,15 +50,15 @@ func Test_new_simple_report_with_duplicate_artifact(t *testing.T) {
when.an_artifact_is_added_to_the_run(run, "file://broken.go").
and().
an_artifact_is_added_to_the_run(run, "file://broken.go")
then.report_text_is(`{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"artifacts":[{"location":{"uri":"file://broken.go"},"length":-1},{"location":{"uri":"file://broken.go"},"length":-1}],"results":[]}]}`)
then.report_text_is(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"artifacts":[{"location":{"uri":"file://broken.go"},"length":-1},{"location":{"uri":"file://broken.go"},"length":-1}],"results":[]}]}`)
}

func Test_load_sarif_from_string(t *testing.T) {
given, _, then := newReportTest(t)

content := `{
"version": "2.1.0",
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
"runs": [
{
"tool": {
Expand All @@ -80,7 +80,7 @@ func Test_load_sarif_report_from_file(t *testing.T) {

content := `{
"version": "2.1.0",
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
"runs": [
{
"tool": {
Expand Down
8 changes: 5 additions & 3 deletions v2/sarif/sarif.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ type Version string

// Version210 represents Version210 of Sarif
const (
Version210 Version = "2.1.0"
Version210 Version = "2.1.0"
// @Deprecated - use Version210 instead
Version210RTM5 Version = "2.1.0-rtm.5"
)

var versions = map[Version]string{
Version210: "https://json.schemastore.org/sarif-2.1.0.json",
Version210RTM5: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
Version210: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
// keeping this for backwards support but marked as deprecated
Version210RTM5: "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
}

// Report is the encapsulating type representing a Sarif Report
Expand Down
14 changes: 7 additions & 7 deletions v2/test/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ func Test_new_simple_report_with_single_run(t *testing.T) {

given.a_new_report().
with_a_run_added("tfsec", "https://tfsec.dev")
then.report_text_is(`{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[]}]}`)
then.report_text_is(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[]}]}`)
}

func Test_new_report_with_empty_run(t *testing.T) {
given, _, then := newReportTest(t)

given.a_new_report().
with_a_run_with_empty_result_added("tfsec", "https://tfsec.dev")
then.report_text_is(`{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[]}]}`)
then.report_text_is(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[]}]}`)
}

func Test_new_simple_report_with_artifact(t *testing.T) {
Expand All @@ -30,7 +30,7 @@ func Test_new_simple_report_with_artifact(t *testing.T) {
run := given.a_new_report().
with_a_run_added("tfsec", "https://tfsec.dev")
when.an_artifact_is_added_to_the_run(run, "file://broken.go")
then.report_text_is(`{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"artifacts":[{"location":{"uri":"file://broken.go"},"length":-1}],"results":[]}]}`)
then.report_text_is(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"artifacts":[{"location":{"uri":"file://broken.go"},"length":-1}],"results":[]}]}`)
}

func Test_new_simple_report_with_propertybag(t *testing.T) {
Expand All @@ -39,7 +39,7 @@ func Test_new_simple_report_with_propertybag(t *testing.T) {
run := given.a_new_report().
with_a_run_added("tfsec", "https://tfsec.dev")
when.some_properties_are_added_to_the_run(run)
then.report_text_is(`{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[],"properties":{"integer_property":10,"string_property":"this is a string"}}]}`)
then.report_text_is(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"results":[],"properties":{"integer_property":10,"string_property":"this is a string"}}]}`)
}

func Test_new_simple_report_with_duplicate_artifact(t *testing.T) {
Expand All @@ -50,15 +50,15 @@ func Test_new_simple_report_with_duplicate_artifact(t *testing.T) {
when.an_artifact_is_added_to_the_run(run, "file://broken.go").
and().
an_artifact_is_added_to_the_run(run, "file://broken.go")
then.report_text_is(`{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"artifacts":[{"location":{"uri":"file://broken.go"},"length":-1},{"location":{"uri":"file://broken.go"},"length":-1}],"results":[]}]}`)
then.report_text_is(`{"version":"2.1.0","$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json","runs":[{"tool":{"driver":{"name":"tfsec","informationUri":"https://tfsec.dev"}},"artifacts":[{"location":{"uri":"file://broken.go"},"length":-1},{"location":{"uri":"file://broken.go"},"length":-1}],"results":[]}]}`)
}

func Test_load_sarif_from_string(t *testing.T) {
given, _, then := newReportTest(t)

content := `{
"version": "2.1.0",
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
"runs": [
{
"tool": {
Expand All @@ -80,7 +80,7 @@ func Test_load_sarif_report_from_file(t *testing.T) {

content := `{
"version": "2.1.0",
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
"runs": [
{
"tool": {
Expand Down

0 comments on commit 1000f5e

Please sign in to comment.