From 0f53fc9720991d8ba3d5a0470cc51e038ddd68b2 Mon Sep 17 00:00:00 2001 From: Eddy Nakamura Date: Sat, 27 Feb 2021 14:48:41 -0300 Subject: [PATCH] Adding verbose as obsolete with warning message (#347) --- SetCurrentVersion.cmd | 4 ++-- src/BinSkim.Driver/AnalyzeCommand.cs | 17 ++++++++++++++++- src/BinSkim.Driver/AnalyzeOptions.cs | 7 +++++++ src/BinSkim.Sdk/SdkResources.Designer.cs | 9 +++++++++ src/BinSkim.Sdk/SdkResources.resx | 3 +++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/SetCurrentVersion.cmd b/SetCurrentVersion.cmd index 60774d2ef..a88556e83 100644 --- a/SetCurrentVersion.cmd +++ b/SetCurrentVersion.cmd @@ -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= diff --git a/src/BinSkim.Driver/AnalyzeCommand.cs b/src/BinSkim.Driver/AnalyzeCommand.cs index 8f5ad076f..103ca9c24 100644 --- a/src/BinSkim.Driver/AnalyzeCommand.cs +++ b/src/BinSkim.Driver/AnalyzeCommand.cs @@ -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; } @@ -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.Error, FailureLevel.Warning, FailureLevel.Note }; + analyzeOptions.Kind = new List { 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) diff --git a/src/BinSkim.Driver/AnalyzeOptions.cs b/src/BinSkim.Driver/AnalyzeOptions.cs index 35e3d556d..26769699c 100644 --- a/src/BinSkim.Driver/AnalyzeOptions.cs +++ b/src/BinSkim.Driver/AnalyzeOptions.cs @@ -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; @@ -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; } } } diff --git a/src/BinSkim.Sdk/SdkResources.Designer.cs b/src/BinSkim.Sdk/SdkResources.Designer.cs index f79c510db..0a3aefc73 100644 --- a/src/BinSkim.Sdk/SdkResources.Designer.cs +++ b/src/BinSkim.Sdk/SdkResources.Designer.cs @@ -365,5 +365,14 @@ internal static string TargetNotAnalyzed_NotApplicable { return ResourceManager.GetString("TargetNotAnalyzed_NotApplicable", resourceCulture); } } + + /// + /// Looks up a localized string similar to use --level and --kind. + /// + internal static string Verbose_ReplaceWithLevelAndKind { + get { + return ResourceManager.GetString("Verbose_ReplaceWithLevelAndKind", resourceCulture); + } + } } } diff --git a/src/BinSkim.Sdk/SdkResources.resx b/src/BinSkim.Sdk/SdkResources.resx index 7b0991c21..8f6716e11 100644 --- a/src/BinSkim.Sdk/SdkResources.resx +++ b/src/BinSkim.Sdk/SdkResources.resx @@ -219,4 +219,7 @@ image is a .NET native bootstrap exe + + use --level and --kind + \ No newline at end of file