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

BREAKING: Removed SARIF 1.0 support from BinSkim. Now option -v | --sarif-output-version does not accept value OneZeroZero. #719

Merged
merged 7 commits into from
Oct 25, 2022

Conversation

shaopeng-gh
Copy link
Contributor

BREAKING: Removed SARIF 1.0 support from BinSkim. Now option -v | --sarif-output-version does not accept value OneZeroZero.

I found most of the code is from SARIF SDK and unless we also zap the support in SDK we can not change those codes.
for example, the option itself is from SDK, and the help text will say "Valid values are OneZeroZero and Current".
We do not want that false information.
So a simple way of fix I tried working is to new a same name parameter to hide the underlying one, this way we can show something like "The only valid value is Current." and also only support Current instead of supporting both.
The error message user get this way is unified with other parameter not supported and will print the help page with the info on what is supported.
Added tests show the actual value will be Current as we want for various input.

…sarif-output-version` does not accept value `OneZeroZero`.
if (!Environment.GetCommandLineArgs().Any(arg => arg.Equals("--sarif-output-version")))
if (!Environment.GetCommandLineArgs().
Any(arg => arg.Equals("--sarif-output-version", StringComparison.OrdinalIgnoreCase) ||
arg.Equals("-v", StringComparison.OrdinalIgnoreCase)))
Copy link
Contributor Author

@shaopeng-gh shaopeng-gh Oct 19, 2022

Choose a reason for hiding this comment

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

this is not related to the change,
the code clearly missed the -v variant so I added it btw. #Closed

HelpText =
"The SARIF version of the output log file. The only valid value is Current.",
Default = BinSkimSarifVersion.Current)]
public new BinSkimSarifVersion SarifOutputVersion { get; set; } = BinSkimSarifVersion.Current;
Copy link
Contributor Author

@shaopeng-gh shaopeng-gh Oct 19, 2022

Choose a reason for hiding this comment

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

new

please see the desc of the PR for more info. #Closed

@@ -48,5 +48,13 @@ public class AnalyzeOptions : AnalyzeOptionsBase
"ignorePdbLoadError",
HelpText = "If enabled, BinSkim won't break if we have a 'PdbLoadingException'.")]
public bool IgnorePdbLoadError { get; set; }

[Option(
Copy link
Contributor Author

@shaopeng-gh shaopeng-gh Oct 20, 2022

Choose a reason for hiding this comment

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

Option

This is the main change of the PR.
The support of the v1 in Binskim, actually comes from SARIF SDK. Without remove the support in SDK we can not really remove it.
The change is to disable it in BinSkim. Please see more details in PR desc.
Now option -v | --sarif-output-version does not accept value OneZeroZero in BinSkim. #Resolved

Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need this. We should delete it.

Instead, just find the right place in our code and throw an InvalidOperationException in cases where someone passes SarifOneZeroZero on the command-line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed accordingly.


namespace Microsoft.CodeAnalysis.IL
{
public enum BinSkimSarifVersion
Copy link
Member

@michaelcfanning michaelcfanning Oct 21, 2022

Choose a reason for hiding this comment

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

BinSkimSarifVersion

I think we can delete this code. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed.

{
analyzeOptions.SarifOutputVersion = Sarif.SarifVersion.Current;
Copy link
Member

@michaelcfanning michaelcfanning Oct 21, 2022

Choose a reason for hiding this comment

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

SarifOutputVersion

put a check here for use of Sarif.SarifVersion.OneZeroZero and just throw an ArgumentException or InvalidOperationException in that case.

'BinSkim no longer supports emitting SARIF 1.0 (an obsolete format). Pass 'Current' on the command-line or omit this argument entirely.' #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about this simple throw as well, I think my way is better because simple throw will still have the wrong info in the tool help.

Let me change to simple throw.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

Copy link
Member

Choose a reason for hiding this comment

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

I see your point! We should be thinking about where this area is going. I think the right thing to do moving forward is to actually eliminate this argument entirely, i.e., we don't want the driver SDK itself to provide for SARIF v1 support by default. And so that argues for taking this approach: the help will be broken, but a future update of the driver SDK could drop this argument entirely.

{
analyzeOptions.SarifOutputVersion = Sarif.SarifVersion.Current;
}

if (s_UnitTestOutputVersion != Sarif.SarifVersion.Unknown)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

s_UnitTestOutputVersion

Multi test run have issue, I changed to instance.

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 a2f5541 into main Oct 25, 2022
@michaelcfanning michaelcfanning deleted the users/shaopeng-gh/zapsarifv1 branch October 25, 2022 18:48
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.

2 participants