Prefer providing CodeQL via dependency injection

This commit is contained in:
Henry Mercer
2025-08-07 12:13:59 +01:00
parent c7884c6fd8
commit f8c2086872
42 changed files with 138 additions and 126 deletions

View File

@@ -96,8 +96,10 @@ const util = __importStar(require("./util"));
// runFinalize and runQueries are correctly captured by spies, we explicitly
// wait for the action promise to complete before starting verification.
await analyzeAction.runPromise;
t.assert(runFinalizeStub.calledOnce);
t.deepEqual(runFinalizeStub.firstCall.args[1], "--threads=-1");
t.deepEqual(runFinalizeStub.firstCall.args[2], "--ram=4992");
t.assert(runQueriesStub.calledOnce);
t.deepEqual(runQueriesStub.firstCall.args[3], "--threads=-1");
t.deepEqual(runQueriesStub.firstCall.args[1], "--ram=4992");
});

View File

@@ -1 +1 @@
{"version":3,"file":"analyze-action-env.test.js","sourceRoot":"","sources":["../src/analyze-action-env.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,kDAAoC;AACpC,4DAA8C;AAC9C,sDAAwC;AACxC,8DAAgD;AAChD,mDAIyB;AACzB,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,8DAA8D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC/E,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAC1D,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,sCAAsC,CAAC;QAC1E,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,wBAAwB,CAAC;QACzD,KAAK;aACF,IAAI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CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACpC,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

View File

@@ -96,8 +96,10 @@ const util = __importStar(require("./util"));
// runFinalize and runQueries are correctly captured by spies, we explicitly
// wait for the action promise to complete before starting verification.
await analyzeAction.runPromise;
t.assert(runFinalizeStub.calledOnce);
t.deepEqual(runFinalizeStub.firstCall.args[1], "--threads=-1");
t.deepEqual(runFinalizeStub.firstCall.args[2], "--ram=3012");
t.assert(runQueriesStub.calledOnce);
t.deepEqual(runQueriesStub.firstCall.args[3], "--threads=-1");
t.deepEqual(runQueriesStub.firstCall.args[1], "--ram=3012");
});

View File

@@ -1 +1 @@
{"version":3,"file":"analyze-action-input.test.js","sourceRoot":"","sources":["../src/analyze-action-input.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,kDAAoC;AACpC,4DAA8C;AAC9C,sDAAwC;AACxC,8DAAgD;AAChD,mDAIyB;AACzB,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,sDAAsD,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACvE,MAAM,IAAI,CAAC,UAAU,CAAC,K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,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzD,iEAAiE;QACjE,MAAM,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAElD,uEAAuE;QACvE,oEAAoE;QACpE,4EAA4E;QAC5E,wEAAwE;QACxE,MAAM,aAAa,CAAC,UAAU,CAAC;QAE/B,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACpC,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

2
lib/analyze-action.js generated
View File

@@ -206,7 +206,7 @@ async function run() {
await runAutobuildIfLegacyGoWorkflow(config, logger);
dbCreationTimings = await (0, analyze_1.runFinalize)(outputDir, threads, memory, codeql, config, logger);
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, diffRangePackDir, actionsUtil.getOptionalInput("category"), config, logger, features);
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, diffRangePackDir, actionsUtil.getOptionalInput("category"), codeql, config, logger, features);
}
const dbLocations = {};
for (const language of config.languages) {

File diff suppressed because one or more lines are too long

4
lib/analyze.js generated
View File

@@ -53,7 +53,6 @@ const yaml = __importStar(require("js-yaml"));
const actions_util_1 = require("./actions-util");
const api_client_1 = require("./api-client");
const autobuild_1 = require("./autobuild");
const codeql_1 = require("./codeql");
const dependency_caching_1 = require("./dependency-caching");
const diagnostics_1 = require("./diagnostics");
const diff_informed_analysis_utils_1 = require("./diff-informed-analysis-utils");
@@ -410,7 +409,7 @@ function resolveQuerySuiteAlias(language, maybeSuite) {
return maybeSuite;
}
// Runs queries and creates sarif files in the given folder
async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, diffRangePackDir, automationDetailsId, config, logger, features) {
async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, diffRangePackDir, automationDetailsId, codeql, config, logger, features) {
const statusReport = {};
const queryFlags = [memoryFlag, threadsFlag];
const incrementalMode = [];
@@ -438,7 +437,6 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
const sarifRunPropertyFlag = incrementalMode.length > 0
? `--sarif-run-property=incrementalMode=${incrementalMode.join(",")}`
: undefined;
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
for (const language of config.languages) {
try {
const sarifFile = path.join(sarifFolder, `${language}.sarif`);

File diff suppressed because one or more lines are too long

4
lib/analyze.test.js generated
View File

@@ -64,7 +64,7 @@ const util = __importStar(require("./util"));
const threadsFlag = "";
sinon.stub(uploadLib, "validateSarifFileSchema");
for (const language of Object.values(languages_1.KnownLanguage)) {
(0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
databaseRunQueries: async () => { },
packDownload: async () => ({ packs: [] }),
databaseInterpretResults: async (_db, _queriesRun, sarifFile) => {
@@ -114,7 +114,7 @@ const util = __importStar(require("./util"));
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
recursive: true,
});
const statusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, undefined, config, (0, logging_1.getRunnerLogger)(true), (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.QaTelemetryEnabled]));
const statusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, undefined, codeql, config, (0, logging_1.getRunnerLogger)(true), (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.QaTelemetryEnabled]));
t.deepEqual(Object.keys(statusReport).sort(), [
"analysis_builds_overlay_base_database",
"analysis_is_diff_informed",

File diff suppressed because one or more lines are too long

35
lib/codeql.js generated
View File

@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.setupCodeQL = setupCodeQL;
exports.getCodeQL = getCodeQL;
exports.setCodeQL = setCodeQL;
exports.getCachedCodeQL = getCachedCodeQL;
exports.createStubCodeQL = createStubCodeQL;
exports.getCodeQLForTesting = getCodeQLForTesting;
exports.getCodeQLForCmd = getCodeQLForCmd;
exports.getExtraOptions = getExtraOptions;
@@ -63,7 +63,6 @@ const util = __importStar(require("./util"));
const util_1 = require("./util");
/**
* Stores the CodeQL object, and is populated by `setupCodeQL` or `getCodeQL`.
* Can be overridden in tests using `setCodeQL`.
*/
let cachedCodeQL = undefined;
/**
@@ -150,6 +149,16 @@ async function getCodeQL(cmd) {
}
return cachedCodeQL;
}
/**
* Overrides the CodeQL object. Only for use in tests that cannot override
* CodeQL via dependency injection.
*
* Accepts a partial object. Any undefined methods will be implemented
* to immediately throw an exception indicating which method is missing.
*/
function setCodeQL(codeql) {
cachedCodeQL = createStubCodeQL(codeql);
}
function resolveFunction(partialCodeql, methodName, defaultImplementation) {
if (typeof partialCodeql[methodName] !== "function") {
if (defaultImplementation !== undefined) {
@@ -163,13 +172,13 @@ function resolveFunction(partialCodeql, methodName, defaultImplementation) {
return partialCodeql[methodName];
}
/**
* Set the functionality for CodeQL methods. Only for use in tests.
* Creates a stub CodeQL object. Only for use in tests.
*
* Accepts a partial object and any undefined methods will be implemented
* Accepts a partial object. Any undefined methods will be implemented
* to immediately throw an exception indicating which method is missing.
*/
function setCodeQL(partialCodeql) {
cachedCodeQL = {
function createStubCodeQL(partialCodeql) {
return {
getPath: resolveFunction(partialCodeql, "getPath", () => "/tmp/dummy-path"),
getVersion: resolveFunction(partialCodeql, "getVersion", async () => ({
version: "1.0.0",
@@ -200,20 +209,6 @@ function setCodeQL(partialCodeql) {
resolveExtractor: resolveFunction(partialCodeql, "resolveExtractor"),
mergeResults: resolveFunction(partialCodeql, "mergeResults"),
};
return cachedCodeQL;
}
/**
* Get the cached CodeQL object. Should only be used from tests.
*
* TODO: Work out a good way for tests to get this from the test context
* instead of having to have this method.
*/
function getCachedCodeQL() {
if (cachedCodeQL === undefined) {
// Should never happen as setCodeQL is called by testing-utils.setupTests
throw new Error("cachedCodeQL undefined");
}
return cachedCodeQL;
}
/**
* Get a real, newly created CodeQL instance for testing. The instance refers to

File diff suppressed because one or more lines are too long

View File

@@ -74,7 +74,15 @@ function createTestInitConfigInputs(overrides) {
debugDatabaseName: "",
repository: { owner: "github", repo: "example" },
tempDir: "",
codeql: {},
codeql: (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
javascript: [{ extractor_root: "" }],
},
};
},
}),
workspacePath: "",
sourceRoot: "",
githubVersion,
@@ -126,7 +134,7 @@ function mockListLanguages(languages) {
return await (0, util_1.withTmpDir)(async (tempDir) => {
const logger = (0, logging_1.getRunnerLogger)(true);
const languages = "javascript,python";
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
@@ -167,7 +175,7 @@ function mockListLanguages(languages) {
(0, ava_1.default)("loading config saves config", async (t) => {
return await (0, util_1.withTmpDir)(async (tempDir) => {
const logger = (0, logging_1.getRunnerLogger)(true);
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
@@ -219,7 +227,6 @@ function mockListLanguages(languages) {
await configUtils.initConfig(createTestInitConfigInputs({
configFile: "../input",
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -237,7 +244,6 @@ function mockListLanguages(languages) {
await configUtils.initConfig(createTestInitConfigInputs({
configFile,
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -257,7 +263,6 @@ function mockListLanguages(languages) {
languagesInput,
configFile,
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -269,7 +274,7 @@ function mockListLanguages(languages) {
});
(0, ava_1.default)("load non-empty input", async (t) => {
return await (0, util_1.withTmpDir)(async (tempDir) => {
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
@@ -383,7 +388,7 @@ function queriesToResolvedQueryForm(queries) {
`;
fs.mkdirSync(path.join(tempDir, "foo"));
const resolveQueriesArgs = [];
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
@@ -415,7 +420,7 @@ function queriesToResolvedQueryForm(queries) {
});
(0, ava_1.default)("API client used when reading remote config", async (t) => {
return await (0, util_1.withTmpDir)(async (tempDir) => {
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
@@ -477,7 +482,6 @@ function queriesToResolvedQueryForm(queries) {
await configUtils.initConfig(createTestInitConfigInputs({
configFile: repoReference,
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -498,7 +502,6 @@ function queriesToResolvedQueryForm(queries) {
await configUtils.initConfig(createTestInitConfigInputs({
configFile: repoReference,
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -511,7 +514,7 @@ function queriesToResolvedQueryForm(queries) {
(0, ava_1.default)("No detected languages", async (t) => {
return await (0, util_1.withTmpDir)(async (tempDir) => {
mockListLanguages([]);
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async resolveLanguages() {
return {};
},
@@ -539,7 +542,6 @@ function queriesToResolvedQueryForm(queries) {
await configUtils.initConfig(createTestInitConfigInputs({
languagesInput,
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -807,7 +809,7 @@ const mockRepositoryNwo = (0, repository_1.parseRepositoryNwo)("owner/repo");
const stubExtractorEntry = {
extractor_root: "",
};
const codeQL = (0, codeql_1.setCodeQL)({
const codeQL = (0, codeql_1.createStubCodeQL)({
betterResolveLanguages: () => Promise.resolve({
aliases: {
"c#": languages_1.KnownLanguage.csharp,

File diff suppressed because one or more lines are too long

View File

@@ -80,7 +80,7 @@ async function mockHttpRequests(databaseUploadStatusCode) {
return databaseUploadSpy;
}
function getCodeQL() {
return (0, codeql_1.setCodeQL)({
return (0, codeql_1.createStubCodeQL)({
async databaseBundle(_, outputFilePath) {
fs.writeFileSync(outputFilePath, "");
},

File diff suppressed because one or more lines are too long

13
lib/debug-artifacts.js generated
View File

@@ -50,7 +50,6 @@ const archiver_1 = __importDefault(require("archiver"));
const del_1 = __importDefault(require("del"));
const actions_util_1 = require("./actions-util");
const analyze_1 = require("./analyze");
const codeql_1 = require("./codeql");
const environment_1 = require("./environment");
const logging_1 = require("./logging");
const tools_features_1 = require("./tools-features");
@@ -120,11 +119,11 @@ function tryPrepareSarifDebugArtifact(config, language, logger) {
*
* @return The path to the database bundle, or undefined if an error occurs.
*/
async function tryBundleDatabase(config, language, logger) {
async function tryBundleDatabase(codeql, config, language, logger) {
try {
if ((0, analyze_1.dbIsFinalized)(config, language, logger)) {
try {
return await createDatabaseBundleCli(config, language);
return await createDatabaseBundleCli(codeql, config, language);
}
catch (e) {
logger.warning(`Failed to bundle database for ${language} using the CLI. ` +
@@ -143,7 +142,7 @@ async function tryBundleDatabase(config, language, logger) {
*
* Logs and suppresses any errors that occur.
*/
async function tryUploadAllAvailableDebugArtifacts(config, logger, codeQlVersion) {
async function tryUploadAllAvailableDebugArtifacts(codeql, config, logger, codeQlVersion) {
const filesToUpload = [];
try {
for (const language of config.languages) {
@@ -170,7 +169,7 @@ async function tryUploadAllAvailableDebugArtifacts(config, logger, codeQlVersion
}
// Add database bundle
logger.info("Preparing database bundle debug artifact...");
const databaseBundle = await tryBundleDatabase(config, language, logger);
const databaseBundle = await tryBundleDatabase(codeql, config, language, logger);
if (databaseBundle) {
filesToUpload.push(databaseBundle);
logger.info("Database bundle debug artifact ready for upload.");
@@ -269,8 +268,8 @@ async function createPartialDatabaseBundle(config, language) {
/**
* Runs `codeql database bundle` command and returns the path.
*/
async function createDatabaseBundleCli(config, language) {
const databaseBundlePath = await (0, util_1.bundleDb)(config, language, await (0, codeql_1.getCodeQL)(config.codeQLCmd), `${config.debugDatabaseName}-${language}`);
async function createDatabaseBundleCli(codeql, config, language) {
const databaseBundlePath = await (0, util_1.bundleDb)(config, language, codeql, `${config.debugDatabaseName}-${language}`);
return databaseBundlePath;
}
//# sourceMappingURL=debug-artifacts.js.map

File diff suppressed because one or more lines are too long

View File

@@ -116,7 +116,7 @@ async function tryUploadSarifIfRunFailed(config, repositoryNwo, features, logger
};
}
}
async function run(uploadAllAvailableDebugArtifacts, printDebugLogs, config, repositoryNwo, features, logger) {
async function run(uploadAllAvailableDebugArtifacts, printDebugLogs, codeql, config, repositoryNwo, features, logger) {
const uploadFailedSarifResult = await tryUploadSarifIfRunFailed(config, repositoryNwo, features, logger);
if (uploadFailedSarifResult.upload_failed_run_skipped_because) {
logger.debug("Won't upload a failed SARIF file for this CodeQL code scanning run because: " +
@@ -142,9 +142,8 @@ async function run(uploadAllAvailableDebugArtifacts, printDebugLogs, config, rep
// Upload appropriate Actions artifacts for debugging
if (config.debugMode) {
logger.info("Debug mode is on. Uploading available database bundles and logs as Actions debugging artifacts...");
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
const version = await codeql.getVersion();
await uploadAllAvailableDebugArtifacts(config, logger, version.version);
await uploadAllAvailableDebugArtifacts(codeql, config, logger, version.version);
await printDebugLogs(config);
}
if (actionsUtil.isSelfHostedRunner()) {

File diff suppressed because one or more lines are too long

View File

@@ -65,7 +65,7 @@ const workflow = __importStar(require("./workflow"));
});
const uploadAllAvailableDebugArtifactsSpy = sinon.spy();
const printDebugLogsSpy = sinon.spy();
await initActionPostHelper.run(uploadAllAvailableDebugArtifactsSpy, printDebugLogsSpy, (0, testing_utils_1.createTestConfig)({ debugMode: false }), (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
await initActionPostHelper.run(uploadAllAvailableDebugArtifactsSpy, printDebugLogsSpy, codeql.createStubCodeQL({}), (0, testing_utils_1.createTestConfig)({ debugMode: false }), (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
t.assert(uploadAllAvailableDebugArtifactsSpy.notCalled);
t.assert(printDebugLogsSpy.notCalled);
});
@@ -76,7 +76,7 @@ const workflow = __importStar(require("./workflow"));
process.env["RUNNER_TEMP"] = tmpDir;
const uploadAllAvailableDebugArtifactsSpy = sinon.spy();
const printDebugLogsSpy = sinon.spy();
await initActionPostHelper.run(uploadAllAvailableDebugArtifactsSpy, printDebugLogsSpy, (0, testing_utils_1.createTestConfig)({ debugMode: true }), (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
await initActionPostHelper.run(uploadAllAvailableDebugArtifactsSpy, printDebugLogsSpy, codeql.createStubCodeQL({}), (0, testing_utils_1.createTestConfig)({ debugMode: true }), (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
t.assert(uploadAllAvailableDebugArtifactsSpy.called);
t.assert(printDebugLogsSpy.called);
});

File diff suppressed because one or more lines are too long

View File

@@ -41,6 +41,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const actions_util_1 = require("./actions-util");
const api_client_1 = require("./api-client");
const codeql_1 = require("./codeql");
const config_utils_1 = require("./config-utils");
const debugArtifacts = __importStar(require("./debug-artifacts"));
const feature_flags_1 = require("./feature-flags");
@@ -66,7 +67,8 @@ async function runWrapper() {
logger.warning("Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.");
}
else {
uploadFailedSarifResult = await initActionPostHelper.run(debugArtifacts.tryUploadAllAvailableDebugArtifacts, actions_util_1.printDebugLogs, config, repositoryNwo, features, logger);
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
uploadFailedSarifResult = await initActionPostHelper.run(debugArtifacts.tryUploadAllAvailableDebugArtifacts, actions_util_1.printDebugLogs, codeql, config, repositoryNwo, features, logger);
}
}
catch (unwrappedError) {

View File

@@ -1 +1 @@
{"version":3,"file":"init-action-post.js","sourceRoot":"","sources":["../src/init-action-post.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AAEtC,iDAIwB;AACxB,6CAAgD;AAChD,iDAAmD;AACnD,kEAAoD;AACpD,mDAA2C;AAC3C,gFAAkE;AAClE,uCAA6C;AAC7C,6CAAgD;AAChD,mDAOyB;AACzB,iCAA8E;AAO9E,KAAK,UAAU,UAAU;IACvB,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IA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AAK,CACZ,CAAC;QACF,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM,IAAA,gCAAgB,EAAC,gBAAgB,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO;IACT,CAAC;IACD,MAAM,SAAS,GAAG,oBAAoB,CAAC,iBAAiB,EAAE,CAAC;IAC3D,MAAM,CAAC,IAAI,CAAC,yBAAyB,IAAA,uCAAuB,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAE5E,MAAM,gBAAgB,GAAG,MAAM,IAAA,sCAAsB,EACnD,0BAAU,CAAC,QAAQ,EACnB,SAAS,EACT,SAAS,EACT,MAAM,EACN,MAAM,IAAA,qBAAc,EAAC,MAAM,CAAC,EAC5B,MAAM,CACP,CAAC;IACF,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,YAAY,GAAyB;YACzC,GAAG,gBAAgB;YACnB,GAAG,uBAAuB;YAC1B,UAAU,EAAE,oBAAoB,CAAC,iBAAiB,EAAE;SACrD,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;QACzD,MAAM,IAAA,gCAAgB,EAAC,YAAY,CAAC,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}

2
lib/testing-utils.js generated
View File

@@ -233,7 +233,7 @@ const makeVersionInfo = (version, features) => ({
});
exports.makeVersionInfo = makeVersionInfo;
function mockCodeQLVersion(version, features) {
return codeql.setCodeQL({
return codeql.createStubCodeQL({
async getVersion() {
return (0, exports.makeVersionInfo)(version, features);
},

File diff suppressed because one or more lines are too long

View File

@@ -52,7 +52,7 @@ const testing_utils_1 = require("./testing-utils");
const trap_caching_1 = require("./trap-caching");
const util = __importStar(require("./util"));
(0, testing_utils_1.setupTests)(ava_1.default);
const stubCodeql = (0, codeql_1.setCodeQL)({
const stubCodeql = (0, codeql_1.createStubCodeQL)({
async getVersion() {
return (0, testing_utils_1.makeVersionInfo)("2.10.3");
},

File diff suppressed because one or more lines are too long

View File

@@ -71,8 +71,10 @@ test("analyze action with RAM & threads from environment variables", async (t) =
// wait for the action promise to complete before starting verification.
await analyzeAction.runPromise;
t.assert(runFinalizeStub.calledOnce);
t.deepEqual(runFinalizeStub.firstCall.args[1], "--threads=-1");
t.deepEqual(runFinalizeStub.firstCall.args[2], "--ram=4992");
t.assert(runQueriesStub.calledOnce);
t.deepEqual(runQueriesStub.firstCall.args[3], "--threads=-1");
t.deepEqual(runQueriesStub.firstCall.args[1], "--ram=4992");
});

View File

@@ -71,8 +71,10 @@ test("analyze action with RAM & threads from action inputs", async (t) => {
// wait for the action promise to complete before starting verification.
await analyzeAction.runPromise;
t.assert(runFinalizeStub.calledOnce);
t.deepEqual(runFinalizeStub.firstCall.args[1], "--threads=-1");
t.deepEqual(runFinalizeStub.firstCall.args[2], "--ram=3012");
t.assert(runQueriesStub.calledOnce);
t.deepEqual(runQueriesStub.firstCall.args[3], "--threads=-1");
t.deepEqual(runQueriesStub.firstCall.args[1], "--ram=3012");
});

View File

@@ -308,6 +308,7 @@ async function run() {
threads,
diffRangePackDir,
actionsUtil.getOptionalInput("category"),
codeql,
config,
logger,
features,

View File

@@ -11,7 +11,7 @@ import {
defaultSuites,
resolveQuerySuiteAlias,
} from "./analyze";
import { setCodeQL } from "./codeql";
import { createStubCodeQL } from "./codeql";
import { Feature } from "./feature-flags";
import { KnownLanguage } from "./languages";
import { getRunnerLogger } from "./logging";
@@ -42,7 +42,7 @@ test("status report fields", async (t) => {
sinon.stub(uploadLib, "validateSarifFileSchema");
for (const language of Object.values(KnownLanguage)) {
setCodeQL({
const codeql = createStubCodeQL({
databaseRunQueries: async () => {},
packDownload: async () => ({ packs: [] }),
databaseInterpretResults: async (
@@ -108,6 +108,7 @@ test("status report fields", async (t) => {
threadsFlag,
undefined,
undefined,
codeql,
config,
getRunnerLogger(true),
createFeatures([Feature.QaTelemetryEnabled]),

View File

@@ -13,7 +13,7 @@ import {
} from "./actions-util";
import { getApiClient } from "./api-client";
import { setupCppAutobuild } from "./autobuild";
import { CodeQL, getCodeQL } from "./codeql";
import { type CodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { getJavaTempDependencyDir } from "./dependency-caching";
import { addDiagnostic, makeDiagnostic } from "./diagnostics";
@@ -614,6 +614,7 @@ export async function runQueries(
threadsFlag: string,
diffRangePackDir: string | undefined,
automationDetailsId: string | undefined,
codeql: CodeQL,
config: configUtils.Config,
logger: Logger,
features: FeatureEnablement,
@@ -655,8 +656,6 @@ export async function runQueries(
? `--sarif-run-property=incrementalMode=${incrementalMode.join(",")}`
: undefined;
const codeql = await getCodeQL(config.codeQLCmd);
for (const language of config.languages) {
try {
const sarifFile = path.join(sarifFolder, `${language}.sarif`);

View File

@@ -285,7 +285,6 @@ interface PackDownloadItem {
/**
* Stores the CodeQL object, and is populated by `setupCodeQL` or `getCodeQL`.
* Can be overridden in tests using `setCodeQL`.
*/
let cachedCodeQL: CodeQL | undefined = undefined;
@@ -424,6 +423,17 @@ export async function getCodeQL(cmd: string): Promise<CodeQL> {
return cachedCodeQL;
}
/**
* Overrides the CodeQL object. Only for use in tests that cannot override
* CodeQL via dependency injection.
*
* Accepts a partial object. Any undefined methods will be implemented
* to immediately throw an exception indicating which method is missing.
*/
export function setCodeQL(codeql: Partial<CodeQL>): void {
cachedCodeQL = createStubCodeQL(codeql);
}
function resolveFunction<T>(
partialCodeql: Partial<CodeQL>,
methodName: string,
@@ -442,13 +452,13 @@ function resolveFunction<T>(
}
/**
* Set the functionality for CodeQL methods. Only for use in tests.
* Creates a stub CodeQL object. Only for use in tests.
*
* Accepts a partial object and any undefined methods will be implemented
* Accepts a partial object. Any undefined methods will be implemented
* to immediately throw an exception indicating which method is missing.
*/
export function setCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
cachedCodeQL = {
export function createStubCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
return {
getPath: resolveFunction(partialCodeql, "getPath", () => "/tmp/dummy-path"),
getVersion: resolveFunction(partialCodeql, "getVersion", async () => ({
version: "1.0.0",
@@ -509,21 +519,6 @@ export function setCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
resolveExtractor: resolveFunction(partialCodeql, "resolveExtractor"),
mergeResults: resolveFunction(partialCodeql, "mergeResults"),
};
return cachedCodeQL;
}
/**
* Get the cached CodeQL object. Should only be used from tests.
*
* TODO: Work out a good way for tests to get this from the test context
* instead of having to have this method.
*/
export function getCachedCodeQL(): CodeQL {
if (cachedCodeQL === undefined) {
// Should never happen as setCodeQL is called by testing-utils.setupTests
throw new Error("cachedCodeQL undefined");
}
return cachedCodeQL;
}
/**

View File

@@ -9,12 +9,7 @@ import * as sinon from "sinon";
import * as actionsUtil from "./actions-util";
import * as api from "./api-client";
import { CachingKind } from "./caching-utils";
import {
CodeQL,
getCachedCodeQL,
PackDownloadOutput,
setCodeQL,
} from "./codeql";
import { PackDownloadOutput, createStubCodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { Feature } from "./feature-flags";
import * as gitUtils from "./git-utils";
@@ -64,7 +59,15 @@ function createTestInitConfigInputs(
debugDatabaseName: "",
repository: { owner: "github", repo: "example" },
tempDir: "",
codeql: {} as CodeQL,
codeql: createStubCodeQL({
async betterResolveLanguages() {
return {
extractors: {
javascript: [{ extractor_root: "" }],
},
};
},
}),
workspacePath: "",
sourceRoot: "",
githubVersion,
@@ -127,7 +130,7 @@ test("load empty config", async (t) => {
const logger = getRunnerLogger(true);
const languages = "javascript,python";
const codeql = setCodeQL({
const codeql = createStubCodeQL({
async betterResolveLanguages() {
return {
extractors: {
@@ -179,7 +182,7 @@ test("loading config saves config", async (t) => {
return await withTmpDir(async (tempDir) => {
const logger = getRunnerLogger(true);
const codeql = setCodeQL({
const codeql = createStubCodeQL({
async betterResolveLanguages() {
return {
extractors: {
@@ -240,7 +243,6 @@ test("load input outside of workspace", async (t) => {
createTestInitConfigInputs({
configFile: "../input",
tempDir,
codeql: getCachedCodeQL(),
workspacePath: tempDir,
}),
);
@@ -268,7 +270,6 @@ test("load non-local input with invalid repo syntax", async (t) => {
createTestInitConfigInputs({
configFile,
tempDir,
codeql: getCachedCodeQL(),
workspacePath: tempDir,
}),
);
@@ -298,7 +299,6 @@ test("load non-existent input", async (t) => {
languagesInput,
configFile,
tempDir,
codeql: getCachedCodeQL(),
workspacePath: tempDir,
}),
);
@@ -318,7 +318,7 @@ test("load non-existent input", async (t) => {
test("load non-empty input", async (t) => {
return await withTmpDir(async (tempDir) => {
const codeql = setCodeQL({
const codeql = createStubCodeQL({
async betterResolveLanguages() {
return {
extractors: {
@@ -449,7 +449,7 @@ test("Using config input and file together, config input should be used.", async
queries: string[];
extraSearchPath: string | undefined;
}> = [];
const codeql = setCodeQL({
const codeql = createStubCodeQL({
async betterResolveLanguages() {
return {
extractors: {
@@ -490,7 +490,7 @@ test("Using config input and file together, config input should be used.", async
test("API client used when reading remote config", async (t) => {
return await withTmpDir(async (tempDir) => {
const codeql = setCodeQL({
const codeql = createStubCodeQL({
async betterResolveLanguages() {
return {
extractors: {
@@ -561,7 +561,6 @@ test("Remote config handles the case where a directory is provided", async (t) =
createTestInitConfigInputs({
configFile: repoReference,
tempDir,
codeql: getCachedCodeQL(),
workspacePath: tempDir,
}),
);
@@ -590,7 +589,6 @@ test("Invalid format of remote config handled correctly", async (t) => {
createTestInitConfigInputs({
configFile: repoReference,
tempDir,
codeql: getCachedCodeQL(),
workspacePath: tempDir,
}),
);
@@ -609,7 +607,7 @@ test("Invalid format of remote config handled correctly", async (t) => {
test("No detected languages", async (t) => {
return await withTmpDir(async (tempDir) => {
mockListLanguages([]);
const codeql = setCodeQL({
const codeql = createStubCodeQL({
async resolveLanguages() {
return {};
},
@@ -645,7 +643,6 @@ test("Unknown languages", async (t) => {
createTestInitConfigInputs({
languagesInput,
tempDir,
codeql: getCachedCodeQL(),
workspacePath: tempDir,
}),
);
@@ -1134,7 +1131,7 @@ const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
const stubExtractorEntry = {
extractor_root: "",
};
const codeQL = setCodeQL({
const codeQL = createStubCodeQL({
betterResolveLanguages: () =>
Promise.resolve({
aliases: {

View File

@@ -7,7 +7,7 @@ import * as sinon from "sinon";
import * as actionsUtil from "./actions-util";
import { GitHubApiDetails } from "./api-client";
import * as apiClient from "./api-client";
import { setCodeQL } from "./codeql";
import { createStubCodeQL } from "./codeql";
import { Config } from "./config-utils";
import { uploadDatabases } from "./database-upload";
import * as gitUtils from "./git-utils";
@@ -70,7 +70,7 @@ async function mockHttpRequests(databaseUploadStatusCode: number) {
}
function getCodeQL() {
return setCodeQL({
return createStubCodeQL({
async databaseBundle(_: string, outputFilePath: string) {
fs.writeFileSync(outputFilePath, "");
},

View File

@@ -9,7 +9,7 @@ import del from "del";
import { getOptionalInput, getTemporaryDirectory } from "./actions-util";
import { dbIsFinalized } from "./analyze";
import { getCodeQL } from "./codeql";
import { type CodeQL } from "./codeql";
import { Config } from "./config-utils";
import { EnvVar } from "./environment";
import { Language } from "./languages";
@@ -134,6 +134,7 @@ function tryPrepareSarifDebugArtifact(
* @return The path to the database bundle, or undefined if an error occurs.
*/
async function tryBundleDatabase(
codeql: CodeQL,
config: Config,
language: Language,
logger: Logger,
@@ -141,7 +142,7 @@ async function tryBundleDatabase(
try {
if (dbIsFinalized(config, language, logger)) {
try {
return await createDatabaseBundleCli(config, language);
return await createDatabaseBundleCli(codeql, config, language);
} catch (e) {
logger.warning(
`Failed to bundle database for ${language} using the CLI. ` +
@@ -166,6 +167,7 @@ async function tryBundleDatabase(
* Logs and suppresses any errors that occur.
*/
export async function tryUploadAllAvailableDebugArtifacts(
codeql: CodeQL,
config: Config,
logger: Logger,
codeQlVersion: string | undefined,
@@ -207,6 +209,7 @@ export async function tryUploadAllAvailableDebugArtifacts(
// Add database bundle
logger.info("Preparing database bundle debug artifact...");
const databaseBundle = await tryBundleDatabase(
codeql,
config,
language,
logger,
@@ -369,13 +372,14 @@ async function createPartialDatabaseBundle(
* Runs `codeql database bundle` command and returns the path.
*/
async function createDatabaseBundleCli(
codeql: CodeQL,
config: Config,
language: Language,
): Promise<string> {
const databaseBundlePath = await bundleDb(
config,
language,
await getCodeQL(config.codeQLCmd),
codeql,
`${config.debugDatabaseName}-${language}`,
);
return databaseBundlePath;

View File

@@ -41,6 +41,7 @@ test("post: init action with debug mode off", async (t) => {
await initActionPostHelper.run(
uploadAllAvailableDebugArtifactsSpy,
printDebugLogsSpy,
codeql.createStubCodeQL({}),
createTestConfig({ debugMode: false }),
parseRepositoryNwo("github/codeql-action"),
createFeatures([]),
@@ -63,6 +64,7 @@ test("post: init action with debug mode on", async (t) => {
await initActionPostHelper.run(
uploadAllAvailableDebugArtifactsSpy,
printDebugLogsSpy,
codeql.createStubCodeQL({}),
createTestConfig({ debugMode: true }),
parseRepositoryNwo("github/codeql-action"),
createFeatures([]),

View File

@@ -5,7 +5,7 @@ import * as github from "@actions/github";
import * as actionsUtil from "./actions-util";
import { getApiClient } from "./api-client";
import { getCodeQL } from "./codeql";
import { CodeQL, getCodeQL } from "./codeql";
import { Config } from "./config-utils";
import { EnvVar } from "./environment";
import { Feature, FeatureEnablement } from "./feature-flags";
@@ -160,11 +160,13 @@ export async function tryUploadSarifIfRunFailed(
export async function run(
uploadAllAvailableDebugArtifacts: (
codeql: CodeQL,
config: Config,
logger: Logger,
codeQlVersion: string,
) => Promise<void>,
printDebugLogs: (config: Config) => Promise<void>,
codeql: CodeQL,
config: Config,
repositoryNwo: RepositoryNwo,
features: FeatureEnablement,
@@ -212,9 +214,13 @@ export async function run(
logger.info(
"Debug mode is on. Uploading available database bundles and logs as Actions debugging artifacts...",
);
const codeql = await getCodeQL(config.codeQLCmd);
const version = await codeql.getVersion();
await uploadAllAvailableDebugArtifacts(config, logger, version.version);
await uploadAllAvailableDebugArtifacts(
codeql,
config,
logger,
version.version,
);
await printDebugLogs(config);
}

View File

@@ -12,6 +12,7 @@ import {
printDebugLogs,
} from "./actions-util";
import { getGitHubVersion } from "./api-client";
import { getCodeQL } from "./codeql";
import { Config, getConfig } from "./config-utils";
import * as debugArtifacts from "./debug-artifacts";
import { Features } from "./feature-flags";
@@ -61,9 +62,12 @@ async function runWrapper() {
"Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.",
);
} else {
const codeql = await getCodeQL(config.codeQLCmd);
uploadFailedSarifResult = await initActionPostHelper.run(
debugArtifacts.tryUploadAllAvailableDebugArtifacts,
printDebugLogs,
codeql,
config,
repositoryNwo,
features,

View File

@@ -263,7 +263,7 @@ export function mockCodeQLVersion(
version: string,
features?: { [name: string]: boolean },
) {
return codeql.setCodeQL({
return codeql.createStubCodeQL({
async getVersion() {
return makeVersionInfo(version, features);
},

View File

@@ -8,9 +8,9 @@ import * as sinon from "sinon";
import * as actionsUtil from "./actions-util";
import * as apiClient from "./api-client";
import {
setCodeQL,
getTrapCachingExtractorConfigArgs,
getTrapCachingExtractorConfigArgsForLang,
createStubCodeQL,
} from "./codeql";
import * as configUtils from "./config-utils";
import { Feature } from "./feature-flags";
@@ -34,7 +34,7 @@ import * as util from "./util";
setupTests(test);
const stubCodeql = setCodeQL({
const stubCodeql = createStubCodeQL({
async getVersion() {
return makeVersionInfo("2.10.3");
},