Skip to content

Commit

Permalink
Merge branch 'main' into sarif-location
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelcfanning authored Aug 23, 2023
2 parents 36841b0 + ff8c721 commit cb3198c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ReleaseHistory.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# SARIF Package Release History (SDK, Driver, Converters, and Multitool)
## Unreleased

* BUG: Correct `run.language` regex in JSON schema. [#2708]https://github.com/microsoft/sarif-sdk/pull/2708

## **v4.3.0** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/v4.3.0) | [Driver](https://www.nuget.org/packages/Sarif.Driver/v4.3.0) | [Converters](https://www.nuget.org/packages/Sarif.Converters/v4.3.0) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/v4.3.0) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/v4.3.0)
* BUG: Resolve `NullReferenceException` retrieving `MultithreadedZipArchiveArtifactProvider.SizeInBytes` after content have been faulted in.

Expand Down
2 changes: 1 addition & 1 deletion src/Sarif/Schemata/sarif-2.1.0-rtm.6.json
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,7 @@
"description": "The language of the messages emitted into the log file during this run (expressed as an ISO 639-1 two-letter lowercase culture code) and an optional region (expressed as an ISO 3166-1 two-letter uppercase subculture code associated with a country or region). The casing is recommended but not required (in order for this data to conform to RFC5646).",
"type": "string",
"default": "en-US",
"pattern": "^[a-zA-Z]{2}|^[a-zA-Z]{2}-[a-zA-Z]{2}]?$"
"pattern": "^[a-zA-Z]{2}(-[a-zA-Z]{2})?$"
},

"versionControlProvenance": {
Expand Down
56 changes: 56 additions & 0 deletions src/Test.UnitTests.Sarif.Driver/Sdk/AnalyzeCommandBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using Microsoft.CodeAnalysis.Sarif.Converters;
using Microsoft.CodeAnalysis.Sarif.Writers;

using Mono.Cecil.Cil;

using Moq;

using Newtonsoft.Json;
Expand All @@ -36,6 +38,60 @@ public AnalyzeCommandBaseTests(ITestOutputHelper output)
Output.WriteLine($"The seed that will be used is: {TestRule.s_seed}");
}

[Fact]
public void AnalyzeCommandBase_OptionsSettingsOverrideContextSettings()
{
// For every configuration knob, we choose an explicit,
// non-default value that differs between options and configuration.
// This allows us to be sure that the explicit options setting
// is honored.

ResultKind optionsKind = ResultKind.Review;
ResultKind contextKind = ResultKind.Open;

FailureLevel optionsLevel = FailureLevel.Note;
FailureLevel contextLevel = FailureLevel.Error;

var options = new TestAnalyzeOptions
{
Kind = new[] { optionsKind, ResultKind.Fail },
Level = new[] { optionsLevel },
};

var context = new TestAnalysisContext()
{
ResultKinds = new ResultKindSet(new[] { contextKind, ResultKind.Fail }),
FailureLevels = new FailureLevelSet(new[] { contextLevel }),
};

var multithreadedAnalyzeCommand = new TestMultithreadedAnalyzeCommand();
multithreadedAnalyzeCommand.InitializeGlobalContextFromOptions(options, ref context);

context.ResultKinds.Should().BeEquivalentTo(new ResultKindSet(new[] { optionsKind, ResultKind.Fail }));
context.FailureLevels.Should().BeEquivalentTo(new FailureLevelSet(new[] { optionsLevel }));
}

[Fact]
public void AnalyzeCommandBase_EmptyOptionsSettingsDoNotOverrideContextSettings()
{
var options = new TestAnalyzeOptions
{
};

FailureLevel contextLevel = FailureLevel.Error;
var failureLevels = new FailureLevelSet(new[] { contextLevel });

var context = new TestAnalysisContext()
{
FailureLevels = failureLevels
};

var multithreadedAnalyzeCommand = new TestMultithreadedAnalyzeCommand();
multithreadedAnalyzeCommand.InitializeGlobalContextFromOptions(options, ref context);

context.FailureLevels.Should().BeEquivalentTo(failureLevels);
}

[Fact]
public void AnalyzeCommandBase_PerTargetAnalyzeEventsAreReceived()
{
Expand Down

0 comments on commit cb3198c

Please sign in to comment.