Use supportsFeature check for merging SARIF files
This commit is contained in:
parent
2bbafcdd7f
commit
e20c273295
9 changed files with 27 additions and 9 deletions
3
lib/feature-flags.js
generated
3
lib/feature-flags.js
generated
|
|
@ -61,8 +61,7 @@ var Feature;
|
|||
exports.featureConfig = {
|
||||
[Feature.CliSarifMerge]: {
|
||||
envVar: "CODEQL_ACTION_CLI_SARIF_MERGE",
|
||||
// This feature is only supported in 2.17.0, but we'll want to test this feature
|
||||
// with nightly builds before that. We'll update this to 2.17.0 once it's released.
|
||||
// This is guarded by a `supportsFeature` check rather than by a version check.
|
||||
minimumVersion: undefined,
|
||||
defaultValue: false,
|
||||
},
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
1
lib/tools-features.js
generated
1
lib/tools-features.js
generated
|
|
@ -8,6 +8,7 @@ var ToolsFeature;
|
|||
ToolsFeature["InformsAboutUnsupportedPathFilters"] = "informsAboutUnsupportedPathFilters";
|
||||
ToolsFeature["SetsCodeqlRunnerEnvVar"] = "setsCodeqlRunnerEnvVar";
|
||||
ToolsFeature["TraceCommandUseBuildMode"] = "traceCommandUseBuildMode";
|
||||
ToolsFeature["SarifMergeRunsFromEqualCategory"] = "sarifMergeRunsFromEqualCategory";
|
||||
})(ToolsFeature || (exports.ToolsFeature = ToolsFeature = {}));
|
||||
/**
|
||||
* Determines if the given feature is supported by the CLI.
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"tools-features.js","sourceRoot":"","sources":["../src/tools-features.ts"],"names":[],"mappings":";;;AAEA,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,mDAAmC,CAAA;IACnC,+FAA+E,CAAA;IAC/E,yFAAyE,CAAA;IACzE,iEAAiD,CAAA;IACjD,qEAAqD,CAAA;AACvD,CAAC,EANW,YAAY,4BAAZ,YAAY,QAMvB;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,WAAwB,EACxB,OAAqB;IAErB,OAAO,CAAC,CAAC,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACjE,CAAC;AALD,0DAKC"}
|
||||
{"version":3,"file":"tools-features.js","sourceRoot":"","sources":["../src/tools-features.ts"],"names":[],"mappings":";;;AAEA,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,mDAAmC,CAAA;IACnC,+FAA+E,CAAA;IAC/E,yFAAyE,CAAA;IACzE,iEAAiD,CAAA;IACjD,qEAAqD,CAAA;IACrD,mFAAmE,CAAA;AACrE,CAAC,EAPW,YAAY,4BAAZ,YAAY,QAOvB;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,WAAwB,EACxB,OAAqB;IAErB,OAAO,CAAC,CAAC,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACjE,CAAC;AALD,0DAKC"}
|
||||
5
lib/upload-lib.js
generated
5
lib/upload-lib.js
generated
|
|
@ -44,6 +44,7 @@ const feature_flags_1 = require("./feature-flags");
|
|||
const fingerprints = __importStar(require("./fingerprints"));
|
||||
const init_1 = require("./init");
|
||||
const repository_1 = require("./repository");
|
||||
const tools_features_1 = require("./tools-features");
|
||||
const util = __importStar(require("./util"));
|
||||
const util_1 = require("./util");
|
||||
const GENERIC_403_MSG = "The repo on which this action is running has not opted-in to CodeQL code scanning.";
|
||||
|
|
@ -110,6 +111,10 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
|||
apiDetails, tempDir, gitHubVersion.type, codeQLDefaultVersionInfo, logger);
|
||||
codeQL = initCodeQLResult.codeql;
|
||||
}
|
||||
if (!(await codeQL.supportsFeature(tools_features_1.ToolsFeature.SarifMergeRunsFromEqualCategory))) {
|
||||
logger.warning("The CodeQL CLI does not support merging SARIF files. Merging files in the action.");
|
||||
return combineSarifFiles(sarifFiles);
|
||||
}
|
||||
const baseTempDir = path.resolve(tempDir, "combined-sarif");
|
||||
fs.mkdirSync(baseTempDir, { recursive: true });
|
||||
const outputDirectory = fs.mkdtempSync(path.resolve(baseTempDir, "output-"));
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -61,8 +61,7 @@ export const featureConfig: Record<
|
|||
> = {
|
||||
[Feature.CliSarifMerge]: {
|
||||
envVar: "CODEQL_ACTION_CLI_SARIF_MERGE",
|
||||
// This feature is only supported in 2.17.0, but we'll want to test this feature
|
||||
// with nightly builds before that. We'll update this to 2.17.0 once it's released.
|
||||
// This is guarded by a `supportsFeature` check rather than by a version check.
|
||||
minimumVersion: undefined,
|
||||
defaultValue: false,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export enum ToolsFeature {
|
|||
InformsAboutUnsupportedPathFilters = "informsAboutUnsupportedPathFilters",
|
||||
SetsCodeqlRunnerEnvVar = "setsCodeqlRunnerEnvVar",
|
||||
TraceCommandUseBuildMode = "traceCommandUseBuildMode",
|
||||
SarifMergeRunsFromEqualCategory = "sarifMergeRunsFromEqualCategory",
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@ import * as fingerprints from "./fingerprints";
|
|||
import { initCodeQL } from "./init";
|
||||
import { Logger } from "./logging";
|
||||
import { parseRepositoryNwo, RepositoryNwo } from "./repository";
|
||||
import { ToolsFeature } from "./tools-features";
|
||||
import * as util from "./util";
|
||||
import {
|
||||
SarifFile,
|
||||
ConfigurationError,
|
||||
wrapError,
|
||||
getRequiredEnvParam,
|
||||
GitHubVersion,
|
||||
SarifFile,
|
||||
wrapError,
|
||||
} from "./util";
|
||||
|
||||
const GENERIC_403_MSG =
|
||||
|
|
@ -134,6 +135,18 @@ async function combineSarifFilesUsingCLI(
|
|||
codeQL = initCodeQLResult.codeql;
|
||||
}
|
||||
|
||||
if (
|
||||
!(await codeQL.supportsFeature(
|
||||
ToolsFeature.SarifMergeRunsFromEqualCategory,
|
||||
))
|
||||
) {
|
||||
logger.warning(
|
||||
"The CodeQL CLI does not support merging SARIF files. Merging files in the action.",
|
||||
);
|
||||
|
||||
return combineSarifFiles(sarifFiles);
|
||||
}
|
||||
|
||||
const baseTempDir = path.resolve(tempDir, "combined-sarif");
|
||||
fs.mkdirSync(baseTempDir, { recursive: true });
|
||||
const outputDirectory = fs.mkdtempSync(path.resolve(baseTempDir, "output-"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue