Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove dynamic severity #1469

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading