Avoid passing an undefined qlconfig arg
This commit is contained in:
parent
8340258886
commit
4366485427
6 changed files with 55 additions and 10 deletions
3
lib/codeql.js
generated
3
lib/codeql.js
generated
|
|
@ -335,7 +335,8 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||
extraArgs.push("--external-repository-token-stdin");
|
||||
}
|
||||
}
|
||||
if (await util.codeQlVersionAbove(this, exports.CODEQL_VERSION_INIT_WITH_QLCONFIG)) {
|
||||
if (qlconfigFile !== undefined &&
|
||||
(await util.codeQlVersionAbove(this, exports.CODEQL_VERSION_INIT_WITH_QLCONFIG))) {
|
||||
extraArgs.push(`--qlconfig=${qlconfigFile}`);
|
||||
}
|
||||
await runTool(cmd, [
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
20
lib/codeql.test.js
generated
20
lib/codeql.test.js
generated
|
|
@ -707,10 +707,24 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
// should have used a config file
|
||||
const hasCodeScanningConfigArg = args.some((arg) => arg.startsWith("--codescanning-config="));
|
||||
t.true(hasCodeScanningConfigArg, "Should NOT have injected a qlconfig");
|
||||
// should have passed a qlconfig file
|
||||
t.true(hasCodeScanningConfigArg, "Should have injected a codescanning config");
|
||||
// should not have passed a qlconfig file
|
||||
const hasQlconfigArg = args.some((arg) => arg.startsWith("--qlconfig="));
|
||||
t.false(hasQlconfigArg, "Should have injected a codescanning config");
|
||||
t.false(hasQlconfigArg, "should NOT have injected a qlconfig");
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("does not pass a qlconfig to the CLI when it is undefined", async (t) => {
|
||||
await util.withTmpDir(async (tempDir) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG);
|
||||
await codeqlObject.databaseInitCluster({ ...stubConfig, tempDir }, "", undefined, (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CliConfigFileEnabled]), undefined, // undefined qlconfigFile
|
||||
(0, logging_1.getRunnerLogger)(true));
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
const hasQlconfigArg = args.some((arg) => arg.startsWith("--qlconfig="));
|
||||
t.false(hasQlconfigArg, "should NOT have injected a qlconfig");
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-baseline-file-info for 2.11.3", async (t) => {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1064,6 +1064,7 @@ test("passes a code scanning config AND qlconfig to the CLI when CLI config pass
|
|||
t.truthy(hasQlconfigArg, "Should have injected a codescanning config");
|
||||
});
|
||||
});
|
||||
|
||||
test("passes a code scanning config BUT NOT a qlconfig to the CLI when CLI config passing is enabled", async (t: ExecutionContext<unknown>) => {
|
||||
await util.withTmpDir(async (tempDir) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
|
|
@ -1084,13 +1085,41 @@ test("passes a code scanning config BUT NOT a qlconfig to the CLI when CLI confi
|
|||
const hasCodeScanningConfigArg = args.some((arg: string) =>
|
||||
arg.startsWith("--codescanning-config=")
|
||||
);
|
||||
t.true(hasCodeScanningConfigArg, "Should NOT have injected a qlconfig");
|
||||
t.true(
|
||||
hasCodeScanningConfigArg,
|
||||
"Should have injected a codescanning config"
|
||||
);
|
||||
|
||||
// should have passed a qlconfig file
|
||||
// should not have passed a qlconfig file
|
||||
const hasQlconfigArg = args.some((arg: string) =>
|
||||
arg.startsWith("--qlconfig=")
|
||||
);
|
||||
t.false(hasQlconfigArg, "Should have injected a codescanning config");
|
||||
t.false(hasQlconfigArg, "should NOT have injected a qlconfig");
|
||||
});
|
||||
});
|
||||
|
||||
test("does not pass a qlconfig to the CLI when it is undefined", async (t: ExecutionContext<unknown>) => {
|
||||
await util.withTmpDir(async (tempDir) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG);
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
{ ...stubConfig, tempDir },
|
||||
"",
|
||||
undefined,
|
||||
createFeatures([Feature.CliConfigFileEnabled]),
|
||||
undefined, // undefined qlconfigFile
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
const args = runnerConstructorStub.firstCall.args[1] as any[];
|
||||
const hasQlconfigArg = args.some((arg: string) =>
|
||||
arg.startsWith("--qlconfig=")
|
||||
);
|
||||
t.false(hasQlconfigArg, "should NOT have injected a qlconfig");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -619,7 +619,8 @@ export async function getCodeQLForCmd(
|
|||
}
|
||||
|
||||
if (
|
||||
await util.codeQlVersionAbove(this, CODEQL_VERSION_INIT_WITH_QLCONFIG)
|
||||
qlconfigFile !== undefined &&
|
||||
(await util.codeQlVersionAbove(this, CODEQL_VERSION_INIT_WITH_QLCONFIG))
|
||||
) {
|
||||
extraArgs.push(`--qlconfig=${qlconfigFile}`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue