Skip to content

Commit

Permalink
feat: remove dynamic severity (#1469)
Browse files Browse the repository at this point in the history
* feat: remove dynamic severity

* docs: remove dynamic severity

* test: update snapshots
  • Loading branch information
cfabianski authored Jan 22, 2024
1 parent 39eb85d commit b01bc95
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 145 deletions.
4 changes: 0 additions & 4 deletions docs/_data/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ module.exports = [
name: "Sensitive data flow",
url: "/explanations/discovery-and-classification/",
},
{
name: "Dynamic severity levels",
url: "/explanations/severity/",
},
],
},
{
Expand Down
1 change: 0 additions & 1 deletion docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ Explanations dive into the rational behind Bearer CLI and explain some of its he
- [Bearer CLI's scanner types](/explanations/scanners/)
- [Bearer CLI's report types](/explanations/reports/)
- [How Bearer CLI discovers and classifies data](/explanations/discovery-and-classification/)
- [How Bearer CLI sets severity levels](/explanations/severity/)

## Reference

Expand Down
100 changes: 0 additions & 100 deletions docs/explanations/severity.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
medium:
low:
- rule:
cwe_ids:
- "319"
Expand Down
17 changes: 7 additions & 10 deletions internal/report/output/security/.snapshots/TestAddReportData
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}
}
},
(string) (len=4) "high": ([]types.Finding) (len=1) {
(string) (len=6) "medium": ([]types.Finding) (len=1) {
(types.Finding) {
Rule: (*types.Rule)({
CWEIDs: ([]string) (len=1) {
Expand Down Expand Up @@ -117,15 +117,12 @@
},
SeverityMeta: (types.SeverityMeta) {
RuleSeverity: (string) (len=6) "medium",
SensitiveDataCategories: ([]string) (len=2) {
(string) (len=3) "PII",
(string) (len=13) "Personal Data"
},
HasLocalDataTypes: (*bool)(false),
SensitiveDataCategoryWeighting: (int) 2,
RuleSeverityWeighting: (int) 3,
FinalWeighting: (int) 5,
DisplaySeverity: (string) (len=4) "high"
SensitiveDataCategories: ([]string) <nil>,
HasLocalDataTypes: (*bool)(<nil>),
SensitiveDataCategoryWeighting: (int) 0,
RuleSeverityWeighting: (int) 0,
FinalWeighting: (int) 0,
DisplaySeverity: (string) (len=6) "medium"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ File: :1



HIGH: Missing SSL certificate verification detected. [CWE-295]
MEDIUM: Missing SSL certificate verification detected. [CWE-295]
https://docs.bearer.com/reference/rules/ruby_lang_ssl_verification
To ignore this finding, run: bearer ignore add 9005ef3db844b32c1a0317e032f4a16a_0

Expand All @@ -30,8 +30,8 @@ File: :2
3 checks, 2 findings

CRITICAL: 1 (CWE-209, CWE-532)
HIGH: 1 (CWE-295)
MEDIUM: 0
HIGH: 0
MEDIUM: 1 (CWE-295)
LOW: 0
WARNING: 0

Expand Down
28 changes: 12 additions & 16 deletions internal/report/output/security/.snapshots/TestCalculateSeverity
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,21 @@
},
(types.SeverityMeta) {
RuleSeverity: (string) (len=3) "low",
SensitiveDataCategories: ([]string) (len=1) {
(string) (len=25) "Personal Data (Sensitive)"
},
HasLocalDataTypes: (*bool)(false),
SensitiveDataCategoryWeighting: (int) 3,
RuleSeverityWeighting: (int) 2,
FinalWeighting: (int) 5,
DisplaySeverity: (string) (len=4) "high"
SensitiveDataCategories: ([]string) <nil>,
HasLocalDataTypes: (*bool)(<nil>),
SensitiveDataCategoryWeighting: (int) 0,
RuleSeverityWeighting: (int) 0,
FinalWeighting: (int) 0,
DisplaySeverity: (string) (len=3) "low"
},
(types.SeverityMeta) {
RuleSeverity: (string) (len=3) "low",
SensitiveDataCategories: ([]string) (len=1) {
(string) (len=13) "Personal Data"
},
HasLocalDataTypes: (*bool)(false),
SensitiveDataCategoryWeighting: (int) 2,
RuleSeverityWeighting: (int) 2,
FinalWeighting: (int) 4,
DisplaySeverity: (string) (len=6) "medium"
SensitiveDataCategories: ([]string) <nil>,
HasLocalDataTypes: (*bool)(<nil>),
SensitiveDataCategoryWeighting: (int) 0,
RuleSeverityWeighting: (int) 0,
FinalWeighting: (int) 0,
DisplaySeverity: (string) (len=3) "low"
},
(types.SeverityMeta) {
RuleSeverity: (string) (len=7) "warning",
Expand Down
12 changes: 8 additions & 4 deletions internal/report/output/security/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,13 @@ func CalculateSeverity(groups []string, severity string, hasLocalDataTypes bool)
}
}

if !hasLocalDataTypes {
return types.SeverityMeta{
RuleSeverity: severity,
DisplaySeverity: severity,
}
}

// highest sensitive data category
sensitiveDataCategoryWeighting := 0
if slices.Contains(groups, "PHI") {
Expand All @@ -496,10 +503,7 @@ func CalculateSeverity(groups []string, severity string, hasLocalDataTypes bool)
ruleSeverityWeighting = 2 // low weighting as default
}

triggerWeighting := 1
if hasLocalDataTypes {
triggerWeighting = 2
}
triggerWeighting := 2

var displaySeverity string
finalWeighting := ruleSeverityWeighting + (sensitiveDataCategoryWeighting * triggerWeighting)
Expand Down
31 changes: 25 additions & 6 deletions internal/report/output/security/security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,31 @@ func TestAddReportDataWithFailOnSeverity(t *testing.T) {
Severity string
Expected bool
}{
{FailOnSeverity: globaltypes.LevelCritical, Expected: true},
{FailOnSeverity: globaltypes.LevelHigh, Expected: true},
{FailOnSeverity: globaltypes.LevelHigh, Severity: globaltypes.LevelCritical, Expected: false},
{FailOnSeverity: globaltypes.LevelMedium, Expected: false},
{FailOnSeverity: globaltypes.LevelLow, Expected: false},
{FailOnSeverity: globaltypes.LevelWarning, Expected: false},
{
FailOnSeverity: globaltypes.LevelCritical,
Expected: true,
},
{
FailOnSeverity: globaltypes.LevelHigh,
Expected: false,
},
{
FailOnSeverity: globaltypes.LevelHigh,
Severity: globaltypes.LevelCritical,
Expected: false,
},
{
FailOnSeverity: globaltypes.LevelMedium,
Expected: true,
},
{
FailOnSeverity: globaltypes.LevelLow,
Expected: false,
},
{
FailOnSeverity: globaltypes.LevelWarning,
Expected: false,
},
} {
t.Run(test.FailOnSeverity, func(tt *testing.T) {
failOnSeverity := set.New[string]()
Expand Down

0 comments on commit b01bc95

Please sign in to comment.