github / github/codeql

Question on directory structure

Offen
#6,432 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
question
Vorherrschende Sprache
CodeQL
Sterne
10.1k
Forks
2.1k
Ø Merge
2 T. 15 Std.
Gemergte PRs (30 T.)
141

Beschreibung

I've recently started playing with CodeQL and it seems a very interesting tool. Since I'd like to learn how to use it properly in the long run, I'd like first to understand some basics about the intended directory structure. I'm currently playing with a tiny example file (`example.js`) and a very simple custom query (`example-query.ql`) from the documentation.

So far, I created a `codeql-home` directory in my home with the following folders inside:

- `codeql`: the extracted CodeQL package
- `codeql-repo`: the cloned repository suggested in the documentation
- `javascript-database`: the database created from a toy example

I created the database running the following command from the folder where `example.js` is located:

`codeql database create --language=javascript ~/codeql-home/javascript-database`

The first problem I have is that this creates a database not only for my JavaScript file `example.js`, but also for many others files shipped with CodeQL. I originally thought this was intended to support the analysis, however I realized that queries are checked against those files as well. This is annoying, because I get some alarms I'm not interested into. Am I doing something wrong so far?

The second problem I have is how to properly store custom queries. I initially tried to place `example-query.ql` in a custom folder, but I was getting errors due to undefined references, i.e., it was impossible to load module `javascript`. To address this, I temporarily placed the query at the following location:

`/codeql-home/codeql-repo/javascript/ql/src/example-query.ql`

This is also annoying, because I'd prefer to keep custom queries on a separated folder on my own Git repository. For the moment, I run the analysis as follows:

`codeql query run --database=~/codeql-home/javascript-database/ ~/codeql-home/codeql-repo/javascript/ql/src/example-query.ql`

Any comment on this setup and how to solve the issues? Thanks in advance!

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.