Documentation
¶
Overview ¶
Package codeql provides a scanner implementation for GitHub CodeQL. CodeQL provides full inter-procedural dataflow analysis and outputs SARIF with complete codeFlows for taint tracking. The SARIF is converted by the SDK's SARIF parser (the ctis importer), not here.
Index ¶
- Constants
- Variables
- type Database
- type Language
- type QuerySuite
- type Scanner
- func (s *Scanner) AnalyzeExistingDatabase(ctx context.Context, dbPath string, opts *core.ScanOptions) (*core.ScanResult, error)
- func (s *Scanner) Capabilities() []string
- func (s *Scanner) IsInstalled(ctx context.Context) (bool, string, error)
- func (s *Scanner) Name() string
- func (s *Scanner) RoutesEgress() bool
- func (s *Scanner) Scan(ctx context.Context, target string, opts *core.ScanOptions) (*core.ScanResult, error)
- func (s *Scanner) SetVerbose(v bool)
- func (s *Scanner) SetVersion(v string)
- func (s *Scanner) SettingsSchema() *core.SettingsSchema
- func (s *Scanner) TakesCapabilityJobs() bool
- func (s *Scanner) ToolContract() *core.ToolContract
- func (s *Scanner) Type() core.ScannerType
- func (s *Scanner) Version() string
Constants ¶
const ( // DefaultBinary is the default CodeQL CLI binary name. DefaultBinary = "codeql" // DefaultOutputFile is the default SARIF output file name. DefaultOutputFile = "codeql-results.sarif" // DefaultTimeout is the default scan timeout. DefaultTimeout = 60 * time.Minute // DefaultQuerySuite is the default security query suite. DefaultQuerySuite = "security-extended" )
Variables ¶
var ContractTool = toolrun.Register(tool.New(ToolManifest, runTool))
ContractTool runs codeql in the tool child (Tool is the SARIF tool type).
var ToolManifest = toolrun.MustManifest(ToolYAML)
ToolManifest describes the codeql tool.
var ToolYAML []byte
ToolYAML is the tool's descriptor (OpenCTEM Tool Contract v1): the one place its contract is written. The sensor loads it at start and reports it to the platform by digest.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
Path string `json:"path"`
Language string `json:"language"`
CreatedAt string `json:"created_at,omitempty"`
SourceRoot string `json:"source_root,omitempty"`
ExtractorName string `json:"extractor_name,omitempty"`
}
Database represents a CodeQL database.
type Language ¶
type Language string
Language represents a CodeQL-supported language.
func SupportedLanguages ¶
func SupportedLanguages() []Language
SupportedLanguages returns all CodeQL-supported languages.
type QuerySuite ¶
type QuerySuite struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Queries []string `json:"queries"`
}
QuerySuite represents a collection of CodeQL queries.
type Scanner ¶
type Scanner struct {
// Configuration
Binary string // Path to codeql binary (default: "codeql")
OutputFile string // Report file: an absolute path is used as is; otherwise the base name, in a temporary directory removed after the scan
Timeout time.Duration // Scan timeout (default: 60 minutes)
Verbose bool // Enable verbose output
// CodeQL-specific options
Language Language // Target language (required)
DatabasePath string // Path to CodeQL database (optional: when empty, built in a temporary directory removed after the scan)
QueryPacks []string // Query packs to use (default: security-extended)
QueryFiles []string // Specific .ql files to run
Threads int // Number of threads (0 = auto)
RAMPerThread int // RAM per thread in MB (0 = default)
Format string // Output format (sarif-latest, csv, json)
SkipDBCreation bool // Skip database creation (use existing)
// contains filtered or unexported fields
}
Scanner implements the SAST scanner interface for CodeQL. CodeQL provides full inter-procedural dataflow analysis, making it ideal for detecting vulnerabilities that require taint tracking across functions and files.
func NewFullScanner ¶
NewFullScanner creates a scanner that runs all available queries.
func NewQualityScanner ¶
NewQualityScanner creates a scanner for code quality issues.
func NewScanner ¶
func NewScanner() *Scanner
NewScanner creates a new CodeQL scanner with default settings.
func NewSecurityScanner ¶
NewSecurityScanner creates a scanner focused on security vulnerabilities.
func (*Scanner) AnalyzeExistingDatabase ¶
func (s *Scanner) AnalyzeExistingDatabase(ctx context.Context, dbPath string, opts *core.ScanOptions) (*core.ScanResult, error)
AnalyzeExistingDatabase analyzes a pre-built CodeQL database.
func (*Scanner) Capabilities ¶
Capabilities returns the scanner capabilities.
func (*Scanner) IsInstalled ¶
IsInstalled checks if CodeQL is installed.
func (*Scanner) RoutesEgress ¶ added in v0.24.0
RoutesEgress reports whether a job's proxy pool carries every connection of the tool (core.EgressScanner): the tool runs out of process, behind the task forwarder; the in-process path would go direct, so a pooled job is refused there.
func (*Scanner) Scan ¶
func (s *Scanner) Scan(ctx context.Context, target string, opts *core.ScanOptions) (*core.ScanResult, error)
Scan performs a CodeQL scan on the target.
The scan runs out of process, in the task sandbox (tool.go), unless SENSOR_TOOL_RUNTIME=in-process.
func (*Scanner) SetVerbose ¶
SetVerbose enables/disables verbose output.
func (*Scanner) SetVersion ¶ added in v0.10.0
SetVersion sets the version IsInstalled found (a tool child that did not probe the binary itself reports the parent's).
func (*Scanner) SettingsSchema ¶ added in v0.11.0
func (s *Scanner) SettingsSchema() *core.SettingsSchema
SettingsSchema returns codeql's settings schema (core.SettingsSchemaProvider).
func (*Scanner) TakesCapabilityJobs ¶ added in v0.11.0
TakesCapabilityJobs reports whether the tool runs capability jobs (core.CapabilityScanner): its descriptor implements capabilities.
func (*Scanner) ToolContract ¶ added in v0.10.0
func (s *Scanner) ToolContract() *core.ToolContract
ToolContract names codeql's tool manifest in the sensor manifest.