-
Notifications
You must be signed in to change notification settings - Fork 92
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
API/other improvements for improved in-memory analysis. #2639
Conversation
@@ -15,8 +15,18 @@ | |||
|
|||
namespace Microsoft.CodeAnalysis.Sarif | |||
{ | |||
public static class ExtensionMethods | |||
public static class SarifExtensions |
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.
@@ -101,11 +100,6 @@ public class SarifLogger : BaseLogger, IDisposable, IAnalysisLogger | |||
RuleToIndexMap = new Dictionary<ReportingDescriptor, int>(ReportingDescriptor.ValueComparer); | |||
ExtensionGuidToIndexMap = new Dictionary<Guid, int>(); | |||
|
|||
if (dataToInsert.HasFlag(OptionallyEmittedData.Hashes)) |
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.
I'm deleting this aggressive hashing of targets data on initialization for now. First, we previously had at least three mechanisms for hashing, this one, the hash delegate and on-demand hashing via the insert data visitor. This particular mechanism always held all this data in memory, as opposed to the file regions cache mechanism, which only holds that previous 100 files hashed...
@@ -144,7 +139,8 @@ public class SarifLogger : BaseLogger, IDisposable, IAnalysisLogger | |||
} | |||
|
|||
} | |||
else if (_run.Tool.Driver?.Rules != null) | |||
|
|||
if (_run.Tool.Driver?.Rules != null) |
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.
sb.AppendLine($"\t{trace} : did not observe term 'elapsed' in rule timing notifications."); | ||
} | ||
// We expected timing data for every rule. | ||
if (executionNotifications.Count != expectedNotificationsCount) |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null
|
||
public virtual FileFormat ConfigurationFormat => FileFormat.Json; | ||
|
||
protected MultithreadedAnalyzeCommandBase(IFileSystem fileSystem = null) | ||
{ | ||
// TBD can we zap this? | ||
Tool ??= Tool.CreateFromAssemblyData(); |
Check warning
Code scanning / CodeQL
Virtual call in constructor or destructor
} | ||
} | ||
catch (IOException) { } | ||
catch (SecurityException) { } |
Check notice
Code scanning / CodeQL
Poor error handling: empty catch block
} | ||
} | ||
catch (IOException) { } | ||
catch (SecurityException) { } | ||
catch (UnauthorizedAccessException) { } |
Check notice
Code scanning / CodeQL
Poor error handling: empty catch block
@@ -197,12 +192,13 @@ | |||
|
|||
foreach (string target in analysisTargets) | |||
{ | |||
Uri uri = new Uri(UriHelper.MakeValidUri(target), UriKind.RelativeOrAbsolute); | |||
string uriText = UriHelper.MakeValidUri(target); |
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.
@@ -262,10 +258,6 @@ | |||
_run.Invocations.Add(invocation); | |||
} | |||
|
|||
public Func<Uri, HashData> ComputeHashData { get; set; } |
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.
HelpText = "A semicolon delimited list to filter output of scan results to one or more failure levels. Valid values: Error, Warning and Note.")] | ||
public IEnumerable<FailureLevel> Level { get; set; } | ||
|
||
private FailureLevelSet failureLevels; |
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.
Providing defaults in the options classes is problematic because it interferes with the context object default value functionality (which is much richer/close to the analysis model.). In the options classes, we should actually return null for all cases where the property isn't explicit on the command-line, otherwise reflect the command-line precisely. That's the model. There's more clean-up to do.
src/Sarif.Driver/Sdk/CommandBase.cs
Outdated
{ | ||
normalizedSpecifier = uri.LocalPath; | ||
} | ||
normalizedSpecifier = uri.GetFileName(); |
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.
@@ -38,13 +38,13 @@ | |||
|
|||
public static bool RaiseUnhandledExceptionInDriverCode { get; set; } | |||
|
|||
protected virtual Tool Tool { get; set; } | |||
public virtual Tool Tool { get; set; } |
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.
@@ -236,24 +236,27 @@ | |||
context.OutputFilePath = options.OutputFilePath; | |||
context.AutomationGuid = options.AutomationGuid; | |||
context.BaselineFilePath = options.BaselineFilePath; | |||
context.Traces = InitializeStringSet(options.Trace); | |||
context.Traces = options.Trace != null ? InitializeStringSet(options.Trace) : context.Traces; |
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.
@@ -511,7 +511,7 @@ public void SarifLogger_ScrapesFilesFromResult() | |||
{ | |||
using (var sarifLogger = new SarifLogger(textWriter, | |||
analysisTargets: null, | |||
dataToInsert: OptionallyEmittedData.Hashes, | |||
dataToInsert: OptionallyEmittedData.None, |
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.
|
||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.Sarif.Driver |
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.
Turns out that test code doesn't use this delegate action injection mechanism highly, so I just ripped it out.
Moving forward we should be updating tests to use the new improved analysis model (which is designed to allow solid testing using the core analyze command mechanism, just as the actual client tool does). So this sort of testing model should wither away, rather than being built on.
…if-sdk into in-memory-analysis
No description provided.