Skip to content

Commit 4366485

Browse files
henrymerceraeisenberg
authored andcommitted
Avoid passing an undefined qlconfig arg
1 parent 8340258 commit 4366485

6 files changed

+55
-10
lines changed

lib/codeql.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.test.js

+17-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.test.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codeql.test.ts

+32-3
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ test("passes a code scanning config AND qlconfig to the CLI when CLI config pass
10641064
t.truthy(hasQlconfigArg, "Should have injected a codescanning config");
10651065
});
10661066
});
1067+
10671068
test("passes a code scanning config BUT NOT a qlconfig to the CLI when CLI config passing is enabled", async (t: ExecutionContext<unknown>) => {
10681069
await util.withTmpDir(async (tempDir) => {
10691070
const runnerConstructorStub = stubToolRunnerConstructor();
@@ -1084,13 +1085,41 @@ test("passes a code scanning config BUT NOT a qlconfig to the CLI when CLI confi
10841085
const hasCodeScanningConfigArg = args.some((arg: string) =>
10851086
arg.startsWith("--codescanning-config=")
10861087
);
1087-
t.true(hasCodeScanningConfigArg, "Should NOT have injected a qlconfig");
1088+
t.true(
1089+
hasCodeScanningConfigArg,
1090+
"Should have injected a codescanning config"
1091+
);
10881092

1089-
// should have passed a qlconfig file
1093+
// should not have passed a qlconfig file
1094+
const hasQlconfigArg = args.some((arg: string) =>
1095+
arg.startsWith("--qlconfig=")
1096+
);
1097+
t.false(hasQlconfigArg, "should NOT have injected a qlconfig");
1098+
});
1099+
});
1100+
1101+
test("does not pass a qlconfig to the CLI when it is undefined", async (t: ExecutionContext<unknown>) => {
1102+
await util.withTmpDir(async (tempDir) => {
1103+
const runnerConstructorStub = stubToolRunnerConstructor();
1104+
const codeqlObject = await codeql.getCodeQLForTesting();
1105+
sinon
1106+
.stub(codeqlObject, "getVersion")
1107+
.resolves(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG);
1108+
1109+
await codeqlObject.databaseInitCluster(
1110+
{ ...stubConfig, tempDir },
1111+
"",
1112+
undefined,
1113+
createFeatures([Feature.CliConfigFileEnabled]),
1114+
undefined, // undefined qlconfigFile
1115+
getRunnerLogger(true)
1116+
);
1117+
1118+
const args = runnerConstructorStub.firstCall.args[1] as any[];
10901119
const hasQlconfigArg = args.some((arg: string) =>
10911120
arg.startsWith("--qlconfig=")
10921121
);
1093-
t.false(hasQlconfigArg, "Should have injected a codescanning config");
1122+
t.false(hasQlconfigArg, "should NOT have injected a qlconfig");
10941123
});
10951124
});
10961125

src/codeql.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ export async function getCodeQLForCmd(
619619
}
620620

621621
if (
622-
await util.codeQlVersionAbove(this, CODEQL_VERSION_INIT_WITH_QLCONFIG)
622+
qlconfigFile !== undefined &&
623+
(await util.codeQlVersionAbove(this, CODEQL_VERSION_INIT_WITH_QLCONFIG))
623624
) {
624625
extraArgs.push(`--qlconfig=${qlconfigFile}`);
625626
}

0 commit comments

Comments
 (0)