mirror of
https://github.com/github/codeql.git
synced 2026-05-04 13:15:21 +02:00
C#: Introduce extractor mode to identify DBs created with codeql test run
This commit is contained in:
@@ -400,7 +400,7 @@ namespace Semmle.Extraction
|
||||
|
||||
private void ReportError(InternalError error)
|
||||
{
|
||||
if (!Extractor.Standalone)
|
||||
if (!Extractor.Mode.HasFlag(ExtractorMode.Standalone))
|
||||
throw error;
|
||||
|
||||
ExtractionError(error);
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Semmle.Extraction
|
||||
/// </summary>
|
||||
public abstract class Extractor
|
||||
{
|
||||
public abstract bool Standalone { get; }
|
||||
public abstract ExtractorMode Mode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new extractor instance for one compilation unit.
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace Semmle.Extraction
|
||||
{
|
||||
/// <summary>
|
||||
/// The mode in which a file is extracted.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ExtractorMode
|
||||
{
|
||||
None = 0,
|
||||
Standalone = 1,
|
||||
Pdb = 2,
|
||||
QlTest = 4,
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,19 @@ namespace Semmle.Extraction
|
||||
{
|
||||
public class StandaloneExtractor : Extractor
|
||||
{
|
||||
public override bool Standalone => true;
|
||||
private readonly ExtractorMode mode;
|
||||
public override ExtractorMode Mode => mode;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new extractor instance for one compilation unit.
|
||||
/// </summary>
|
||||
/// <param name="logger">The object used for logging.</param>
|
||||
/// <param name="pathTransformer">The object used for path transformations.</param>
|
||||
public StandaloneExtractor(ILogger logger, PathTransformer pathTransformer) : base(logger, pathTransformer)
|
||||
public StandaloneExtractor(ILogger logger, PathTransformer pathTransformer, CommonOptions options) : base(logger, pathTransformer)
|
||||
{
|
||||
mode = ExtractorMode.Standalone;
|
||||
if (options.QlTest)
|
||||
mode |= ExtractorMode.QlTest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace Semmle.Extraction
|
||||
{
|
||||
public class TracingExtractor : Extractor
|
||||
{
|
||||
public override bool Standalone => false;
|
||||
|
||||
private readonly ExtractorMode mode;
|
||||
public override ExtractorMode Mode => mode;
|
||||
public string OutputPath { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -14,9 +14,12 @@ namespace Semmle.Extraction
|
||||
/// <param name="outputPath">The name of the output DLL/EXE, or null if not specified (standalone extraction).</param>
|
||||
/// <param name="logger">The object used for logging.</param>
|
||||
/// <param name="pathTransformer">The object used for path transformations.</param>
|
||||
public TracingExtractor(string outputPath, ILogger logger, PathTransformer pathTransformer) : base(logger, pathTransformer)
|
||||
public TracingExtractor(string outputPath, ILogger logger, PathTransformer pathTransformer, CommonOptions options) : base(logger, pathTransformer)
|
||||
{
|
||||
OutputPath = outputPath;
|
||||
mode = ExtractorMode.None;
|
||||
if (options.QlTest)
|
||||
mode |= ExtractorMode.QlTest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,13 +37,18 @@ namespace Semmle.Extraction
|
||||
/// <summary>
|
||||
/// Whether to extract PDB information.
|
||||
/// </summary>
|
||||
public bool PDB { get; private set; } = false;
|
||||
public bool PDB { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether "fast extraction mode" has been enabled.
|
||||
/// </summary>
|
||||
public bool Fast { get; private set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether extraction is done using `codeql test run`.
|
||||
/// </summary>
|
||||
public bool QlTest { get; private set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// The compression algorithm used for trap files.
|
||||
/// </summary>
|
||||
@@ -70,6 +75,10 @@ namespace Semmle.Extraction
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
case "silent":
|
||||
if (value)
|
||||
Verbosity = Verbosity.Off;
|
||||
return true;
|
||||
case "verbose":
|
||||
Verbosity = value ? Verbosity.Debug : Verbosity.Error;
|
||||
return true;
|
||||
@@ -90,6 +99,9 @@ namespace Semmle.Extraction
|
||||
CIL = !value;
|
||||
Fast = value;
|
||||
return true;
|
||||
case "qltest":
|
||||
QlTest = value;
|
||||
return true;
|
||||
case "brotli":
|
||||
TrapCompression = value ? TrapWriter.CompressionMode.Brotli : TrapWriter.CompressionMode.Gzip;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user