mirror of
https://github.com/github/codeql-action.git
synced 2025-12-22 23:30:05 +08:00
Ensure qlconfig file is created when config parsing in cli is on
Previously, with the config parsing in the cli feature flag turned on, the CLI was not able to download packs from other registries. This PR adds the codeql-action changes required for this. The CLI changes will be in a separate, internal PR.
This commit is contained in:
@@ -681,6 +681,7 @@ test("databaseInitCluster() without injected codescanning config", async (t) =>
|
||||
"",
|
||||
undefined,
|
||||
createFeatures([]),
|
||||
"/path/to/qlconfig.yml",
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
@@ -689,7 +690,7 @@ test("databaseInitCluster() without injected codescanning config", async (t) =>
|
||||
const configArg = args.find((arg: string) =>
|
||||
arg.startsWith("--codescanning-config=")
|
||||
);
|
||||
t.falsy(configArg, "Should have injected a codescanning config");
|
||||
t.falsy(configArg, "Should NOT have injected a codescanning config");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -720,6 +721,7 @@ const injectedConfigMacro = test.macro({
|
||||
"",
|
||||
undefined,
|
||||
createFeatures([Feature.CliConfigFileEnabled]),
|
||||
undefined,
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
@@ -1011,33 +1013,59 @@ test(
|
||||
);
|
||||
|
||||
test("does not use injected config", async (t: ExecutionContext<unknown>) => {
|
||||
const origCODEQL_PASS_CONFIG_TO_CLI = process.env.CODEQL_PASS_CONFIG_TO_CLI;
|
||||
process.env["CODEQL_PASS_CONFIG_TO_CLI"] = "false";
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(featureConfig[Feature.CliConfigFileEnabled].minimumVersion);
|
||||
|
||||
try {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(featureConfig[Feature.CliConfigFileEnabled].minimumVersion);
|
||||
await codeqlObject.databaseInitCluster(
|
||||
stubConfig,
|
||||
"",
|
||||
undefined,
|
||||
createFeatures([]),
|
||||
"/path/to/qlconfig.yml",
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
stubConfig,
|
||||
"",
|
||||
undefined,
|
||||
createFeatures([]),
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
// should not have used a config file
|
||||
const configArg = args.find((arg: string) =>
|
||||
arg.startsWith("--codescanning-config=")
|
||||
);
|
||||
t.falsy(configArg, "Should NOT have injected a codescanning config");
|
||||
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
// should have used an config file
|
||||
const configArg = args.find((arg: string) =>
|
||||
arg.startsWith("--codescanning-config=")
|
||||
);
|
||||
t.falsy(configArg, "Should NOT have injected a codescanning config");
|
||||
} finally {
|
||||
process.env["CODEQL_PASS_CONFIG_TO_CLI"] = origCODEQL_PASS_CONFIG_TO_CLI;
|
||||
}
|
||||
// should not have passed a qlconfig file
|
||||
const qlconfigArg = args.find((arg: string) => arg.startsWith("--qlconfig="));
|
||||
t.falsy(qlconfigArg, "Should NOT have injected a codescanning config");
|
||||
});
|
||||
|
||||
test("uses injected config AND qlconfig", async (t: ExecutionContext<unknown>) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG);
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
stubConfig,
|
||||
"",
|
||||
undefined,
|
||||
createFeatures([Feature.CliConfigFileEnabled]),
|
||||
"/path/to/qlconfig.yml",
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
// should have used a config file
|
||||
const configArg = args.find((arg: string) =>
|
||||
arg.startsWith("--codescanning-config=")
|
||||
);
|
||||
t.truthy(configArg, "Should have injected a qlconfig");
|
||||
|
||||
// should have passed a qlconfig file
|
||||
const qlconfigArg = args.find((arg: string) => arg.startsWith("--qlconfig="));
|
||||
t.truthy(qlconfigArg, "Should have injected a codescanning config");
|
||||
});
|
||||
|
||||
test("databaseInterpretResults() sets --sarif-add-baseline-file-info for 2.11.3", async (t) => {
|
||||
|
||||
Reference in New Issue
Block a user