Skip to content

Commit

Permalink
fix: make ResultProperties.Policy nillable
Browse files Browse the repository at this point in the history
  • Loading branch information
j-luong committed Nov 27, 2024
1 parent c1be7d5 commit 80d438b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions internal/analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ func TestAnalysis_RunAnalysis(t *testing.T) {

require.NoError(t, err)
assert.Equal(t, "scripts/db/migrations/20230811153738_add_generated_grouping_columns_to_collections_table.ts", actual.Sarif.Runs[0].Results[0].Locations[0].PhysicalLocation.ArtifactLocation.URI)

t.Run("should default policy to nil if not provided", func(t *testing.T) {
assert.Nil(t, actual.Sarif.Runs[0].Results[0].Properties.Policy)
})
}

func TestAnalysis_RunAnalysis_TriggerFunctionError(t *testing.T) {
Expand Down
14 changes: 8 additions & 6 deletions sarif/sarif_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,20 @@ type Fingerprints struct {
Identity string `json:"identity"`
}

type Policy struct {
OriginalLevel string `json:"originalLevel"`
OriginalSeverity string `json:"originalSeverity"`
Severity string `json:"severity"`
}

type ResultProperties struct {
PriorityScore int `json:"priorityScore"`
PriorityScoreFactors []struct {
Label bool `json:"label"`
Type string `json:"type"`
} `json:"priorityScoreFactors"`
IsAutofixable bool `json:"isAutofixable"`
Policy struct {
OriginalLevel string `json:"originalLevel"`
OriginalSeverity string `json:"originalSeverity"`
Severity string `json:"severity"`
} `json:"snykPolicy/v1"`
IsAutofixable bool `json:"isAutofixable"`
Policy *Policy `json:"snykPolicy/v1,omitempty"`
}

type Result struct {
Expand Down

0 comments on commit 80d438b

Please sign in to comment.