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

Conversation

shaopeng-gh
Copy link
Collaborator

@shaopeng-gh shaopeng-gh commented Dec 16, 2021

Description:

reported issue with
error BA2006: '...' was compiled with one or more modules which were not built using minimum required tool versions
this error happens in new version 1.9.0
tested it passes in old version 1.7.2

Fix:

related to changeset #344
location: file BA2006.BuildWithSecureTools.cs line 104

we should add a skip if the compiler is not the ones we currently support those we can check min version.
After we widen the support we should remove this skip.

{
// TODO: 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

@@ -772,13 +772,10 @@
"rules": [
{
"id": "BA2001",
"name": "LoadImageAboveFourGigabyteAddress",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"name": "LoadImageAboveFourGigabyteAddress",

all json node ordering change are not caused by this change, we did not run the baseline for sometime,
running re-baseline from current main will also get this change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks for the feedback, working on

  1. update SDK to have those re-ordering reverted.
  2. review
  3. change only one ordering so that name is right after id.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have created a fix in SDK
microsoft/sarif-sdk#2420 (please review together)
and then point binskim to that branch and run re-baseline to verify the fix.
Now this PR is clearer to review.

After all looks good to you, we should get the desired ordering from you and I will update both PR with that order.(you mentioned one name field)

@shaopeng-gh
Copy link
Collaborator Author

shaopeng-gh commented Dec 17, 2021

      "kind": "pass",

skip those re-ordering changes,
this is a real change for this pr,

clang version 13 is latest version should be supported, after this fix now it will not compare {13.0.0.0} to VS Version(17, 0, 65501, 17013) and report it.
(skipped if not MS compiler)


In reply to: 996301745


In reply to: 996301745


Refers to: src/Test.FunctionalTests.BinSkim.Driver/BaselineTestsData/Expected/clangcl.pe.cpp.codeview.exe.sarif:431 in d845a11. [](commit_id = d845a11, deletion_comment = False)

if (omDetails.WellKnownCompiler != WellKnownCompilers.MicrosoftC
&& omDetails.WellKnownCompiler != WellKnownCompilers.MicrosoftCxx)
{
// TODO: https://github.com/Microsoft/binskim/issues/114
Copy link
Member

@michaelcfanning michaelcfanning Jan 6, 2022

Choose a reason for hiding this comment

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

TODO

TODO: MikeFan (1/6/2022)
We need to take a step back and comprehensively review our compiler/language support.
#114 #Resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@michaelcfanning
Copy link
Member

michaelcfanning commented Jan 6, 2022

                //case Language.MASM:

Comment this whole block, using C

/*
repeat your TODO information here.

case Language.MASM

*/


In reply to: 1006978150


In reply to: 1006978150


In reply to: 1006978150


In reply to: 1006978150


Refers to: src/BinSkim.Rules/PERules/BA2006.BuildWithSecureTools.cs:142 in af6ff95. [](commit_id = af6ff95, deletion_comment = False)

@@ -50,6 +50,7 @@
}
}
],
"automationDetails": {},
Copy link
Member

@michaelcfanning michaelcfanning Jan 6, 2022

Choose a reason for hiding this comment

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

This is valid SARIF, automationDetails has no required members, but it's inefficient, we don't need to serialize an empty object. In general, we don't want our log file persistence to change version-over-version. #Resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed together in the SDK PR, link in the other comment with json node ordering.

@shaopeng-gh
Copy link
Collaborator Author

                //case Language.MASM:

fixed


In reply to: 1006978150


Refers to: src/BinSkim.Rules/PERules/BA2006.BuildWithSecureTools.cs:142 in af6ff95. [](commit_id = af6ff95, deletion_comment = False)

@marmegh
Copy link
Contributor

marmegh commented Jan 8, 2022

Is there supposed to be a sarif file for the clangcl.pe.c.codeview.exe in the expected folder?

@shaopeng-gh
Copy link
Collaborator Author

good question, I think this was the similar thing that confused Michael in the review :)
I added test files in the Functional tests folder, and there is a "modified" file in the expected folder.
Because if add new test file in the Baseline folder we are expecting "new" file not "modified" file.

the cpp one was already in the baseline, I added it also to the Functional folder because I think it benefit that if future regression we might see a very clear test failure with the rule id.
I also draft an additional exe for c to cover c.

related info:
1.if you put exe in the Baseline folder and run .\UpdateBaselines.ps1 it will update the .sarif file in the expected folder.
2. for exe in Functional folder it is used for loop all files and check if pass or fail depend on the folder name it is put in. No .sarif file need to be generated.


In reply to: 1007837347

@@ -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?

@@ -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)
Copy link
Contributor

@eddynaka eddynaka Jan 8, 2022

Choose a reason for hiding this comment

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

should this be:

omDetails.WellKnownCompiler != WellKnownCompilers.MicrosoftC &&
omDetails.WellKnownCompiler != WellKnownCompilers.MicrosoftCxx
``` #Resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@eddynaka
Copy link
Contributor

eddynaka commented Jan 8, 2022

Just remembering that we must review the sarif-sdk change before reviewing this. Because we cannot merge this without merging the other.


In reply to: 1007848170

@eddynaka
Copy link
Contributor

Re-open the PR and point the submodule to main.
it won't have any change in the testing since u were already pointing to ur branch


In reply to: 1007979314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants