From b7e5e864b97165b05273630e8f992c22b2ae3628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Fabianski?= Date: Thu, 17 Aug 2023 18:15:12 +0200 Subject: [PATCH] fix: update tests and always include bool --- ...estReferenceFilters-testdata-data-reference_filters | 1 + e2e/rules/.snapshots/TestSecrets-secrets | 1 + .../TestSimpleRuby-testdata-data-simple_ruby | 1 + .../composition/java/.snapshots/TestScope--scope.yml | 6 ++++++ .../.snapshots/TestPatternVariables--main.yml | 2 ++ .../javascript/.snapshots/TestScope--scope.yml | 6 ++++++ .../.snapshots/import/TestImport--import.yml | 5 +++++ .../TestObjectDeconstructing--deconstructing.yml | 1 + .../TestObjectDeconstructing--multiple_objects.yml | 1 + .../ruby/.snapshots/TestPatternVariables--main.yml | 3 +++ .../composition/ruby/.snapshots/TestScope--scope.yml | 6 ++++++ .../output/security/.snapshots/TestCalculateSeverity | 10 +++++----- pkg/report/output/security/.snapshots/TestGetOutput | 4 ++-- .../security/.snapshots/TestTestGetOutputWithSeverity | 2 +- pkg/report/output/security/security.go | 4 ++-- 15 files changed, 43 insertions(+), 10 deletions(-) diff --git a/e2e/rules/.snapshots/TestReferenceFilters-testdata-data-reference_filters b/e2e/rules/.snapshots/TestReferenceFilters-testdata-data-reference_filters index e10a166a2..563e29d72 100644 --- a/e2e/rules/.snapshots/TestReferenceFilters-testdata-data-reference_filters +++ b/e2e/rules/.snapshots/TestReferenceFilters-testdata-data-reference_filters @@ -34,6 +34,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 diff --git a/e2e/rules/.snapshots/TestSecrets-secrets b/e2e/rules/.snapshots/TestSecrets-secrets index 3f174c5ce..dda5b13cd 100644 --- a/e2e/rules/.snapshots/TestSecrets-secrets +++ b/e2e/rules/.snapshots/TestSecrets-secrets @@ -45,6 +45,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 diff --git a/e2e/rules/.snapshots/TestSimpleRuby-testdata-data-simple_ruby b/e2e/rules/.snapshots/TestSimpleRuby-testdata-data-simple_ruby index 29054a84f..635d7d442 100644 --- a/e2e/rules/.snapshots/TestSimpleRuby-testdata-data-simple_ruby +++ b/e2e/rules/.snapshots/TestSimpleRuby-testdata-data-simple_ruby @@ -54,6 +54,7 @@ medium: display_severity: medium sensitive_data_category_weighting: 2 rule_severity_weighting: 2 + trigger_weighting: false final_weighting: 4 diff --git a/new/detector/composition/java/.snapshots/TestScope--scope.yml b/new/detector/composition/java/.snapshots/TestScope--scope.yml index 31fff9574..b6e902063 100644 --- a/new/detector/composition/java/.snapshots/TestScope--scope.yml +++ b/new/detector/composition/java/.snapshots/TestScope--scope.yml @@ -33,6 +33,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -68,6 +69,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -103,6 +105,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -138,6 +141,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -173,6 +177,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -208,5 +213,6 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 diff --git a/new/detector/composition/javascript/.snapshots/TestPatternVariables--main.yml b/new/detector/composition/javascript/.snapshots/TestPatternVariables--main.yml index 146fbe29b..57cadd1c0 100644 --- a/new/detector/composition/javascript/.snapshots/TestPatternVariables--main.yml +++ b/new/detector/composition/javascript/.snapshots/TestPatternVariables--main.yml @@ -33,6 +33,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -68,5 +69,6 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 diff --git a/new/detector/composition/javascript/.snapshots/TestScope--scope.yml b/new/detector/composition/javascript/.snapshots/TestScope--scope.yml index 2d1d399aa..3dae26144 100644 --- a/new/detector/composition/javascript/.snapshots/TestScope--scope.yml +++ b/new/detector/composition/javascript/.snapshots/TestScope--scope.yml @@ -33,6 +33,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -68,6 +69,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -103,6 +105,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -138,6 +141,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -173,6 +177,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -208,5 +213,6 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 diff --git a/new/detector/composition/javascript/.snapshots/import/TestImport--import.yml b/new/detector/composition/javascript/.snapshots/import/TestImport--import.yml index e473afdcf..55f70ffb2 100644 --- a/new/detector/composition/javascript/.snapshots/import/TestImport--import.yml +++ b/new/detector/composition/javascript/.snapshots/import/TestImport--import.yml @@ -33,6 +33,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -68,6 +69,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -103,6 +105,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -138,6 +141,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -173,5 +177,6 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 diff --git a/new/detector/composition/javascript/.snapshots/object-deconstructing/TestObjectDeconstructing--deconstructing.yml b/new/detector/composition/javascript/.snapshots/object-deconstructing/TestObjectDeconstructing--deconstructing.yml index bab4a7763..fd2c2cded 100644 --- a/new/detector/composition/javascript/.snapshots/object-deconstructing/TestObjectDeconstructing--deconstructing.yml +++ b/new/detector/composition/javascript/.snapshots/object-deconstructing/TestObjectDeconstructing--deconstructing.yml @@ -32,5 +32,6 @@ low: rule_severity: "" display_severity: low rule_severity_weighting: 2 + trigger_weighting: false final_weighting: 2 diff --git a/new/detector/composition/javascript/.snapshots/object-deconstructing/TestObjectDeconstructing--multiple_objects.yml b/new/detector/composition/javascript/.snapshots/object-deconstructing/TestObjectDeconstructing--multiple_objects.yml index 045fe9a1b..aa8bc7b8b 100644 --- a/new/detector/composition/javascript/.snapshots/object-deconstructing/TestObjectDeconstructing--multiple_objects.yml +++ b/new/detector/composition/javascript/.snapshots/object-deconstructing/TestObjectDeconstructing--multiple_objects.yml @@ -32,5 +32,6 @@ low: rule_severity: "" display_severity: low rule_severity_weighting: 2 + trigger_weighting: false final_weighting: 2 diff --git a/new/detector/composition/ruby/.snapshots/TestPatternVariables--main.yml b/new/detector/composition/ruby/.snapshots/TestPatternVariables--main.yml index 26e7cce06..9282335ae 100644 --- a/new/detector/composition/ruby/.snapshots/TestPatternVariables--main.yml +++ b/new/detector/composition/ruby/.snapshots/TestPatternVariables--main.yml @@ -33,6 +33,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -72,6 +73,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -113,5 +115,6 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 diff --git a/new/detector/composition/ruby/.snapshots/TestScope--scope.yml b/new/detector/composition/ruby/.snapshots/TestScope--scope.yml index 7b346d052..d58ac7bd9 100644 --- a/new/detector/composition/ruby/.snapshots/TestScope--scope.yml +++ b/new/detector/composition/ruby/.snapshots/TestScope--scope.yml @@ -33,6 +33,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -68,6 +69,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -103,6 +105,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -138,6 +141,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -173,6 +177,7 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 - rule: cwe_ids: @@ -208,5 +213,6 @@ high: rule_severity: high display_severity: high rule_severity_weighting: 5 + trigger_weighting: false final_weighting: 5 diff --git a/pkg/report/output/security/.snapshots/TestCalculateSeverity b/pkg/report/output/security/.snapshots/TestCalculateSeverity index 4dbae8a81..5310fae2c 100644 --- a/pkg/report/output/security/.snapshots/TestCalculateSeverity +++ b/pkg/report/output/security/.snapshots/TestCalculateSeverity @@ -4,7 +4,7 @@ DisplaySeverity: (string) (len=8) "critical", SensitiveDataCategoryWeighting: (int) 3, RuleSeverityWeighting: (int) 2, - TriggerWeighting: (bool) true, + TriggerWeighting: (*bool)(true), FinalWeighting: (int) 8 }, (security.SeverityWeighting) { @@ -12,7 +12,7 @@ DisplaySeverity: (string) (len=4) "high", SensitiveDataCategoryWeighting: (int) 3, RuleSeverityWeighting: (int) 2, - TriggerWeighting: (bool) false, + TriggerWeighting: (*bool)(false), FinalWeighting: (int) 5 }, (security.SeverityWeighting) { @@ -20,7 +20,7 @@ DisplaySeverity: (string) (len=6) "medium", SensitiveDataCategoryWeighting: (int) 2, RuleSeverityWeighting: (int) 2, - TriggerWeighting: (bool) false, + TriggerWeighting: (*bool)(false), FinalWeighting: (int) 4 }, (security.SeverityWeighting) { @@ -28,7 +28,7 @@ DisplaySeverity: (string) (len=7) "warning", SensitiveDataCategoryWeighting: (int) 0, RuleSeverityWeighting: (int) 0, - TriggerWeighting: (bool) false, + TriggerWeighting: (*bool)(), FinalWeighting: (int) 0 }, (security.SeverityWeighting) { @@ -36,7 +36,7 @@ DisplaySeverity: (string) (len=7) "warning", SensitiveDataCategoryWeighting: (int) 0, RuleSeverityWeighting: (int) 0, - TriggerWeighting: (bool) false, + TriggerWeighting: (*bool)(), FinalWeighting: (int) 0 } } diff --git a/pkg/report/output/security/.snapshots/TestGetOutput b/pkg/report/output/security/.snapshots/TestGetOutput index 7e77820e1..95f079958 100644 --- a/pkg/report/output/security/.snapshots/TestGetOutput +++ b/pkg/report/output/security/.snapshots/TestGetOutput @@ -56,7 +56,7 @@ DisplaySeverity: (string) (len=8) "critical", SensitiveDataCategoryWeighting: (int) 3, RuleSeverityWeighting: (int) 2, - TriggerWeighting: (bool) true, + TriggerWeighting: (*bool)(true), FinalWeighting: (int) 8 }, RawCodeExtract: ([]file.Line) { @@ -115,7 +115,7 @@ DisplaySeverity: (string) (len=4) "high", SensitiveDataCategoryWeighting: (int) 2, RuleSeverityWeighting: (int) 3, - TriggerWeighting: (bool) false, + TriggerWeighting: (*bool)(false), FinalWeighting: (int) 5 }, RawCodeExtract: ([]file.Line) { diff --git a/pkg/report/output/security/.snapshots/TestTestGetOutputWithSeverity b/pkg/report/output/security/.snapshots/TestTestGetOutputWithSeverity index cb701f10c..c5a342b70 100644 --- a/pkg/report/output/security/.snapshots/TestTestGetOutputWithSeverity +++ b/pkg/report/output/security/.snapshots/TestTestGetOutputWithSeverity @@ -56,7 +56,7 @@ DisplaySeverity: (string) (len=8) "critical", SensitiveDataCategoryWeighting: (int) 3, RuleSeverityWeighting: (int) 2, - TriggerWeighting: (bool) true, + TriggerWeighting: (*bool)(true), FinalWeighting: (int) 8 }, RawCodeExtract: ([]file.Line) { diff --git a/pkg/report/output/security/security.go b/pkg/report/output/security/security.go index b720fd09a..b41535cd2 100644 --- a/pkg/report/output/security/security.go +++ b/pkg/report/output/security/security.go @@ -63,7 +63,7 @@ type SeverityWeighting struct { DisplaySeverity string `json:"display_severity" yaml:"display_severity"` SensitiveDataCategoryWeighting int `json:"sensitive_data_category_weighting,omitempty" yaml:"sensitive_data_category_weighting,omitempty"` RuleSeverityWeighting int `json:"rule_severity_weighting,omitempty" yaml:"rule_severity_weighting,omitempty"` - TriggerWeighting bool `json:"trigger_weighting,omitempty" yaml:"trigger_weighting,omitempty"` + TriggerWeighting *bool `json:"trigger_weighting,omitempty" yaml:"trigger_weighting,omitempty"` FinalWeighting int `json:"final_weighting,omitempty" yaml:"final_weighting,omitempty"` } @@ -478,7 +478,7 @@ func CalculateSeverity(groups []string, severity string, hasLocalDataTypes bool) RuleSeverity: severity, SensitiveDataCategoryWeighting: sensitiveDataCategoryWeighting, RuleSeverityWeighting: ruleSeverityWeighting, - TriggerWeighting: hasLocalDataTypes, + TriggerWeighting: &hasLocalDataTypes, FinalWeighting: finalWeighting, DisplaySeverity: displaySeverity, }