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

Throwing once per file #465

Merged
merged 6 commits into from
Aug 24, 2021
Merged

Throwing once per file #465

merged 6 commits into from
Aug 24, 2021

Conversation

eddynaka
Copy link
Contributor

@eddynaka eddynaka commented Aug 23, 2021

Fixes #304

Previous:

Analyzing...
Analyzing 'Native_x64_VS2013_Default.dll'...
Native_x64_VS2013_Default.dll : error ERR997.ExceptionLoadingPdb : BA2002 : 'Native_x64_VS2013_Default.dll' was not evaluated for check 'DoNotIncorporateVulnerableDependencies' because its PDB could not be loaded (E_PDB_NOT_FOUND).
Native_x64_VS2013_Default.dll : error ERR997.ExceptionLoadingPdb : BA2004 : 'Native_x64_VS2013_Default.dll' was not evaluated for check 'EnableSecureSourceCodeHashing' because its PDB could not be loaded (E_PDB_NOT_FOUND).
Native_x64_VS2013_Default.dll : error ERR997.ExceptionLoadingPdb : BA2006 : 'Native_x64_VS2013_Default.dll' was not evaluated for check 'BuildWithSecureTools' because its PDB could not be loaded (E_PDB_NOT_FOUND).
Native_x64_VS2013_Default.dll : error ERR997.ExceptionLoadingPdb : BA2007 : 'Native_x64_VS2013_Default.dll' was not evaluated for check 'EnableCriticalCompilerWarnings' because its PDB could not be loaded (E_PDB_NOT_FOUND).
Native_x64_VS2013_Default.dll : error ERR997.ExceptionLoadingPdb : BA2011 : 'Native_x64_VS2013_Default.dll' was not evaluated for check 'EnableStackProtection' because its PDB could not be loaded (E_PDB_NOT_FOUND).
Native_x64_VS2013_Default.dll : error ERR997.ExceptionLoadingPdb : BA2013 : 'Native_x64_VS2013_Default.dll' was not evaluated for check 'InitializeStackProtection' because its PDB could not be loaded (E_PDB_NOT_FOUND).
Native_x64_VS2013_Default.dll : error ERR997.ExceptionLoadingPdb : BA2014 : 'Native_x64_VS2013_Default.dll' was not evaluated for check 'DoNotDisableStackProtectionForFunctions' because its PDB could not be loaded (E_PDB_NOT_FOUND).
Native_x64_VS2013_Default.dll : error ERR997.ExceptionLoadingPdb : BA2024 : 'Native_x64_VS2013_Default.dll' was not evaluated for check 'EnableSpectreMitigations' because its PDB could not be loaded (E_PDB_NOT_FOUND).
Native_x64_VS2013_Default.dll : error ERR997.ExceptionLoadingPdb : BA2025 : 'Native_x64_VS2013_Default.dll' was not evaluated for check 'EnableShadowStack' because its PDB could not be loaded (E_PDB_NOT_FOUND).
Native_x64_VS2013_Default.dll : error ERR997.ExceptionLoadingPdb : BA2026 : 'Native_x64_VS2013_Default.dll' was not evaluated for check 'EnableAdditionalSdlSecurityChecks' because its PDB could not be loaded (E_PDB_NOT_FOUND).

One or more rules was disabled for an analysis target, as it was determined not to be applicable to it (this is a common condition). Pass --verbose on the command-line for more information.

Analysis did not complete due to one or more unrecoverable execution conditions.
Unexpected fatal runtime condition(s) observed: ExceptionLoadingPdb

Current:

Analyzing...
Analyzing 'Native_x64_VS2013_Default.dll'...
Native_x64_VS2013_Default.dll : error ERR997.ExceptionLoadingPdb : 'Native_x64_VS2013_Default.dll' was not evaluated because its PDB could not be loaded (E_PDB_NOT_FOUND).

One or more rules was disabled for an analysis target, as it was determined not to be applicable to it (this is a common condition). Pass --verbose on the command-line for more information.

Analysis did not complete due to one or more unrecoverable execution conditions.
Unexpected fatal runtime condition(s) observed: ExceptionLoadingPdb

// '{0}' was not evaluated for check '{1}' because its PDB could not be loaded ({2}).
string fileName = context.TargetUri.GetFileName();
string key = $"{fileName}@{pdbException.ExceptionDisplayMessage}";
if (s_PdbExceptions.ContainsKey(key))
Copy link
Contributor Author

@eddynaka eddynaka Aug 23, 2021

Choose a reason for hiding this comment

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

s_PdbExceptions.ContainsKey(key)

If we already reported this issue for this target, we won't report twice. #ByDesign

context.Logger.LogConfigurationNotification(
Errors.CreateNotification(
context.TargetUri,
"ERR997.ExceptionLoadingPdb",
context.Rule.Id,
string.Empty,
Copy link
Contributor Author

@eddynaka eddynaka Aug 23, 2021

Choose a reason for hiding this comment

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

string.Empty

To be generic, I removed context.Rule.Id and context.Rule.Name. #ByDesign

pdbException.ExceptionDisplayMessage));

s_PdbExceptions.TryAdd(key, true);
Copy link
Contributor Author

@eddynaka eddynaka Aug 23, 2021

Choose a reason for hiding this comment

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

s_PdbExceptions.TryAdd

Once we log the notification, we will add to the caching variable. Since it's static and concurrent, it won't face any issue during analysis #ByDesign

@@ -569,4 +569,7 @@ Modules did not meet the criteria: {1}</value>
<data name="BA5002_Pass" xml:space="preserve">
<value>Executable stack is not allowed on executable '{0}'.</value>
</data>
<data name="ERR997)ExceptionLoadingPdbGeneric" xml:space="preserve">
Copy link
Collaborator

@shaopeng-gh shaopeng-gh Aug 23, 2021

Choose a reason for hiding this comment

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

)

typo? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes! thanks for reviewing!

@@ -130,20 +134,27 @@ public static void LogExceptionLoadingPdb(IAnalysisContext context, PdbException
throw new ArgumentNullException(nameof(context));
}

// '{0}' was not evaluated for check '{1}' because its PDB could not be loaded ({2}).
string fileName = context.TargetUri.GetFileName();
Copy link
Collaborator

@shaopeng-gh shaopeng-gh Aug 23, 2021

Choose a reason for hiding this comment

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

fileName

key sould also consider path?
/x86/a.exe
/x64/a.exe #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to OriginalString as path. That will prevent issues like you showed.

thanks!

@eddynaka eddynaka merged commit b7c72ec into main Aug 24, 2021
@eddynaka eddynaka deleted the users/ednakamu/throwing-once-per-pdb branch August 24, 2021 13:35
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.

Add an explicit error that is fired once per file for missing PDBs
2 participants