Skip to content

Commit

Permalink
Revert "Use --codescanning-config flag of CLI"
Browse files Browse the repository at this point in the history
This reverts commit 0d87b8c.
  • Loading branch information
edoardopirovano committed Feb 17, 2022
1 parent 6a961c0 commit 326e511
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 50 deletions.
27 changes: 6 additions & 21 deletions lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/init.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 10 additions & 25 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ 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 { Config, PackWithVersion } from "./config-utils";
import { 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";
Expand Down Expand Up @@ -81,7 +80,8 @@ export interface CodeQL {
* Run 'codeql database init --db-cluster'.
*/
databaseInitCluster(
config: Config,
databasePath: string,
languages: Language[],
sourceRoot: string,
processName: string | undefined,
processLevel: number | undefined
Expand Down Expand Up @@ -220,7 +220,6 @@ 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";

/**
Expand Down Expand Up @@ -693,35 +692,26 @@ async function getCodeQLForCmd(
]);
},
async databaseInitCluster(
config: Config,
databasePath: string,
languages: Language[],
sourceRoot: string,
processName: string | undefined,
processLevel: number | undefined
) {
const extraArgs = config.languages.map(
(language) => `--language=${language}`
);
if (config.languages.filter(isTracedLanguage).length > 0) {
const extraArgs = languages.map((language) => `--language=${language}`);
if (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",
config.dbLocation,
databasePath,
`--source-root=${sourceRoot}`,
...extraArgs,
...getExtraOptionsFromEnv(["database", "init"]),
Expand Down Expand Up @@ -874,9 +864,7 @@ async function getCodeQLForCmd(
if (extraSearchPath !== undefined) {
codeqlArgs.push("--additional-packs", extraSearchPath);
}
if (!(await util.codeQlVersionAbove(this, CODEQL_VERSION_CONFIG_FILES))) {
codeqlArgs.push(querySuitePath);
}
codeqlArgs.push(querySuitePath);
await runTool(cmd, codeqlArgs);
},
async databaseInterpretResults(
Expand Down Expand Up @@ -911,10 +899,7 @@ async function getCodeQLForCmd(
) {
codeqlArgs.push("--sarif-category", automationDetailsId);
}
codeqlArgs.push(databasePath);
if (!(await util.codeQlVersionAbove(this, CODEQL_VERSION_CONFIG_FILES))) {
codeqlArgs.push(...querySuitePaths);
}
codeqlArgs.push(databasePath, ...querySuitePaths);
// capture stdout, which contains analysis summaries
return await runTool(cmd, codeqlArgs);
},
Expand Down
3 changes: 2 additions & 1 deletion src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export async function runInit(
if (await codeQlVersionAbove(codeql, CODEQL_VERSION_NEW_TRACING)) {
// Init a database cluster
await codeql.databaseInitCluster(
config,
config.dbLocation,
config.languages,
sourceRoot,
processName,
processLevel
Expand Down

0 comments on commit 326e511

Please sign in to comment.