-
Notifications
You must be signed in to change notification settings - Fork 160
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
Changes from 2 commits
abe95b5
40af07d
19f3bb4
4881ebd
bd3cb63
579c8db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
// 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.Diagnostics; | ||
|
||
using Microsoft.CodeAnalysis.BinaryParsers; | ||
|
@@ -26,6 +28,8 @@ public abstract class WindowsBinaryAndPdbSkimmerBase : WindowsBinarySkimmerBase | |
|
||
public virtual bool LogPdbLoadException => true; | ||
|
||
public static readonly ConcurrentDictionary<string, bool> s_PdbExceptions = new ConcurrentDictionary<string, bool>(); | ||
|
||
public sealed override void Analyze(BinaryAnalyzerContext context) | ||
{ | ||
// Uses PDB Parsing. | ||
|
@@ -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(); | ||
string key = $"{fileName}@{pdbException.ExceptionDisplayMessage}"; | ||
if (s_PdbExceptions.ContainsKey(key)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ | ||
return; | ||
} | ||
|
||
// '{0}' was not evaluated because its PDB could not be loaded ({1}). | ||
context.Logger.LogConfigurationNotification( | ||
Errors.CreateNotification( | ||
context.TargetUri, | ||
"ERR997.ExceptionLoadingPdb", | ||
context.Rule.Id, | ||
string.Empty, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
FailureLevel.Error, | ||
pdbException, | ||
persistExceptionStack: false, | ||
RuleResources.ERR997_ExceptionLoadingPdb, | ||
context.TargetUri.GetFileName(), | ||
context.Rule.Name, | ||
RuleResources.ERR997_ExceptionLoadingPdbGeneric, | ||
fileName, | ||
pdbException.ExceptionDisplayMessage)); | ||
|
||
s_PdbExceptions.TryAdd(key, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
context.RuntimeErrors |= RuntimeConditions.ExceptionLoadingPdb; | ||
|
||
if (!string.IsNullOrEmpty(pdbException.LoadTrace)) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes! thanks for reviewing! |
||
<value>'{0}' was not evaluated because its PDB could not be loaded ({1}).</value> | ||
</data> | ||
</root> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key sould also consider path?
/x86/a.exe
/x64/a.exe #Closed
There was a problem hiding this comment.
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!