github / github/codeql-cli-binaries
Cannot access CodeQL environment variables in `database create --command`
- Vorherrschende Sprache
- Keine Sprachdaten
- Sterne
- 1k
- Forks
- 184
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Rechercherichtung
Beginnen Sie mit dem Einstiegspunkt `codeql database create --command` und seiner Argument-Variablenexpansion, wobei Sie die gemeldeten Beispiele `CODEQL_EXTRACTOR_JAVASCRIPT_ROOT` und `env.` als Reproduktionsfälle verwenden. Verfolgen Sie, warum die Befehlsumgebung während der Expansion nicht verfügbar ist; die Arbeit ist abgeschlossen, wenn der JavaScript-Autobuilder-Pfad über die CodeQL-Umgebungsvariable angegeben werden kann und das Verhalten durch einen geeigneten Test abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, shell
- Bereich
- cli
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100