-
Notifications
You must be signed in to change notification settings - Fork 88
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
Update MSBuild Converter regex to support more MSBuild log variants #2579
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
* BUGFIX: Update `merge` command to properly produce runs by tool and version when passed the `--merge-runs` argument. [#2488](https://github.com/microsoft/sarif-sdk/pull/2488) | ||
* BUGFIX: Eliminate `IOException` and `DirectoryNotFoundException` exceptions thrown by `merge` command when splitting by rule (due to invalid file characters in rule ids). [#2513](https://github.com/microsoft/sarif-sdk/pull/2513) | ||
* BUGFIX: Fix classes inside NotYetAutoGenerated folder missing `virtual` keyword for public methods and properties, by regenerate and manually sync the changes. [#2537](https://github.com/microsoft/sarif-sdk/pull/2537) | ||
* BUGFIX: MSBuild Converter accepts case insensitive keywords and supports PackageValidator msbuild log. [#2579](https://github.com/microsoft/sarif-sdk/pull/2579) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the suggestion. updated. |
||
|
||
## **v3.1.0** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/3.1.0) | [Driver](https://www.nuget.org/packages/Sarif.Driver/3.1.0) | [Converters](https://www.nuget.org/packages/Sarif.Converters/3.1.0) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/3.1.0) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/3.1.0) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ private IList<Result> GetResults(TextReader reader) | |
} | ||
|
||
private const string ErrorLinePattern = @" | ||
(?i) # Case insensitive | ||
^ | ||
\s* | ||
( # EITHER | ||
|
@@ -83,9 +84,9 @@ private IList<Result> GetResults(TextReader reader) | |
\s*:\s* | ||
(?<qualifiedLevel> | ||
(?<levelQualification>.*) # For example, 'fatal'. | ||
(?<level>error|warning|note|info|pass|review|open|notapplicable) | ||
(?<level>error|err|warning|wrn|note|info|pass|review|open|notapplicable) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't see a definition of what the level should be in .ERR file. Have seen "Error"/"Warning" also the abbreviation forms "ERR"/"WRN" in build logs. Here just try to match the keyword as much as possible |
||
) | ||
\s+ | ||
\s*:?\s* | ||
(?<ruleId>[^\s:]+) | ||
\s*:\s* | ||
(?<message>.*) | ||
|
@@ -154,11 +155,17 @@ private static FailureLevel GetFailureLevelFrom(string level, out ResultKind res | |
resultKind = ResultKind.Fail; | ||
FailureLevel failureLevel = FailureLevel.None; | ||
|
||
switch (level) | ||
switch (level.ToLower()) | ||
{ | ||
// Failure cases. ResultKind.Fail + specific failure level | ||
case "warning": { failureLevel = FailureLevel.Warning; break; } | ||
case "error": { failureLevel = FailureLevel.Error; break; } | ||
case "warning": | ||
case "wrn": | ||
failureLevel = FailureLevel.Warning; | ||
break; | ||
case "error": | ||
case "err": | ||
failureLevel = FailureLevel.Error; | ||
break; | ||
case "note": { failureLevel = FailureLevel.Note; break; } | ||
|
||
// Non-failure cases. FailureLevel.None + specific result kind | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.IO; | ||
|
||
using FluentAssertions; | ||
|
||
using Microsoft.CodeAnalysis.Sarif.Writers; | ||
|
||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.Sarif.Converters | ||
{ | ||
public class MSBuildConverterTests : ConverterTestsBase<MSBuildConverter> | ||
{ | ||
[Fact] | ||
public void Converter_RequiresInputStream() | ||
{ | ||
var converter = new MSBuildConverter(); | ||
Action action = () => converter.Convert(input: null, output: new ResultLogObjectWriter(), dataToInsert: OptionallyEmittedData.None); | ||
action.Should().Throw<ArgumentNullException>(); | ||
} | ||
|
||
[Fact] | ||
public void Converter_RequiresResultLogWriter() | ||
{ | ||
var converter = new MSBuildConverter(); | ||
Action action = () => converter.Convert(input: new MemoryStream(), output: null, dataToInsert: OptionallyEmittedData.None); | ||
action.Should().Throw<ArgumentNullException>(); | ||
} | ||
|
||
[Fact] | ||
public void Converter_WhenInputIsEmpty_ReturnsNoResults() | ||
{ | ||
string input = s_extractor.GetResourceInputText("Empty.ERR"); | ||
string expectedOutput = s_extractor.GetResourceExpectedOutputsText("NoResults.sarif"); | ||
RunTestCase(input, expectedOutput); | ||
} | ||
|
||
[Fact] | ||
public void Converter_WhenResultRowIsInvalid_ReturnsNoResults() | ||
{ | ||
string input = s_extractor.GetResourceInputText("InvalidResult.ERR"); | ||
string expectedOutput = s_extractor.GetResourceExpectedOutputsText("NoResults.sarif"); | ||
RunTestCase(input, expectedOutput); | ||
} | ||
|
||
[Fact] | ||
public void Converter_WhenInputContainsValidResults_ReturnsExpectedOutput() | ||
{ | ||
string input = s_extractor.GetResourceInputText("ValidResults.ERR"); | ||
string expectedOutput = s_extractor.GetResourceExpectedOutputsText("ValidResults.sarif"); | ||
RunTestCase(input, expectedOutput); | ||
} | ||
|
||
private static readonly TestAssetResourceExtractor s_extractor = new TestAssetResourceExtractor(typeof(MSBuildConverterTests)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.6.json", | ||
"version": "2.1.0", | ||
"runs": [ | ||
{ | ||
"results": [], | ||
"tool": { | ||
"driver": { | ||
"name": "MSBuild" | ||
} | ||
}, | ||
"columnKind": "utf16CodeUnits" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.6.json", | ||
"version": "2.1.0", | ||
"runs": [ | ||
{ | ||
"results": [ | ||
{ | ||
"ruleId": "MSB1003", | ||
"level": "error", | ||
"message": { | ||
"text": "Specify a project or solution file. The current working directory does not contain a project or solution file." | ||
} | ||
}, | ||
{ | ||
"ruleId": "MSB1001", | ||
"level": "error", | ||
"message": { | ||
"text": "Unknown switch, Switch: /maxcpucount." | ||
} | ||
}, | ||
{ | ||
"ruleId": "PV1002", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bug fixed |
||
"level": "error", | ||
"message": { | ||
"text": "Package sense1ds[1.1000.1] is missing the content manifest. For more information, see https://osgwiki.com/wiki/PackageValidator#PV1002" | ||
} | ||
}, | ||
{ | ||
"ruleId": "PV1000", | ||
"level": "note", | ||
"message": { | ||
"text": "Package diagtrackservice.vb_release.x86[0.0.0] is missing provenance data. For more information, see https://osgwiki.com/wiki/PackageValidator#PV1000" | ||
} | ||
}, | ||
{ | ||
"ruleId": "PV1004", | ||
"message": { | ||
"text": "Package microsoft.timetraveldebugging.test.x86[0.0.25] is missing the manifest catalog. For more information, see https://osgwiki.com/wiki/PackageValidator#PV1004" | ||
} | ||
} | ||
], | ||
"tool": { | ||
"driver": { | ||
"name": "MSBuild" | ||
} | ||
}, | ||
"columnKind": "utf16CodeUnits" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
----- Catalog construction errors ----- | ||
Error #1 | ||
Microsoft.VisualStudio.Composition.PartDiscoveryException: ReflectionTypeLoadException while enumerating types in assembly "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\ENTERPRISE\COMMON7\IDE\EXTENSIONS\MICROSOFT\GRAPHICS\DEBUGGER\VsGraphicsDebuggerPkg.dll". Results will be incomplete. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. | ||
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) | ||
at System.Reflection.RuntimeModule.GetTypes() | ||
at System.Reflection.Assembly.GetTypes() | ||
at Microsoft.VisualStudio.Composition.PartDiscovery.CombinedPartDiscovery.GetTypes(Assembly assembly) | ||
at Microsoft.VisualStudio.Composition.PartDiscovery.<>c__DisplayClass32_0.<CreateAssemblyDiscoveryBlockChain>b__0(Assembly a) | ||
--- End of inner exception stack trace --- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
----- non msbuild error ----- | ||
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.UniversalApps.Deployment, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. | ||
File name: 'Microsoft.UniversalApps.Deployment, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' | ||
|
||
----- VS msbuild error ----- | ||
msbuild : err MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file. | ||
msbuild : error MSB1001: Unknown switch, Switch: /maxcpucount. | ||
|
||
----- Package Validator build error ----- | ||
%object_root%\amcore\wcd\source\communicator\sense1ds\dll\$(o)\vpack : ERROR: PV1002: Package sense1ds[1.1000.1] is missing the content manifest. For more information, see https://osgwiki.com/wiki/PackageValidator#PV1002 | ||
%object_root%\onecore\base\telemetry\utc\tests\functionaltests\vpacks\diagtrackservice.vb_release\$(o)\vpack : NOTE: PV1000: Package diagtrackservice.vb_release.x86[0.0.0] is missing provenance data. For more information, see https://osgwiki.com/wiki/PackageValidator#PV1000 | ||
%object_root%\onecore\sdktools\debuggers\ttd\undocked\testbinaries\$(o)\vpack : WRN: PV1004: Package microsoft.timetraveldebugging.test.x86[0.0.25] is missing the manifest catalog. For more information, see https://osgwiki.com/wiki/PackageValidator#PV1004 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may need some lang update make it more clear that
accepts case insensitive keywords
is the the bug fixed but after fix, e.g.now accepts
#Resolved