mirror of
https://github.com/github/codeql-action.git
synced 2026-01-06 22:50:17 +08:00
Use --codescanning-config flag of CLI
This commit is contained in:
@@ -4,12 +4,13 @@ import * as path from "path";
|
||||
import * as toolrunner from "@actions/exec/lib/toolrunner";
|
||||
import { IHeaders } from "@actions/http-client/interfaces";
|
||||
import { default as deepEqual } from "fast-deep-equal";
|
||||
import * as yaml from "js-yaml";
|
||||
import { default as queryString } from "query-string";
|
||||
import * as semver from "semver";
|
||||
|
||||
import { isRunningLocalAction, getRelativeScriptPath } from "./actions-util";
|
||||
import * as api from "./api-client";
|
||||
import { PackWithVersion } from "./config-utils";
|
||||
import { Config, PackWithVersion } from "./config-utils";
|
||||
import * as defaults from "./defaults.json"; // Referenced from codeql-action-sync-tool!
|
||||
import { errorMatchers } from "./error-matcher";
|
||||
import { isTracedLanguage, Language } from "./languages";
|
||||
@@ -80,8 +81,7 @@ export interface CodeQL {
|
||||
* Run 'codeql database init --db-cluster'.
|
||||
*/
|
||||
databaseInitCluster(
|
||||
databasePath: string,
|
||||
languages: Language[],
|
||||
config: Config,
|
||||
sourceRoot: string,
|
||||
processName: string | undefined,
|
||||
processLevel: number | undefined
|
||||
@@ -219,6 +219,7 @@ const CODEQL_VERSION_GROUP_RULES = "2.5.5";
|
||||
const CODEQL_VERSION_SARIF_GROUP = "2.5.3";
|
||||
export const CODEQL_VERSION_COUNTS_LINES = "2.6.2";
|
||||
const CODEQL_VERSION_CUSTOM_QUERY_HELP = "2.7.1";
|
||||
const CODEQL_VERSION_CONFIG_FILES = "2.7.3";
|
||||
export const CODEQL_VERSION_ML_POWERED_QUERIES = "2.7.5";
|
||||
|
||||
/**
|
||||
@@ -691,26 +692,35 @@ async function getCodeQLForCmd(
|
||||
]);
|
||||
},
|
||||
async databaseInitCluster(
|
||||
databasePath: string,
|
||||
languages: Language[],
|
||||
config: Config,
|
||||
sourceRoot: string,
|
||||
processName: string | undefined,
|
||||
processLevel: number | undefined
|
||||
) {
|
||||
const extraArgs = languages.map((language) => `--language=${language}`);
|
||||
if (languages.filter(isTracedLanguage).length > 0) {
|
||||
const extraArgs = config.languages.map(
|
||||
(language) => `--language=${language}`
|
||||
);
|
||||
if (config.languages.filter(isTracedLanguage).length > 0) {
|
||||
extraArgs.push("--begin-tracing");
|
||||
if (processName !== undefined) {
|
||||
extraArgs.push(`--trace-process-name=${processName}`);
|
||||
} else {
|
||||
// We default to 3 if no other arguments are provided since this was the default
|
||||
// behaviour of the Runner. Note this path never happens in the CodeQL Action
|
||||
// because that always passes in a process name.
|
||||
extraArgs.push(`--trace-process-level=${processLevel || 3}`);
|
||||
}
|
||||
}
|
||||
if (await util.codeQlVersionAbove(codeql, CODEQL_VERSION_CONFIG_FILES)) {
|
||||
const configLocation = path.resolve(config.tempDir, "user-config.yaml");
|
||||
fs.writeFileSync(configLocation, yaml.dump(config.originalUserInput));
|
||||
extraArgs.push(`--codescanning-config=${configLocation}`);
|
||||
}
|
||||
await runTool(cmd, [
|
||||
"database",
|
||||
"init",
|
||||
"--db-cluster",
|
||||
databasePath,
|
||||
config.dbLocation,
|
||||
`--source-root=${sourceRoot}`,
|
||||
...extraArgs,
|
||||
...getExtraOptionsFromEnv(["database", "init"]),
|
||||
@@ -863,7 +873,9 @@ async function getCodeQLForCmd(
|
||||
if (extraSearchPath !== undefined) {
|
||||
codeqlArgs.push("--additional-packs", extraSearchPath);
|
||||
}
|
||||
codeqlArgs.push(querySuitePath);
|
||||
if (!(await util.codeQlVersionAbove(this, CODEQL_VERSION_CONFIG_FILES))) {
|
||||
codeqlArgs.push(querySuitePath);
|
||||
}
|
||||
await runTool(cmd, codeqlArgs);
|
||||
},
|
||||
async databaseInterpretResults(
|
||||
@@ -898,7 +910,10 @@ async function getCodeQLForCmd(
|
||||
) {
|
||||
codeqlArgs.push("--sarif-category", automationDetailsId);
|
||||
}
|
||||
codeqlArgs.push(databasePath, ...querySuitePaths);
|
||||
codeqlArgs.push(databasePath);
|
||||
if (!(await util.codeQlVersionAbove(this, CODEQL_VERSION_CONFIG_FILES))) {
|
||||
codeqlArgs.push(...querySuitePaths);
|
||||
}
|
||||
// capture stdout, which contains analysis summaries
|
||||
return await runTool(cmd, codeqlArgs);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user