github / github/codeql

Question on directory structure

未关闭
#6,432 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
question
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

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!

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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