Add warnings about CLI hack to codeql.ts

These warnings refer to a hack that was added to the CLI in
https://github.com/github/semmle-code/pull/39335

They can be removed again once the CLI has a more principled way for
the CLI to recognize that it's being invoked by the runner/action.
This commit is contained in:
Henning Makholm 2021-05-13 22:01:26 +02:00
parent 97887fe996
commit e7d4215894
3 changed files with 27 additions and 1 deletions

12
lib/codeql.js generated
View file

@ -312,6 +312,12 @@ function getCodeQLForCmd(cmd) {
}, },
async getTracerEnv(databasePath) { async getTracerEnv(databasePath) {
// Write tracer-env.js to a temp location. // Write tracer-env.js to a temp location.
// BEWARE: The name and location of this file is recognized by `codeql database
// trace-command` in order to enable special support for concatenable tracer
// configurations. Consequently the name must not be changed.
// (This warning can be removed once a different way to recognize the
// action/runner has been implemented in `codeql database trace-command`
// _and_ is present in the latest supported CLI release.)
const tracerEnvJs = path.resolve(databasePath, "working", "tracer-env.js"); const tracerEnvJs = path.resolve(databasePath, "working", "tracer-env.js");
fs.mkdirSync(path.dirname(tracerEnvJs), { recursive: true }); fs.mkdirSync(path.dirname(tracerEnvJs), { recursive: true });
fs.writeFileSync(tracerEnvJs, ` fs.writeFileSync(tracerEnvJs, `
@ -326,6 +332,12 @@ function getCodeQLForCmd(cmd) {
} }
process.stdout.write(process.argv[2]); process.stdout.write(process.argv[2]);
fs.writeFileSync(process.argv[2], JSON.stringify(env), 'utf-8');`); fs.writeFileSync(process.argv[2], JSON.stringify(env), 'utf-8');`);
// BEWARE: The name and location of this file is recognized by `codeql database
// trace-command` in order to enable special support for concatenable tracer
// configurations. Consequently the name must not be changed.
// (This warning can be removed once a different way to recognize the
// action/runner has been implemented in `codeql database trace-command`
// _and_ is present in the latest supported CLI release.)
const envFile = path.resolve(databasePath, "working", "env.tmp"); const envFile = path.resolve(databasePath, "working", "env.tmp");
await new toolrunner.ToolRunner(cmd, [ await new toolrunner.ToolRunner(cmd, [
"database", "database",

File diff suppressed because one or more lines are too long

View file

@ -508,11 +508,18 @@ function getCodeQLForCmd(cmd: string): CodeQL {
}, },
async getTracerEnv(databasePath: string) { async getTracerEnv(databasePath: string) {
// Write tracer-env.js to a temp location. // Write tracer-env.js to a temp location.
// BEWARE: The name and location of this file is recognized by `codeql database
// trace-command` in order to enable special support for concatenable tracer
// configurations. Consequently the name must not be changed.
// (This warning can be removed once a different way to recognize the
// action/runner has been implemented in `codeql database trace-command`
// _and_ is present in the latest supported CLI release.)
const tracerEnvJs = path.resolve( const tracerEnvJs = path.resolve(
databasePath, databasePath,
"working", "working",
"tracer-env.js" "tracer-env.js"
); );
fs.mkdirSync(path.dirname(tracerEnvJs), { recursive: true }); fs.mkdirSync(path.dirname(tracerEnvJs), { recursive: true });
fs.writeFileSync( fs.writeFileSync(
tracerEnvJs, tracerEnvJs,
@ -530,7 +537,14 @@ function getCodeQLForCmd(cmd: string): CodeQL {
fs.writeFileSync(process.argv[2], JSON.stringify(env), 'utf-8');` fs.writeFileSync(process.argv[2], JSON.stringify(env), 'utf-8');`
); );
// BEWARE: The name and location of this file is recognized by `codeql database
// trace-command` in order to enable special support for concatenable tracer
// configurations. Consequently the name must not be changed.
// (This warning can be removed once a different way to recognize the
// action/runner has been implemented in `codeql database trace-command`
// _and_ is present in the latest supported CLI release.)
const envFile = path.resolve(databasePath, "working", "env.tmp"); const envFile = path.resolve(databasePath, "working", "env.tmp");
await new toolrunner.ToolRunner(cmd, [ await new toolrunner.ToolRunner(cmd, [
"database", "database",
"trace-command", "trace-command",