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

Update MSBuild Converter regex to support more MSBuild log variants #2579

Merged
merged 4 commits into from
Dec 22, 2022

Conversation

yongyan-gh
Copy link
Collaborator

Description

The information regarding MSBuild log format https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-diagnostic-format-for-tasks?view=vs-2022

{Origin} : {Subcategory (optional)} {Category} {Code} : {Text}
  • Update regex to accept case insensitive error level keywords.
  • Support the format of PackageValidator log: a colon between {Category} and {Code}.
  • Add test cases.

<None Remove="TestData\MSBuildConverter\ExpectedOutputs\ValidResults.sarif" />
<None Remove="TestData\MSBuildConverter\Inputs\Empty.ERR" />
<None Remove="TestData\MSBuildConverter\Inputs\InvalidResult.ERR" />
<None Remove="TestData\MSBuildConverter\Inputs\ValidResults.ERR" />
</ItemGroup>
Copy link
Collaborator

@shaopeng-gh shaopeng-gh Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi I remember Michael once had a comment about removing the whole <ItemGroup> instead, if all of the content is not needed, see if applies here. #Resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks removed

@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrn

just to get info, the reason we need wrn and err ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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

}
},
{
"ruleId": "PV1002",
Copy link
Collaborator

@shaopeng-gh shaopeng-gh Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PV1002

should this also be "level": "error", ?
ERROR: PV1002 #Resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug fixed

@yongyan-gh
Copy link
Collaborator Author

For testing the regex:
https://regex101.com/r/WXQuqL/1

@@ -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)
Copy link
Collaborator

@shaopeng-gh shaopeng-gh Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUGFIX: MSBuild Converter accepts case insensitive keywords and supports PackageValidator msbuild log

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

Copy link
Collaborator

@shaopeng-gh shaopeng-gh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@@ -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)
Copy link
Member

@michaelcfanning michaelcfanning Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSBuild Converter accepts case insensitive keywords and supports PackageValidator msbuild log

It's super close! Use this:

MSBuild Converter now accepts case insensitive keywords and supports PackageValidator msbuild log output.
#Resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the suggestion. updated.

Copy link
Member

@michaelcfanning michaelcfanning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@michaelcfanning michaelcfanning merged commit 3fcfe90 into main Dec 22, 2022
@michaelcfanning michaelcfanning deleted the user/yongyan-gh/msbuildConverter branch December 22, 2022 17:44
This was referenced Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants