More renaming

This commit is contained in:
Andrew Eisenberg 2022-10-11 10:39:40 -07:00
parent 6c869f8b03
commit 701cea34ba
45 changed files with 356 additions and 358 deletions

12
lib/analyze-action.js generated
View file

@ -107,11 +107,11 @@ function doesGoExtractionOutputExist(config) {
* - We approximate whether manual build steps are present by looking at * - We approximate whether manual build steps are present by looking at
* whether any extraction output already exists for Go. * whether any extraction output already exists for Go.
*/ */
async function runAutobuildIfLegacyGoWorkflow(config, featureFlags, logger) { async function runAutobuildIfLegacyGoWorkflow(config, featureEnablement, logger) {
if (!config.languages.includes(languages_1.Language.go)) { if (!config.languages.includes(languages_1.Language.go)) {
return; return;
} }
if (!(await util.isGoExtractionReconciliationEnabled(featureFlags))) { if (!(await util.isGoExtractionReconciliationEnabled(featureEnablement))) {
logger.debug("Won't run Go autobuild since Go extraction reconciliation is not enabled."); logger.debug("Won't run Go autobuild since Go extraction reconciliation is not enabled.");
return; return;
} }
@ -159,11 +159,11 @@ async function run() {
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]); const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")); const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)(); const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
const featureFlags = new feature_flags_1.Features(gitHubVersion, apiDetails, repositoryNwo, logger); const features = new feature_flags_1.Features(gitHubVersion, apiDetails, repositoryNwo, logger);
await runAutobuildIfLegacyGoWorkflow(config, featureFlags, logger); await runAutobuildIfLegacyGoWorkflow(config, features, logger);
dbCreationTimings = await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, featureFlags); dbCreationTimings = await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, features);
if (actionsUtil.getRequiredInput("skip-queries") !== "true") { if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger, featureFlags); runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger, features);
} }
if (actionsUtil.getOptionalInput("cleanup-level") !== "none") { if (actionsUtil.getOptionalInput("cleanup-level") !== "none") {
await (0, analyze_1.runCleanup)(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger); await (0, analyze_1.runCleanup)(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger);

File diff suppressed because one or more lines are too long

20
lib/analyze.js generated
View file

@ -70,12 +70,12 @@ async function setupPythonExtractor(logger) {
logger.info(`Setting LGTM_PYTHON_SETUP_VERSION=${output}`); logger.info(`Setting LGTM_PYTHON_SETUP_VERSION=${output}`);
process.env["LGTM_PYTHON_SETUP_VERSION"] = output; process.env["LGTM_PYTHON_SETUP_VERSION"] = output;
} }
async function createdDBForScannedLanguages(codeql, config, logger, featureFlags) { async function createdDBForScannedLanguages(codeql, config, logger, featureEnablement) {
// Insert the LGTM_INDEX_X env vars at this point so they are set when // Insert the LGTM_INDEX_X env vars at this point so they are set when
// we extract any scanned languages. // we extract any scanned languages.
analysisPaths.includeAndExcludeAnalysisPaths(config); analysisPaths.includeAndExcludeAnalysisPaths(config);
for (const language of config.languages) { for (const language of config.languages) {
if ((0, languages_1.isScannedLanguage)(language, await util.isGoExtractionReconciliationEnabled(featureFlags), logger) && if ((0, languages_1.isScannedLanguage)(language, await util.isGoExtractionReconciliationEnabled(featureEnablement), logger) &&
!dbIsFinalized(config, language, logger)) { !dbIsFinalized(config, language, logger)) {
logger.startGroup(`Extracting ${language}`); logger.startGroup(`Extracting ${language}`);
if (language === languages_1.Language.python) { if (language === languages_1.Language.python) {
@ -99,10 +99,10 @@ function dbIsFinalized(config, language, logger) {
} }
} }
exports.dbIsFinalized = dbIsFinalized; exports.dbIsFinalized = dbIsFinalized;
async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger, featureFlags) { async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger, featureEnablement) {
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd); const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
const extractionStart = perf_hooks_1.performance.now(); const extractionStart = perf_hooks_1.performance.now();
await createdDBForScannedLanguages(codeql, config, logger, featureFlags); await createdDBForScannedLanguages(codeql, config, logger, featureEnablement);
const extractionTime = perf_hooks_1.performance.now() - extractionStart; const extractionTime = perf_hooks_1.performance.now() - extractionStart;
const trapImportStart = perf_hooks_1.performance.now(); const trapImportStart = perf_hooks_1.performance.now();
for (const language of config.languages) { for (const language of config.languages) {
@ -122,7 +122,7 @@ async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger,
}; };
} }
// Runs queries and creates sarif files in the given folder // Runs queries and creates sarif files in the given folder
async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId, config, logger, featureFlags) { async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId, config, logger, featureEnablement) {
const statusReport = {}; const statusReport = {};
let locPromise = Promise.resolve({}); let locPromise = Promise.resolve({});
const cliCanCountBaseline = await cliCanCountLoC(); const cliCanCountBaseline = await cliCanCountLoC();
@ -136,7 +136,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
config.paths, config.pathsIgnore, config.languages, logger); config.paths, config.pathsIgnore, config.languages, logger);
} }
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd); const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
await util.logCodeScanningConfigInCli(codeql, featureFlags, logger); await util.logCodeScanningConfigInCli(codeql, featureEnablement, logger);
for (const language of config.languages) { for (const language of config.languages) {
const queries = config.queries[language]; const queries = config.queries[language];
const queryFilters = validateQueryFilters(config.originalUserInput["query-filters"]); const queryFilters = validateQueryFilters(config.originalUserInput["query-filters"]);
@ -148,7 +148,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
throw new Error(`Unable to analyse ${language} as no queries were selected for this language`); throw new Error(`Unable to analyse ${language} as no queries were selected for this language`);
} }
try { try {
if (await util.useCodeScanningConfigInCli(codeql, featureFlags)) { if (await util.useCodeScanningConfigInCli(codeql, featureEnablement)) {
// If we are using the codescanning config in the CLI, // If we are using the codescanning config in the CLI,
// much of the work needed to generate the query suites // much of the work needed to generate the query suites
// is done in the CLI. We just need to make a single // is done in the CLI. We just need to make a single
@ -285,7 +285,7 @@ function createQuerySuiteContents(queries, queryFilters) {
return yaml.dump(queries.map((q) => ({ query: q })).concat(queryFilters)); return yaml.dump(queries.map((q) => ({ query: q })).concat(queryFilters));
} }
exports.createQuerySuiteContents = createQuerySuiteContents; exports.createQuerySuiteContents = createQuerySuiteContents;
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger, featureFlags) { async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger, featureEnablement) {
try { try {
await (0, del_1.default)(outputDir, { force: true }); await (0, del_1.default)(outputDir, { force: true });
} }
@ -295,7 +295,7 @@ async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger, f
} }
} }
await fs.promises.mkdir(outputDir, { recursive: true }); await fs.promises.mkdir(outputDir, { recursive: true });
const timings = await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger, featureFlags); const timings = await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger, featureEnablement);
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd); const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
// WARNING: This does not _really_ end tracing, as the tracer will restore its // WARNING: This does not _really_ end tracing, as the tracer will restore its
// critical environment variables and it'll still be active for all processes // critical environment variables and it'll still be active for all processes
@ -304,7 +304,7 @@ async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger, f
// step. // step.
if (await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) { if (await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
// Delete variables as specified by the end-tracing script // Delete variables as specified by the end-tracing script
await (0, tracer_config_1.endTracingForCluster)(config, await util.isGoExtractionReconciliationEnabled(featureFlags), logger); await (0, tracer_config_1.endTracingForCluster)(config, await util.isGoExtractionReconciliationEnabled(featureEnablement), logger);
} }
else { else {
// Delete the tracer config env var to avoid tracing ourselves // Delete the tracer config env var to avoid tracing ourselves

File diff suppressed because one or more lines are too long

4
lib/analyze.test.js generated
View file

@ -131,7 +131,7 @@ const util = __importStar(require("./util"));
builtin: ["foo.ql"], builtin: ["foo.ql"],
custom: [], custom: [],
}; };
const builtinStatusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, (0, logging_1.getRunnerLogger)(true), (0, testing_utils_1.createFeatureFlags)([])); const builtinStatusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, (0, logging_1.getRunnerLogger)(true), (0, testing_utils_1.createFeatures)([]));
const hasPacks = language in packs; const hasPacks = language in packs;
const statusReportKeys = Object.keys(builtinStatusReport).sort(); const statusReportKeys = Object.keys(builtinStatusReport).sort();
if (hasPacks) { if (hasPacks) {
@ -157,7 +157,7 @@ const util = __importStar(require("./util"));
}, },
], ],
}; };
const customStatusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, (0, logging_1.getRunnerLogger)(true), (0, testing_utils_1.createFeatureFlags)([])); const customStatusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, (0, logging_1.getRunnerLogger)(true), (0, testing_utils_1.createFeatures)([]));
t.deepEqual(Object.keys(customStatusReport).length, 2); t.deepEqual(Object.keys(customStatusReport).length, 2);
t.true(`analyze_custom_queries_${language}_duration_ms` in customStatusReport); t.true(`analyze_custom_queries_${language}_duration_ms` in customStatusReport);
const expectedSearchPathsUsed = hasPacks const expectedSearchPathsUsed = hasPacks

File diff suppressed because one or more lines are too long

View file

@ -54,12 +54,12 @@ async function run() {
} }
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)(); const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
(0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger, util_1.Mode.actions); (0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger, util_1.Mode.actions);
const featureFlags = new feature_flags_1.Features(gitHubVersion, (0, api_client_1.getApiDetails)(), (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), logger); const features = new feature_flags_1.Features(gitHubVersion, (0, api_client_1.getApiDetails)(), (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), logger);
const config = await configUtils.getConfig((0, actions_util_1.getTemporaryDirectory)(), logger); const config = await configUtils.getConfig((0, actions_util_1.getTemporaryDirectory)(), logger);
if (config === undefined) { if (config === undefined) {
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?"); throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
} }
languages = await (0, autobuild_1.determineAutobuildLanguages)(config, featureFlags, logger); languages = await (0, autobuild_1.determineAutobuildLanguages)(config, features, logger);
if (languages !== undefined) { if (languages !== undefined) {
const workingDirectory = (0, actions_util_1.getOptionalInput)("working-directory"); const workingDirectory = (0, actions_util_1.getOptionalInput)("working-directory");
if (workingDirectory) { if (workingDirectory) {

View file

@ -1 +1 @@
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,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AT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}

4
lib/autobuild.js generated
View file

@ -23,8 +23,8 @@ exports.runAutobuild = exports.determineAutobuildLanguages = void 0;
const codeql_1 = require("./codeql"); const codeql_1 = require("./codeql");
const languages_1 = require("./languages"); const languages_1 = require("./languages");
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
async function determineAutobuildLanguages(config, featureFlags, logger) { async function determineAutobuildLanguages(config, featureEnablement, logger) {
const isGoExtractionReconciliationEnabled = await util.isGoExtractionReconciliationEnabled(featureFlags); const isGoExtractionReconciliationEnabled = await util.isGoExtractionReconciliationEnabled(featureEnablement);
// Attempt to find a language to autobuild // Attempt to find a language to autobuild
// We want pick the dominant language in the repo from the ones we're able to build // We want pick the dominant language in the repo from the ones we're able to build
// The languages are sorted in order specified by user or by lines of code if we got // The languages are sorted in order specified by user or by lines of code if we got

View file

@ -1 +1 @@
{"version":3,"file":"autobuild.js","sourceRoot":"","sources":["../src/autobuild.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAqC;AAGrC,2CAAyD;AAEzD,6CAA+B;AAExB,KAAK,UAAU,2BAA2B,CAC/C,MAA0B,EAC1B,YAA+B,EAC/B,MAAc;IAEd,MAAM,mCAAmC,GACvC,MAAM,IAAI,CAAC,mCAAmC,CAAC,YAAY,CAAC,CAAC;IAC/D,0CAA0C;IAC1C,mFAAmF;IACnF,oFAAoF;IACpF,4EAA4E;IAC5E,MAAM,kBAAkB,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC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EAAE;QAChD,SAAS,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC,CAAC;KAChD;IACD,uEAAuE;IACvE,wCAAwC;IACxC,IAAI,kBAAkB,CAAC,MAAM,KAAK,2BAA2B,CAAC,MAAM,EAAE;QACpE,SAAS,CAAC,IAAI,CAAC,oBAAQ,CAAC,EAAE,CAAC,CAAC;KAC7B;IAED,MAAM,CAAC,KAAK,CAAC,kBAAkB,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE3D,2EAA2E;IAC3E,4EAA4E;IAC5E,2CAA2C;IAC3C,uEAAuE;IACvE,2EAA2E;IAC3E,uEAAuE;IACvE,yCAAyC;IACzC,IAAI,2BAA2B,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1C,MAAM,CAAC,OAAO,CACZ,oCAAoC,SAAS,CAAC,IAAI,CAChD,OAAO,CACR,8BAA8B,2BAA2B;aACvD,KAAK,CAAC,CAAC,CAAC;aACR,IAAI,CACH,OAAO,CACR,kFAAkF;YACnF,4BAA4B;YAC5B,0NAA0N,CAC7N,CAAC;KACH;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAzFD,kEAyFC;AAEM,KAAK,UAAU,YAAY,CAChC,QAAkB,EAClB,MAA0B,EAC1B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,qCAAqC,QAAQ,OAAO,CAAC,CAAC;IACxE,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AATD,oCASC"}

10
lib/codeql.js generated
View file

@ -488,9 +488,9 @@ async function getCodeQLForCmd(cmd, checkVersion) {
...getExtraOptionsFromEnv(["database", "init"]), ...getExtraOptionsFromEnv(["database", "init"]),
]); ]);
}, },
async databaseInitCluster(config, sourceRoot, processName, processLevel, featureFlags, logger) { async databaseInitCluster(config, sourceRoot, processName, processLevel, featureEnablement, logger) {
const extraArgs = config.languages.map((language) => `--language=${language}`); const extraArgs = config.languages.map((language) => `--language=${language}`);
const isGoExtractionReconciliationEnabled = await util.isGoExtractionReconciliationEnabled(featureFlags); const isGoExtractionReconciliationEnabled = await util.isGoExtractionReconciliationEnabled(featureEnablement);
if (config.languages.filter((l) => (0, languages_1.isTracedLanguage)(l, isGoExtractionReconciliationEnabled, logger)).length > 0) { if (config.languages.filter((l) => (0, languages_1.isTracedLanguage)(l, isGoExtractionReconciliationEnabled, logger)).length > 0) {
extraArgs.push("--begin-tracing"); extraArgs.push("--begin-tracing");
extraArgs.push(...(await (0, trap_caching_1.getTrapCachingExtractorConfigArgs)(config))); extraArgs.push(...(await (0, trap_caching_1.getTrapCachingExtractorConfigArgs)(config)));
@ -515,7 +515,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
extraArgs.push("--no-internal-use-lua-tracing"); extraArgs.push("--no-internal-use-lua-tracing");
} }
} }
const configLocation = await generateCodescanningConfig(codeql, config, featureFlags); const configLocation = await generateCodescanningConfig(codeql, config, featureEnablement);
if (configLocation) { if (configLocation) {
extraArgs.push(`--codescanning-config=${configLocation}`); extraArgs.push(`--codescanning-config=${configLocation}`);
} }
@ -875,9 +875,9 @@ async function runTool(cmd, args = []) {
* @param config The configuration to use. * @param config The configuration to use.
* @returns the path to the generated user configuration file. * @returns the path to the generated user configuration file.
*/ */
async function generateCodescanningConfig(codeql, config, featureFlags) { async function generateCodescanningConfig(codeql, config, featureEnablement) {
var _a; var _a;
if (!(await util.useCodeScanningConfigInCli(codeql, featureFlags))) { if (!(await util.useCodeScanningConfigInCli(codeql, featureEnablement))) {
return; return;
} }
const configLocation = path.resolve(config.tempDir, "user-config.yaml"); const configLocation = path.resolve(config.tempDir, "user-config.yaml");

File diff suppressed because one or more lines are too long

20
lib/codeql.test.js generated
View file

@ -81,7 +81,7 @@ ava_1.default.beforeEach(() => {
trapCacheDownloadTime: 0, trapCacheDownloadTime: 0,
}; };
}); });
async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDir, toolsInput, version, }) { async function mockApiAndSetupCodeQL({ apiDetails, featureEnablement, isPinned, tmpDir, toolsInput, version, }) {
var _a; var _a;
const platform = process.platform === "win32" const platform = process.platform === "win32"
? "win64" ? "win64"
@ -95,7 +95,7 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
(0, nock_1.default)(baseUrl) (0, nock_1.default)(baseUrl)
.get(relativeUrl) .get(relativeUrl)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle${isPinned ? "-pinned" : ""}.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle${isPinned ? "-pinned" : ""}.tar.gz`));
return await codeql.setupCodeQL(toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`, apiDetails !== null && apiDetails !== void 0 ? apiDetails : sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, featureFlags !== null && featureFlags !== void 0 ? featureFlags : (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false); return await codeql.setupCodeQL(toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`, apiDetails !== null && apiDetails !== void 0 ? apiDetails : sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, featureEnablement !== null && featureEnablement !== void 0 ? featureEnablement : (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true), false);
} }
(0, ava_1.default)("download codeql bundle cache", async (t) => { (0, ava_1.default)("download codeql bundle cache", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
@ -138,7 +138,7 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
}); });
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601"); t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
const codeQLConfig = await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false); const codeQLConfig = await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true), false);
t.deepEqual(codeQLConfig.toolsVersion, "0.0.0-20200601"); t.deepEqual(codeQLConfig.toolsVersion, "0.0.0-20200601");
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 1); t.is(cachedVersions.length, 1);
@ -194,8 +194,8 @@ const TOOLCACHE_BYPASS_TEST_CASES = [
false, false,
], ],
]; ];
for (const [isFeatureFlagEnabled, toolsInput, shouldToolcacheBeBypassed,] of TOOLCACHE_BYPASS_TEST_CASES) { for (const [isFeatureEnabled, toolsInput, shouldToolcacheBeBypassed,] of TOOLCACHE_BYPASS_TEST_CASES) {
(0, ava_1.default)(`download codeql bundle ${shouldToolcacheBeBypassed ? "bypasses" : "does not bypass"} toolcache when feature flag ${isFeatureFlagEnabled ? "enabled" : "disabled"} and tools: ${toolsInput} passed`, async (t) => { (0, ava_1.default)(`download codeql bundle ${shouldToolcacheBeBypassed ? "bypasses" : "does not bypass"} toolcache when feature flag ${isFeatureEnabled ? "enabled" : "disabled"} and tools: ${toolsInput} passed`, async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir); (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
await mockApiAndSetupCodeQL({ await mockApiAndSetupCodeQL({
@ -208,7 +208,7 @@ for (const [isFeatureFlagEnabled, toolsInput, shouldToolcacheBeBypassed,] of TOO
await mockApiAndSetupCodeQL({ await mockApiAndSetupCodeQL({
version: defaults.bundleVersion, version: defaults.bundleVersion,
apiDetails: sampleApiDetails, apiDetails: sampleApiDetails,
featureFlags: (0, testing_utils_1.createFeatureFlags)(isFeatureFlagEnabled ? [feature_flags_1.Feature.BypassToolcacheEnabled] : []), featureEnablement: (0, testing_utils_1.createFeatures)(isFeatureEnabled ? [feature_flags_1.Feature.BypassToolcacheEnabled] : []),
toolsInput: { input: toolsInput }, toolsInput: { input: toolsInput },
tmpDir, tmpDir,
}); });
@ -240,7 +240,7 @@ for (const [isFeatureFlagEnabled, toolsInput, shouldToolcacheBeBypassed,] of TOO
(0, nock_1.default)("https://example.githubenterprise.com") (0, nock_1.default)("https://example.githubenterprise.com")
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`) .get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, util.GitHubVariant.GHAE, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false); await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, util.GitHubVariant.GHAE, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true), false);
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 1); t.is(cachedVersions.length, 1);
}); });
@ -332,7 +332,7 @@ for (const [isFeatureFlagEnabled, toolsInput, shouldToolcacheBeBypassed,] of TOO
packsInputCombines: false, packsInputCombines: false,
}, },
}; };
await codeqlObject.databaseInitCluster(thisStubConfig, "", undefined, undefined, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await codeqlObject.databaseInitCluster(thisStubConfig, "", undefined, undefined, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
const args = runnerConstructorStub.firstCall.args[1]; const args = runnerConstructorStub.firstCall.args[1];
// should NOT have used an config file // should NOT have used an config file
const configArg = args.find((arg) => arg.startsWith("--codescanning-config=")); const configArg = args.find((arg) => arg.startsWith("--codescanning-config="));
@ -354,7 +354,7 @@ const injectedConfigMacro = ava_1.default.macro({
tempDir, tempDir,
augmentationProperties, augmentationProperties,
}; };
await codeqlObject.databaseInitCluster(thisStubConfig, "", undefined, undefined, (0, testing_utils_1.createFeatureFlags)([feature_flags_1.Feature.CliConfigFileEnabled]), (0, logging_1.getRunnerLogger)(true)); await codeqlObject.databaseInitCluster(thisStubConfig, "", undefined, undefined, (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CliConfigFileEnabled]), (0, logging_1.getRunnerLogger)(true));
const args = runnerConstructorStub.firstCall.args[1]; const args = runnerConstructorStub.firstCall.args[1];
// should have used an config file // should have used an config file
const configArg = args.find((arg) => arg.startsWith("--codescanning-config=")); const configArg = args.find((arg) => arg.startsWith("--codescanning-config="));
@ -554,7 +554,7 @@ const injectedConfigMacro = ava_1.default.macro({
sinon sinon
.stub(codeqlObject, "getVersion") .stub(codeqlObject, "getVersion")
.resolves(codeql.CODEQL_VERSION_CONFIG_FILES); .resolves(codeql.CODEQL_VERSION_CONFIG_FILES);
await codeqlObject.databaseInitCluster(stubConfig, "", undefined, undefined, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await codeqlObject.databaseInitCluster(stubConfig, "", undefined, undefined, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
const args = runnerConstructorStub.firstCall.args[1]; const args = runnerConstructorStub.firstCall.args[1];
// should have used an config file // should have used an config file
const configArg = args.find((arg) => arg.startsWith("--codescanning-config=")); const configArg = args.find((arg) => arg.startsWith("--codescanning-config="));

File diff suppressed because one or more lines are too long

32
lib/config-utils.js generated
View file

@ -134,7 +134,7 @@ const builtinSuites = ["security-extended", "security-and-quality"];
* Throws an error if suiteName is not a valid builtin suite. * Throws an error if suiteName is not a valid builtin suite.
* May inject ML queries, and the return value will declare if this was done. * May inject ML queries, and the return value will declare if this was done.
*/ */
async function addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, suiteName, featureFlags, configFile) { async function addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, suiteName, featureEnablement, configFile) {
var _a; var _a;
let injectedMlQueries = false; let injectedMlQueries = false;
const found = builtinSuites.find((suite) => suite === suiteName); const found = builtinSuites.find((suite) => suite === suiteName);
@ -151,7 +151,7 @@ async function addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, suite
languages.includes("javascript") && languages.includes("javascript") &&
(found === "security-extended" || found === "security-and-quality") && (found === "security-extended" || found === "security-and-quality") &&
!((_a = packs.javascript) === null || _a === void 0 ? void 0 : _a.some(isMlPoweredJsQueriesPack)) && !((_a = packs.javascript) === null || _a === void 0 ? void 0 : _a.some(isMlPoweredJsQueriesPack)) &&
(await featureFlags.getValue(feature_flags_1.Feature.MlPoweredQueriesEnabled, codeQL))) { (await featureEnablement.getValue(feature_flags_1.Feature.MlPoweredQueriesEnabled, codeQL))) {
if (!packs.javascript) { if (!packs.javascript) {
packs.javascript = []; packs.javascript = [];
} }
@ -226,7 +226,7 @@ async function addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetail
* *
* @returns whether or not we injected ML queries into the packs * @returns whether or not we injected ML queries into the packs
*/ */
async function parseQueryUses(languages, codeQL, resultMap, packs, queryUses, tempDir, workspacePath, apiDetails, featureFlags, logger, configFile) { async function parseQueryUses(languages, codeQL, resultMap, packs, queryUses, tempDir, workspacePath, apiDetails, featureEnablement, logger, configFile) {
queryUses = queryUses.trim(); queryUses = queryUses.trim();
if (queryUses === "") { if (queryUses === "") {
throw new Error(getQueryUsesInvalid(configFile)); throw new Error(getQueryUsesInvalid(configFile));
@ -238,7 +238,7 @@ async function parseQueryUses(languages, codeQL, resultMap, packs, queryUses, te
} }
// Check for one of the builtin suites // Check for one of the builtin suites
if (queryUses.indexOf("/") === -1 && queryUses.indexOf("@") === -1) { if (queryUses.indexOf("/") === -1 && queryUses.indexOf("@") === -1) {
return await addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, queryUses, featureFlags, configFile); return await addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, queryUses, featureEnablement, configFile);
} }
// Otherwise, must be a reference to another repo // Otherwise, must be a reference to another repo
await addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetails, logger, configFile); await addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetails, logger, configFile);
@ -453,13 +453,13 @@ async function getLanguages(codeQL, languagesInput, repository, apiDetails, logg
} }
return parsedLanguages; return parsedLanguages;
} }
async function addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, resultMap, packs, tempDir, workspacePath, apiDetails, featureFlags, logger) { async function addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, resultMap, packs, tempDir, workspacePath, apiDetails, featureEnablement, logger) {
let injectedMlQueries = false; let injectedMlQueries = false;
queriesInput = queriesInput.trim(); queriesInput = queriesInput.trim();
// "+" means "don't override config file" - see shouldAddConfigFileQueries // "+" means "don't override config file" - see shouldAddConfigFileQueries
queriesInput = queriesInput.replace(/^\+/, ""); queriesInput = queriesInput.replace(/^\+/, "");
for (const query of queriesInput.split(",")) { for (const query of queriesInput.split(",")) {
const didInject = await parseQueryUses(languages, codeQL, resultMap, packs, query, tempDir, workspacePath, apiDetails, featureFlags, logger); const didInject = await parseQueryUses(languages, codeQL, resultMap, packs, query, tempDir, workspacePath, apiDetails, featureEnablement, logger);
injectedMlQueries = injectedMlQueries || didInject; injectedMlQueries = injectedMlQueries || didInject;
} }
return injectedMlQueries; return injectedMlQueries;
@ -477,7 +477,7 @@ function shouldAddConfigFileQueries(queriesInput) {
/** /**
* Get the default config for when the user has not supplied one. * Get the default config for when the user has not supplied one.
*/ */
async function getDefaultConfig(languagesInput, rawQueriesInput, rawPacksInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) { async function getDefaultConfig(languagesInput, rawQueriesInput, rawPacksInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureEnablement, logger) {
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger); const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
const queries = {}; const queries = {};
for (const language of languages) { for (const language of languages) {
@ -495,7 +495,7 @@ async function getDefaultConfig(languagesInput, rawQueriesInput, rawPacksInput,
: {}; : {};
if (rawQueriesInput) { if (rawQueriesInput) {
augmentationProperties.injectedMlQueries = augmentationProperties.injectedMlQueries =
await addQueriesAndPacksFromWorkflow(codeQL, rawQueriesInput, languages, queries, packs, tempDir, workspacePath, apiDetails, featureFlags, logger); await addQueriesAndPacksFromWorkflow(codeQL, rawQueriesInput, languages, queries, packs, tempDir, workspacePath, apiDetails, featureEnablement, logger);
} }
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(trapCachingEnabled, codeQL, languages, logger); const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(trapCachingEnabled, codeQL, languages, logger);
return { return {
@ -531,7 +531,7 @@ async function downloadCacheWithTime(trapCachingEnabled, codeQL, languages, logg
/** /**
* Load the config from the given file. * Load the config from the given file.
*/ */
async function loadConfig(languagesInput, rawQueriesInput, rawPacksInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) { async function loadConfig(languagesInput, rawQueriesInput, rawPacksInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureEnablement, logger) {
var _a; var _a;
let parsedYAML; let parsedYAML;
if (isLocal(configFile)) { if (isLocal(configFile)) {
@ -580,7 +580,7 @@ async function loadConfig(languagesInput, rawQueriesInput, rawPacksInput, config
// in the config file. // in the config file.
if (rawQueriesInput) { if (rawQueriesInput) {
augmentationProperties.injectedMlQueries = augmentationProperties.injectedMlQueries =
await addQueriesAndPacksFromWorkflow(codeQL, rawQueriesInput, languages, queries, packs, tempDir, workspacePath, apiDetails, featureFlags, logger); await addQueriesAndPacksFromWorkflow(codeQL, rawQueriesInput, languages, queries, packs, tempDir, workspacePath, apiDetails, featureEnablement, logger);
} }
if (shouldAddConfigFileQueries(rawQueriesInput) && if (shouldAddConfigFileQueries(rawQueriesInput) &&
QUERIES_PROPERTY in parsedYAML) { QUERIES_PROPERTY in parsedYAML) {
@ -592,7 +592,7 @@ async function loadConfig(languagesInput, rawQueriesInput, rawPacksInput, config
if (typeof query[QUERIES_USES_PROPERTY] !== "string") { if (typeof query[QUERIES_USES_PROPERTY] !== "string") {
throw new Error(getQueriesMissingUses(configFile)); throw new Error(getQueriesMissingUses(configFile));
} }
await parseQueryUses(languages, codeQL, queries, packs, query[QUERIES_USES_PROPERTY], tempDir, workspacePath, apiDetails, featureFlags, logger, configFile); await parseQueryUses(languages, codeQL, queries, packs, query[QUERIES_USES_PROPERTY], tempDir, workspacePath, apiDetails, featureEnablement, logger, configFile);
} }
} }
if (PATHS_IGNORE_PROPERTY in parsedYAML) { if (PATHS_IGNORE_PROPERTY in parsedYAML) {
@ -882,16 +882,16 @@ function dbLocationOrDefault(dbLocation, tempDir) {
* This will parse the config from the user input if present, or generate * This will parse the config from the user input if present, or generate
* a default config. The parsed config is then stored to a known location. * a default config. The parsed config is then stored to a known location.
*/ */
async function initConfig(languagesInput, queriesInput, packsInput, registriesInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) { async function initConfig(languagesInput, queriesInput, packsInput, registriesInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureEnablement, logger) {
var _a, _b, _c; var _a, _b, _c;
let config; let config;
// If no config file was provided create an empty one // If no config file was provided create an empty one
if (!configFile) { if (!configFile) {
logger.debug("No configuration file was provided"); logger.debug("No configuration file was provided");
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger); config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureEnablement, logger);
} }
else { else {
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger); config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureEnablement, logger);
} }
// The list of queries should not be empty for any language. If it is then // The list of queries should not be empty for any language. If it is then
// it is a user configuration error. // it is a user configuration error.
@ -907,8 +907,8 @@ async function initConfig(languagesInput, queriesInput, packsInput, registriesIn
// When using the codescanning config in the CLI, pack downloads // When using the codescanning config in the CLI, pack downloads
// happen in the CLI during the `database init` command, so no need // happen in the CLI during the `database init` command, so no need
// to download them here. // to download them here.
await (0, util_1.logCodeScanningConfigInCli)(codeQL, featureFlags, logger); await (0, util_1.logCodeScanningConfigInCli)(codeQL, featureEnablement, logger);
if (!(await (0, util_1.useCodeScanningConfigInCli)(codeQL, featureFlags))) { if (!(await (0, util_1.useCodeScanningConfigInCli)(codeQL, featureEnablement))) {
const registries = parseRegistries(registriesInput); const registries = parseRegistries(registriesInput);
await downloadPacks(codeQL, config.languages, config.packs, registries, apiDetails, config.tempDir, logger); await downloadPacks(codeQL, config.languages, config.packs, registries, apiDetails, config.tempDir, logger);
} }

File diff suppressed because one or more lines are too long

View file

@ -94,8 +94,8 @@ function mockListLanguages(languages) {
return { packs: [] }; return { packs: [] };
}, },
}); });
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), logger); const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), logger);
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), logger)); t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), logger));
}); });
}); });
(0, ava_1.default)("loading config saves config", async (t) => { (0, ava_1.default)("loading config saves config", async (t) => {
@ -120,7 +120,7 @@ function mockListLanguages(languages) {
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir))); t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
// Sanity check that getConfig returns undefined before we have called initConfig // Sanity check that getConfig returns undefined before we have called initConfig
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined); t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), logger); const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), logger);
// The saved config file should now exist // The saved config file should now exist
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir))); t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
// And that same newly-initialised config should now be returned by getConfig // And that same newly-initialised config should now be returned by getConfig
@ -136,7 +136,7 @@ function mockListLanguages(languages) {
(0, ava_1.default)("load input outside of workspace", async (t) => { (0, ava_1.default)("load input outside of workspace", async (t) => {
return await util.withTmpDir(async (tmpDir) => { return await util.withTmpDir(async (tmpDir) => {
try { try {
await configUtils.initConfig(undefined, undefined, undefined, undefined, "../input", undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(undefined, undefined, undefined, undefined, "../input", undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@ -149,7 +149,7 @@ function mockListLanguages(languages) {
// no filename given, just a repo // no filename given, just a repo
const configFile = "octo-org/codeql-config@main"; const configFile = "octo-org/codeql-config@main";
try { try {
await configUtils.initConfig(undefined, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(undefined, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@ -163,7 +163,7 @@ function mockListLanguages(languages) {
const configFile = "input"; const configFile = "input";
t.false(fs.existsSync(path.join(tmpDir, configFile))); t.false(fs.existsSync(path.join(tmpDir, configFile)));
try { try {
await configUtils.initConfig(languages, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@ -239,7 +239,7 @@ function mockListLanguages(languages) {
}; };
const languages = "javascript"; const languages = "javascript";
const configFilePath = createConfigFile(inputFileContents, tmpDir); const configFilePath = createConfigFile(inputFileContents, tmpDir);
const actualConfig = await configUtils.initConfig(languages, undefined, undefined, undefined, configFilePath, undefined, false, false, "my-artifact", "my-db", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const actualConfig = await configUtils.initConfig(languages, undefined, undefined, undefined, configFilePath, undefined, false, false, "my-artifact", "my-db", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
// Should exactly equal the object we constructed earlier // Should exactly equal the object we constructed earlier
t.deepEqual(actualConfig, expectedConfig); t.deepEqual(actualConfig, expectedConfig);
}); });
@ -278,7 +278,7 @@ function mockListLanguages(languages) {
fs.mkdirSync(path.join(tmpDir, "foo")); fs.mkdirSync(path.join(tmpDir, "foo"));
const languages = "javascript"; const languages = "javascript";
const configFilePath = createConfigFile(inputFileContents, tmpDir); const configFilePath = createConfigFile(inputFileContents, tmpDir);
await configUtils.initConfig(languages, undefined, undefined, undefined, configFilePath, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, undefined, undefined, undefined, configFilePath, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolve queries was called correctly // Check resolve queries was called correctly
t.deepEqual(resolveQueriesArgs.length, 1); t.deepEqual(resolveQueriesArgs.length, 1);
t.deepEqual(resolveQueriesArgs[0].queries, [ t.deepEqual(resolveQueriesArgs[0].queries, [
@ -324,7 +324,7 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
const languages = "javascript"; const languages = "javascript";
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, configFilePath, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const config = await configUtils.initConfig(languages, undefined, undefined, undefined, configFilePath, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolveQueries was called correctly // Check resolveQueries was called correctly
// It'll be called once for the default queries // It'll be called once for the default queries
// and once for `./foo` from the config file. // and once for `./foo` from the config file.
@ -360,7 +360,7 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
const languages = "javascript"; const languages = "javascript";
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, configFilePath, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, configFilePath, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolveQueries was called correctly // Check resolveQueries was called correctly
// It'll be called once for the default queries and once for `./override`, // It'll be called once for the default queries and once for `./override`,
// but won't be called for './foo' from the config file. // but won't be called for './foo' from the config file.
@ -395,7 +395,7 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
const languages = "javascript"; const languages = "javascript";
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, configFilePath, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, configFilePath, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolveQueries was called correctly // Check resolveQueries was called correctly
// It'll be called once for `./workflow-query`, // It'll be called once for `./workflow-query`,
// but won't be called for the default one since that was disabled // but won't be called for the default one since that was disabled
@ -424,7 +424,7 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
const languages = "javascript"; const languages = "javascript";
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolveQueries was called correctly: // Check resolveQueries was called correctly:
// It'll be called once for the default queries, // It'll be called once for the default queries,
// and then once for each of the two queries from the workflow // and then once for each of the two queries from the workflow
@ -466,7 +466,7 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
const languages = "javascript"; const languages = "javascript";
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, configFilePath, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, configFilePath, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolveQueries was called correctly // Check resolveQueries was called correctly
// It'll be called once for the default queries, // It'll be called once for the default queries,
// once for each of additional1 and additional2, // once for each of additional1 and additional2,
@ -508,7 +508,7 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
try { try {
await configUtils.initConfig(languages, queries, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, queries, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
t.fail("initConfig did not throw error"); t.fail("initConfig did not throw error");
} }
catch (err) { catch (err) {
@ -554,7 +554,7 @@ function queriesToResolvedQueryForm(queries) {
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true }); fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
const configFile = "octo-org/codeql-config/config.yaml@main"; const configFile = "octo-org/codeql-config/config.yaml@main";
const languages = "javascript"; const languages = "javascript";
await configUtils.initConfig(languages, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
t.assert(spyGetContents.called); t.assert(spyGetContents.called);
}); });
}); });
@ -564,7 +564,7 @@ function queriesToResolvedQueryForm(queries) {
mockGetContents(dummyResponse); mockGetContents(dummyResponse);
const repoReference = "octo-org/codeql-config/config.yaml@main"; const repoReference = "octo-org/codeql-config/config.yaml@main";
try { try {
await configUtils.initConfig(undefined, undefined, undefined, undefined, repoReference, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(undefined, undefined, undefined, undefined, repoReference, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@ -580,7 +580,7 @@ function queriesToResolvedQueryForm(queries) {
mockGetContents(dummyResponse); mockGetContents(dummyResponse);
const repoReference = "octo-org/codeql-config/config.yaml@main"; const repoReference = "octo-org/codeql-config/config.yaml@main";
try { try {
await configUtils.initConfig(undefined, undefined, undefined, undefined, repoReference, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(undefined, undefined, undefined, undefined, repoReference, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@ -600,7 +600,7 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
try { try {
await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@ -612,7 +612,7 @@ function queriesToResolvedQueryForm(queries) {
return await util.withTmpDir(async (tmpDir) => { return await util.withTmpDir(async (tmpDir) => {
const languages = "rubbish,english"; const languages = "rubbish,english";
try { try {
await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@ -643,7 +643,7 @@ function queriesToResolvedQueryForm(queries) {
const configFile = path.join(tmpDir, "codeql-config.yaml"); const configFile = path.join(tmpDir, "codeql-config.yaml");
fs.writeFileSync(configFile, inputFileContents); fs.writeFileSync(configFile, inputFileContents);
const languages = "javascript"; const languages = "javascript";
const { packs } = await configUtils.initConfig(languages, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const { packs } = await configUtils.initConfig(languages, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
t.deepEqual(packs, { t.deepEqual(packs, {
[languages_1.Language.javascript]: ["a/b@1.2.3"], [languages_1.Language.javascript]: ["a/b@1.2.3"],
}); });
@ -680,7 +680,7 @@ function queriesToResolvedQueryForm(queries) {
fs.writeFileSync(configFile, inputFileContents); fs.writeFileSync(configFile, inputFileContents);
fs.mkdirSync(path.join(tmpDir, "foo")); fs.mkdirSync(path.join(tmpDir, "foo"));
const languages = "javascript,python,cpp"; const languages = "javascript,python,cpp";
const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
t.deepEqual(packs, { t.deepEqual(packs, {
[languages_1.Language.javascript]: ["a/b@1.2.3"], [languages_1.Language.javascript]: ["a/b@1.2.3"],
[languages_1.Language.python]: ["c/d@1.2.3"], [languages_1.Language.python]: ["c/d@1.2.3"],
@ -726,7 +726,7 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
const inputFile = path.join(tmpDir, configFile); const inputFile = path.join(tmpDir, configFile);
fs.writeFileSync(inputFile, inputFileContents, "utf8"); fs.writeFileSync(inputFile, inputFileContents, "utf8");
try { try {
await configUtils.initConfig(languages, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, undefined, undefined, undefined, configFile, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@ -987,7 +987,7 @@ const mlPoweredQueriesMacro = ava_1.default.macro({
return { packs: [] }; return { packs: [] };
}, },
}); });
const { packs } = await configUtils.initConfig("javascript", queriesInput, packsInput, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatureFlags)(isMlPoweredQueriesFlagEnabled ? [feature_flags_1.Feature.MlPoweredQueriesEnabled] : []), (0, logging_1.getRunnerLogger)(true)); const { packs } = await configUtils.initConfig("javascript", queriesInput, packsInput, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, testing_utils_1.createFeatures)(isMlPoweredQueriesFlagEnabled ? [feature_flags_1.Feature.MlPoweredQueriesEnabled] : []), (0, logging_1.getRunnerLogger)(true));
if (expectedVersionString !== undefined) { if (expectedVersionString !== undefined) {
t.deepEqual(packs, { t.deepEqual(packs, {
[languages_1.Language.javascript]: [ [languages_1.Language.javascript]: [

File diff suppressed because one or more lines are too long

View file

@ -30,9 +30,9 @@ for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
(0, ava_1.default)(`All feature flags are disabled if running against ${variant.description}`, async (t) => { (0, ava_1.default)(`All feature flags are disabled if running against ${variant.description}`, async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => { await (0, util_1.withTmpDir)(async (tmpDir) => {
const loggedMessages = []; const loggedMessages = [];
const featureFlags = setUpTests(tmpDir, (0, testing_utils_1.getRecordingLogger)(loggedMessages), variant.gitHubVersion); const featureEnablement = setUpTests(tmpDir, (0, testing_utils_1.getRecordingLogger)(loggedMessages), variant.gitHubVersion);
for (const flag of Object.values(feature_flags_1.Feature)) { for (const flag of Object.values(feature_flags_1.Feature)) {
t.false(await featureFlags.getValue(flag, includeCodeQlIfRequired(flag))); t.false(await featureEnablement.getValue(flag, includeCodeQlIfRequired(flag)));
} }
t.assert(loggedMessages.find((v) => v.type === "debug" && t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message === v.message ===
@ -43,11 +43,10 @@ for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
(0, ava_1.default)("API response missing", async (t) => { (0, ava_1.default)("API response missing", async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => { await (0, util_1.withTmpDir)(async (tmpDir) => {
const loggedMessages = []; const loggedMessages = [];
const featureFlags = setUpTests(tmpDir, (0, testing_utils_1.getRecordingLogger)(loggedMessages)); const featureEnablement = setUpTests(tmpDir, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(403, {}); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(403, {});
for (const flag of Object.values(feature_flags_1.Feature)) { for (const flag of Object.values(feature_flags_1.Feature)) {
t.assert((await featureFlags.getValue(flag, includeCodeQlIfRequired(flag))) === t.assert((await featureEnablement.getValue(flag, includeCodeQlIfRequired(flag))) === false);
false);
} }
assertAllFeaturesUndefinedInApi(t, loggedMessages); assertAllFeaturesUndefinedInApi(t, loggedMessages);
}); });
@ -55,100 +54,99 @@ for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
(0, ava_1.default)("Feature flags are disabled if they're not returned in API response", async (t) => { (0, ava_1.default)("Feature flags are disabled if they're not returned in API response", async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => { await (0, util_1.withTmpDir)(async (tmpDir) => {
const loggedMessages = []; const loggedMessages = [];
const featureFlags = setUpTests(tmpDir, (0, testing_utils_1.getRecordingLogger)(loggedMessages)); const featureEnablement = setUpTests(tmpDir, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {}); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
for (const flag of Object.values(feature_flags_1.Feature)) { for (const flag of Object.values(feature_flags_1.Feature)) {
t.assert((await featureFlags.getValue(flag, includeCodeQlIfRequired(flag))) === t.assert((await featureEnablement.getValue(flag, includeCodeQlIfRequired(flag))) === false);
false);
} }
assertAllFeaturesUndefinedInApi(t, loggedMessages); assertAllFeaturesUndefinedInApi(t, loggedMessages);
}); });
}); });
(0, ava_1.default)("Feature flags exception is propagated if the API request errors", async (t) => { (0, ava_1.default)("Feature flags exception is propagated if the API request errors", async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => { await (0, util_1.withTmpDir)(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(500, {}); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(500, {});
await t.throwsAsync(async () => featureFlags.getValue(feature_flags_1.Feature.MlPoweredQueriesEnabled, includeCodeQlIfRequired(feature_flags_1.Feature.MlPoweredQueriesEnabled)), { await t.throwsAsync(async () => featureEnablement.getValue(feature_flags_1.Feature.MlPoweredQueriesEnabled, includeCodeQlIfRequired(feature_flags_1.Feature.MlPoweredQueriesEnabled)), {
message: "Encountered an error while trying to determine feature enablement: Error: some error message", message: "Encountered an error while trying to determine feature enablement: Error: some error message",
}); });
}); });
}); });
for (const featureFlag of Object.keys(feature_flags_1.featureConfig)) { for (const feature of Object.keys(feature_flags_1.featureConfig)) {
(0, ava_1.default)(`Only feature flag '${featureFlag}' is enabled if enabled in the API response. Other flags disabled`, async (t) => { (0, ava_1.default)(`Only feature flag '${feature}' is enabled if enabled in the API response. Other flags disabled`, async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => { await (0, util_1.withTmpDir)(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
// set all feature flags to false except the one we're testing // set all feature flags to false except the one we're testing
const expectedFeatureFlags = {}; const expectedFeatureEnablement = {};
for (const f of Object.keys(feature_flags_1.featureConfig)) { for (const f of Object.keys(feature_flags_1.featureConfig)) {
expectedFeatureFlags[f] = f === featureFlag; expectedFeatureEnablement[f] = f === feature;
} }
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureEnablement);
// retrieve the values of the actual feature flags // retrieve the values of the actual feature flags
const actualFeatureFlags = {}; const actualFeatureEnablement = {};
for (const f of Object.keys(feature_flags_1.featureConfig)) { for (const f of Object.keys(feature_flags_1.featureConfig)) {
actualFeatureFlags[f] = await featureFlags.getValue(f, includeCodeQlIfRequired(f)); actualFeatureEnablement[f] = await featureEnablement.getValue(f, includeCodeQlIfRequired(f));
} }
// Alls flags should be false except the one we're testing // Alls flags should be false except the one we're testing
t.deepEqual(actualFeatureFlags, expectedFeatureFlags); t.deepEqual(actualFeatureEnablement, expectedFeatureEnablement);
}); });
}); });
(0, ava_1.default)(`Only feature flag '${featureFlag}' is enabled if the associated environment variable is true. Others disabled.`, async (t) => { (0, ava_1.default)(`Only feature flag '${feature}' is enabled if the associated environment variable is true. Others disabled.`, async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => { await (0, util_1.withTmpDir)(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
const expectedFeatureFlags = initializeFeatures(false); const expectedFeatureEnablement = initializeFeatures(false);
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureEnablement);
// feature flag should be disabled initially // feature flag should be disabled initially
t.assert(!(await featureFlags.getValue(featureFlag, includeCodeQlIfRequired(featureFlag)))); t.assert(!(await featureEnablement.getValue(feature, includeCodeQlIfRequired(feature))));
// set env var to true and check that the feature flag is now enabled // set env var to true and check that the feature flag is now enabled
process.env[feature_flags_1.featureConfig[featureFlag].envVar] = "true"; process.env[feature_flags_1.featureConfig[feature].envVar] = "true";
t.assert(await featureFlags.getValue(featureFlag, includeCodeQlIfRequired(featureFlag))); t.assert(await featureEnablement.getValue(feature, includeCodeQlIfRequired(feature)));
}); });
}); });
(0, ava_1.default)(`Feature flag '${featureFlag}' is disabled if the associated environment variable is false, even if enabled in API`, async (t) => { (0, ava_1.default)(`Feature flag '${feature}' is disabled if the associated environment variable is false, even if enabled in API`, async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => { await (0, util_1.withTmpDir)(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
const expectedFeatureFlags = initializeFeatures(true); const expectedFeatureEnablement = initializeFeatures(true);
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureEnablement);
// feature flag should be enabled initially // feature flag should be enabled initially
t.assert(await featureFlags.getValue(featureFlag, includeCodeQlIfRequired(featureFlag))); t.assert(await featureEnablement.getValue(feature, includeCodeQlIfRequired(feature)));
// set env var to false and check that the feature flag is now disabled // set env var to false and check that the feature flag is now disabled
process.env[feature_flags_1.featureConfig[featureFlag].envVar] = "false"; process.env[feature_flags_1.featureConfig[feature].envVar] = "false";
t.assert(!(await featureFlags.getValue(featureFlag, includeCodeQlIfRequired(featureFlag)))); t.assert(!(await featureEnablement.getValue(feature, includeCodeQlIfRequired(feature))));
}); });
}); });
if (feature_flags_1.featureConfig[featureFlag].minimumVersion !== undefined) { if (feature_flags_1.featureConfig[feature].minimumVersion !== undefined) {
(0, ava_1.default)(`Getting Feature Flag '${featureFlag} should throw if no codeql is provided`, async (t) => { (0, ava_1.default)(`Getting Feature Flag '${feature} should throw if no codeql is provided`, async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => { await (0, util_1.withTmpDir)(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
const expectedFeatureFlags = initializeFeatures(true); const expectedFeatureEnablement = initializeFeatures(true);
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureEnablement);
await t.throwsAsync(async () => featureFlags.getValue(featureFlag), { await t.throwsAsync(async () => featureEnablement.getValue(feature), {
message: `Internal error: A minimum version is specified for feature ${featureFlag}, but no instance of CodeQL was provided.`, message: `Internal error: A minimum version is specified for feature ${feature}, but no instance of CodeQL was provided.`,
}); });
}); });
}); });
} }
if (feature_flags_1.featureConfig[featureFlag].minimumVersion !== undefined) { if (feature_flags_1.featureConfig[feature].minimumVersion !== undefined) {
(0, ava_1.default)(`Feature flag '${featureFlag}' is disabled if the minimum CLI version is below ${feature_flags_1.featureConfig[featureFlag].minimumVersion}`, async (t) => { (0, ava_1.default)(`Feature flag '${feature}' is disabled if the minimum CLI version is below ${feature_flags_1.featureConfig[feature].minimumVersion}`, async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => { await (0, util_1.withTmpDir)(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
const expectedFeatureFlags = initializeFeatures(true); const expectedFeatureEnablement = initializeFeatures(true);
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureEnablement);
// feature flag should be disabled when an old CLI version is set // feature flag should be disabled when an old CLI version is set
let codeql = (0, testing_utils_1.mockCodeQLVersion)("2.0.0"); let codeql = (0, testing_utils_1.mockCodeQLVersion)("2.0.0");
t.assert(!(await featureFlags.getValue(featureFlag, codeql))); t.assert(!(await featureEnablement.getValue(feature, codeql)));
// even setting the env var to true should not enable the feature flag if // even setting the env var to true should not enable the feature flag if
// the minimum CLI version is not met // the minimum CLI version is not met
process.env[feature_flags_1.featureConfig[featureFlag].envVar] = "true"; process.env[feature_flags_1.featureConfig[feature].envVar] = "true";
t.assert(!(await featureFlags.getValue(featureFlag, codeql))); t.assert(!(await featureEnablement.getValue(feature, codeql)));
// feature flag should be enabled when a new CLI version is set // feature flag should be enabled when a new CLI version is set
// and env var is not set // and env var is not set
process.env[feature_flags_1.featureConfig[featureFlag].envVar] = ""; process.env[feature_flags_1.featureConfig[feature].envVar] = "";
codeql = (0, testing_utils_1.mockCodeQLVersion)(feature_flags_1.featureConfig[featureFlag].minimumVersion); codeql = (0, testing_utils_1.mockCodeQLVersion)(feature_flags_1.featureConfig[feature].minimumVersion);
t.assert(await featureFlags.getValue(featureFlag, codeql)); t.assert(await featureEnablement.getValue(feature, codeql));
// set env var to false and check that the feature flag is now disabled // set env var to false and check that the feature flag is now disabled
process.env[feature_flags_1.featureConfig[featureFlag].envVar] = "false"; process.env[feature_flags_1.featureConfig[feature].envVar] = "false";
t.assert(!(await featureFlags.getValue(featureFlag, codeql))); t.assert(!(await featureEnablement.getValue(feature, codeql)));
}); });
}); });
} }
@ -164,9 +162,9 @@ for (const featureFlag of Object.keys(feature_flags_1.featureConfig)) {
t.assert(Object.values(feature_flags_1.featureConfig).length > 0, "There should be at least one feature flag"); t.assert(Object.values(feature_flags_1.featureConfig).length > 0, "There should be at least one feature flag");
}); });
function assertAllFeaturesUndefinedInApi(t, loggedMessages) { function assertAllFeaturesUndefinedInApi(t, loggedMessages) {
for (const featureFlag of Object.keys(feature_flags_1.featureConfig)) { for (const feature of Object.keys(feature_flags_1.featureConfig)) {
t.assert(loggedMessages.find((v) => v.type === "debug" && t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message.includes(featureFlag) && v.message.includes(feature) &&
v.message.includes("considering it disabled")) !== undefined); v.message.includes("considering it disabled")) !== undefined);
} }
} }

File diff suppressed because one or more lines are too long

14
lib/init-action.js generated
View file

@ -88,22 +88,22 @@ async function run() {
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)(); const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
(0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger, util_1.Mode.actions); (0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger, util_1.Mode.actions);
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")); const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
const featureFlags = new feature_flags_1.Features(gitHubVersion, apiDetails, repositoryNwo, logger); const features = new feature_flags_1.Features(gitHubVersion, apiDetails, repositoryNwo, logger);
try { try {
const workflowErrors = await (0, actions_util_1.validateWorkflow)(); const workflowErrors = await (0, actions_util_1.validateWorkflow)();
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "starting", startedAt, workflowErrors)))) { if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "starting", startedAt, workflowErrors)))) {
return; return;
} }
const initCodeQLResult = await (0, init_1.initCodeQL)((0, actions_util_1.getOptionalInput)("tools"), apiDetails, (0, actions_util_1.getTemporaryDirectory)(), gitHubVersion.type, featureFlags, logger); const initCodeQLResult = await (0, init_1.initCodeQL)((0, actions_util_1.getOptionalInput)("tools"), apiDetails, (0, actions_util_1.getTemporaryDirectory)(), gitHubVersion.type, features, logger);
codeql = initCodeQLResult.codeql; codeql = initCodeQLResult.codeql;
toolsVersion = initCodeQLResult.toolsVersion; toolsVersion = initCodeQLResult.toolsVersion;
await (0, util_1.enrichEnvironment)(util_1.Mode.actions, codeql); await (0, util_1.enrichEnvironment)(util_1.Mode.actions, codeql);
config = await (0, init_1.initConfig)((0, actions_util_1.getOptionalInput)("languages"), (0, actions_util_1.getOptionalInput)("queries"), (0, actions_util_1.getOptionalInput)("packs"), (0, actions_util_1.getOptionalInput)("registries"), (0, actions_util_1.getOptionalInput)("config-file"), (0, actions_util_1.getOptionalInput)("db-location"), await getTrapCachingEnabled(featureFlags), config = await (0, init_1.initConfig)((0, actions_util_1.getOptionalInput)("languages"), (0, actions_util_1.getOptionalInput)("queries"), (0, actions_util_1.getOptionalInput)("packs"), (0, actions_util_1.getOptionalInput)("registries"), (0, actions_util_1.getOptionalInput)("config-file"), (0, actions_util_1.getOptionalInput)("db-location"), await getTrapCachingEnabled(features),
// Debug mode is enabled if: // Debug mode is enabled if:
// - The `init` Action is passed `debug: true`. // - The `init` Action is passed `debug: true`.
// - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow), // - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow),
// or by setting the `ACTIONS_STEP_DEBUG` secret to `true`). // or by setting the `ACTIONS_STEP_DEBUG` secret to `true`).
(0, actions_util_1.getOptionalInput)("debug") === "true" || core.isDebug(), (0, actions_util_1.getOptionalInput)("debug-artifact-name") || util_1.DEFAULT_DEBUG_ARTIFACT_NAME, (0, actions_util_1.getOptionalInput)("debug-database-name") || util_1.DEFAULT_DEBUG_DATABASE_NAME, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), codeql, (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, featureFlags, logger); (0, actions_util_1.getOptionalInput)("debug") === "true" || core.isDebug(), (0, actions_util_1.getOptionalInput)("debug-artifact-name") || util_1.DEFAULT_DEBUG_ARTIFACT_NAME, (0, actions_util_1.getOptionalInput)("debug-database-name") || util_1.DEFAULT_DEBUG_DATABASE_NAME, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), codeql, (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, features, logger);
if (config.languages.includes(languages_1.Language.python) && if (config.languages.includes(languages_1.Language.python) &&
(0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") { (0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") {
try { try {
@ -138,7 +138,7 @@ async function run() {
(0, util_1.getMemoryFlagValue)((0, actions_util_1.getOptionalInput)("ram")).toString()); (0, util_1.getMemoryFlagValue)((0, actions_util_1.getOptionalInput)("ram")).toString());
core.exportVariable("CODEQL_THREADS", (0, util_1.getThreadsFlagValue)((0, actions_util_1.getOptionalInput)("threads"), logger).toString()); core.exportVariable("CODEQL_THREADS", (0, util_1.getThreadsFlagValue)((0, actions_util_1.getOptionalInput)("threads"), logger).toString());
const sourceRoot = path.resolve((0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), (0, actions_util_1.getOptionalInput)("source-root") || ""); const sourceRoot = path.resolve((0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), (0, actions_util_1.getOptionalInput)("source-root") || "");
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, "Runner.Worker.exe", undefined, featureFlags, logger); const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, "Runner.Worker.exe", undefined, features, logger);
if (tracerConfig !== undefined) { if (tracerConfig !== undefined) {
for (const [key, value] of Object.entries(tracerConfig.env)) { for (const [key, value] of Object.entries(tracerConfig.env)) {
core.exportVariable(key, value); core.exportVariable(key, value);
@ -158,12 +158,12 @@ async function run() {
} }
await sendSuccessStatusReport(startedAt, config, toolsVersion, logger); await sendSuccessStatusReport(startedAt, config, toolsVersion, logger);
} }
async function getTrapCachingEnabled(featureFlags) { async function getTrapCachingEnabled(featureEnablement) {
const trapCaching = (0, actions_util_1.getOptionalInput)("trap-caching"); const trapCaching = (0, actions_util_1.getOptionalInput)("trap-caching");
if (trapCaching !== undefined) { if (trapCaching !== undefined) {
return trapCaching === "true"; return trapCaching === "true";
} }
return await featureFlags.getValue(feature_flags_1.Feature.TrapCachingEnabled); return await featureEnablement.getValue(feature_flags_1.Feature.TrapCachingEnabled);
} }
async function runWrapper() { async function runWrapper() {
try { try {

File diff suppressed because one or more lines are too long

14
lib/init.js generated
View file

@ -30,28 +30,28 @@ const configUtils = __importStar(require("./config-utils"));
const tracer_config_1 = require("./tracer-config"); const tracer_config_1 = require("./tracer-config");
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
const util_1 = require("./util"); const util_1 = require("./util");
async function initCodeQL(codeqlURL, apiDetails, tempDir, variant, featureFlags, logger) { async function initCodeQL(codeqlURL, apiDetails, tempDir, variant, featureEnablement, logger) {
logger.startGroup("Setup CodeQL tools"); logger.startGroup("Setup CodeQL tools");
const { codeql, toolsVersion } = await (0, codeql_1.setupCodeQL)(codeqlURL, apiDetails, tempDir, variant, featureFlags, logger, true); const { codeql, toolsVersion } = await (0, codeql_1.setupCodeQL)(codeqlURL, apiDetails, tempDir, variant, featureEnablement, logger, true);
await codeql.printVersion(); await codeql.printVersion();
logger.endGroup(); logger.endGroup();
return { codeql, toolsVersion }; return { codeql, toolsVersion };
} }
exports.initCodeQL = initCodeQL; exports.initCodeQL = initCodeQL;
async function initConfig(languagesInput, queriesInput, packsInput, registriesInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) { async function initConfig(languagesInput, queriesInput, packsInput, registriesInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureEnablement, logger) {
logger.startGroup("Load language configuration"); logger.startGroup("Load language configuration");
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, registriesInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger); const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, registriesInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureEnablement, logger);
analysisPaths.printPathFiltersWarning(config, logger); analysisPaths.printPathFiltersWarning(config, logger);
logger.endGroup(); logger.endGroup();
return config; return config;
} }
exports.initConfig = initConfig; exports.initConfig = initConfig;
async function runInit(codeql, config, sourceRoot, processName, processLevel, featureFlags, logger) { async function runInit(codeql, config, sourceRoot, processName, processLevel, featureEnablement, logger) {
fs.mkdirSync(config.dbLocation, { recursive: true }); fs.mkdirSync(config.dbLocation, { recursive: true });
try { try {
if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) { if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
// Init a database cluster // Init a database cluster
await codeql.databaseInitCluster(config, sourceRoot, processName, processLevel, featureFlags, logger); await codeql.databaseInitCluster(config, sourceRoot, processName, processLevel, featureEnablement, logger);
} }
else { else {
for (const language of config.languages) { for (const language of config.languages) {
@ -63,7 +63,7 @@ async function runInit(codeql, config, sourceRoot, processName, processLevel, fe
catch (e) { catch (e) {
throw processError(e); throw processError(e);
} }
return await (0, tracer_config_1.getCombinedTracerConfig)(config, codeql, await util.isGoExtractionReconciliationEnabled(featureFlags), logger); return await (0, tracer_config_1.getCombinedTracerConfig)(config, codeql, await util.isGoExtractionReconciliationEnabled(featureEnablement), logger);
} }
exports.runInit = runInit; exports.runInit = runInit;
/** /**

View file

@ -1 +1 @@
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAEpD,gEAAkD;AAElD,qCAA2E;AAC3E,4DAA8C;AAI9C,mDAAwE;AACxE,6CAA+B;AAC/B,iCAA4C;AAErC,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAA4B,EAC5B,OAAe,EACf,OAA2B,EAC3B,YAA+B,EAC/B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,oBAAW,EAChD,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,MAAM,EACN,IAAI,CACL,CAAC;IACF,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAClC,CAAC;AArBD,gCAqBC;AAEM,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O,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;gBACpE,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,gFAAgF,CAAC,IAAI;YACnF,qGAAqG;YACrG,oGAAoG;YACpG,iDAAiD,CACpD,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAzCD,8CAyCC"}

12
lib/runner.js generated
View file

@ -152,14 +152,14 @@ program
codeql = await (0, codeql_1.getCodeQL)(cmd.codeqlPath); codeql = await (0, codeql_1.getCodeQL)(cmd.codeqlPath);
} }
else { else {
codeql = (await (0, init_1.initCodeQL)(undefined, apiDetails, tempDir, gitHubVersion.type, (0, testing_utils_1.createFeatureFlags)([]), logger)).codeql; codeql = (await (0, init_1.initCodeQL)(undefined, apiDetails, tempDir, gitHubVersion.type, (0, testing_utils_1.createFeatures)([]), logger)).codeql;
} }
await (0, util_1.enrichEnvironment)(util_1.Mode.runner, codeql); await (0, util_1.enrichEnvironment)(util_1.Mode.runner, codeql);
const workspacePath = checkoutPath; const workspacePath = checkoutPath;
const config = await (0, init_1.initConfig)(cmd.languages, cmd.queries, cmd.packs, undefined, // we won't support registries in the runner const config = await (0, init_1.initConfig)(cmd.languages, cmd.queries, cmd.packs, undefined, // we won't support registries in the runner
cmd.configFile, undefined, false, false, "", "", (0, repository_1.parseRepositoryNwo)(cmd.repository), tempDir, codeql, workspacePath, gitHubVersion, apiDetails, (0, testing_utils_1.createFeatureFlags)([]), logger); cmd.configFile, undefined, false, false, "", "", (0, repository_1.parseRepositoryNwo)(cmd.repository), tempDir, codeql, workspacePath, gitHubVersion, apiDetails, (0, testing_utils_1.createFeatures)([]), logger);
const sourceRoot = checkoutPath; const sourceRoot = checkoutPath;
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, parseTraceProcessName(), parseTraceProcessLevel(), (0, testing_utils_1.createFeatureFlags)([]), logger); const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, parseTraceProcessName(), parseTraceProcessLevel(), (0, testing_utils_1.createFeatures)([]), logger);
if (tracerConfig === undefined) { if (tracerConfig === undefined) {
return; return;
} }
@ -231,7 +231,7 @@ program
languages = [language]; languages = [language];
} }
else { else {
languages = await (0, autobuild_1.determineAutobuildLanguages)(config, (0, testing_utils_1.createFeatureFlags)([]), logger); languages = await (0, autobuild_1.determineAutobuildLanguages)(config, (0, testing_utils_1.createFeatures)([]), logger);
} }
if (languages !== undefined) { if (languages !== undefined) {
for (const language of languages) { for (const language of languages) {
@ -294,8 +294,8 @@ program
} }
const threads = (0, util_1.getThreadsFlag)(cmd.threads || initEnv["CODEQL_THREADS"], logger); const threads = (0, util_1.getThreadsFlag)(cmd.threads || initEnv["CODEQL_THREADS"], logger);
const memory = (0, util_1.getMemoryFlag)(cmd.ram || initEnv["CODEQL_RAM"]); const memory = (0, util_1.getMemoryFlag)(cmd.ram || initEnv["CODEQL_RAM"]);
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, (0, testing_utils_1.createFeatureFlags)([])); await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, (0, testing_utils_1.createFeatures)([]));
await (0, analyze_1.runQueries)(outputDir, memory, (0, util_1.getAddSnippetsFlag)(cmd.addSnippets), threads, cmd.category, config, logger, (0, testing_utils_1.createFeatureFlags)([])); await (0, analyze_1.runQueries)(outputDir, memory, (0, util_1.getAddSnippetsFlag)(cmd.addSnippets), threads, cmd.category, config, logger, (0, testing_utils_1.createFeatures)([]));
if (!cmd.upload) { if (!cmd.upload) {
logger.info("Not uploading results"); logger.info("Not uploading results");
return; return;

File diff suppressed because one or more lines are too long

6
lib/testing-utils.js generated
View file

@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.createFeatureFlags = exports.mockCodeQLVersion = exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = void 0; exports.createFeatures = exports.mockCodeQLVersion = exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = void 0;
const github = __importStar(require("@actions/github")); const github = __importStar(require("@actions/github"));
const sinon = __importStar(require("sinon")); const sinon = __importStar(require("sinon"));
const apiClient = __importStar(require("./api-client")); const apiClient = __importStar(require("./api-client"));
@ -157,12 +157,12 @@ exports.mockCodeQLVersion = mockCodeQLVersion;
* *
* This should be only used within tests. * This should be only used within tests.
*/ */
function createFeatureFlags(enabledFeatures) { function createFeatures(enabledFeatures) {
return { return {
getValue: async (feature) => { getValue: async (feature) => {
return enabledFeatures.includes(feature); return enabledFeatures.includes(feature);
}, },
}; };
} }
exports.createFeatureFlags = createFeatureFlags; exports.createFeatures = createFeatures;
//# sourceMappingURL=testing-utils.js.map //# sourceMappingURL=testing-utils.js.map

View file

@ -1 +1 @@
{"version":3,"file":"testing-utils.js","sourceRoot":"","sources":["../src/testing-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0C;AAE1C,6CAA+B;AAE/B,wDAA0C;AAC1C,iDAAmC;AAGnC,iCAAmC;AASnC,SAAS,UAAU,CAAC,OAAoB;IACtC,8CAA8C;IAC9C,gCAAgC;IAChC,2EAA2E;IAC3E,2FAA2F;IAC3F,OAAO,CACL,KAA0B,EAC1B,QAAiB,EACjB,EAA0B,EACjB,EAAE;QACX,2CAA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Ae,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;AACJ,CAAC;AAND,wCAMC"}

12
lib/util.js generated
View file

@ -653,12 +653,12 @@ exports.isInTestMode = isInTestMode;
* @returns true if the action should generate a conde-scanning config file * @returns true if the action should generate a conde-scanning config file
* that gets passed to the CLI. * that gets passed to the CLI.
*/ */
async function useCodeScanningConfigInCli(codeql, featureFlags) { async function useCodeScanningConfigInCli(codeql, featureEnablement) {
return await featureFlags.getValue(feature_flags_1.Feature.CliConfigFileEnabled, codeql); return await featureEnablement.getValue(feature_flags_1.Feature.CliConfigFileEnabled, codeql);
} }
exports.useCodeScanningConfigInCli = useCodeScanningConfigInCli; exports.useCodeScanningConfigInCli = useCodeScanningConfigInCli;
async function logCodeScanningConfigInCli(codeql, featureFlags, logger) { async function logCodeScanningConfigInCli(codeql, featureEnablement, logger) {
if (await useCodeScanningConfigInCli(codeql, featureFlags)) { if (await useCodeScanningConfigInCli(codeql, featureEnablement)) {
logger.info("Code Scanning configuration file being processed in the codeql CLI."); logger.info("Code Scanning configuration file being processed in the codeql CLI.");
} }
else { else {
@ -699,8 +699,8 @@ function listFolder(dir) {
return files; return files;
} }
exports.listFolder = listFolder; exports.listFolder = listFolder;
async function isGoExtractionReconciliationEnabled(featureFlags) { async function isGoExtractionReconciliationEnabled(featureEnablement) {
return await featureFlags.getValue(feature_flags_1.Feature.GolangExtractionReconciliationEnabled); return await featureEnablement.getValue(feature_flags_1.Feature.GolangExtractionReconciliationEnabled);
} }
exports.isGoExtractionReconciliationEnabled = isGoExtractionReconciliationEnabled; exports.isGoExtractionReconciliationEnabled = isGoExtractionReconciliationEnabled;
/** /**

File diff suppressed because one or more lines are too long

View file

@ -140,13 +140,13 @@ function doesGoExtractionOutputExist(config: Config): boolean {
*/ */
async function runAutobuildIfLegacyGoWorkflow( async function runAutobuildIfLegacyGoWorkflow(
config: Config, config: Config,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
) { ) {
if (!config.languages.includes(Language.go)) { if (!config.languages.includes(Language.go)) {
return; return;
} }
if (!(await util.isGoExtractionReconciliationEnabled(featureFlags))) { if (!(await util.isGoExtractionReconciliationEnabled(featureEnablement))) {
logger.debug( logger.debug(
"Won't run Go autobuild since Go extraction reconciliation is not enabled." "Won't run Go autobuild since Go extraction reconciliation is not enabled."
); );
@ -228,14 +228,14 @@ async function run() {
const gitHubVersion = await getGitHubVersionActionsOnly(); const gitHubVersion = await getGitHubVersionActionsOnly();
const featureFlags = new Features( const features = new Features(
gitHubVersion, gitHubVersion,
apiDetails, apiDetails,
repositoryNwo, repositoryNwo,
logger logger
); );
await runAutobuildIfLegacyGoWorkflow(config, featureFlags, logger); await runAutobuildIfLegacyGoWorkflow(config, features, logger);
dbCreationTimings = await runFinalize( dbCreationTimings = await runFinalize(
outputDir, outputDir,
@ -243,7 +243,7 @@ async function run() {
memory, memory,
config, config,
logger, logger,
featureFlags features
); );
if (actionsUtil.getRequiredInput("skip-queries") !== "true") { if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
@ -255,7 +255,7 @@ async function run() {
actionsUtil.getOptionalInput("category"), actionsUtil.getOptionalInput("category"),
config, config,
logger, logger,
featureFlags features
); );
} }

View file

@ -16,11 +16,7 @@ import { Config } from "./config-utils";
import * as count from "./count-loc"; import * as count from "./count-loc";
import { Language } from "./languages"; import { Language } from "./languages";
import { getRunnerLogger } from "./logging"; import { getRunnerLogger } from "./logging";
import { import { setupTests, setupActionsVars, createFeatures } from "./testing-utils";
setupTests,
setupActionsVars,
createFeatureFlags,
} from "./testing-utils";
import * as util from "./util"; import * as util from "./util";
setupTests(test); setupTests(test);
@ -143,7 +139,7 @@ test("status report fields and search path setting", async (t) => {
undefined, undefined,
config, config,
getRunnerLogger(true), getRunnerLogger(true),
createFeatureFlags([]) createFeatures([])
); );
const hasPacks = language in packs; const hasPacks = language in packs;
const statusReportKeys = Object.keys(builtinStatusReport).sort(); const statusReportKeys = Object.keys(builtinStatusReport).sort();
@ -193,7 +189,7 @@ test("status report fields and search path setting", async (t) => {
undefined, undefined,
config, config,
getRunnerLogger(true), getRunnerLogger(true),
createFeatureFlags([]) createFeatures([])
); );
t.deepEqual(Object.keys(customStatusReport).length, 2); t.deepEqual(Object.keys(customStatusReport).length, 2);
t.true( t.true(

View file

@ -122,7 +122,7 @@ export async function createdDBForScannedLanguages(
codeql: CodeQL, codeql: CodeQL,
config: configUtils.Config, config: configUtils.Config,
logger: Logger, logger: Logger,
featureFlags: FeatureEnablement featureEnablement: FeatureEnablement
) { ) {
// Insert the LGTM_INDEX_X env vars at this point so they are set when // Insert the LGTM_INDEX_X env vars at this point so they are set when
// we extract any scanned languages. // we extract any scanned languages.
@ -132,7 +132,7 @@ export async function createdDBForScannedLanguages(
if ( if (
isScannedLanguage( isScannedLanguage(
language, language,
await util.isGoExtractionReconciliationEnabled(featureFlags), await util.isGoExtractionReconciliationEnabled(featureEnablement),
logger logger
) && ) &&
!dbIsFinalized(config, language, logger) !dbIsFinalized(config, language, logger)
@ -173,12 +173,12 @@ async function finalizeDatabaseCreation(
threadsFlag: string, threadsFlag: string,
memoryFlag: string, memoryFlag: string,
logger: Logger, logger: Logger,
featureFlags: FeatureEnablement featureEnablement: FeatureEnablement
): Promise<DatabaseCreationTimings> { ): Promise<DatabaseCreationTimings> {
const codeql = await getCodeQL(config.codeQLCmd); const codeql = await getCodeQL(config.codeQLCmd);
const extractionStart = performance.now(); const extractionStart = performance.now();
await createdDBForScannedLanguages(codeql, config, logger, featureFlags); await createdDBForScannedLanguages(codeql, config, logger, featureEnablement);
const extractionTime = performance.now() - extractionStart; const extractionTime = performance.now() - extractionStart;
const trapImportStart = performance.now(); const trapImportStart = performance.now();
@ -214,7 +214,7 @@ export async function runQueries(
automationDetailsId: string | undefined, automationDetailsId: string | undefined,
config: configUtils.Config, config: configUtils.Config,
logger: Logger, logger: Logger,
featureFlags: FeatureEnablement featureEnablement: FeatureEnablement
): Promise<QueriesStatusReport> { ): Promise<QueriesStatusReport> {
const statusReport: QueriesStatusReport = {}; const statusReport: QueriesStatusReport = {};
@ -240,7 +240,7 @@ export async function runQueries(
const codeql = await getCodeQL(config.codeQLCmd); const codeql = await getCodeQL(config.codeQLCmd);
await util.logCodeScanningConfigInCli(codeql, featureFlags, logger); await util.logCodeScanningConfigInCli(codeql, featureEnablement, logger);
for (const language of config.languages) { for (const language of config.languages) {
const queries = config.queries[language]; const queries = config.queries[language];
@ -260,7 +260,7 @@ export async function runQueries(
} }
try { try {
if (await util.useCodeScanningConfigInCli(codeql, featureFlags)) { if (await util.useCodeScanningConfigInCli(codeql, featureEnablement)) {
// If we are using the codescanning config in the CLI, // If we are using the codescanning config in the CLI,
// much of the work needed to generate the query suites // much of the work needed to generate the query suites
// is done in the CLI. We just need to make a single // is done in the CLI. We just need to make a single
@ -500,7 +500,7 @@ export async function runFinalize(
memoryFlag: string, memoryFlag: string,
config: configUtils.Config, config: configUtils.Config,
logger: Logger, logger: Logger,
featureFlags: FeatureEnablement featureEnablement: FeatureEnablement
): Promise<DatabaseCreationTimings> { ): Promise<DatabaseCreationTimings> {
try { try {
await del(outputDir, { force: true }); await del(outputDir, { force: true });
@ -516,7 +516,7 @@ export async function runFinalize(
threadsFlag, threadsFlag,
memoryFlag, memoryFlag,
logger, logger,
featureFlags featureEnablement
); );
const codeql = await getCodeQL(config.codeQLCmd); const codeql = await getCodeQL(config.codeQLCmd);
@ -529,7 +529,7 @@ export async function runFinalize(
// Delete variables as specified by the end-tracing script // Delete variables as specified by the end-tracing script
await endTracingForCluster( await endTracingForCluster(
config, config,
await util.isGoExtractionReconciliationEnabled(featureFlags), await util.isGoExtractionReconciliationEnabled(featureEnablement),
logger logger
); );
} else { } else {

View file

@ -76,7 +76,7 @@ async function run() {
const gitHubVersion = await getGitHubVersionActionsOnly(); const gitHubVersion = await getGitHubVersionActionsOnly();
checkGitHubVersionInRange(gitHubVersion, logger, Mode.actions); checkGitHubVersionInRange(gitHubVersion, logger, Mode.actions);
const featureFlags = new Features( const features = new Features(
gitHubVersion, gitHubVersion,
getApiDetails(), getApiDetails(),
parseRepositoryNwo(getRequiredEnvParam("GITHUB_REPOSITORY")), parseRepositoryNwo(getRequiredEnvParam("GITHUB_REPOSITORY")),
@ -90,7 +90,7 @@ async function run() {
); );
} }
languages = await determineAutobuildLanguages(config, featureFlags, logger); languages = await determineAutobuildLanguages(config, features, logger);
if (languages !== undefined) { if (languages !== undefined) {
const workingDirectory = getOptionalInput("working-directory"); const workingDirectory = getOptionalInput("working-directory");
if (workingDirectory) { if (workingDirectory) {

View file

@ -7,11 +7,11 @@ import * as util from "./util";
export async function determineAutobuildLanguages( export async function determineAutobuildLanguages(
config: configUtils.Config, config: configUtils.Config,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
): Promise<Language[] | undefined> { ): Promise<Language[] | undefined> {
const isGoExtractionReconciliationEnabled = const isGoExtractionReconciliationEnabled =
await util.isGoExtractionReconciliationEnabled(featureFlags); await util.isGoExtractionReconciliationEnabled(featureEnablement);
// Attempt to find a language to autobuild // Attempt to find a language to autobuild
// We want pick the dominant language in the repo from the ones we're able to build // We want pick the dominant language in the repo from the ones we're able to build
// The languages are sorted in order specified by user or by lines of code if we got // The languages are sorted in order specified by user or by lines of code if we got

View file

@ -16,11 +16,7 @@ import * as defaults from "./defaults.json";
import { Feature, FeatureEnablement } from "./feature-flags"; import { Feature, FeatureEnablement } from "./feature-flags";
import { Language } from "./languages"; import { Language } from "./languages";
import { getRunnerLogger } from "./logging"; import { getRunnerLogger } from "./logging";
import { import { setupTests, setupActionsVars, createFeatures } from "./testing-utils";
setupTests,
setupActionsVars,
createFeatureFlags,
} from "./testing-utils";
import * as util from "./util"; import * as util from "./util";
import { Mode, initializeEnvironment } from "./util"; import { Mode, initializeEnvironment } from "./util";
@ -73,14 +69,14 @@ test.beforeEach(() => {
async function mockApiAndSetupCodeQL({ async function mockApiAndSetupCodeQL({
apiDetails, apiDetails,
featureFlags, featureEnablement,
isPinned, isPinned,
tmpDir, tmpDir,
toolsInput, toolsInput,
version, version,
}: { }: {
apiDetails?: GitHubApiDetails; apiDetails?: GitHubApiDetails;
featureFlags?: FeatureEnablement; featureEnablement?: FeatureEnablement;
isPinned?: boolean; isPinned?: boolean;
tmpDir: string; tmpDir: string;
toolsInput?: { input?: string }; toolsInput?: { input?: string };
@ -113,7 +109,7 @@ async function mockApiAndSetupCodeQL({
apiDetails ?? sampleApiDetails, apiDetails ?? sampleApiDetails,
tmpDir, tmpDir,
util.GitHubVariant.DOTCOM, util.GitHubVariant.DOTCOM,
featureFlags ?? createFeatureFlags([]), featureEnablement ?? createFeatures([]),
getRunnerLogger(true), getRunnerLogger(true),
false false
); );
@ -176,7 +172,7 @@ test("don't download codeql bundle cache with pinned different version cached",
sampleApiDetails, sampleApiDetails,
tmpDir, tmpDir,
util.GitHubVariant.DOTCOM, util.GitHubVariant.DOTCOM,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true), getRunnerLogger(true),
false false
); );
@ -260,14 +256,14 @@ const TOOLCACHE_BYPASS_TEST_CASES: Array<
]; ];
for (const [ for (const [
isFeatureFlagEnabled, isFeatureEnabled,
toolsInput, toolsInput,
shouldToolcacheBeBypassed, shouldToolcacheBeBypassed,
] of TOOLCACHE_BYPASS_TEST_CASES) { ] of TOOLCACHE_BYPASS_TEST_CASES) {
test(`download codeql bundle ${ test(`download codeql bundle ${
shouldToolcacheBeBypassed ? "bypasses" : "does not bypass" shouldToolcacheBeBypassed ? "bypasses" : "does not bypass"
} toolcache when feature flag ${ } toolcache when feature flag ${
isFeatureFlagEnabled ? "enabled" : "disabled" isFeatureEnabled ? "enabled" : "disabled"
} and tools: ${toolsInput} passed`, async (t) => { } and tools: ${toolsInput} passed`, async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
setupActionsVars(tmpDir, tmpDir); setupActionsVars(tmpDir, tmpDir);
@ -284,8 +280,8 @@ for (const [
await mockApiAndSetupCodeQL({ await mockApiAndSetupCodeQL({
version: defaults.bundleVersion, version: defaults.bundleVersion,
apiDetails: sampleApiDetails, apiDetails: sampleApiDetails,
featureFlags: createFeatureFlags( featureEnablement: createFeatures(
isFeatureFlagEnabled ? [Feature.BypassToolcacheEnabled] : [] isFeatureEnabled ? [Feature.BypassToolcacheEnabled] : []
), ),
toolsInput: { input: toolsInput }, toolsInput: { input: toolsInput },
tmpDir, tmpDir,
@ -342,7 +338,7 @@ test("download codeql bundle from github ae endpoint", async (t) => {
sampleGHAEApiDetails, sampleGHAEApiDetails,
tmpDir, tmpDir,
util.GitHubVariant.GHAE, util.GitHubVariant.GHAE,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true), getRunnerLogger(true),
false false
); );
@ -488,7 +484,7 @@ test("databaseInitCluster() without injected codescanning config", async (t) =>
"", "",
undefined, undefined,
undefined, undefined,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
@ -528,7 +524,7 @@ const injectedConfigMacro = test.macro({
"", "",
undefined, undefined,
undefined, undefined,
createFeatureFlags([Feature.CliConfigFileEnabled]), createFeatures([Feature.CliConfigFileEnabled]),
getRunnerLogger(true) getRunnerLogger(true)
); );
@ -835,7 +831,7 @@ test("does not use injected config", async (t: ExecutionContext<unknown>) => {
"", "",
undefined, undefined,
undefined, undefined,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );

View file

@ -91,7 +91,7 @@ export interface CodeQL {
sourceRoot: string, sourceRoot: string,
processName: string | undefined, processName: string | undefined,
processLevel: number | undefined, processLevel: number | undefined,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
): Promise<void>; ): Promise<void>;
/** /**
@ -772,14 +772,14 @@ async function getCodeQLForCmd(
sourceRoot: string, sourceRoot: string,
processName: string | undefined, processName: string | undefined,
processLevel: number | undefined, processLevel: number | undefined,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
) { ) {
const extraArgs = config.languages.map( const extraArgs = config.languages.map(
(language) => `--language=${language}` (language) => `--language=${language}`
); );
const isGoExtractionReconciliationEnabled = const isGoExtractionReconciliationEnabled =
await util.isGoExtractionReconciliationEnabled(featureFlags); await util.isGoExtractionReconciliationEnabled(featureEnablement);
if ( if (
config.languages.filter((l) => config.languages.filter((l) =>
isTracedLanguage(l, isGoExtractionReconciliationEnabled, logger) isTracedLanguage(l, isGoExtractionReconciliationEnabled, logger)
@ -822,7 +822,7 @@ async function getCodeQLForCmd(
const configLocation = await generateCodescanningConfig( const configLocation = await generateCodescanningConfig(
codeql, codeql,
config, config,
featureFlags featureEnablement
); );
if (configLocation) { if (configLocation) {
extraArgs.push(`--codescanning-config=${configLocation}`); extraArgs.push(`--codescanning-config=${configLocation}`);
@ -1274,9 +1274,9 @@ async function runTool(cmd: string, args: string[] = []) {
async function generateCodescanningConfig( async function generateCodescanningConfig(
codeql: CodeQL, codeql: CodeQL,
config: Config, config: Config,
featureFlags: FeatureEnablement featureEnablement: FeatureEnablement
): Promise<string | undefined> { ): Promise<string | undefined> {
if (!(await util.useCodeScanningConfigInCli(codeql, featureFlags))) { if (!(await util.useCodeScanningConfigInCli(codeql, featureEnablement))) {
return; return;
} }
const configLocation = path.resolve(config.tempDir, "user-config.yaml"); const configLocation = path.resolve(config.tempDir, "user-config.yaml");

View file

@ -12,7 +12,7 @@ import * as configUtils from "./config-utils";
import { Feature } from "./feature-flags"; import { Feature } from "./feature-flags";
import { Language } from "./languages"; import { Language } from "./languages";
import { getRunnerLogger, Logger } from "./logging"; import { getRunnerLogger, Logger } from "./logging";
import { setupTests, createFeatureFlags } from "./testing-utils"; import { setupTests, createFeatures } from "./testing-utils";
import * as util from "./util"; import * as util from "./util";
setupTests(test); setupTests(test);
@ -102,7 +102,7 @@ test("load empty config", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
logger logger
); );
@ -123,7 +123,7 @@ test("load empty config", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
logger logger
) )
); );
@ -173,7 +173,7 @@ test("loading config saves config", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
logger logger
); );
@ -211,7 +211,7 @@ test("load input outside of workspace", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
@ -251,7 +251,7 @@ test("load non-local input with invalid repo syntax", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
@ -292,7 +292,7 @@ test("load non-existent input", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
@ -399,7 +399,7 @@ test("load non-empty input", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
@ -470,7 +470,7 @@ test("Default queries are used", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
@ -549,7 +549,7 @@ test("Queries can be specified in config file", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
@ -627,7 +627,7 @@ test("Queries from config file can be overridden in workflow file", async (t) =>
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
@ -703,7 +703,7 @@ test("Queries in workflow file can be used in tandem with the 'disable default q
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
@ -770,7 +770,7 @@ test("Multiple queries can be specified in workflow file, no config file require
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
@ -858,7 +858,7 @@ test("Queries in workflow file can be added to the set of queries without overri
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
@ -940,7 +940,7 @@ test("Invalid queries in workflow file handled correctly", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
t.fail("initConfig did not throw error"); t.fail("initConfig did not throw error");
@ -1012,7 +1012,7 @@ test("API client used when reading remote config", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
t.assert(spyGetContents.called); t.assert(spyGetContents.called);
@ -1043,7 +1043,7 @@ test("Remote config handles the case where a directory is provided", async (t) =
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
@ -1082,7 +1082,7 @@ test("Invalid format of remote config handled correctly", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
@ -1125,7 +1125,7 @@ test("No detected languages", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
@ -1157,7 +1157,7 @@ test("Unknown languages", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
@ -1214,7 +1214,7 @@ test("Config specifies packages", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
t.deepEqual(packs as unknown, { t.deepEqual(packs as unknown, {
@ -1275,7 +1275,7 @@ test("Config specifies packages for multiple languages", async (t) => {
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
t.deepEqual(packs as unknown, { t.deepEqual(packs as unknown, {
@ -1347,7 +1347,7 @@ function doInvalidInputTest(
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags([]), createFeatures([]),
getRunnerLogger(true) getRunnerLogger(true)
); );
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
@ -1935,7 +1935,7 @@ const mlPoweredQueriesMacro = test.macro({
tmpDir, tmpDir,
gitHubVersion, gitHubVersion,
sampleApiDetails, sampleApiDetails,
createFeatureFlags( createFeatures(
isMlPoweredQueriesFlagEnabled ? [Feature.MlPoweredQueriesEnabled] : [] isMlPoweredQueriesFlagEnabled ? [Feature.MlPoweredQueriesEnabled] : []
), ),
getRunnerLogger(true) getRunnerLogger(true)

View file

@ -389,7 +389,7 @@ async function addBuiltinSuiteQueries(
resultMap: Queries, resultMap: Queries,
packs: Packs, packs: Packs,
suiteName: string, suiteName: string,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
configFile?: string configFile?: string
): Promise<boolean> { ): Promise<boolean> {
let injectedMlQueries = false; let injectedMlQueries = false;
@ -411,7 +411,7 @@ async function addBuiltinSuiteQueries(
languages.includes("javascript") && languages.includes("javascript") &&
(found === "security-extended" || found === "security-and-quality") && (found === "security-extended" || found === "security-and-quality") &&
!packs.javascript?.some(isMlPoweredJsQueriesPack) && !packs.javascript?.some(isMlPoweredJsQueriesPack) &&
(await featureFlags.getValue(Feature.MlPoweredQueriesEnabled, codeQL)) (await featureEnablement.getValue(Feature.MlPoweredQueriesEnabled, codeQL))
) { ) {
if (!packs.javascript) { if (!packs.javascript) {
packs.javascript = []; packs.javascript = [];
@ -543,7 +543,7 @@ async function parseQueryUses(
tempDir: string, tempDir: string,
workspacePath: string, workspacePath: string,
apiDetails: api.GitHubApiExternalRepoDetails, apiDetails: api.GitHubApiExternalRepoDetails,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger, logger: Logger,
configFile?: string configFile?: string
): Promise<boolean> { ): Promise<boolean> {
@ -572,7 +572,7 @@ async function parseQueryUses(
resultMap, resultMap,
packs, packs,
queryUses, queryUses,
featureFlags, featureEnablement,
configFile configFile
); );
} }
@ -948,7 +948,7 @@ async function addQueriesAndPacksFromWorkflow(
tempDir: string, tempDir: string,
workspacePath: string, workspacePath: string,
apiDetails: api.GitHubApiExternalRepoDetails, apiDetails: api.GitHubApiExternalRepoDetails,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
): Promise<boolean> { ): Promise<boolean> {
let injectedMlQueries = false; let injectedMlQueries = false;
@ -966,7 +966,7 @@ async function addQueriesAndPacksFromWorkflow(
tempDir, tempDir,
workspacePath, workspacePath,
apiDetails, apiDetails,
featureFlags, featureEnablement,
logger logger
); );
injectedMlQueries = injectedMlQueries || didInject; injectedMlQueries = injectedMlQueries || didInject;
@ -1005,7 +1005,7 @@ export async function getDefaultConfig(
workspacePath: string, workspacePath: string,
gitHubVersion: GitHubVersion, gitHubVersion: GitHubVersion,
apiDetails: api.GitHubApiCombinedDetails, apiDetails: api.GitHubApiCombinedDetails,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
): Promise<Config> { ): Promise<Config> {
const languages = await getLanguages( const languages = await getLanguages(
@ -1044,7 +1044,7 @@ export async function getDefaultConfig(
tempDir, tempDir,
workspacePath, workspacePath,
apiDetails, apiDetails,
featureFlags, featureEnablement,
logger logger
); );
} }
@ -1114,7 +1114,7 @@ async function loadConfig(
workspacePath: string, workspacePath: string,
gitHubVersion: GitHubVersion, gitHubVersion: GitHubVersion,
apiDetails: api.GitHubApiCombinedDetails, apiDetails: api.GitHubApiCombinedDetails,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
): Promise<Config> { ): Promise<Config> {
let parsedYAML: UserConfig; let parsedYAML: UserConfig;
@ -1195,7 +1195,7 @@ async function loadConfig(
tempDir, tempDir,
workspacePath, workspacePath,
apiDetails, apiDetails,
featureFlags, featureEnablement,
logger logger
); );
} }
@ -1220,7 +1220,7 @@ async function loadConfig(
tempDir, tempDir,
workspacePath, workspacePath,
apiDetails, apiDetails,
featureFlags, featureEnablement,
logger, logger,
configFile configFile
); );
@ -1638,7 +1638,7 @@ export async function initConfig(
workspacePath: string, workspacePath: string,
gitHubVersion: GitHubVersion, gitHubVersion: GitHubVersion,
apiDetails: api.GitHubApiCombinedDetails, apiDetails: api.GitHubApiCombinedDetails,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
): Promise<Config> { ): Promise<Config> {
let config: Config; let config: Config;
@ -1661,7 +1661,7 @@ export async function initConfig(
workspacePath, workspacePath,
gitHubVersion, gitHubVersion,
apiDetails, apiDetails,
featureFlags, featureEnablement,
logger logger
); );
} else { } else {
@ -1681,7 +1681,7 @@ export async function initConfig(
workspacePath, workspacePath,
gitHubVersion, gitHubVersion,
apiDetails, apiDetails,
featureFlags, featureEnablement,
logger logger
); );
} }
@ -1703,9 +1703,9 @@ export async function initConfig(
// When using the codescanning config in the CLI, pack downloads // When using the codescanning config in the CLI, pack downloads
// happen in the CLI during the `database init` command, so no need // happen in the CLI during the `database init` command, so no need
// to download them here. // to download them here.
await logCodeScanningConfigInCli(codeQL, featureFlags, logger); await logCodeScanningConfigInCli(codeQL, featureEnablement, logger);
if (!(await useCodeScanningConfigInCli(codeQL, featureFlags))) { if (!(await useCodeScanningConfigInCli(codeQL, featureEnablement))) {
const registries = parseRegistries(registriesInput); const registries = parseRegistries(registriesInput);
await downloadPacks( await downloadPacks(
codeQL, codeQL,

View file

@ -49,7 +49,7 @@ for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
test(`All feature flags are disabled if running against ${variant.description}`, async (t) => { test(`All feature flags are disabled if running against ${variant.description}`, async (t) => {
await withTmpDir(async (tmpDir) => { await withTmpDir(async (tmpDir) => {
const loggedMessages = []; const loggedMessages = [];
const featureFlags = setUpTests( const featureEnablement = setUpTests(
tmpDir, tmpDir,
getRecordingLogger(loggedMessages), getRecordingLogger(loggedMessages),
variant.gitHubVersion variant.gitHubVersion
@ -57,7 +57,7 @@ for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
for (const flag of Object.values(Feature)) { for (const flag of Object.values(Feature)) {
t.false( t.false(
await featureFlags.getValue(flag, includeCodeQlIfRequired(flag)) await featureEnablement.getValue(flag, includeCodeQlIfRequired(flag))
); );
} }
@ -76,14 +76,19 @@ for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
test("API response missing", async (t) => { test("API response missing", async (t) => {
await withTmpDir(async (tmpDir) => { await withTmpDir(async (tmpDir) => {
const loggedMessages: LoggedMessage[] = []; const loggedMessages: LoggedMessage[] = [];
const featureFlags = setUpTests(tmpDir, getRecordingLogger(loggedMessages)); const featureEnablement = setUpTests(
tmpDir,
getRecordingLogger(loggedMessages)
);
mockFeatureFlagApiEndpoint(403, {}); mockFeatureFlagApiEndpoint(403, {});
for (const flag of Object.values(Feature)) { for (const flag of Object.values(Feature)) {
t.assert( t.assert(
(await featureFlags.getValue(flag, includeCodeQlIfRequired(flag))) === (await featureEnablement.getValue(
false flag,
includeCodeQlIfRequired(flag)
)) === false
); );
} }
assertAllFeaturesUndefinedInApi(t, loggedMessages); assertAllFeaturesUndefinedInApi(t, loggedMessages);
@ -93,14 +98,19 @@ test("API response missing", async (t) => {
test("Feature flags are disabled if they're not returned in API response", async (t) => { test("Feature flags are disabled if they're not returned in API response", async (t) => {
await withTmpDir(async (tmpDir) => { await withTmpDir(async (tmpDir) => {
const loggedMessages: LoggedMessage[] = []; const loggedMessages: LoggedMessage[] = [];
const featureFlags = setUpTests(tmpDir, getRecordingLogger(loggedMessages)); const featureEnablement = setUpTests(
tmpDir,
getRecordingLogger(loggedMessages)
);
mockFeatureFlagApiEndpoint(200, {}); mockFeatureFlagApiEndpoint(200, {});
for (const flag of Object.values(Feature)) { for (const flag of Object.values(Feature)) {
t.assert( t.assert(
(await featureFlags.getValue(flag, includeCodeQlIfRequired(flag))) === (await featureEnablement.getValue(
false flag,
includeCodeQlIfRequired(flag)
)) === false
); );
} }
@ -110,13 +120,13 @@ test("Feature flags are disabled if they're not returned in API response", async
test("Feature flags exception is propagated if the API request errors", async (t) => { test("Feature flags exception is propagated if the API request errors", async (t) => {
await withTmpDir(async (tmpDir) => { await withTmpDir(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
mockFeatureFlagApiEndpoint(500, {}); mockFeatureFlagApiEndpoint(500, {});
await t.throwsAsync( await t.throwsAsync(
async () => async () =>
featureFlags.getValue( featureEnablement.getValue(
Feature.MlPoweredQueriesEnabled, Feature.MlPoweredQueriesEnabled,
includeCodeQlIfRequired(Feature.MlPoweredQueriesEnabled) includeCodeQlIfRequired(Feature.MlPoweredQueriesEnabled)
), ),
@ -128,133 +138,133 @@ test("Feature flags exception is propagated if the API request errors", async (t
}); });
}); });
for (const featureFlag of Object.keys(featureConfig)) { for (const feature of Object.keys(featureConfig)) {
test(`Only feature flag '${featureFlag}' is enabled if enabled in the API response. Other flags disabled`, async (t) => { test(`Only feature flag '${feature}' is enabled if enabled in the API response. Other flags disabled`, async (t) => {
await withTmpDir(async (tmpDir) => { await withTmpDir(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
// set all feature flags to false except the one we're testing // set all feature flags to false except the one we're testing
const expectedFeatureFlags: { [flag: string]: boolean } = {}; const expectedFeatureEnablement: { [flag: string]: boolean } = {};
for (const f of Object.keys(featureConfig)) { for (const f of Object.keys(featureConfig)) {
expectedFeatureFlags[f] = f === featureFlag; expectedFeatureEnablement[f] = f === feature;
} }
mockFeatureFlagApiEndpoint(200, expectedFeatureFlags); mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
// retrieve the values of the actual feature flags // retrieve the values of the actual feature flags
const actualFeatureFlags: { [flag: string]: boolean } = {}; const actualFeatureEnablement: { [flag: string]: boolean } = {};
for (const f of Object.keys(featureConfig)) { for (const f of Object.keys(featureConfig)) {
actualFeatureFlags[f] = await featureFlags.getValue( actualFeatureEnablement[f] = await featureEnablement.getValue(
f as Feature, f as Feature,
includeCodeQlIfRequired(f) includeCodeQlIfRequired(f)
); );
} }
// Alls flags should be false except the one we're testing // Alls flags should be false except the one we're testing
t.deepEqual(actualFeatureFlags, expectedFeatureFlags); t.deepEqual(actualFeatureEnablement, expectedFeatureEnablement);
}); });
}); });
test(`Only feature flag '${featureFlag}' is enabled if the associated environment variable is true. Others disabled.`, async (t) => { test(`Only feature flag '${feature}' is enabled if the associated environment variable is true. Others disabled.`, async (t) => {
await withTmpDir(async (tmpDir) => { await withTmpDir(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
const expectedFeatureFlags = initializeFeatures(false); const expectedFeatureEnablement = initializeFeatures(false);
mockFeatureFlagApiEndpoint(200, expectedFeatureFlags); mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
// feature flag should be disabled initially // feature flag should be disabled initially
t.assert( t.assert(
!(await featureFlags.getValue( !(await featureEnablement.getValue(
featureFlag as Feature, feature as Feature,
includeCodeQlIfRequired(featureFlag) includeCodeQlIfRequired(feature)
)) ))
); );
// set env var to true and check that the feature flag is now enabled // set env var to true and check that the feature flag is now enabled
process.env[featureConfig[featureFlag].envVar] = "true"; process.env[featureConfig[feature].envVar] = "true";
t.assert( t.assert(
await featureFlags.getValue( await featureEnablement.getValue(
featureFlag as Feature, feature as Feature,
includeCodeQlIfRequired(featureFlag) includeCodeQlIfRequired(feature)
) )
); );
}); });
}); });
test(`Feature flag '${featureFlag}' is disabled if the associated environment variable is false, even if enabled in API`, async (t) => { test(`Feature flag '${feature}' is disabled if the associated environment variable is false, even if enabled in API`, async (t) => {
await withTmpDir(async (tmpDir) => { await withTmpDir(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
const expectedFeatureFlags = initializeFeatures(true); const expectedFeatureEnablement = initializeFeatures(true);
mockFeatureFlagApiEndpoint(200, expectedFeatureFlags); mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
// feature flag should be enabled initially // feature flag should be enabled initially
t.assert( t.assert(
await featureFlags.getValue( await featureEnablement.getValue(
featureFlag as Feature, feature as Feature,
includeCodeQlIfRequired(featureFlag) includeCodeQlIfRequired(feature)
) )
); );
// set env var to false and check that the feature flag is now disabled // set env var to false and check that the feature flag is now disabled
process.env[featureConfig[featureFlag].envVar] = "false"; process.env[featureConfig[feature].envVar] = "false";
t.assert( t.assert(
!(await featureFlags.getValue( !(await featureEnablement.getValue(
featureFlag as Feature, feature as Feature,
includeCodeQlIfRequired(featureFlag) includeCodeQlIfRequired(feature)
)) ))
); );
}); });
}); });
if (featureConfig[featureFlag].minimumVersion !== undefined) { if (featureConfig[feature].minimumVersion !== undefined) {
test(`Getting Feature Flag '${featureFlag} should throw if no codeql is provided`, async (t) => { test(`Getting Feature Flag '${feature} should throw if no codeql is provided`, async (t) => {
await withTmpDir(async (tmpDir) => { await withTmpDir(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
const expectedFeatureFlags = initializeFeatures(true); const expectedFeatureEnablement = initializeFeatures(true);
mockFeatureFlagApiEndpoint(200, expectedFeatureFlags); mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
await t.throwsAsync( await t.throwsAsync(
async () => featureFlags.getValue(featureFlag as Feature), async () => featureEnablement.getValue(feature as Feature),
{ {
message: `Internal error: A minimum version is specified for feature ${featureFlag}, but no instance of CodeQL was provided.`, message: `Internal error: A minimum version is specified for feature ${feature}, but no instance of CodeQL was provided.`,
} }
); );
}); });
}); });
} }
if (featureConfig[featureFlag].minimumVersion !== undefined) { if (featureConfig[feature].minimumVersion !== undefined) {
test(`Feature flag '${featureFlag}' is disabled if the minimum CLI version is below ${featureConfig[featureFlag].minimumVersion}`, async (t) => { test(`Feature flag '${feature}' is disabled if the minimum CLI version is below ${featureConfig[feature].minimumVersion}`, async (t) => {
await withTmpDir(async (tmpDir) => { await withTmpDir(async (tmpDir) => {
const featureFlags = setUpTests(tmpDir); const featureEnablement = setUpTests(tmpDir);
const expectedFeatureFlags = initializeFeatures(true); const expectedFeatureEnablement = initializeFeatures(true);
mockFeatureFlagApiEndpoint(200, expectedFeatureFlags); mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
// feature flag should be disabled when an old CLI version is set // feature flag should be disabled when an old CLI version is set
let codeql = mockCodeQLVersion("2.0.0"); let codeql = mockCodeQLVersion("2.0.0");
t.assert( t.assert(
!(await featureFlags.getValue(featureFlag as Feature, codeql)) !(await featureEnablement.getValue(feature as Feature, codeql))
); );
// even setting the env var to true should not enable the feature flag if // even setting the env var to true should not enable the feature flag if
// the minimum CLI version is not met // the minimum CLI version is not met
process.env[featureConfig[featureFlag].envVar] = "true"; process.env[featureConfig[feature].envVar] = "true";
t.assert( t.assert(
!(await featureFlags.getValue(featureFlag as Feature, codeql)) !(await featureEnablement.getValue(feature as Feature, codeql))
); );
// feature flag should be enabled when a new CLI version is set // feature flag should be enabled when a new CLI version is set
// and env var is not set // and env var is not set
process.env[featureConfig[featureFlag].envVar] = ""; process.env[featureConfig[feature].envVar] = "";
codeql = mockCodeQLVersion(featureConfig[featureFlag].minimumVersion); codeql = mockCodeQLVersion(featureConfig[feature].minimumVersion);
t.assert(await featureFlags.getValue(featureFlag as Feature, codeql)); t.assert(await featureEnablement.getValue(feature as Feature, codeql));
// set env var to false and check that the feature flag is now disabled // set env var to false and check that the feature flag is now disabled
process.env[featureConfig[featureFlag].envVar] = "false"; process.env[featureConfig[feature].envVar] = "false";
t.assert( t.assert(
!(await featureFlags.getValue(featureFlag as Feature, codeql)) !(await featureEnablement.getValue(feature as Feature, codeql))
); );
}); });
}); });
@ -280,12 +290,12 @@ test("At least one feature has a minimum version specified", (t) => {
}); });
function assertAllFeaturesUndefinedInApi(t, loggedMessages: LoggedMessage[]) { function assertAllFeaturesUndefinedInApi(t, loggedMessages: LoggedMessage[]) {
for (const featureFlag of Object.keys(featureConfig)) { for (const feature of Object.keys(featureConfig)) {
t.assert( t.assert(
loggedMessages.find( loggedMessages.find(
(v) => (v) =>
v.type === "debug" && v.type === "debug" &&
(v.message as string).includes(featureFlag) && (v.message as string).includes(feature) &&
(v.message as string).includes("considering it disabled") (v.message as string).includes("considering it disabled")
) !== undefined ) !== undefined
); );

View file

@ -157,7 +157,7 @@ async function run() {
getRequiredEnvParam("GITHUB_REPOSITORY") getRequiredEnvParam("GITHUB_REPOSITORY")
); );
const featureFlags = new Features( const features = new Features(
gitHubVersion, gitHubVersion,
apiDetails, apiDetails,
repositoryNwo, repositoryNwo,
@ -185,7 +185,7 @@ async function run() {
apiDetails, apiDetails,
getTemporaryDirectory(), getTemporaryDirectory(),
gitHubVersion.type, gitHubVersion.type,
featureFlags, features,
logger logger
); );
codeql = initCodeQLResult.codeql; codeql = initCodeQLResult.codeql;
@ -199,7 +199,7 @@ async function run() {
getOptionalInput("registries"), getOptionalInput("registries"),
getOptionalInput("config-file"), getOptionalInput("config-file"),
getOptionalInput("db-location"), getOptionalInput("db-location"),
await getTrapCachingEnabled(featureFlags), await getTrapCachingEnabled(features),
// Debug mode is enabled if: // Debug mode is enabled if:
// - The `init` Action is passed `debug: true`. // - The `init` Action is passed `debug: true`.
// - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow), // - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow),
@ -213,7 +213,7 @@ async function run() {
getRequiredEnvParam("GITHUB_WORKSPACE"), getRequiredEnvParam("GITHUB_WORKSPACE"),
gitHubVersion, gitHubVersion,
apiDetails, apiDetails,
featureFlags, features,
logger logger
); );
@ -276,7 +276,7 @@ async function run() {
sourceRoot, sourceRoot,
"Runner.Worker.exe", "Runner.Worker.exe",
undefined, undefined,
featureFlags, features,
logger logger
); );
if (tracerConfig !== undefined) { if (tracerConfig !== undefined) {
@ -318,13 +318,13 @@ async function run() {
} }
async function getTrapCachingEnabled( async function getTrapCachingEnabled(
featureFlags: FeatureEnablement featureEnablement: FeatureEnablement
): Promise<boolean> { ): Promise<boolean> {
const trapCaching = getOptionalInput("trap-caching"); const trapCaching = getOptionalInput("trap-caching");
if (trapCaching !== undefined) { if (trapCaching !== undefined) {
return trapCaching === "true"; return trapCaching === "true";
} }
return await featureFlags.getValue(Feature.TrapCachingEnabled); return await featureEnablement.getValue(Feature.TrapCachingEnabled);
} }
async function runWrapper() { async function runWrapper() {

View file

@ -20,7 +20,7 @@ export async function initCodeQL(
apiDetails: GitHubApiDetails, apiDetails: GitHubApiDetails,
tempDir: string, tempDir: string,
variant: util.GitHubVariant, variant: util.GitHubVariant,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
): Promise<{ codeql: CodeQL; toolsVersion: string }> { ): Promise<{ codeql: CodeQL; toolsVersion: string }> {
logger.startGroup("Setup CodeQL tools"); logger.startGroup("Setup CodeQL tools");
@ -29,7 +29,7 @@ export async function initCodeQL(
apiDetails, apiDetails,
tempDir, tempDir,
variant, variant,
featureFlags, featureEnablement,
logger, logger,
true true
); );
@ -55,7 +55,7 @@ export async function initConfig(
workspacePath: string, workspacePath: string,
gitHubVersion: util.GitHubVersion, gitHubVersion: util.GitHubVersion,
apiDetails: GitHubApiCombinedDetails, apiDetails: GitHubApiCombinedDetails,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
): Promise<configUtils.Config> { ): Promise<configUtils.Config> {
logger.startGroup("Load language configuration"); logger.startGroup("Load language configuration");
@ -76,7 +76,7 @@ export async function initConfig(
workspacePath, workspacePath,
gitHubVersion, gitHubVersion,
apiDetails, apiDetails,
featureFlags, featureEnablement,
logger logger
); );
analysisPaths.printPathFiltersWarning(config, logger); analysisPaths.printPathFiltersWarning(config, logger);
@ -90,7 +90,7 @@ export async function runInit(
sourceRoot: string, sourceRoot: string,
processName: string | undefined, processName: string | undefined,
processLevel: number | undefined, processLevel: number | undefined,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
): Promise<TracerConfig | undefined> { ): Promise<TracerConfig | undefined> {
fs.mkdirSync(config.dbLocation, { recursive: true }); fs.mkdirSync(config.dbLocation, { recursive: true });
@ -103,7 +103,7 @@ export async function runInit(
sourceRoot, sourceRoot,
processName, processName,
processLevel, processLevel,
featureFlags, featureEnablement,
logger logger
); );
} else { } else {
@ -122,7 +122,7 @@ export async function runInit(
return await getCombinedTracerConfig( return await getCombinedTracerConfig(
config, config,
codeql, codeql,
await util.isGoExtractionReconciliationEnabled(featureFlags), await util.isGoExtractionReconciliationEnabled(featureEnablement),
logger logger
); );
} }

View file

@ -12,7 +12,7 @@ import { initCodeQL, initConfig, injectWindowsTracer, runInit } from "./init";
import { Language, parseLanguage } from "./languages"; import { Language, parseLanguage } from "./languages";
import { getRunnerLogger } from "./logging"; import { getRunnerLogger } from "./logging";
import { parseRepositoryNwo } from "./repository"; import { parseRepositoryNwo } from "./repository";
import { createFeatureFlags } from "./testing-utils"; import { createFeatures } from "./testing-utils";
import * as upload_lib from "./upload-lib"; import * as upload_lib from "./upload-lib";
import { import {
checkGitHubVersionInRange, checkGitHubVersionInRange,
@ -229,7 +229,7 @@ program
apiDetails, apiDetails,
tempDir, tempDir,
gitHubVersion.type, gitHubVersion.type,
createFeatureFlags([]), createFeatures([]),
logger logger
) )
).codeql; ).codeql;
@ -253,7 +253,7 @@ program
workspacePath, workspacePath,
gitHubVersion, gitHubVersion,
apiDetails, apiDetails,
createFeatureFlags([]), createFeatures([]),
logger logger
); );
@ -264,7 +264,7 @@ program
sourceRoot, sourceRoot,
parseTraceProcessName(), parseTraceProcessName(),
parseTraceProcessLevel(), parseTraceProcessLevel(),
createFeatureFlags([]), createFeatures([]),
logger logger
); );
if (tracerConfig === undefined) { if (tracerConfig === undefined) {
@ -377,7 +377,7 @@ program
} else { } else {
languages = await determineAutobuildLanguages( languages = await determineAutobuildLanguages(
config, config,
createFeatureFlags([]), createFeatures([]),
logger logger
); );
} }
@ -508,7 +508,7 @@ program
memory, memory,
config, config,
logger, logger,
createFeatureFlags([]) createFeatures([])
); );
await runQueries( await runQueries(
outputDir, outputDir,
@ -518,7 +518,7 @@ program
cmd.category, cmd.category,
config, config,
logger, logger,
createFeatureFlags([]) createFeatures([])
); );
if (!cmd.upload) { if (!cmd.upload) {

View file

@ -175,9 +175,7 @@ export function mockCodeQLVersion(version) {
* *
* This should be only used within tests. * This should be only used within tests.
*/ */
export function createFeatureFlags( export function createFeatures(enabledFeatures: Feature[]): FeatureEnablement {
enabledFeatures: Feature[]
): FeatureEnablement {
return { return {
getValue: async (feature) => { getValue: async (feature) => {
return enabledFeatures.includes(feature); return enabledFeatures.includes(feature);

View file

@ -779,17 +779,17 @@ export function isInTestMode(): boolean {
*/ */
export async function useCodeScanningConfigInCli( export async function useCodeScanningConfigInCli(
codeql: CodeQL, codeql: CodeQL,
featureFlags: FeatureEnablement featureEnablement: FeatureEnablement
): Promise<boolean> { ): Promise<boolean> {
return await featureFlags.getValue(Feature.CliConfigFileEnabled, codeql); return await featureEnablement.getValue(Feature.CliConfigFileEnabled, codeql);
} }
export async function logCodeScanningConfigInCli( export async function logCodeScanningConfigInCli(
codeql: CodeQL, codeql: CodeQL,
featureFlags: FeatureEnablement, featureEnablement: FeatureEnablement,
logger: Logger logger: Logger
) { ) {
if (await useCodeScanningConfigInCli(codeql, featureFlags)) { if (await useCodeScanningConfigInCli(codeql, featureEnablement)) {
logger.info( logger.info(
"Code Scanning configuration file being processed in the codeql CLI." "Code Scanning configuration file being processed in the codeql CLI."
); );
@ -832,9 +832,9 @@ export function listFolder(dir: string): string[] {
} }
export async function isGoExtractionReconciliationEnabled( export async function isGoExtractionReconciliationEnabled(
featureFlags: FeatureEnablement featureEnablement: FeatureEnablement
): Promise<boolean> { ): Promise<boolean> {
return await featureFlags.getValue( return await featureEnablement.getValue(
Feature.GolangExtractionReconciliationEnabled Feature.GolangExtractionReconciliationEnabled
); );
} }