Note
This is an unofficial tool created by Field Security Specialists, and is not officially supported by GitHub.
qlsh is a simple shell for running CodeQL queries against a database.
It lets you write and run queries interactively in a REPL, and see the results immediately.
Note
This is an unofficial tool created by Field Security Specialists, and is not officially supported by GitHub.
qlsh /path/to/codeql-database
Get help with:
qlsh
The language of the database is autodetected, and any required language packs are downloaded for you from GitHub.com servers.
If the database is bundled it will be extracted into a temporary directory. For large databases, this can take a while. You may prefer to extract the database yourself and pass the path to that.
At the prompt, you can run queries and see the results immediately after a "select " statement is entered.
Any lines not starting with "select " and that are not recognised as a REPL command are added to the current CodeQL query.
Here's an example of using the REPL to run a query:
$ qlsh /path/to/codeql-database
codeql> select "Hello, world!"
| col0 |
+---------------+
| Hello, world! |
codeql> quit
$
Here's a slightly longer example on a Java database:
$ qlsh /path/to/codeql-database
codeql> from Expr expr
... where expr.getLocation().getFile().getBaseName() = "Main.java"
... select expr
| expr |
+-----------------+
| void |
| ...[] |
| String |
| println(...) |
| System.out |
| "Hello, World!" |
| 0 |
codeql> quit
$
Commands:
quit
- exit the shell (you can also use Control-D)help
- show the help messagehelp <search term>
- search CodeQL online library for provided terms, backed by AddSearch (see Privacy)show
- show the current queryreset
- clear the current query (you can also use Control-C)lang
- show the database languagedir
- show the current query's temporary directoryunlock
- unlock the database, if a.lock
file is present, by deleting it
- CodeQL CLI
- You can get this by one of:
- The CodeQL CLI with the CodeQL CLI extension installed with
gh extensions install github/gh-codeql
- Install on MacOS with
brew install codeql
- binary release
- Actions bundle
- The CodeQL CLI with the CodeQL CLI extension installed with
- You can get this by one of:
bash
jq
- a CodeQL database, for a codebase you are licensed to analyze
Optional:
rlwrap
for readline supportcurl
for online helplynx
for showing online help
It's just a bash script, so you can download it and run it from anywhere, such as your .local/bin
directory, if that's on your PATH
:
cp qlsh ~/.local/bin
You can also add an alias to your shell configuration:
Bash:
echo 'alias qlsh="/path/to/qlsh/qlsh"' >> ~/.bashrc
Zsh:
echo 'alias qlsh="/path/to/qlsh/qlsh"' >> ~/.zshrc
This project is licensed under the terms of the MIT open source license. Please refer to the LICENSE for the full terms.
This tool uses the codeql
binary, for which you must separately accept the license to use.
See CODEOWNERS for the list of maintainers.
Note
This is an unofficial tool created by Field Security Specialists, and is not officially supported by GitHub.
See the SUPPORT file.
This tool uses the codeql
binary. That tool can communicate with GitHub servers to perform its functions - in this case, to download required language packs. See PRIVACY for a link to the GitHub General Privacy Statement.
The help <keyword>
function uses the same service as used by the CodeQL docs website, which is hosted by AddSearch and subject to their privacy notice.
See the CHANGELOG, CONTRIBUTING, SECURITY, SUPPORT, CODE OF CONDUCT and PRIVACY files for more information.