Skip to main content

CLI Usage

Complete command-line reference for CodeQL Wrapper.

Basic Commands​

Analyze Command​

The main command for running CodeQL analysis:

codeql-wrapper analyze [OPTIONS] REPOSITORY_PATH

Options​

OptionShortDescriptionDefault
--languages-lComma-separated list of languages to analyzeAll detected
--output-dir-oOutput directory for results./codeql-results
--monorepoTreat as monorepo (analyze sub-projects)false
--force-installForce CodeQL reinstallation using the latest versionfalse
--upload-sarifUpload SARIF results to GitHubfalse
--repositoryGitHub repository (owner/repo)Auto-detected
--commit-shaGit commit SHAAuto-detected
--refGit reference (branch/tag)Auto-detected
--github-tokenGitHub token for SARIF upload$GITHUB_TOKEN
--verbose-vEnable verbose loggingfalse
--only-changed-filesOnly analyze projects with changed files (monorepo only)false
--max-workersMaximum number of parallel workers for analysisAuto-detected
--build-modeBuild mode for compiled languages (e.g., "autobuild", "none")none
--build-scriptPath to a custom build scriptNone
--queriesComma-separated list of CodeQL query suite paths or namesDefault

Examples​

Single Repository Analysis​

# Basic analysis
codeql-wrapper analyze /path/to/repository

# Analyze specific languages only
codeql-wrapper analyze /path/to/repo --languages python,javascript

# Custom output directory
codeql-wrapper analyze /path/to/repo --output-dir /path/to/results

# Force CodeQL reinstallation using the latest CodeQL version before runing the analyze
codeql-wrapper analyze /path/to/repo --force-install

# Verbose output
codeql-wrapper analyze /path/to/repo --verbose

Monorepo Analysis​

# Analyze all sub-projects in a monorepo
codeql-wrapper analyze /path/to/monorepo --monorepo

# Analyze only changed files in a monorepo
codeql-wrapper analyze /path/to/monorepo --monorepo --only-changed-files

# Analyze with a custom build script and specific queries
codeql-wrapper analyze /path/to/monorepo --monorepo --build-script ./build.sh --queries security-and-quality,my-custom-queries

SARIF Upload​

# Analyze and upload (auto-detects Git info)
codeql-wrapper analyze /path/to/repo --upload-sarif

# With explicit parameters
codeql-wrapper analyze /path/to/repo \
--upload-sarif \
--repository owner/repository \
--commit-sha $COMMIT_SHA \
--ref refs/heads/main

Install Command​

Install or update CodeQL:

codeql-wrapper install [OPTIONS]

Options​

OptionShortDescription
--version-vSpecific CodeQL version to install
--force-fForce reinstallation

Examples​

# Install latest CodeQL
codeql-wrapper install

# Install specific version
codeql-wrapper install --version 2.15.0

# Force reinstallation
codeql-wrapper install --force

Upload SARIF Command​

Upload SARIF files to GitHub Code Scanning:

codeql-wrapper upload-sarif [OPTIONS] SARIF_FILES...

Options​

OptionDescriptionDefault
--repositoryGitHub repository (owner/repo)Auto-detected
--commit-shaGit commit SHAAuto-detected
--refGit referenceAuto-detected
--github-tokenGitHub token$GITHUB_TOKEN

Examples​

# Upload with auto-detection (single file)
codeql-wrapper upload-sarif results.sarif

# Upload multiple SARIF files
codeql-wrapper upload-sarif results-python.sarif results-java.sarif

# Upload with explicit parameters
codeql-wrapper upload-sarif results.sarif \
--repository owner/repo \
--commit-sha abc123 \
--ref refs/heads/main

Global Options​

These options work with all commands:

OptionShortDescription
--help-hShow help message
--versionShow version
--verbose-vEnable verbose logging

Supported Languages​

CodeQL Wrapper supports analysis for the following languages:

  • JavaScript/TypeScript - .js, .ts, .jsx, .tsx
  • Python - .py
  • Java - .java
  • C# - .cs
  • C/C++ - .c, .cpp, .h, .hpp
  • Go - .go
  • Ruby - .rb
  • Swift - .swift
  • Kotlin - .kt, .kts
  • GitHub Actions - .yml, .yaml (in .github/workflows/)

Environment Variables​

CodeQL Wrapper uses these environment variables:

VariableDescription
GITHUB_TOKENGitHub token for SARIF upload
CODEQL_DISTCodeQL installation directory (auto-set)
CODEQL_REPOCodeQL search paths (auto-set)

Exit Codes​

CodeMeaning
0Success
1General error
2Invalid arguments
3Analysis failure
4Upload failure

Configuration Files​

Currently, CodeQL Wrapper doesn't use configuration files, but you can create shell scripts or batch files to standardize your usage:

Example Script​

#!/bin/bash
# analyze-repo.sh

REPO_PATH=${1:-"."}
OUTPUT_DIR=${2:-"./security-results"}

codeql-wrapper analyze "$REPO_PATH" \
--output-dir "$OUTPUT_DIR" \
--upload-sarif \
--verbose

Usage:

chmod +x analyze-repo.sh
./analyze-repo.sh /path/to/repo