A Bash tool to install the CodeQL CLI, pull in the official packs, build your Go project workspace, build a CodeQL database, run custom queries, and decode results. No bs—just repeatable steps and clear outputs.
☑️ Fighting CodeQL extensions in VS Code.
☑️ Wasting hours configuring analysis for each project.
☑️ Being limited to GUI tools when you live in tmux/vim/neovim.
-
Zero-IDE Setup
./codeql_analyzer.sh install
handles all dependencies
(For those who are not VS Code friendly) -
Terminal-First Workflow
Works with vim/emacs/nano + tmux/screen
(Cloud/server-friendly for SSH workflows)
-
Multi-Language Support : All Compiled languages (Java/C++ - when CodeQL's analysis works reliably in CLI mode)
--language=javascript|cpp|java|python
flags
- Cloud servers with no GUI? No problem - runs headless
- Need quick scans during CI/CD? Drops results in your pipeline
- Hate IDE bloat? Your favorite terminal editor works fine
- Automated CodeQL CLI and pack installation
- Project structure scaffolding
- Go code database creation
- Static analysis with SARIF/BQRS outputs
- Automatic result decoding to text
- Unified commands for different workflows
- Bash (Linux environment)
- CodeQL CLI (auto-installed)
- CodeQL Queries (auto-installed)
unzip
,git
,wget
,golang
(auto-installed if missing)- Tested on Debian/Ubuntu systems
git clone https://github.com/madedis/CodeQL-Automation-Tool.git
cd codeql-analyzer
chmod +x main.sh
- Working on headless servers/cloud instances
- Needing quick scans without IDE configuration
- Running repeatable analyses across environments
Command | What It Does |
---|---|
install |
Gets CodeQL CLI + queries |
create-db |
Builds DB from source dir |
analyze |
Runs queries → outputs SARIF/text |
full |
Install+create+analyze in one go |
--no-create |
Skips creating database if it's already created |
--help |
Usage |
sudo ./main.sh [OPTIONS] COMMAND [PARAMETERS]
sudo ./main.sh --help
--work-dir DIR
: Set working directory (default: current)--install-dir DIR
: Set installation root (default: /opt/static_recon_codeql/workspace)--project-name NAME
: Set project name (default: current directory name)--no-create
: skip creating database if it's already created.
-
Install Dependencies
sudo ./main.sh install
-
Create Project Structure
sudo ./main.sh setup
-
Create Code Database
sudo ./main.sh create-db /path/to/source-code
-
Run Analysis
sudo ./main.sh analyze --queries-dir /path/to/queries --src-dir /path/to/source
Run Analysis without the creation of a database again
sudo ./main.sh analyze --queries-dir /path/to/queries --src-dir /path/to/source --no-create
-
Full Pipeline
sudo ./main.sh full /path/to/source /path/to/queries
-
Install Core Components
sudo ./main.sh install
-
Initialize Project
sudo ./main.sh setup --project-name myapp
-
Build & Analyze
sudo ./main.sh full ./src ./security-queries
📂 install-dir/
├── codeql-cli/ # CLI binaries
├── codeql-repo/ # Standard queries
└── [project-name]/
├── artifacts/ # Analysis artifacts(optional)
├── go-database/ # CodeQL database
└── results/ # Analysis results (SARIF/TXT)
- First run requires
sudo
for package installations - Default analysis format is SARIF v2.1.0
- Logs stored in
codeql_auto.log
- Customize
INSTALL_DIR
in script for different locations
- Missing Dependencies: Ensure
apt
access and internet connection - Database Errors: Delete corrupted
go-database
folder and retry - Permission Issues: Run with
sudo
for system-wide installation
This is a time-saver - not a security silver bullet.
Test outputs before relying on critical systems.
Contributions welcome for bug fixes and QoL improvements.