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

HdfConverter: Map Impact=0 to Kind=Not Applicable #2701

Merged
merged 3 commits into from
Jul 27, 2023
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
2 changes: 2 additions & 0 deletions ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
## **v4.2.2** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/4.2.2) | [Driver](https://www.nuget.org/packages/Sarif.Driver/4.2.2) | [Converters](https://www.nuget.org/packages/Sarif.Converters/4.2.2) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/4.2.2) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/4.2.2)
* BUG: Resolve `NullReferenceException` retrieving `MultithreadedZipArchiveArtifactProvider.SizeInBytes` after content have been faulted in.

* BUG: Improve HDF->SARIF conversion to properly map various properties (e.g., `kind`, `level`, `rank`) and generally prepare the converted SARIF for ingestion to [GitHub Advanced Security](https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning).

## **v4.2.1** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/4.2.1) | [Driver](https://www.nuget.org/packages/Sarif.Driver/4.2.1) | [Converters](https://www.nuget.org/packages/Sarif.Converters/4.2.1) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/4.2.1) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/4.2.1)
* BUG: Resolve `NotSupportedException` thrown (on .NET 4.8 and earlier) on accessing `DeflateStream.Length` from `MultithreadedZipArchiveArtifactProvider.SizeInBytes` property.

Expand Down
22 changes: 15 additions & 7 deletions src/Sarif.Converters/HdfConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,22 @@ private static (ReportingDescriptor, IList<Result>) SarifRuleAndResultFromHdfCon
var results = new List<Result>(execJsonControl.Results.Count);
foreach (ControlResult controlResult in execJsonControl.Results)
{
ResultKind kind = controlResult.Status switch
ResultKind kind;
if (execJsonControl.Impact <= 0.1)
{
ControlResultStatus.Passed => ResultKind.Pass,
ControlResultStatus.Failed => ResultKind.Fail,
ControlResultStatus.Error => ResultKind.Review,
ControlResultStatus.Skipped => ResultKind.NotApplicable,
_ => ResultKind.Fail,
};
kind = ResultKind.NotApplicable;
}
else
{
kind = controlResult.Status switch
{
ControlResultStatus.Passed => ResultKind.Pass,
ControlResultStatus.Failed => ResultKind.Fail,
ControlResultStatus.Error => ResultKind.Review,
ControlResultStatus.Skipped => ResultKind.Review,
_ => ResultKind.Fail,
};
}
FailureLevel level = (kind == ResultKind.Fail) ? SarifLevelFromHdfImpact(execJsonControl.Impact) : FailureLevel.None;
double rank = (kind == ResultKind.Fail) ? SarifRankFromHdfImpact(execJsonControl.Impact) : -1.0;
var result = new Result
Expand Down
Loading