Skip to content

Commit

Permalink
Adding verbose as obsolete with warning message (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddynaka authored Feb 27, 2021
1 parent 6eb0ca7 commit 0f53fc9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
4 changes: 2 additions & 2 deletions SetCurrentVersion.cmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
set MAJOR_PREVIOUS=1
set MINOR_PREVIOUS=7
set PATCH_PREVIOUS=2
set PATCH_PREVIOUS=3
set PRERELEASE_PREVIOUS=

set MAJOR=1
set MINOR=7
set PATCH=3
set PATCH=4
set PRERELEASE=
17 changes: 16 additions & 1 deletion src/BinSkim.Driver/AnalyzeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ protected override BinaryAnalyzerContext CreateContext(AnalyzeOptions options, I
binaryAnalyzerContext.TracePdbLoads = options.Traces.Contains(nameof(Traces.PdbLoad));
binaryAnalyzerContext.LocalSymbolDirectories = options.LocalSymbolDirectories;

#pragma warning disable CS0618 // Type or member is obsolete
if (options.Verbose)
#pragma warning restore CS0618 // Type or member is obsolete
{
Warnings.LogObsoleteOption(binaryAnalyzerContext, "--verbose", Sdk.SdkResources.Verbose_ReplaceWithLevelAndKind);
}

return binaryAnalyzerContext;
}

Expand All @@ -48,12 +55,20 @@ public override int Run(AnalyzeOptions analyzeOptions)
analyzeOptions.SarifOutputVersion = s_UnitTestOutputVersion;
}

#pragma warning disable CS0618 // Type or member is obsolete
if (analyzeOptions.Verbose)
#pragma warning restore CS0618 // Type or member is obsolete
{
analyzeOptions.Level = new List<FailureLevel> { FailureLevel.Error, FailureLevel.Warning, FailureLevel.Note };
analyzeOptions.Kind = new List<ResultKind> { ResultKind.Fail, ResultKind.NotApplicable, ResultKind.Pass };
}

int result = base.Run(analyzeOptions);

// In BinSkim, no rule is ever applicable to every target type. For example,
// we have checks that are only relevant to either 32-bit or 64-bit binaries.
// Because of this, the return code bit for RuleNotApplicableToTarget is not
// interesting (it will always be set).
// interesting (it will always be set).

return analyzeOptions.RichReturnCode
? (int)((uint)result & ~(uint)RuntimeConditions.RuleNotApplicableToTarget)
Expand Down
7 changes: 7 additions & 0 deletions src/BinSkim.Driver/AnalyzeOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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.Collections.Generic;

using CommandLine;
Expand Down Expand Up @@ -36,5 +37,11 @@ public class AnalyzeOptions : AnalyzeOptionsBase
"local-symbol-directories",
HelpText = "A set of semicolon-delimited local directory paths that will be examined when attempting to locate PDBs.")]
public string LocalSymbolDirectories { get; internal set; }

[Option(
"verbose",
HelpText = "Emit verbose output. The resulting comprehensive report is designed to provide appropriate evidence for compliance scenarios.")]
[Obsolete("Use --level and --kind instead.")]
public bool Verbose { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/BinSkim.Sdk/SdkResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/BinSkim.Sdk/SdkResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,7 @@
<data name="MetadataCondition_ImageIsDotNetNativeBootstrapExe" xml:space="preserve">
<value>image is a .NET native bootstrap exe</value>
</data>
<data name="Verbose_ReplaceWithLevelAndKind" xml:space="preserve">
<value>use --level and --kind</value>
</data>
</root>

0 comments on commit 0f53fc9

Please sign in to comment.