Skip to content

Commit

Permalink
feat(scan): add a critical level to the severity (#150)
Browse files Browse the repository at this point in the history
Introduce the ability to set the severity threshold to the `Critical`
level using the `Threshold` method:

```csharp
scan.Threshold(Severity.Critical);
```

With this implementation, the scan will continue despite the presence of
issues with a severity lower than `Critical`, and will only stop for
issues of `Critical` severity.

closes #149
  • Loading branch information
ostridm authored Feb 8, 2023
1 parent 38a49b5 commit 5c61e83
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/SecTester.Scan/Models/Severity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ public enum Severity
Medium = 2,

[EnumMember(Value = "High")]
High = 3
High = 3,

[EnumMember(Value = "Critical")]
Critical = 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class MessageSerializerTests

public static readonly IEnumerable<object[]> SeverityEnumerable = new List<object[]>
{
new object[] { Severity.Critical, @"""Critical""" },
new object[] { Severity.Medium, @"""Medium""" },
new object[] { Severity.High, @"""High""" },
new object[] { Severity.Low, @"""Low""" }
Expand Down
4 changes: 2 additions & 2 deletions test/SecTester.Scan.Tests/ScanTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,11 @@ public async Task Expect_ConditionSatisfied_Returns(ScanStatus scanStatus)
// arrange
_scans.GetScan(ScanId).Returns(new ScanState(scanStatus), new ScanState(scanStatus)
{
IssuesBySeverity = new[] { new IssueGroup(1, Severity.High) }
IssuesBySeverity = new[] { new IssueGroup(1, Severity.Critical) }
});

// act
var act = () => _sut.Expect(Severity.Medium);
var act = () => _sut.Expect(Severity.Low);

// assert
await act.Should().NotThrowAsync<Exception>();
Expand Down

0 comments on commit 5c61e83

Please sign in to comment.