diff --git a/finding/finding.go b/finding/finding.go index 761fb876..a2df9b64 100644 --- a/finding/finding.go +++ b/finding/finding.go @@ -45,14 +45,12 @@ const ( ) // Location represents the location of a finding. -// -//nolint:govet type Location struct { - Type FileType `json:"type"` - Path string `json:"path"` LineStart *uint `json:"lineStart,omitempty"` LineEnd *uint `json:"lineEnd,omitempty"` Snippet *string `json:"snippet,omitempty"` + Path string `json:"path"` + Type FileType `json:"type"` } // Outcome is the result of a finding. @@ -96,23 +94,19 @@ const ( ) // Finding represents a finding. -// -//nolint:govet type Finding struct { - Probe string `json:"probe"` - Outcome Outcome `json:"outcome"` - Message string `json:"message"` Location *Location `json:"location,omitempty"` Remediation *probe.Remediation `json:"remediation,omitempty"` Values map[string]int `json:"values,omitempty"` + Probe string `json:"probe"` + Message string `json:"message"` + Outcome Outcome `json:"outcome"` } // AnonymousFinding is a finding without a corerpsonding probe ID. type AnonymousFinding struct { - Finding - // Remove the probe ID from - // the structure until the probes are GA. Probe string `json:"probe,omitempty"` + Finding } var errInvalid = errors.New("invalid") diff --git a/finding/finding_test.go b/finding/finding_test.go index 33d792e9..94d80455 100644 --- a/finding/finding_test.go +++ b/finding/finding_test.go @@ -38,15 +38,14 @@ func Test_FromBytes(t *testing.T) { positiveOutcome := OutcomePositive negativeOutcome := OutcomeNegative t.Parallel() - //nolint:govet tests := []struct { + err error + outcome *Outcome + metadata map[string]string + finding *Finding name string id string path string - outcome *Outcome - err error - metadata map[string]string - finding *Finding }{ { name: "effort low", @@ -205,10 +204,10 @@ func TestOutcome_UnmarshalYAML(t *testing.T) { type args struct { n *yaml.Node } - tests := []struct { //nolint:govet + tests := []struct { + args args name string wantOutcome Outcome - args args wantErr bool }{ { diff --git a/remediation/remediations_test.go b/remediation/remediations_test.go index 3ea529aa..a2906659 100644 --- a/remediation/remediations_test.go +++ b/remediation/remediations_test.go @@ -74,11 +74,10 @@ func (s stubDigester) Digest(name string) (string, error) { func TestCreateDockerfilePinningRemediation(t *testing.T) { t.Parallel() - //nolint:govet tests := []struct { - name string - dep checker.Dependency expected *rule.Remediation + dep checker.Dependency + name string }{ { name: "no depdendency", @@ -143,12 +142,12 @@ func TestCreateDockerfilePinningRemediation(t *testing.T) { func TestCreateWorkflowPinningRemediation(t *testing.T) { t.Parallel() - tests := []struct { //nolint:govet + tests := []struct { + expected *rule.Remediation name string branch string repo string filepath string - expected *rule.Remediation }{ { name: "valid input", diff --git a/rule/rule.go b/rule/rule.go index f7df3c31..e5aa7f6d 100644 --- a/rule/rule.go +++ b/rule/rule.go @@ -55,14 +55,13 @@ type jsonRemediation struct { Effort RemediationEffort `yaml:"effort"` } -//nolint:govet type jsonRule struct { Short string `yaml:"short"` Desc string `yaml:"desc"` Motivation string `yaml:"motivation"` Implementation string `yaml:"implementation"` - Risk Risk `yaml:"risk"` Remediation jsonRemediation `yaml:"remediation"` + Risk Risk `yaml:"risk"` } // Risk indicates a risk. @@ -81,14 +80,13 @@ const ( RiskCritical ) -//nolint:govet type Rule struct { + Remediation *Remediation Name string Short string Desc string Motivation string Risk Risk - Remediation *Remediation } var errInvalid = errors.New("invalid") diff --git a/rule/rule_test.go b/rule/rule_test.go index 83a6eebd..89f484f4 100644 --- a/rule/rule_test.go +++ b/rule/rule_test.go @@ -34,12 +34,11 @@ var testfs embed.FS func Test_New(t *testing.T) { t.Parallel() - //nolint:govet tests := []struct { - name string - id string err error rule *Rule + name string + id string }{ { name: "all fields set", @@ -131,10 +130,10 @@ func TestRisk_GreaterThan(t *testing.T) { func TestRisk_String(t *testing.T) { t.Parallel() - tests := []struct { //nolint:govet + tests := []struct { name string - r Risk want string + r Risk }{ { name: "RiskNone", @@ -182,10 +181,10 @@ func TestRisk_String(t *testing.T) { func TestRemediationEffort_String(t *testing.T) { t.Parallel() - tests := []struct { //nolint:govet + tests := []struct { name string - effort RemediationEffort want string + effort RemediationEffort }{ { name: "RemediationEffortNone", @@ -228,10 +227,10 @@ func TestRemediationEffort_String(t *testing.T) { func TestRisk_UnmarshalYAML(t *testing.T) { t.Parallel() - tests := []struct { //nolint:govet + tests := []struct { + wantErr error name string input string - wantErr error want Risk }{ { @@ -283,10 +282,10 @@ func TestRisk_UnmarshalYAML(t *testing.T) { func TestRemediationEffort_UnmarshalYAML(t *testing.T) { t.Parallel() - tests := []struct { //nolint:govet + tests := []struct { + wantErr error name string input string - wantErr error want RemediationEffort }{ { @@ -328,10 +327,10 @@ func TestRemediationEffort_UnmarshalYAML(t *testing.T) { func Test_validate(t *testing.T) { t.Parallel() - tests := []struct { //nolint:govet - name string - rule *jsonRule + tests := []struct { wantErr error + rule *jsonRule + name string }{ { name: "valid",