Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Error BA2006: '...' was compiled with one or more modules which were not built using minimum required tool versions #533

Closed
wants to merge 8 commits into from
Closed
59 changes: 39 additions & 20 deletions src/BinSkim.Rules/PERules/BA2006.BuildWithSecureTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Copy link
Collaborator Author

@shaopeng-gh shaopeng-gh Dec 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In changeset
#344
We have this check and skip in BA2011, I think we should have it for BA2006 as well.

BA2006 had this and were removed:
if (omDetails.WellKnownCompiler != WellKnownCompilers.MicrosoftNativeCompiler)
{
continue;
}

The reason is currently the only know compiler in the enum WellKnownCompilers are Microsoft compilers, and the version to compare are only Microsoft VS versions. We should remove this check after we also have the codes and determined min versions for all other compilers.

#Resolved


switch (omDetails.Language)
{
case Language.LINK:
Expand All @@ -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:
{
Expand Down
1 change: 1 addition & 0 deletions src/ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

* BUGFIX: Fix Error BA2006: '...' was compiled with one or more modules which were not built using minimum required tool versions [533](https://github.com/microsoft/binskim/pull/533)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • BUGFIX: Fix Error BA2006: '...' was compiled with one or more modules which were not built using minimum required tool versions

This seems a little too generic. Can we specify which instances this is being fixed for?

* 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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.