mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Gate config export behind a feature flag
This commit is contained in:
2
lib/analyze.js
generated
2
lib/analyze.js
generated
@@ -218,7 +218,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
return statusReport;
|
return statusReport;
|
||||||
async function runInterpretResults(language, queries, sarifFile, enableDebugLogging) {
|
async function runInterpretResults(language, queries, sarifFile, enableDebugLogging) {
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, enableDebugLogging ? "-vv" : "-v", automationDetailsId, config);
|
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, enableDebugLogging ? "-vv" : "-v", automationDetailsId, config, featureEnablement);
|
||||||
}
|
}
|
||||||
async function runPrintLinesOfCode(language) {
|
async function runPrintLinesOfCode(language) {
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
13
lib/codeql.js
generated
13
lib/codeql.js
generated
@@ -31,6 +31,7 @@ const yaml = __importStar(require("js-yaml"));
|
|||||||
const actions_util_1 = require("./actions-util");
|
const actions_util_1 = require("./actions-util");
|
||||||
const config_utils_1 = require("./config-utils");
|
const config_utils_1 = require("./config-utils");
|
||||||
const error_matcher_1 = require("./error-matcher");
|
const error_matcher_1 = require("./error-matcher");
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const setupCodeql = __importStar(require("./setup-codeql"));
|
const setupCodeql = __importStar(require("./setup-codeql"));
|
||||||
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
||||||
@@ -508,7 +509,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
}
|
}
|
||||||
await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, codeqlArgs, error_matcher_1.errorMatchers);
|
await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, codeqlArgs, error_matcher_1.errorMatchers);
|
||||||
},
|
},
|
||||||
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, verbosityFlag, automationDetailsId, config) {
|
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, verbosityFlag, automationDetailsId, config, features) {
|
||||||
const codeqlArgs = [
|
const codeqlArgs = [
|
||||||
"database",
|
"database",
|
||||||
"interpret-results",
|
"interpret-results",
|
||||||
@@ -520,7 +521,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
"--print-diagnostics-summary",
|
"--print-diagnostics-summary",
|
||||||
"--print-metrics-summary",
|
"--print-metrics-summary",
|
||||||
"--sarif-group-rules-by-pack",
|
"--sarif-group-rules-by-pack",
|
||||||
...(await getCodeScanningConfigExportArguments(config, this)),
|
...(await getCodeScanningConfigExportArguments(config, this, features)),
|
||||||
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
||||||
];
|
];
|
||||||
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_CUSTOM_QUERY_HELP))
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_CUSTOM_QUERY_HELP))
|
||||||
@@ -613,13 +614,13 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
];
|
];
|
||||||
await new toolrunner.ToolRunner(cmd, args).exec();
|
await new toolrunner.ToolRunner(cmd, args).exec();
|
||||||
},
|
},
|
||||||
async diagnosticsExport(sarifFile, automationDetailsId, config) {
|
async diagnosticsExport(sarifFile, automationDetailsId, config, features) {
|
||||||
const args = [
|
const args = [
|
||||||
"diagnostics",
|
"diagnostics",
|
||||||
"export",
|
"export",
|
||||||
"--format=sarif-latest",
|
"--format=sarif-latest",
|
||||||
`--output=${sarifFile}`,
|
`--output=${sarifFile}`,
|
||||||
...(await getCodeScanningConfigExportArguments(config, this)),
|
...(await getCodeScanningConfigExportArguments(config, this, features)),
|
||||||
...getExtraOptionsFromEnv(["diagnostics", "export"]),
|
...getExtraOptionsFromEnv(["diagnostics", "export"]),
|
||||||
];
|
];
|
||||||
if (automationDetailsId !== undefined) {
|
if (automationDetailsId !== undefined) {
|
||||||
@@ -804,10 +805,10 @@ function cloneObject(obj) {
|
|||||||
*
|
*
|
||||||
* Returns an empty list if a code scanning configuration file was not generated by the CLI.
|
* Returns an empty list if a code scanning configuration file was not generated by the CLI.
|
||||||
*/
|
*/
|
||||||
async function getCodeScanningConfigExportArguments(config, codeql) {
|
async function getCodeScanningConfigExportArguments(config, codeql, features) {
|
||||||
const codeScanningConfigPath = (0, config_utils_1.getGeneratedCodeScanningConfigPath)(config);
|
const codeScanningConfigPath = (0, config_utils_1.getGeneratedCodeScanningConfigPath)(config);
|
||||||
if (fs.existsSync(codeScanningConfigPath) &&
|
if (fs.existsSync(codeScanningConfigPath) &&
|
||||||
(await util.codeQlVersionAbove(codeql, exports.CODEQL_VERSION_EXPORT_CODE_SCANNING_CONFIG))) {
|
(await features.getValue(feature_flags_1.Feature.ExportCodeScanningConfigEnabled, codeql))) {
|
||||||
return ["--sarif-codescanning-config", codeScanningConfigPath];
|
return ["--sarif-codescanning-config", codeScanningConfigPath];
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
8
lib/codeql.test.js
generated
8
lib/codeql.test.js
generated
@@ -424,7 +424,7 @@ for (const isBundleVersionInUrl of [true, false]) {
|
|||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
|
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig);
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig, (0, testing_utils_1.createFeatures)([]));
|
||||||
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be absent, but it is present");
|
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be absent, but it is present");
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (t) => {
|
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (t) => {
|
||||||
@@ -433,7 +433,7 @@ for (const isBundleVersionInUrl of [true, false]) {
|
|||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
|
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig);
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig, (0, testing_utils_1.createFeatures)([]));
|
||||||
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be present, but it is absent");
|
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be present, but it is absent");
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("databaseInitCluster() without injected codescanning config", async (t) => {
|
(0, ava_1.default)("databaseInitCluster() without injected codescanning config", async (t) => {
|
||||||
@@ -733,7 +733,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.11.3");
|
sinon.stub(codeqlObject, "getVersion").resolves("2.11.3");
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig);
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig, (0, testing_utils_1.createFeatures)([]));
|
||||||
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-baseline-file-info"), "--sarif-add-baseline-file-info should be present, but it is absent");
|
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-baseline-file-info"), "--sarif-add-baseline-file-info should be present, but it is absent");
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("databaseInterpretResults() does not set --sarif-add-baseline-file-info for 2.11.2", async (t) => {
|
(0, ava_1.default)("databaseInterpretResults() does not set --sarif-add-baseline-file-info for 2.11.2", async (t) => {
|
||||||
@@ -742,7 +742,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.11.2");
|
sinon.stub(codeqlObject, "getVersion").resolves("2.11.2");
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig);
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig, (0, testing_utils_1.createFeatures)([]));
|
||||||
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-baseline-file-info"), "--sarif-add-baseline-file-info must be absent, but it is present");
|
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-baseline-file-info"), "--sarif-add-baseline-file-info must be absent, but it is present");
|
||||||
});
|
});
|
||||||
function stubToolRunnerConstructor() {
|
function stubToolRunnerConstructor() {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
6
lib/feature-flags.js
generated
6
lib/feature-flags.js
generated
@@ -28,6 +28,7 @@ const fs = __importStar(require("fs"));
|
|||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
|
const codeql_1 = require("./codeql");
|
||||||
const defaults = __importStar(require("./defaults.json"));
|
const defaults = __importStar(require("./defaults.json"));
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
const DEFAULT_VERSION_FEATURE_FLAG_PREFIX = "default_codeql_version_";
|
const DEFAULT_VERSION_FEATURE_FLAG_PREFIX = "default_codeql_version_";
|
||||||
@@ -36,6 +37,7 @@ var Feature;
|
|||||||
(function (Feature) {
|
(function (Feature) {
|
||||||
Feature["CliConfigFileEnabled"] = "cli_config_file_enabled";
|
Feature["CliConfigFileEnabled"] = "cli_config_file_enabled";
|
||||||
Feature["DisableKotlinAnalysisEnabled"] = "disable_kotlin_analysis_enabled";
|
Feature["DisableKotlinAnalysisEnabled"] = "disable_kotlin_analysis_enabled";
|
||||||
|
Feature["ExportCodeScanningConfigEnabled"] = "export_code_scanning_config_enabled";
|
||||||
Feature["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
Feature["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
||||||
Feature["UploadFailedSarifEnabled"] = "upload_failed_sarif_enabled";
|
Feature["UploadFailedSarifEnabled"] = "upload_failed_sarif_enabled";
|
||||||
})(Feature = exports.Feature || (exports.Feature = {}));
|
})(Feature = exports.Feature || (exports.Feature = {}));
|
||||||
@@ -48,6 +50,10 @@ exports.featureConfig = {
|
|||||||
envVar: "CODEQL_PASS_CONFIG_TO_CLI",
|
envVar: "CODEQL_PASS_CONFIG_TO_CLI",
|
||||||
minimumVersion: "2.11.6",
|
minimumVersion: "2.11.6",
|
||||||
},
|
},
|
||||||
|
[Feature.ExportCodeScanningConfigEnabled]: {
|
||||||
|
envVar: "CODEQL_ACTION_EXPORT_CODE_SCANNING_CONFIG",
|
||||||
|
minimumVersion: codeql_1.CODEQL_VERSION_EXPORT_CODE_SCANNING_CONFIG,
|
||||||
|
},
|
||||||
[Feature.MlPoweredQueriesEnabled]: {
|
[Feature.MlPoweredQueriesEnabled]: {
|
||||||
envVar: "CODEQL_ML_POWERED_QUERIES",
|
envVar: "CODEQL_ML_POWERED_QUERIES",
|
||||||
minimumVersion: "2.7.5",
|
minimumVersion: "2.7.5",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
14
lib/init-action-post-helper.js
generated
14
lib/init-action-post-helper.js
generated
@@ -43,12 +43,12 @@ function createFailedUploadFailedSarifResult(error) {
|
|||||||
* Upload a failed SARIF file if we can verify that SARIF upload is enabled and determine the SARIF
|
* Upload a failed SARIF file if we can verify that SARIF upload is enabled and determine the SARIF
|
||||||
* category for the workflow.
|
* category for the workflow.
|
||||||
*/
|
*/
|
||||||
async function maybeUploadFailedSarif(config, repositoryNwo, featureEnablement, logger) {
|
async function maybeUploadFailedSarif(config, repositoryNwo, features, logger) {
|
||||||
if (!config.codeQLCmd) {
|
if (!config.codeQLCmd) {
|
||||||
return { upload_failed_run_skipped_because: "CodeQL command not found" };
|
return { upload_failed_run_skipped_because: "CodeQL command not found" };
|
||||||
}
|
}
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
if (!(await featureEnablement.getValue(feature_flags_1.Feature.UploadFailedSarifEnabled, codeql))) {
|
if (!(await features.getValue(feature_flags_1.Feature.UploadFailedSarifEnabled, codeql))) {
|
||||||
return { upload_failed_run_skipped_because: "Feature disabled" };
|
return { upload_failed_run_skipped_because: "Feature disabled" };
|
||||||
}
|
}
|
||||||
const workflow = await (0, workflow_1.getWorkflow)();
|
const workflow = await (0, workflow_1.getWorkflow)();
|
||||||
@@ -61,16 +61,16 @@ async function maybeUploadFailedSarif(config, repositoryNwo, featureEnablement,
|
|||||||
const category = (0, workflow_1.getCategoryInputOrThrow)(workflow, jobName, matrix);
|
const category = (0, workflow_1.getCategoryInputOrThrow)(workflow, jobName, matrix);
|
||||||
const checkoutPath = (0, workflow_1.getCheckoutPathInputOrThrow)(workflow, jobName, matrix);
|
const checkoutPath = (0, workflow_1.getCheckoutPathInputOrThrow)(workflow, jobName, matrix);
|
||||||
const sarifFile = "../codeql-failed-run.sarif";
|
const sarifFile = "../codeql-failed-run.sarif";
|
||||||
await codeql.diagnosticsExport(sarifFile, category, config);
|
await codeql.diagnosticsExport(sarifFile, category, config, features);
|
||||||
core.info(`Uploading failed SARIF file ${sarifFile}`);
|
core.info(`Uploading failed SARIF file ${sarifFile}`);
|
||||||
const uploadResult = await uploadLib.uploadFromActions(sarifFile, checkoutPath, category, logger);
|
const uploadResult = await uploadLib.uploadFromActions(sarifFile, checkoutPath, category, logger);
|
||||||
await uploadLib.waitForProcessing(repositoryNwo, uploadResult.sarifID, logger, { isUnsuccessfulExecution: true });
|
await uploadLib.waitForProcessing(repositoryNwo, uploadResult.sarifID, logger, { isUnsuccessfulExecution: true });
|
||||||
return uploadResult?.statusReport ?? {};
|
return uploadResult?.statusReport ?? {};
|
||||||
}
|
}
|
||||||
async function tryUploadSarifIfRunFailed(config, repositoryNwo, featureEnablement, logger) {
|
async function tryUploadSarifIfRunFailed(config, repositoryNwo, features, logger) {
|
||||||
if (process.env[shared_environment_1.CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY] !== "true") {
|
if (process.env[shared_environment_1.CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY] !== "true") {
|
||||||
try {
|
try {
|
||||||
return await maybeUploadFailedSarif(config, repositoryNwo, featureEnablement, logger);
|
return await maybeUploadFailedSarif(config, repositoryNwo, features, logger);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.debug(`Failed to upload a SARIF file for this failed CodeQL code scanning run. ${e}`);
|
logger.debug(`Failed to upload a SARIF file for this failed CodeQL code scanning run. ${e}`);
|
||||||
@@ -84,13 +84,13 @@ async function tryUploadSarifIfRunFailed(config, repositoryNwo, featureEnablemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.tryUploadSarifIfRunFailed = tryUploadSarifIfRunFailed;
|
exports.tryUploadSarifIfRunFailed = tryUploadSarifIfRunFailed;
|
||||||
async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, printDebugLogs, repositoryNwo, featureEnablement, logger) {
|
async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, printDebugLogs, repositoryNwo, features, logger) {
|
||||||
const config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
const config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
||||||
if (config === undefined) {
|
if (config === undefined) {
|
||||||
logger.warning("Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.");
|
logger.warning("Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const uploadFailedSarifResult = await tryUploadSarifIfRunFailed(config, repositoryNwo, featureEnablement, logger);
|
const uploadFailedSarifResult = await tryUploadSarifIfRunFailed(config, repositoryNwo, features, logger);
|
||||||
if (uploadFailedSarifResult.upload_failed_run_skipped_because) {
|
if (uploadFailedSarifResult.upload_failed_run_skipped_because) {
|
||||||
logger.debug("Won't upload a failed SARIF file for this CodeQL code scanning run because: " +
|
logger.debug("Won't upload a failed SARIF file for this CodeQL code scanning run because: " +
|
||||||
`${uploadFailedSarifResult.upload_failed_run_skipped_because}.`);
|
`${uploadFailedSarifResult.upload_failed_run_skipped_because}.`);
|
||||||
|
|||||||
@@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1C,CAAC;KACH;AACH,CAAC;AA1BD,8DA0BC;AAEM,KAAK,UAAU,GAAG,CACvB,iCAA2C,EAC3C,uBAAiC,EACjC,cAAwB,EACxB,aAA4B,EAC5B,iBAAoC,EACpC,MAAc;IAEd,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAS,EAAC,WAAW,CAAC,qBAAqB,EAAE,EAAE,MAAM,CAAC,CAAC;IAC5E,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,MAAM,CAAC,OAAO,CACZ,iGAAiG,CAClG,CAAC;QACF,OAAO;KACR;IAED,MAAM,uBAAuB,GAAG,MAAM,yBAAyB,CAC7D,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,MAAM,CACP,CAAC;IACF,IAAI,uBAAuB,CAAC,iCAAiC,EAAE;QAC7D,MAAM,CAAC,KAAK,CACV,8EAA8E;YAC5E,GAAG,uBAAuB,CAAC,iCAAiC,GAAG,CAClE,CAAC;KACH;IACD,8FAA8F;IAC9F,iCAAiC;IACjC,IACE,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,KAAK,MAAM;QAClE,CAAC,uBAAuB,CAAC,qBAAqB,EAC9C;QACA,MAAM,IAAI,KAAK,CACb,4EAA4E;YAC1E,8BAA8B,uBAAuB,GAAG,CAC3D,CAAC;KACH;IAED,qDAAqD;IACrD,IAAI,MAAM,CAAC,SAAS,EAAE;QACpB,IAAI,CAAC,IAAI,CACP,mGAAmG,CACpG,CAAC;QACF,MAAM,iCAAiC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEtC,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;KAC9B;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC;AApDD,kBAoDC"}
|
{"version":3,"file":"init-action-post-helper.js","sourceRoot":"","sources":["../src/init-action-post-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AA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5B,QAA2B,EAC3B,MAAc;IAEd,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAS,EAAC,WAAW,CAAC,qBAAqB,EAAE,EAAE,MAAM,CAAC,CAAC;IAC5E,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,MAAM,CAAC,OAAO,CACZ,iGAAiG,CAClG,CAAC;QACF,OAAO;KACR;IAED,MAAM,uBAAuB,GAAG,MAAM,yBAAyB,CAC7D,MAAM,EACN,aAAa,EACb,QAAQ,EACR,MAAM,CACP,CAAC;IACF,IAAI,uBAAuB,CAAC,iCAAiC,EAAE;QAC7D,MAAM,CAAC,KAAK,CACV,8EAA8E;YAC5E,GAAG,uBAAuB,CAAC,iCAAiC,GAAG,CAClE,CAAC;KACH;IACD,8FAA8F;IAC9F,iCAAiC;IACjC,IACE,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,KAAK,MAAM;QAClE,CAAC,uBAAuB,CAAC,qBAAqB,EAC9C;QACA,MAAM,IAAI,KAAK,CACb,4EAA4E;YAC1E,8BAA8B,uBAAuB,GAAG,CAC3D,CAAC;KACH;IAED,qDAAqD;IACrD,IAAI,MAAM,CAAC,SAAS,EAAE;QACpB,IAAI,CAAC,IAAI,CACP,mGAAmG,CACpG,CAAC;QACF,MAAM,iCAAiC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEtC,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;KAC9B;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC;AApDD,kBAoDC"}
|
||||||
2
lib/init-action-post-helper.test.js
generated
2
lib/init-action-post-helper.test.js
generated
@@ -254,7 +254,7 @@ async function testFailedSarifUpload(t, actionsWorkflow, { category, expectUploa
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (expectUpload) {
|
if (expectUpload) {
|
||||||
t.true(diagnosticsExportStub.calledOnceWith(sinon.match.string, category, sinon.match.any), `Actual args were: ${diagnosticsExportStub.args}`);
|
t.true(diagnosticsExportStub.calledOnceWith(sinon.match.string, category, sinon.match.any, sinon.match.any), `Actual args were: ${diagnosticsExportStub.args}`);
|
||||||
t.true(uploadFromActions.calledOnceWith(sinon.match.string, sinon.match.string, category, sinon.match.any), `Actual args were: ${uploadFromActions.args}`);
|
t.true(uploadFromActions.calledOnceWith(sinon.match.string, sinon.match.string, category, sinon.match.any), `Actual args were: ${uploadFromActions.args}`);
|
||||||
t.true(waitForProcessing.calledOnceWith(sinon.match.any, "42", sinon.match.any, {
|
t.true(waitForProcessing.calledOnceWith(sinon.match.any, "42", sinon.match.any, {
|
||||||
isUnsuccessfulExecution: true,
|
isUnsuccessfulExecution: true,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -368,7 +368,8 @@ export async function runQueries(
|
|||||||
threadsFlag,
|
threadsFlag,
|
||||||
enableDebugLogging ? "-vv" : "-v",
|
enableDebugLogging ? "-vv" : "-v",
|
||||||
automationDetailsId,
|
automationDetailsId,
|
||||||
config
|
config,
|
||||||
|
featureEnablement
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -636,7 +636,8 @@ test("databaseInterpretResults() does not set --sarif-add-query-help for 2.7.0",
|
|||||||
"",
|
"",
|
||||||
"-v",
|
"-v",
|
||||||
"",
|
"",
|
||||||
stubConfig
|
stubConfig,
|
||||||
|
createFeatures([])
|
||||||
);
|
);
|
||||||
t.false(
|
t.false(
|
||||||
runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"),
|
runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"),
|
||||||
@@ -658,7 +659,8 @@ test("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (
|
|||||||
"",
|
"",
|
||||||
"-v",
|
"-v",
|
||||||
"",
|
"",
|
||||||
stubConfig
|
stubConfig,
|
||||||
|
createFeatures([])
|
||||||
);
|
);
|
||||||
t.true(
|
t.true(
|
||||||
runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"),
|
runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"),
|
||||||
@@ -1155,7 +1157,8 @@ test("databaseInterpretResults() sets --sarif-add-baseline-file-info for 2.11.3"
|
|||||||
"",
|
"",
|
||||||
"-v",
|
"-v",
|
||||||
"",
|
"",
|
||||||
stubConfig
|
stubConfig,
|
||||||
|
createFeatures([])
|
||||||
);
|
);
|
||||||
t.true(
|
t.true(
|
||||||
runnerConstructorStub.firstCall.args[1].includes(
|
runnerConstructorStub.firstCall.args[1].includes(
|
||||||
@@ -1179,7 +1182,8 @@ test("databaseInterpretResults() does not set --sarif-add-baseline-file-info for
|
|||||||
"",
|
"",
|
||||||
"-v",
|
"-v",
|
||||||
"",
|
"",
|
||||||
stubConfig
|
stubConfig,
|
||||||
|
createFeatures([])
|
||||||
);
|
);
|
||||||
t.false(
|
t.false(
|
||||||
runnerConstructorStub.firstCall.args[1].includes(
|
runnerConstructorStub.firstCall.args[1].includes(
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ import { getOptionalInput } from "./actions-util";
|
|||||||
import * as api from "./api-client";
|
import * as api from "./api-client";
|
||||||
import { Config, getGeneratedCodeScanningConfigPath } from "./config-utils";
|
import { Config, getGeneratedCodeScanningConfigPath } from "./config-utils";
|
||||||
import { errorMatchers } from "./error-matcher";
|
import { errorMatchers } from "./error-matcher";
|
||||||
import { CodeQLDefaultVersionInfo, FeatureEnablement } from "./feature-flags";
|
import {
|
||||||
|
CodeQLDefaultVersionInfo,
|
||||||
|
Feature,
|
||||||
|
FeatureEnablement,
|
||||||
|
} from "./feature-flags";
|
||||||
import { ToolsSource } from "./init";
|
import { ToolsSource } from "./init";
|
||||||
import { isTracedLanguage, Language } from "./languages";
|
import { isTracedLanguage, Language } from "./languages";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
@@ -174,7 +178,8 @@ export interface CodeQL {
|
|||||||
threadsFlag: string,
|
threadsFlag: string,
|
||||||
verbosityFlag: string | undefined,
|
verbosityFlag: string | undefined,
|
||||||
automationDetailsId: string | undefined,
|
automationDetailsId: string | undefined,
|
||||||
config: Config
|
config: Config,
|
||||||
|
features: FeatureEnablement
|
||||||
): Promise<string>;
|
): Promise<string>;
|
||||||
/**
|
/**
|
||||||
* Run 'codeql database print-baseline'.
|
* Run 'codeql database print-baseline'.
|
||||||
@@ -186,7 +191,8 @@ export interface CodeQL {
|
|||||||
diagnosticsExport(
|
diagnosticsExport(
|
||||||
sarifFile: string,
|
sarifFile: string,
|
||||||
automationDetailsId: string | undefined,
|
automationDetailsId: string | undefined,
|
||||||
config: Config
|
config: Config,
|
||||||
|
features: FeatureEnablement
|
||||||
): Promise<void>;
|
): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,7 +856,8 @@ export async function getCodeQLForCmd(
|
|||||||
threadsFlag: string,
|
threadsFlag: string,
|
||||||
verbosityFlag: string,
|
verbosityFlag: string,
|
||||||
automationDetailsId: string | undefined,
|
automationDetailsId: string | undefined,
|
||||||
config: Config
|
config: Config,
|
||||||
|
features: FeatureEnablement
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const codeqlArgs = [
|
const codeqlArgs = [
|
||||||
"database",
|
"database",
|
||||||
@@ -863,7 +870,7 @@ export async function getCodeQLForCmd(
|
|||||||
"--print-diagnostics-summary",
|
"--print-diagnostics-summary",
|
||||||
"--print-metrics-summary",
|
"--print-metrics-summary",
|
||||||
"--sarif-group-rules-by-pack",
|
"--sarif-group-rules-by-pack",
|
||||||
...(await getCodeScanningConfigExportArguments(config, this)),
|
...(await getCodeScanningConfigExportArguments(config, this, features)),
|
||||||
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
||||||
];
|
];
|
||||||
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_CUSTOM_QUERY_HELP))
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_CUSTOM_QUERY_HELP))
|
||||||
@@ -984,14 +991,15 @@ export async function getCodeQLForCmd(
|
|||||||
async diagnosticsExport(
|
async diagnosticsExport(
|
||||||
sarifFile: string,
|
sarifFile: string,
|
||||||
automationDetailsId: string | undefined,
|
automationDetailsId: string | undefined,
|
||||||
config: Config
|
config: Config,
|
||||||
|
features: FeatureEnablement
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const args = [
|
const args = [
|
||||||
"diagnostics",
|
"diagnostics",
|
||||||
"export",
|
"export",
|
||||||
"--format=sarif-latest",
|
"--format=sarif-latest",
|
||||||
`--output=${sarifFile}`,
|
`--output=${sarifFile}`,
|
||||||
...(await getCodeScanningConfigExportArguments(config, this)),
|
...(await getCodeScanningConfigExportArguments(config, this, features)),
|
||||||
...getExtraOptionsFromEnv(["diagnostics", "export"]),
|
...getExtraOptionsFromEnv(["diagnostics", "export"]),
|
||||||
];
|
];
|
||||||
if (automationDetailsId !== undefined) {
|
if (automationDetailsId !== undefined) {
|
||||||
@@ -1217,15 +1225,13 @@ function cloneObject<T>(obj: T): T {
|
|||||||
*/
|
*/
|
||||||
async function getCodeScanningConfigExportArguments(
|
async function getCodeScanningConfigExportArguments(
|
||||||
config: Config,
|
config: Config,
|
||||||
codeql: CodeQL
|
codeql: CodeQL,
|
||||||
|
features: FeatureEnablement
|
||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
const codeScanningConfigPath = getGeneratedCodeScanningConfigPath(config);
|
const codeScanningConfigPath = getGeneratedCodeScanningConfigPath(config);
|
||||||
if (
|
if (
|
||||||
fs.existsSync(codeScanningConfigPath) &&
|
fs.existsSync(codeScanningConfigPath) &&
|
||||||
(await util.codeQlVersionAbove(
|
(await features.getValue(Feature.ExportCodeScanningConfigEnabled, codeql))
|
||||||
codeql,
|
|
||||||
CODEQL_VERSION_EXPORT_CODE_SCANNING_CONFIG
|
|
||||||
))
|
|
||||||
) {
|
) {
|
||||||
return ["--sarif-codescanning-config", codeScanningConfigPath];
|
return ["--sarif-codescanning-config", codeScanningConfigPath];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import * as path from "path";
|
|||||||
import * as semver from "semver";
|
import * as semver from "semver";
|
||||||
|
|
||||||
import { getApiClient } from "./api-client";
|
import { getApiClient } from "./api-client";
|
||||||
import { CodeQL } from "./codeql";
|
import { CodeQL, CODEQL_VERSION_EXPORT_CODE_SCANNING_CONFIG } from "./codeql";
|
||||||
import * as defaults from "./defaults.json";
|
import * as defaults from "./defaults.json";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { RepositoryNwo } from "./repository";
|
import { RepositoryNwo } from "./repository";
|
||||||
@@ -36,6 +36,7 @@ export interface FeatureEnablement {
|
|||||||
export enum Feature {
|
export enum Feature {
|
||||||
CliConfigFileEnabled = "cli_config_file_enabled",
|
CliConfigFileEnabled = "cli_config_file_enabled",
|
||||||
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
|
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
|
||||||
|
ExportCodeScanningConfigEnabled = "export_code_scanning_config_enabled",
|
||||||
MlPoweredQueriesEnabled = "ml_powered_queries_enabled",
|
MlPoweredQueriesEnabled = "ml_powered_queries_enabled",
|
||||||
UploadFailedSarifEnabled = "upload_failed_sarif_enabled",
|
UploadFailedSarifEnabled = "upload_failed_sarif_enabled",
|
||||||
}
|
}
|
||||||
@@ -52,6 +53,10 @@ export const featureConfig: Record<
|
|||||||
envVar: "CODEQL_PASS_CONFIG_TO_CLI",
|
envVar: "CODEQL_PASS_CONFIG_TO_CLI",
|
||||||
minimumVersion: "2.11.6",
|
minimumVersion: "2.11.6",
|
||||||
},
|
},
|
||||||
|
[Feature.ExportCodeScanningConfigEnabled]: {
|
||||||
|
envVar: "CODEQL_ACTION_EXPORT_CODE_SCANNING_CONFIG",
|
||||||
|
minimumVersion: CODEQL_VERSION_EXPORT_CODE_SCANNING_CONFIG,
|
||||||
|
},
|
||||||
[Feature.MlPoweredQueriesEnabled]: {
|
[Feature.MlPoweredQueriesEnabled]: {
|
||||||
envVar: "CODEQL_ML_POWERED_QUERIES",
|
envVar: "CODEQL_ML_POWERED_QUERIES",
|
||||||
minimumVersion: "2.7.5",
|
minimumVersion: "2.7.5",
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ async function testFailedSarifUpload(
|
|||||||
diagnosticsExportStub.calledOnceWith(
|
diagnosticsExportStub.calledOnceWith(
|
||||||
sinon.match.string,
|
sinon.match.string,
|
||||||
category,
|
category,
|
||||||
|
sinon.match.any,
|
||||||
sinon.match.any
|
sinon.match.any
|
||||||
),
|
),
|
||||||
`Actual args were: ${diagnosticsExportStub.args}`
|
`Actual args were: ${diagnosticsExportStub.args}`
|
||||||
|
|||||||
@@ -43,19 +43,14 @@ function createFailedUploadFailedSarifResult(
|
|||||||
async function maybeUploadFailedSarif(
|
async function maybeUploadFailedSarif(
|
||||||
config: Config,
|
config: Config,
|
||||||
repositoryNwo: RepositoryNwo,
|
repositoryNwo: RepositoryNwo,
|
||||||
featureEnablement: FeatureEnablement,
|
features: FeatureEnablement,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<UploadFailedSarifResult> {
|
): Promise<UploadFailedSarifResult> {
|
||||||
if (!config.codeQLCmd) {
|
if (!config.codeQLCmd) {
|
||||||
return { upload_failed_run_skipped_because: "CodeQL command not found" };
|
return { upload_failed_run_skipped_because: "CodeQL command not found" };
|
||||||
}
|
}
|
||||||
const codeql = await getCodeQL(config.codeQLCmd);
|
const codeql = await getCodeQL(config.codeQLCmd);
|
||||||
if (
|
if (!(await features.getValue(Feature.UploadFailedSarifEnabled, codeql))) {
|
||||||
!(await featureEnablement.getValue(
|
|
||||||
Feature.UploadFailedSarifEnabled,
|
|
||||||
codeql
|
|
||||||
))
|
|
||||||
) {
|
|
||||||
return { upload_failed_run_skipped_because: "Feature disabled" };
|
return { upload_failed_run_skipped_because: "Feature disabled" };
|
||||||
}
|
}
|
||||||
const workflow = await getWorkflow();
|
const workflow = await getWorkflow();
|
||||||
@@ -71,7 +66,7 @@ async function maybeUploadFailedSarif(
|
|||||||
const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix);
|
const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix);
|
||||||
|
|
||||||
const sarifFile = "../codeql-failed-run.sarif";
|
const sarifFile = "../codeql-failed-run.sarif";
|
||||||
await codeql.diagnosticsExport(sarifFile, category, config);
|
await codeql.diagnosticsExport(sarifFile, category, config, features);
|
||||||
|
|
||||||
core.info(`Uploading failed SARIF file ${sarifFile}`);
|
core.info(`Uploading failed SARIF file ${sarifFile}`);
|
||||||
const uploadResult = await uploadLib.uploadFromActions(
|
const uploadResult = await uploadLib.uploadFromActions(
|
||||||
@@ -92,7 +87,7 @@ async function maybeUploadFailedSarif(
|
|||||||
export async function tryUploadSarifIfRunFailed(
|
export async function tryUploadSarifIfRunFailed(
|
||||||
config: Config,
|
config: Config,
|
||||||
repositoryNwo: RepositoryNwo,
|
repositoryNwo: RepositoryNwo,
|
||||||
featureEnablement: FeatureEnablement,
|
features: FeatureEnablement,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<UploadFailedSarifResult> {
|
): Promise<UploadFailedSarifResult> {
|
||||||
if (process.env[CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY] !== "true") {
|
if (process.env[CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY] !== "true") {
|
||||||
@@ -100,7 +95,7 @@ export async function tryUploadSarifIfRunFailed(
|
|||||||
return await maybeUploadFailedSarif(
|
return await maybeUploadFailedSarif(
|
||||||
config,
|
config,
|
||||||
repositoryNwo,
|
repositoryNwo,
|
||||||
featureEnablement,
|
features,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -122,7 +117,7 @@ export async function run(
|
|||||||
uploadLogsDebugArtifact: Function,
|
uploadLogsDebugArtifact: Function,
|
||||||
printDebugLogs: Function,
|
printDebugLogs: Function,
|
||||||
repositoryNwo: RepositoryNwo,
|
repositoryNwo: RepositoryNwo,
|
||||||
featureEnablement: FeatureEnablement,
|
features: FeatureEnablement,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
) {
|
) {
|
||||||
const config = await getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
const config = await getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
||||||
@@ -136,7 +131,7 @@ export async function run(
|
|||||||
const uploadFailedSarifResult = await tryUploadSarifIfRunFailed(
|
const uploadFailedSarifResult = await tryUploadSarifIfRunFailed(
|
||||||
config,
|
config,
|
||||||
repositoryNwo,
|
repositoryNwo,
|
||||||
featureEnablement,
|
features,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
if (uploadFailedSarifResult.upload_failed_run_skipped_because) {
|
if (uploadFailedSarifResult.upload_failed_run_skipped_because) {
|
||||||
|
|||||||
Reference in New Issue
Block a user