Skip to content

Commit

Permalink
Updating sarif-sdk (#339)
Browse files Browse the repository at this point in the history
* Updating sarif-sdk

* updating markdown files

* updating markdown files
  • Loading branch information
eddynaka authored Jan 26, 2021
1 parent a7816c7 commit 6e10dea
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 24 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ This repository contains the source code for BinSkim, a Portable Executable (PE)
| -------------------------------- | ------- |
| **`--sympath`** | Symbols path value (e.g. `SRV http://msdl.microsoft.com/download/symbols or Cache d:\symbols;Srv http://symweb`) |
| **`-o, --output`** | File path used to write and output analysis using [SARIF](https://github.com/Microsoft/sarif-sdk) |
| **`-v, --verbose`** | Emit verbose output. The comprehensive report is designed to provide appropriate evidence for compliance scenarios |
| **`-r, --recurse`** | Recurse into subdirectories when evaluating file specifier arguments |
| **`-c, --config`** | (Default: ‘default’) Path to policy file to be used to configure analysis. Passing value of 'default' (or omitting the argument) invokes built-in settings |
| **`-q, --quiet`** | Do not log results to the console |
| **`-s, --statistics`** | Generate timing and other statistics for analysis session |
| **`-h, --hashes`** | Output hashes of analysis targets when emitting SARIF reports |
| **`-e, --environment`** | <p>Log machine environment details of run to output file.</p><p>**WARNING:** This option records potentially sensitive information (such as all environment variable values) to the log file.</p> |
| **`-p, --plug-in`** | Path to plug-in that will be invoked against all targets in the analysis set. |
| **`-p, --plugin`** | Path to plugin that will be invoked against all targets in the analysis set. |
| **`--level`** | Filter output of scan results to one or more failure levels. Valid values: Error, Warning and Note. |
| **`--kind`** | Filter output one or more result kinds. Valid values: Fail (for literal scan results), Pass, Review, Open, NotApplicable and Informational. |
| **`--trace`** | Execution traces, expressed as a semicolon-delimited list, that should be emitted to the console and log file (if appropriate). Valid values: PdbLoad. |
| **`--help`** | Table of argument information. |
| **`--version`** | BinSkim version details. |
| **`value pos. 0`** | One or more specifiers to a file, directory, or filter pattern that resolves to one or more binaries to analyze. |
Expand Down
17 changes: 7 additions & 10 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ The primary function of BinSkim is to analyze Windows PEs, such as Dynamic Link

```csharp
// Analyze a single binary named MyProjectFile.dll found in c:\temp
// and emit verbose messages during analysis
binskim.exe analyze c:\temp\MyProjectFile.dll --verbose
binskim.exe analyze c:\temp\MyProjectFile.dll

// Analyze all files with the .dll or .exe extension starting in the
// current working directory and recursing through all child directories
Expand All @@ -44,16 +43,18 @@ The **`analyze`** command supports the following additional arguments:
| -------------------------------- | ------- |
| **`--sympath`** | Symbols path value (e.g. `SRV http://msdl.microsoft.com/download/symbols or Cache d:\symbols;Srv http://symweb`) |
| **`-o, --output`** | File path used to write and output analysis using [SARIF](https://github.com/Microsoft/sarif-sdk) |
| **`-v, --verbose`** | Emit verbose output. The comprehensive report is designed to provide appropriate evidence for compliance scenarios |
| **`-r, --recurse`** | Recurse into subdirectories when evaluating file specifier arguments |
| **`-c, --config`** | (Default: ‘default’) Path to policy file to be used to configure analysis. Passing value of 'default' (or omitting the argument) invokes built-in settings |
| **`-q, --quiet`** | Do not log results to the console |
| **`-s, --statistics`** | Generate timing and other statistics for analysis session |
| **`-h, --hashes`** | Output hashes of analysis targets when emitting SARIF reports |
| **`-e, --environment`** | <p>Log machine environment details of run to output file.</p><p>**WARNING:** This option records potentially sensitive information (such as all environment variable values) to the log file.</p> |
| **`-p, --plug-in`** | Path to plug-in that will be invoked against all targets in the analysis set. |
| **`-p, --plugin`** | Path to plugin that will be invoked against all targets in the analysis set. |
| **`--help`** | Table of argument information. |
| **`--version`** | BinSkim version details. |
| **`--level`** | Filter output of scan results to one or more failure levels. Valid values: Error, Warning and Note. |
| **`--kind`** | Filter output one or more result kinds. Valid values: Fail (for literal scan results), Pass, Review, Open, NotApplicable and Informational. |
| **`--trace`** | Execution traces, expressed as a semicolon-delimited list, that should be emitted to the console and log file (if appropriate). Valid values: PdbLoad. |
| **`--rich-return-code`** | Output a more detailed exit code consisting of a series of flags about execution, rather than outputting '0' for success/'1' for failure (see codes below) |

In addition to the named arguments above, BinSkim accepts one or more specifiers to a file, directory, or filter pattern that resolves to one or more binaries to analyze. Arguments can include wild cards, relative paths (in which case the file or directory path is resolved relative to the current working directory), and environment variables.
Expand Down Expand Up @@ -89,10 +90,6 @@ The `--local-symbol-directories` argument configures a set of semicolon-delimite

The `-o` or `--output` argument specifies a file path to which BinSkim’s SARIF-formatted results will be written. The Microsoft SARIF SDK ships with a Microsoft Visual Studio Add-In that can be compiled and used to load SARIF log files into the Microsoft Visual Studio IDE.

#### -v, --verbose

By default, BinSkim output is restricted to errors and warnings. BinSkim can also be configured to provide more comprehensive output by passing `-v` or `--verbose` on the command-line. In this case, BinSkim will emit explicit messages for each rule as it examines each target, including whether a binary passed the check successfully or if the check was skipped because a target was not applicable to analysis.

#### -r, --recurse

The `-r` or `--recurse` argument will recurse into child directories for each file specifier passed on the command-line. If the argument does not appear on the command-line, each file specifier will be resolved against the provided directory, if there is one, or the current working directory, if there is not.
Expand Down Expand Up @@ -156,9 +153,9 @@ This leads to these masks being helpful when determining what to do with a rich

Note--In the future we may add add new fatal or non-fatal exit codes to this command. They will be documented here and in the release documentation.

#### -p, --plug-in
#### -p, --plugin

The `-p` or `--plug-in` argument is used to provide a path to a BinSkim plug-in that will be loaded and invoked at analysis time, in addition to the built-in checks. This argument can be specified multiple times on the command-line.
The `-p` or `--plugin` argument is used to provide a path to a BinSkim plugin that will be loaded and invoked at analysis time, in addition to the built-in checks. This argument can be specified multiple times on the command-line.

## BinSkim Release History

Expand Down
2 changes: 1 addition & 1 deletion src/BinSkim.Driver/AnalyzeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class AnalyzeCommand : AnalyzeCommandBase<BinaryAnalyzerContext, AnalyzeO
new string[] { ".dll", ".exe", ".sys" }
);

public override IEnumerable<Assembly> DefaultPlugInAssemblies
public override IEnumerable<Assembly> DefaultPluginAssemblies
{
get => new Assembly[] { typeof(MarkImageAsNXCompatible).Assembly };
set => throw new InvalidOperationException();
Expand Down
6 changes: 3 additions & 3 deletions src/BinSkim.Driver/ExportOptionsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace Microsoft.CodeAnalysis.IL
{
internal class ExportConfigurationCommand : ExportConfigurationCommandBase
{
public override IEnumerable<Assembly> DefaultPlugInAssemblies => new Assembly[] {
typeof(MarkImageAsNXCompatible).Assembly
};
public override IEnumerable<Assembly> DefaultPluginAssemblies => new Assembly[] {
typeof(MarkImageAsNXCompatible).Assembly
};
}
}
6 changes: 3 additions & 3 deletions src/BinSkim.Driver/ExportRulesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace Microsoft.CodeAnalysis.IL
{
internal class ExportRulesMetadataCommand : ExportRulesMetadataCommandBase
{
public override IEnumerable<Assembly> DefaultPlugInAssemblies => new Assembly[] {
typeof(MarkImageAsNXCompatible).Assembly
};
public override IEnumerable<Assembly> DefaultPluginAssemblies => new Assembly[] {
typeof(MarkImageAsNXCompatible).Assembly
};
}
}
5 changes: 3 additions & 2 deletions src/ReleaseHistory.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# BinSkim Release History

## **Unreleased**
* **FEATURE**: Update SARIF version to latest (using submodule) [#325](https://github.com/microsoft/binskim/pull/325)
* **FEATURE**: Add BA2004.EnableSecureSourceCodeHashing [#320](https://github.com/microsoft/binskim/pull/320)
* **FEATURE**: Update SARIF version to latest (using submodule). [#325](https://github.com/microsoft/binskim/pull/325)
* **FEATURE**: Add BA2004.EnableSecureSourceCodeHashing. [#320](https://github.com/microsoft/binskim/pull/320)
* **BREAKING**: Replace `--verbose` for `--level` and `--kind`. [#339](https://github.com/microsoft/binskim/pull/339)

## **v2.0.0** In progress (probably May/June 2021)
* **BREAKING**: Change from self-contained to dotnettool.
Expand Down
5 changes: 3 additions & 2 deletions src/Test.FunctionalTests.BinSkim.Driver/BaselineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ private void RunRules(StringBuilder sb, string inputFileName)
var options = new AnalyzeOptions
{
Force = true,
Verbose = true,
Recurse = false,
PrettyPrint = true,
DataToInsert = new[] { OptionallyEmittedData.Hashes },
OutputFilePath = actualFileName,
ConfigurationFilePath = "default",
SarifOutputVersion = Sarif.SarifVersion.Current,
TargetFileSpecifiers = new string[] { inputFileName },
Traces = Array.Empty<string>()
Traces = Array.Empty<string>(),
Level = new List<FailureLevel> { FailureLevel.Error, FailureLevel.Warning, FailureLevel.Note, FailureLevel.None },
Kind = new List<ResultKind> { ResultKind.Fail, ResultKind.NotApplicable, ResultKind.Pass },
};

int result = command.Run(options);
Expand Down
2 changes: 1 addition & 1 deletion src/sarif-sdk
Submodule sarif-sdk updated 77 files
+12 −1 src/ReleaseHistory.md
+1 −1 src/Samples/Sarif.Sdk.Sample/Program.cs
+1 −1 src/Samples/SarifTrim/Program.cs
+1 −1 src/Sarif.Converters/CppCheckLocation.cs
+2 −2 src/Sarif.Converters/Extensions.cs
+2 −8 src/Sarif.Converters/GlobalSuppressions.cs
+2 −2 src/Sarif.Converters/ToolFormatConverter.cs
+1 −1 src/Sarif.Driver/ArgumentSplitter.cs
+17 −8 src/Sarif.Driver/DriverExtensionMethods.cs
+0 −8 src/Sarif.Driver/Sdk/AggregatingLogger.cs
+20 −13 src/Sarif.Driver/Sdk/AnalyzeCommandBase.cs
+17 −8 src/Sarif.Driver/Sdk/AnalyzeOptionsBase.cs
+3 −3 src/Sarif.Driver/Sdk/ExportConfigurationCommandBase.cs
+8 −0 src/Sarif.Driver/Sdk/ExportConfigurationOptions.cs
+2 −2 src/Sarif.Driver/Sdk/ExportRulesMetadataCommandBase.cs
+8 −0 src/Sarif.Driver/Sdk/ExportRulesMetadataOptions.cs
+15 −11 src/Sarif.Driver/Sdk/MultithreadedAnalyzeCommandBase.cs
+0 −18 src/Sarif.Driver/Sdk/PlugInDriverCommand.cs
+34 −0 src/Sarif.Driver/Sdk/PluginDriverCommand.cs
+4 −4 src/Sarif.Multitool.Library/ConvertCommand.cs
+1 −1 src/Sarif.Multitool.Library/ExportValidationConfigurationCommand.cs
+1 −1 src/Sarif.Multitool.Library/ExportValidationRulesMetadataCommand.cs
+1 −1 src/Sarif.Multitool.Library/MergeCommand.cs
+31 −0 src/Sarif.Multitool.Library/Rules/GH1005.LocationsMustBeRelativeUrisOrFilePaths.cs
+1 −1 src/Sarif.Multitool.Library/Rules/SARIF1012.MessageArgumentsMustBeConsistentWithRule.cs
+1 −1 src/Sarif.Multitool.Library/Rules/SarifValidationSkimmerBase.cs
+1 −1 src/Sarif.Multitool.Library/ValidateCommand.cs
+2 −2 src/Sarif.Multitool/AnalyzeTestCommand.cs
+1 −1 src/Sarif/Baseline/ResultMatching/HeuristicMatchers/IResultMatchingComparer.cs
+1 −1 src/Sarif/Baseline/ResultMatching/SarifLogResultMatcher.cs
+1 −1 src/Sarif/Baseline/SarifLogBaseliner.cs
+1 −1 src/Sarif/Core/Notification.cs
+1 −1 src/Sarif/Core/Result.cs
+7 −7 src/Sarif/Core/StackFrame.cs
+1 −1 src/Sarif/Core/WebRequest.cs
+3 −3 src/Sarif/Errors.cs
+1 −0 src/Sarif/FileRegionsCache.cs
+2 −2 src/Sarif/HashUtilities.cs
+1 −8 src/Sarif/IAnalysisLogger.cs
+1 −1 src/Sarif/Map/JsonMapSettings.cs
+1 −1 src/Sarif/Processors/Generic/GenericActionPipeline.cs
+2 −2 src/Sarif/Query/ExpressionParser.cs
+2 −2 src/Sarif/Query/Expressions.cs
+1 −1 src/Sarif/Visitors/FilteringVisitor.cs
+1 −3 src/Sarif/Visitors/InsertOptionalDataVisitor.cs
+2 −0 src/Sarif/Visitors/SarifCurrentToVersionOneVisitor.cs
+71 −0 src/Sarif/Writers/BaseLogger.cs
+13 −34 src/Sarif/Writers/CacheByFileHashLogger.cs
+15 −5 src/Sarif/Writers/CachingLogger.cs
+39 −96 src/Sarif/Writers/ConsoleLogger.cs
+2 −5 src/Sarif/Writers/LogFilePersistenceOptions.cs
+1 −2 src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs
+34 −103 src/Sarif/Writers/SarifLogger.cs
+9 −4 src/Sarif/Writers/SarifOneZeroZeroLogger.cs
+2 −1 src/Test.FunctionalTests.Sarif/Multitool/ValidateCommandTests.cs
+1 −1 src/Test.FunctionalTests.Sarif/SarifConverterTests.cs
+30 −2 .../Multitool/ValidateCommand/ExpectedOutputs/SARIF1012.MessageArgumentsMustBeConsistentWithRule_Invalid.sarif
+32 −0 ...s.Sarif/TestData/Multitool/ValidateCommand/Inputs/GH1005.LocationsMustBeRelativeUrisOrFilePaths_Valid.sarif
+7 −0 .../TestData/Multitool/ValidateCommand/Inputs/SARIF1012.MessageArgumentsMustBeConsistentWithRule_Invalid.sarif
+12 −12 src/Test.UnitTests.Sarif.Converters/ToolFormatConverterTests.cs
+37 −11 src/Test.UnitTests.Sarif.Driver/DriverExtensionMethodsTests.cs
+1 −1 src/Test.UnitTests.Sarif.Driver/ITestAnalyzeCommand.cs
+15 −18 src/Test.UnitTests.Sarif.Driver/Sdk/AnalyzeCommandBaseTests.cs
+1 −1 src/Test.UnitTests.Sarif.Driver/Sdk/ExportConfigurationCommandBaseTests.cs
+5 −2 src/Test.UnitTests.Sarif.Driver/Sdk/SarifLoggerTests.cs
+1 −1 src/Test.UnitTests.Sarif.Driver/TestAnalyzeCommand.cs
+1 −1 src/Test.UnitTests.Sarif.Driver/TestExportConfigurationCommand.cs
+1 −1 src/Test.UnitTests.Sarif.Driver/TestMultithreadedAnalyzeCommand.cs
+10 −3 src/Test.UnitTests.Sarif.Multitool.Library/ValidateCommandTests.cs
+18 −0 src/Test.UnitTests.Sarif/Writers/BaseLoggerTestConcrete.cs
+37 −0 src/Test.UnitTests.Sarif/Writers/BaseLoggerTests.cs
+6 −2 src/Test.UnitTests.Sarif/Writers/CachingLoggerTests.cs
+5 −1 src/Test.UnitTests.Sarif/Writers/ConsoleLoggerTests.cs
+166 −84 src/Test.UnitTests.Sarif/Writers/SarifLoggerTests.cs
+8 −0 src/Test.Utilities.Sarif/TestAnalyzeOptions.cs
+0 −6 src/Test.Utilities.Sarif/TestMessageLogger.cs
+11 −2 src/build.props

0 comments on commit 6e10dea

Please sign in to comment.