diff --git a/src/BinSkim.Rules/PERules/BA2006.BuildWithSecureTools.cs b/src/BinSkim.Rules/PERules/BA2006.BuildWithSecureTools.cs index e4d7a3073..098e149a1 100644 --- a/src/BinSkim.Rules/PERules/BA2006.BuildWithSecureTools.cs +++ b/src/BinSkim.Rules/PERules/BA2006.BuildWithSecureTools.cs @@ -116,6 +116,15 @@ public override void AnalyzePortableExecutableAndPdb(BinaryAnalyzerContext conte Symbol om = omView.Value; ObjectModuleDetails omDetails = om.GetObjectModuleDetails(); + if (omDetails.WellKnownCompiler != WellKnownCompilers.MicrosoftC && + omDetails.WellKnownCompiler != WellKnownCompilers.MicrosoftCxx) + { + // TODO: MikeFan (1/6/2022) + // We need to take a step back and comprehensively review our compiler/language support. + // https://github.com/Microsoft/binskim/issues/114 + continue; + } + switch (omDetails.Language) { case Language.LINK: @@ -132,33 +141,43 @@ public override void AnalyzePortableExecutableAndPdb(BinaryAnalyzerContext conte break; } - //case Language.MASM: - //{ - // minCompilerVersion = - // context.Policy.GetProperty(MinimumToolVersions)[nameof(Language.MASM)]; - // break; - //} - - //case Language.CVTRES: - //{ - // minCompilerVersion = - // context.Policy.GetProperty(MinimumToolVersions)[nameof(Language.CVTRES)]; - // break; - //} - - //case Language.CSharp: - //{ - // minCompilerVersion = - // context.Policy.GetProperty(MinimumToolVersions)[nameof(Language.CSharp)]; - // break; - //} + /* + TODO: MikeFan (1/6/2022) + We need to take a step back and comprehensively review our compiler/language support. + https://github.com/Microsoft/binskim/issues/114 + + case Language.MASM: + { + minCompilerVersion = + context.Policy.GetProperty(MinimumToolVersions)[nameof(Language.MASM)]; + break; + } + + case Language.CVTRES: + { + minCompilerVersion = + context.Policy.GetProperty(MinimumToolVersions)[nameof(Language.CVTRES)]; + break; + } + + case Language.CSharp: + { + minCompilerVersion = + context.Policy.GetProperty(MinimumToolVersions)[nameof(Language.CSharp)]; + break; + } + Language data is not always included if it is only compiled with SymTagCompiland without SymTagCompilandDetails + https://docs.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/compilanddetails?view=vs-2022 + Compiland information is split between symbols with a SymTagCompiland tag (low detail) + and a SymTagCompilandDetails tag (high detail). case Language.Unknown: { minCompilerVersion = context.Policy.GetProperty(MinimumToolVersions)[nameof(Language.Unknown)]; break; } + */ default: { diff --git a/src/ReleaseHistory.md b/src/ReleaseHistory.md index 77ed660d5..fde4e9095 100644 --- a/src/ReleaseHistory.md +++ b/src/ReleaseHistory.md @@ -2,6 +2,7 @@ ## Unreleased +* BUGFIX: Fix incorrect analysis for non-Microsoft compiler on BA2006.BuildWithSecureTools [545](https://github.com/microsoft/binskim/pull/545) * BUGFIX: Fix `JsonSerializationException` that occurs when saving SARIF v1 with telemetry enabled. [#535](https://github.com/microsoft/binskim/pull/535) * BUGFIX: Fix `NullReferenceException` when `--Hashes` and telemetry rules are enabled. [#531](https://github.com/microsoft/binskim/pull/531) diff --git a/src/Test.FunctionalTests.BinSkim.Driver/BaselineTestsData/Expected/clangcl.pe.cpp.codeview.exe.sarif b/src/Test.FunctionalTests.BinSkim.Driver/BaselineTestsData/Expected/clangcl.pe.cpp.codeview.exe.sarif index aa7b2be06..de42adec0 100644 --- a/src/Test.FunctionalTests.BinSkim.Driver/BaselineTestsData/Expected/clangcl.pe.cpp.codeview.exe.sarif +++ b/src/Test.FunctionalTests.BinSkim.Driver/BaselineTestsData/Expected/clangcl.pe.cpp.codeview.exe.sarif @@ -428,13 +428,13 @@ { "ruleId": "BA2006", "ruleIndex": 17, - "level": "error", + "kind": "pass", + "level": "none", "message": { - "id": "Error", + "id": "Pass", "arguments": [ "clangcl.pe.cpp.codeview.exe", - "", - "clang version 13.0.0 : cxx : 13000.0.0.0 : [directly linked] (hello-d24821.obj)\r\n" + "Microsoft (R) Optimizing Compiler:C:19.26.28900.8, Microsoft (R) Optimizing Compiler:C:19.29.30034.2, Microsoft (R) Optimizing Compiler:Cxx:19.26.28900.8, Microsoft (R) Optimizing Compiler:Cxx:19.29.30034.2" ] }, "locations": [ diff --git a/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.c.codeview.exe b/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.c.codeview.exe new file mode 100644 index 000000000..5ed9a6721 Binary files /dev/null and b/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.c.codeview.exe differ diff --git a/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.c.codeview.pdb b/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.c.codeview.pdb new file mode 100644 index 000000000..0f2a2fe5e Binary files /dev/null and b/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.c.codeview.pdb differ diff --git a/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.cpp.codeview.exe b/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.cpp.codeview.exe new file mode 100644 index 000000000..83ca050b5 Binary files /dev/null and b/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.cpp.codeview.exe differ diff --git a/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.cpp.codeview.pdb b/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.cpp.codeview.pdb new file mode 100644 index 000000000..f6fe6f42a Binary files /dev/null and b/src/Test.FunctionalTests.BinSkim.Rules/FunctionalTestsData/BA2006.BuildWithSecureTools/Pass/clangcl.pe.cpp.codeview.pdb differ diff --git a/src/sarif-sdk b/src/sarif-sdk index 744f7206b..4959f73eb 160000 --- a/src/sarif-sdk +++ b/src/sarif-sdk @@ -1 +1 @@ -Subproject commit 744f7206b6d51bf3a285ce2cb80d90e7d1b942f2 +Subproject commit 4959f73ebe231caa914931a9f26699a9b3dd4315