Skip to content

Commit

Permalink
Release History
Browse files Browse the repository at this point in the history
  • Loading branch information
shaopeng-gh committed Dec 1, 2023
1 parent c2d17d3 commit 2effd96
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- NEW => new feature

## UNRELEASED
* NEW: Add `--disable-telemetry` argument to disable telemetry collection.

## **v4.2.1**
* FPS: `BA2004.EnableSecureSourceCodeHashing` now will no longer generate false positives on precompiled headers, they are always without hash. [#965](https://github.com/microsoft/binskim/pull/965)
Expand Down
37 changes: 36 additions & 1 deletion src/Test.FunctionalTests.BinSkim.Driver/CommandLineTests.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 System.Linq;
using System.Text;
Expand All @@ -10,7 +11,6 @@
using FluentAssertions;

using Microsoft.CodeAnalysis.IL;
using Microsoft.CodeAnalysis.Sarif.Driver;

using Xunit;

Expand Down Expand Up @@ -70,5 +70,40 @@ public void MostlyFunctionlessCommandlineTest()
builder.Length.Should().Be(0,
$"all test cases should pass, but the following test cases failed:\n{builder}");
}

[Fact]
public void DisableTelemetryCommandlineTest()
{
var testCases = new List<Tuple<string, bool?>>()
{
new Tuple<string, bool?>(@"analyze C:\Native.exe -o C:\result.sarif", null),
new Tuple<string, bool?>(@"analyze C:\Native.exe -o C:\result.sarif --disable-telemetry true", true),
new Tuple<string, bool?>(@"analyze C:\Native.exe -o C:\result.sarif --disable-telemetry false", false)
};

var builder = new StringBuilder();

foreach (Tuple<string, bool?> testCase in testCases)
{
string[] args = testCase.Item1.Split(' ');
bool parser = new Parser(cfg => cfg.CaseInsensitiveEnumValues = true).ParseArguments<AnalyzeOptions>(args)
.MapResult(
options =>
{
if (options.DisableTelemetry != testCase.Item2)
{
builder.AppendLine($"\u2022 {testCase.Item1}");
}
return true;
},
err =>
{
builder.AppendLine($"\u2022 {testCase.Item1}");
return true;
});
}
builder.Length.Should().Be(0,
$"all test cases should pass, but the following test cases failed:\n{builder}");
}
}
}

0 comments on commit 2effd96

Please sign in to comment.