codeql

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Resolves the latest CodeQL release versions from GitHub's redirect headers, avoiding the rate-limited JSON API.

Index

Constants

View Source
const (
	FallbackCLIVersion = "2.25.1"
)

Variables

This section is empty.

Functions

func Download

func Download(version, platform string) (p string, err error)

func Install

func Install(base, platform string) error

Install downloads and installs the CodeQL CLI or bundle based on config. When EnableCustomCodeQLBundles is true in config, the bundle is installed; otherwise the standalone CLI is used. version overrides the config value for CLI installs.

func LatestCLIVersion

func LatestCLIVersion() string

LatestCLIVersion returns the latest CodeQL CLI version string (e.g. "2.25.1"). Falls back to FallbackCLIVersion on any error.

Types

type CLI

type CLI struct {
	// contains filtered or unexported fields
}

CLI is a typed wrapper around the codeql binary. It owns an Runner and exposes one method per codeql subcommand that qlt invokes.

func NewCLI

func NewCLI(binary string) *CLI

func (*CLI) Binary

func (c *CLI) Binary() string

func (*CLI) DatabaseAnalyze

func (c *CLI) DatabaseAnalyze(opts DatabaseAnalyzeOptions) (*Result, error)

DatabaseAnalyze runs `codeql database analyze --format=... --output=... --threads=N --rerun [--additional-packs=...] <db> <query>`.

func (*CLI) PackBundle

func (c *CLI) PackBundle(dir, output, commonCaches string) (*Result, error)

PackBundle runs `codeql pack bundle --format=json --pack-path=<output> [--common-caches=<caches>] <dir>`.

func (*CLI) PackCreate

func (c *CLI) PackCreate(dir, output, commonCaches string) (*Result, error)

PackCreate runs `codeql pack create --format=json --output=<output> [--common-caches=<caches>] <dir>`.

func (*CLI) PackInstall

func (c *CLI) PackInstall(target, commonCaches string) (*Result, error)

PackInstall runs `codeql pack install --format=json [--common-caches=<caches>] <target>`.

func (*CLI) PackLs

func (c *CLI) PackLs(dir string) (*Result, error)

PackLs runs `codeql pack ls --format=json <dir>`.

func (*CLI) PackPublish

func (c *CLI) PackPublish(dir string) (*Result, error)

PackPublish runs `codeql pack publish <dir>`.

func (*CLI) PackResolveDependencies added in v0.0.2

func (c *CLI) PackResolveDependencies(dir string) (*Result, error)

PackResolveDependencies runs `codeql pack resolve-dependencies --format=json <dir>`.

func (*CLI) QueryCompile

func (c *CLI) QueryCompile(threads int, files ...string) (*Result, error)

QueryCompile runs `codeql query compile [--threads=N] -- <files>`.

func (*CLI) ResolveLanguages

func (c *CLI) ResolveLanguages() (*Result, error)

ResolveLanguages runs `codeql resolve languages --format=json`.

func (*CLI) ResolvePacks added in v0.0.2

func (c *CLI) ResolvePacks() (*Result, error)

ResolvePacks runs `codeql resolve packs --format=json`.

func (*CLI) ResolveTests

func (c *CLI) ResolveTests(dir string) (*Result, error)

ResolveTests runs `codeql resolve tests --strict-test-discovery --format json <dir>`.

func (*CLI) Run

func (c *CLI) Run(args ...string) (*Result, error)

Run is an escape hatch for codeql invocations not yet modelled here.

func (*CLI) TestRun

func (c *CLI) TestRun(threads int, extraArgs, testFile string) (*Result, error)

TestRun runs `codeql test run --threads N --format betterjson --quiet [extraArgs] <testFile>`.

type DatabaseAnalyzeOptions

type DatabaseAnalyzeOptions struct {
	Database        string
	QueryFile       string
	Format          string
	Output          string
	Threads         int
	AdditionalPacks string
}

DatabaseAnalyzeOptions collects the flags used by RunQuery.

type Result added in v0.1.0

type Result struct {
	Stdout   []byte
	Stderr   []byte
	ExitCode int
}

Result contains captured command output.

func (*Result) StderrString added in v0.1.0

func (r *Result) StderrString() string

func (*Result) StdoutString added in v0.1.0

func (r *Result) StdoutString() string

type RunError added in v0.1.0

type RunError struct {
	Binary   string
	Args     []string
	ExitCode int
	Stderr   string
	Cause    error
}

RunError includes command details and captured stderr for failed runs.

func (*RunError) Error added in v0.1.0

func (e *RunError) Error() string

func (*RunError) Unwrap added in v0.1.0

func (e *RunError) Unwrap() error

type Runner added in v0.1.0

type Runner struct {
	Binary string
	Stdin  io.Reader
}

Runner executes external commands and always captures stdout/stderr.

func NewRunner added in v0.1.0

func NewRunner(binary string) *Runner

NewRunner creates a command runner for a binary.

func (*Runner) Run added in v0.1.0

func (r *Runner) Run(args ...string) (*Result, error)

Run executes a command and captures both stdout and stderr.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL