github / github/codeql-cli-binaries

Cannot access CodeQL environment variables in `database create --command`

未关闭
#2 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
CLI
主要语言
没有语言数据
星标
1k
派生
184
PR 合并指标
30 天内没有已合并 PR

描述

I would like to explicitly invoke the JavaScript autobuilder as part of `codeql database create`, with the ultimate goal of passing it some custom options. However, even invoking it without any options isn't as easy as I would have hoped, since I cannot figure out how to access CodeQL environment variables to specify the path to the autobuilder.

My first attempt of

```sh
codeql database create -l javascript --command '${CODEQL_EXTRACTOR_JAVASCRIPT_ROOT}/tools/autobuild.sh /path/to/database
```

was met with

```sh
A fatal error occurred: Failed to expand '${CODEQL_EXTRACTOR_JAVASCRIPT_ROOT}/tools/autobuild.sh' as an argument list.
(eventual cause: UserError "Attempting to expand unknown variable: CODEQL_EXTRACTOR_JAVASCRIPT_ROOT, available variables are: []")
```

@lcartey suggested adding `env.` like so:

```sh
codeql database create -l javascript --command '${env.CODEQL_EXTRACTOR_JAVASCRIPT_ROOT}/tools/autobuild.sh' /path/to/database
```

but that resulted in

```
A fatal error occurred: Failed to expand '${env.CODEQL_EXTRACTOR_JAVASCRIPT_ROOT}/tools/autobuild.sh' as an argument list.
(eventual cause: UserError "Attempting to expand unknown variable: env.CODEQL_EXTRACTOR_JAVASCRIPT_ROOT, ava...")
```

I am pretty sure this is the right environment variable name, cf. [here](https://git.semmle.com/Semmle/code/blob/master/language-packs/javascript/tools/autobuild.sh#L28).

Specifying the full path to the autobuild script is, of course, possible, but annoying.

贡献指南

打开贡献指南

调研方向

从入口点 `codeql database create --command` 及其参数变量展开入手,使用报告中的 `CODEQL_EXTRACTOR_JAVASCRIPT_ROOT` 和 `env.` 示例作为复现用例。追踪命令环境为何在展开期间不可用;当可以通过 CodeQL 环境变量提供 JavaScript autobuilder 路径,并且该行为由适当的测试覆盖时,即完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, shell
领域
cli
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。