diff --git a/src/BinSkim.Driver/AnalyzeCommand.cs b/src/BinSkim.Driver/AnalyzeCommand.cs index 4dc0162b2..adb7e6644 100644 --- a/src/BinSkim.Driver/AnalyzeCommand.cs +++ b/src/BinSkim.Driver/AnalyzeCommand.cs @@ -153,7 +153,7 @@ private AnalysisSummary ExtractAnalysisSummary(SarifLog sarifLog, AnalyzeOptions NormalizedPath = string.Join(";", options.TargetFileSpecifiers.Select(p => System.IO.Path.GetDirectoryName(p)).Distinct()), SymbolPath = options.SymbolsPath, FileAnalyzed = artifacts.Count, - // FileNotAnalyzed = + // FileNotAnalyzed = StartTimeUtc = invocation.StartTimeUtc, EndTimeUtc = invocation.EndTimeUtc, TimeConsumed = invocation.EndTimeUtc - invocation.StartTimeUtc, diff --git a/src/BinSkim.Rules/PERules/BA2024.EnableSpectreMitigations.cs b/src/BinSkim.Rules/PERules/BA2024.EnableSpectreMitigations.cs index b90aa8170..dab96fc4c 100644 --- a/src/BinSkim.Rules/PERules/BA2024.EnableSpectreMitigations.cs +++ b/src/BinSkim.Rules/PERules/BA2024.EnableSpectreMitigations.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; @@ -85,7 +86,7 @@ public IEnumerable GetOptions() // Internal so that we can reset this during testing. In practice this should never get reset, but we use several different configs during unit tests. // Please do not access this field outside of this class and unit tests. - internal static Dictionary compilerData = null; + internal static ConcurrentDictionary compilerData = null; public override AnalysisApplicability CanAnalyzePE(PEBinary target, PropertiesDictionary policy, out string reasonForNotAnalyzing) { @@ -367,7 +368,7 @@ public override void AnalyzePortableExecutableAndPdb(BinaryAnalyzerContext conte internal static Version GetClosestCompilerVersionWithSpectreMitigations(BinaryAnalyzerContext context, ExtendedMachine machine, Version omVersion) { - Dictionary compilerMitigationData = LoadCompilerDataFromConfig(context.Policy); + ConcurrentDictionary compilerMitigationData = LoadCompilerDataFromConfig(context.Policy); MachineFamily machineFamily = machine.GetMachineFamily(); if (!compilerMitigationData.ContainsKey(machineFamily)) @@ -409,7 +410,7 @@ internal static Version GetClosestCompilerVersionWithSpectreMitigations(BinaryAn /// internal static CompilerMitigations GetAvailableMitigations(BinaryAnalyzerContext context, ExtendedMachine machine, Version omVersion) { - Dictionary compilerMitigationData = LoadCompilerDataFromConfig(context.Policy); + ConcurrentDictionary compilerMitigationData = LoadCompilerDataFromConfig(context.Policy); MachineFamily machineFamily = machine.GetMachineFamily(); if (!compilerMitigationData.ContainsKey(machineFamily)) @@ -545,16 +546,16 @@ A servicing update to Visual Studio 2015 Update 3 return compilersData; } - internal static Dictionary LoadCompilerDataFromConfig(PropertiesDictionary policy) + internal static ConcurrentDictionary LoadCompilerDataFromConfig(PropertiesDictionary policy) { if (compilerData == null) { - compilerData = new Dictionary(); + compilerData = new ConcurrentDictionary(); PropertiesDictionary configData = policy.GetProperty(MitigatedCompilers); foreach (string key in configData.Keys) { var machine = (MachineFamily)Enum.Parse(typeof(MachineFamily), key); // Neaten this up. - compilerData.Add(machine, CreateSortedVersionDictionary((PropertiesDictionary)configData[key])); + compilerData.TryAdd(machine, CreateSortedVersionDictionary((PropertiesDictionary)configData[key])); } } return compilerData; diff --git a/src/Test.UnitTests.BinSkim.Rules/EnableSpectreMitigationsTests.cs b/src/Test.UnitTests.BinSkim.Rules/EnableSpectreMitigationsTests.cs index c3034ac8b..1c9d06dd1 100644 --- a/src/Test.UnitTests.BinSkim.Rules/EnableSpectreMitigationsTests.cs +++ b/src/Test.UnitTests.BinSkim.Rules/EnableSpectreMitigationsTests.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using System.Collections.Concurrent; using System.Collections.Generic; using FluentAssertions; @@ -32,7 +33,7 @@ public void LoadCompilerDataFromConfig_ParsesAndCachesAsExpected() this.AddFakeConfigTestData(context.Policy); - Dictionary result = EnableSpectreMitigations.LoadCompilerDataFromConfig(context.Policy); + ConcurrentDictionary result = EnableSpectreMitigations.LoadCompilerDataFromConfig(context.Policy); this.ValidateResultFromFakeTestData(result[MachineFamily.X86]); result.Should().ContainKeys(new MachineFamily[] { MachineFamily.X86, MachineFamily.Arm }); diff --git a/src/sarif-sdk b/src/sarif-sdk index d31bc912f..ca1c2c972 160000 --- a/src/sarif-sdk +++ b/src/sarif-sdk @@ -1 +1 @@ -Subproject commit d31bc912f8b7ea47c3d37b967bb2557fd3b7dd7e +Subproject commit ca1c2c972449ee5bf43f821fe86f67a4112e515f