-
Notifications
You must be signed in to change notification settings - Fork 94
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
Fixing AnalyzeCommandBase
and MultithreadedAnalyzeCommandBase
artifacts generation
#2433
Changes from all commits
2247cbe
6972472
5d87498
af33d03
3869b86
70dffb5
171133f
d322ee4
e800ead
fd9bd16
6996260
8a78dd8
44eb8d2
cabbd5f
a3408b3
dbaae40
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 |
---|---|---|
|
@@ -169,7 +169,7 @@ private void Analyze(TOptions options, AggregatingLogger logger) | |
targets = ValidateTargetsExist(_rootContext, targets); | ||
|
||
// 5. Initialize report file, if configured. | ||
InitializeOutputFile(options, _rootContext, targets); | ||
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. This API isn't exposed to customers. Only tools that use it will see a difference. |
||
InitializeOutputFile(options, _rootContext); | ||
|
||
// 6. Instantiate skimmers. | ||
ISet<Skimmer<TContext>> skimmers = CreateSkimmers(options, _rootContext); | ||
|
@@ -294,6 +294,7 @@ protected virtual TContext CreateContext( | |
else | ||
{ | ||
context.Hashes = HashUtilities.ComputeHashes(filePath); | ||
_pathToHashDataMap?.Add(filePath, context.Hashes); | ||
} | ||
} | ||
} | ||
|
@@ -352,7 +353,7 @@ protected virtual void InitializeConfiguration(TOptions options, TContext contex | |
} | ||
} | ||
|
||
private void InitializeOutputFile(TOptions analyzeOptions, TContext context, ISet<string> targets) | ||
private void InitializeOutputFile(TOptions analyzeOptions, TContext context) | ||
{ | ||
string filePath = analyzeOptions.OutputFilePath; | ||
AggregatingLogger aggregatingLogger = (AggregatingLogger)context.Logger; | ||
|
@@ -388,7 +389,7 @@ private void InitializeOutputFile(TOptions analyzeOptions, TContext context, ISe | |
dataToRemove, | ||
tool: _tool, | ||
run: _run, | ||
analysisTargets: targets, | ||
analysisTargets: null, | ||
quiet: analyzeOptions.Quiet, | ||
invocationTokensToRedact: GenerateSensitiveTokensList(), | ||
invocationPropertiesToLog: analyzeOptions.InvocationPropertiesToLog, | ||
|
@@ -404,7 +405,7 @@ private void InitializeOutputFile(TOptions analyzeOptions, TContext context, ISe | |
dataToRemove, | ||
tool: _tool, | ||
run: _run, | ||
analysisTargets: targets, | ||
analysisTargets: null, | ||
invocationTokensToRedact: GenerateSensitiveTokensList(), | ||
invocationPropertiesToLog: analyzeOptions.InvocationPropertiesToLog, | ||
levels: analyzeOptions.Level, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ public abstract class MultithreadedAnalyzeCommandBase<TContext, TOptions> : Plug | |
private Channel<int> _resultsWritingChannel; | ||
private Channel<int> _fileEnumerationChannel; | ||
private Dictionary<string, List<string>> _hashToFilesMap; | ||
private IDictionary<string, HashData> _pathToHashDataMap; | ||
private ConcurrentDictionary<int, TContext> _fileContexts; | ||
|
||
public Exception ExecutionException { get; set; } | ||
|
@@ -485,12 +486,9 @@ private async Task<bool> HashAsync() | |
_hashToFilesMap[hashData.Sha256] = paths; | ||
} | ||
|
||
_run?.GetFileIndex(new ArtifactLocation { Uri = context.TargetUri }, | ||
dataToInsert: _dataToInsert, | ||
hashData: hashData); | ||
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. removing this to prevent us from generating artifacts for all the files #ByDesign |
||
|
||
paths.Add(localPath); | ||
context.Hashes = hashData; | ||
_pathToHashDataMap?.Add(localPath, hashData); | ||
} | ||
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. Updating this will enable us to use the code from SarifLogger to create the artifacts #ByDesign |
||
|
||
await _fileEnumerationChannel.Writer.WriteAsync(index); | ||
|
@@ -705,6 +703,7 @@ private void InitializeOutputFile(TOptions analyzeOptions, TContext context) | |
kinds: analyzeOptions.Kind, | ||
insertProperties: analyzeOptions.InsertProperties); | ||
} | ||
_pathToHashDataMap = sarifLogger.AnalysisTargetToHashDataMap; | ||
sarifLogger.AnalysisStarted(); | ||
aggregatingLogger.Loggers.Add(sarifLogger); | ||
}, | ||
|
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.
we won't initialize the outputfile with targets because we don't want to emit all targets in the artifacts.