mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
C#: Change extractor to accept multiple binlog files
This commit is contained in:
@@ -106,10 +106,10 @@ namespace Semmle.Extraction.CSharp
|
||||
var canonicalPathCache = CanonicalPathCache.Create(logger, 1000);
|
||||
var pathTransformer = new PathTransformer(canonicalPathCache);
|
||||
|
||||
if (options.BinaryLogPath is string binlogPath)
|
||||
if (options.BinaryLogPaths is string[] binlogPaths)
|
||||
{
|
||||
logger.LogInfo(" Running binary log analysis.");
|
||||
return RunBinaryLogAnalysis(analyzerStopwatch, options, binlogPath, logger, canonicalPathCache, pathTransformer);
|
||||
return RunBinaryLogAnalysis(analyzerStopwatch, options, binlogPaths, logger, canonicalPathCache, pathTransformer);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -124,6 +124,25 @@ namespace Semmle.Extraction.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
private static ExitCode RunBinaryLogAnalysis(Stopwatch stopwatch, Options options, string[] binlogPaths, ILogger logger, CanonicalPathCache canonicalPathCache, PathTransformer pathTransformer)
|
||||
{
|
||||
var allFailed = true;
|
||||
foreach (var binlogPath in binlogPaths)
|
||||
{
|
||||
var exit = RunBinaryLogAnalysis(stopwatch, options, binlogPath, logger, canonicalPathCache, pathTransformer);
|
||||
switch (exit)
|
||||
{
|
||||
case ExitCode.Ok:
|
||||
case ExitCode.Errors:
|
||||
allFailed &= false;
|
||||
break;
|
||||
case ExitCode.Failed:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return allFailed ? ExitCode.Failed : ExitCode.Ok;
|
||||
}
|
||||
|
||||
private static ExitCode RunBinaryLogAnalysis(Stopwatch stopwatch, Options options, string binlogPath, ILogger logger, CanonicalPathCache canonicalPathCache, PathTransformer pathTransformer)
|
||||
{
|
||||
logger.LogInfo($"Reading compiler calls from binary log {binlogPath}");
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace Semmle.Extraction.CSharp
|
||||
public bool AssemblySensitiveTrap { get; private set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// The path to the binary log file, or null if unspecified.
|
||||
/// The paths to the binary log files, or null if unspecified.
|
||||
/// </summary>
|
||||
public string? BinaryLogPath { get; set; }
|
||||
public string[]? BinaryLogPaths { get; set; }
|
||||
|
||||
public static Options CreateWithEnvironment(string[] arguments)
|
||||
{
|
||||
@@ -71,7 +71,7 @@ namespace Semmle.Extraction.CSharp
|
||||
ProjectsToLoad.Add(value);
|
||||
return true;
|
||||
case "binlog":
|
||||
BinaryLogPath = value;
|
||||
BinaryLogPaths = value.Split(FileUtils.NewLineCharacters, StringSplitOptions.RemoveEmptyEntries);
|
||||
return true;
|
||||
default:
|
||||
return base.HandleOption(key, value);
|
||||
|
||||
Reference in New Issue
Block a user