-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the ability to assert on security scan results
- Loading branch information
Showing
7 changed files
with
207 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Microsoft.CodeAnalysis.Sarif; | ||
|
||
namespace Lombiq.Tests.UI.SecurityScanning; | ||
|
||
public class SecurityScanResult | ||
{ | ||
public string ReportsDirectoryPath { get; } | ||
public SarifLog SarifLog { get; } | ||
|
||
public SecurityScanResult(string reportsDirectoryPath, SarifLog sarifLog) | ||
{ | ||
ReportsDirectoryPath = reportsDirectoryPath; | ||
SarifLog = sarifLog; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
Lombiq.Tests.UI/SecurityScanning/SecurityScanningAssertionException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
|
||
namespace Lombiq.Tests.UI.Exceptions; | ||
|
||
public class SecurityScanningAssertionException : Exception | ||
{ | ||
public SecurityScanningAssertionException(Exception innerException) | ||
: base( | ||
"Asserting the security scan result failed. Check the security scan report in the failure dump for details.", | ||
innerException) | ||
{ | ||
} | ||
|
||
public SecurityScanningAssertionException() | ||
{ | ||
} | ||
|
||
public SecurityScanningAssertionException(string message) | ||
: base(message) | ||
{ | ||
} | ||
|
||
public SecurityScanningAssertionException(string message, Exception innerException) | ||
: base(message, innerException) | ||
{ | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Lombiq.Tests.UI/SecurityScanning/SecurityScanningConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Lombiq.Tests.UI.Services; | ||
using Microsoft.CodeAnalysis.Sarif; | ||
using Shouldly; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lombiq.Tests.UI.SecurityScanning; | ||
|
||
public class SecurityScanningConfiguration | ||
{ | ||
/// <summary> | ||
/// Gets or sets a delegate that may modify the deserialized representation of the ZAP Automation Framework YAML. | ||
/// </summary> | ||
public Func<UITestContext, object, Task> ZapAutomationFrameworkYamlModifier { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets a delegate to run assertions on the <see cref="SarifLog"/> when security scanning happens. | ||
/// </summary> | ||
public Action<UITestContext, SarifLog> AssertSecurityScanResult { get; set; } = AssertSecurityScanHasNoFails; | ||
|
||
public static readonly Action<UITestContext, SarifLog> AssertSecurityScanHasNoFails = | ||
(_, sarifLog) => sarifLog.Runs[0].Results.ShouldNotContain(result => result.Kind == ResultKind.Fail); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters