Documentation
¶
Index ¶
- Constants
- func GetAvailableModels(provider Provider) []string
- func GetDefaultModel(provider Provider) string
- func GetSupportedProviders() []string
- func PrintAISummary(term *terminal.Terminal, summary AISummary, provider Provider, model string)
- func ShouldSkipAI(f rules.Finding) (bool, string)
- func ValidateProvider(provider string) error
- type AISummary
- type Analyzer
- type BatchVerificationResult
- type ClaudeClient
- func (c *ClaudeClient) Close() error
- func (c *ClaudeClient) GetProvider() Provider
- func (c *ClaudeClient) VerifyBatch(ctx context.Context, class string, findings []ContextualFinding) ([]BatchVerificationResult, error)
- func (c *ClaudeClient) VerifyFinding(ctx context.Context, finding rules.Finding) (*VerificationResult, error)
- type Client
- type Config
- type ContextProvider
- type ContextualFinding
- type EnhancedFinding
- type FindingContext
- type GeminiClient
- func (c *GeminiClient) Close() error
- func (c *GeminiClient) GetProvider() Provider
- func (c *GeminiClient) VerifyBatch(ctx context.Context, class string, findings []ContextualFinding) ([]BatchVerificationResult, error)
- func (c *GeminiClient) VerifyFinding(ctx context.Context, finding rules.Finding) (*VerificationResult, error)
- type GrokClient
- func (c *GrokClient) Close() error
- func (c *GrokClient) GetProvider() Provider
- func (c *GrokClient) VerifyBatch(ctx context.Context, class string, findings []ContextualFinding) ([]BatchVerificationResult, error)
- func (c *GrokClient) VerifyFinding(ctx context.Context, finding rules.Finding) (*VerificationResult, error)
- type OpenAIClient
- func (c *OpenAIClient) Close() error
- func (c *OpenAIClient) GetProvider() Provider
- func (c *OpenAIClient) VerifyBatch(ctx context.Context, class string, findings []ContextualFinding) ([]BatchVerificationResult, error)
- func (c *OpenAIClient) VerifyFinding(ctx context.Context, finding rules.Finding) (*VerificationResult, error)
- type Options
- type PerplexityClient
- func (c *PerplexityClient) Close() error
- func (c *PerplexityClient) GetProvider() Provider
- func (c *PerplexityClient) VerifyBatch(ctx context.Context, class string, findings []ContextualFinding) ([]BatchVerificationResult, error)
- func (c *PerplexityClient) VerifyFinding(ctx context.Context, finding rules.Finding) (*VerificationResult, error)
- type Provider
- type VerificationResult
Constants ¶
const DefaultWorkers = 4
DefaultWorkers is the batch concurrency used when none is configured.
Variables ¶
This section is empty.
Functions ¶
func GetAvailableModels ¶
GetAvailableModels returns a list of available models for a given provider
func GetDefaultModel ¶
GetDefaultModel returns the default model for a given provider
func GetSupportedProviders ¶
func GetSupportedProviders() []string
GetSupportedProviders returns a list of supported AI providers
func PrintAISummary ¶
PrintAISummary prints a summary box of AI analysis results to the terminal.
func ShouldSkipAI ¶
ShouldSkipAI returns (true, reason) when a finding does not need AI analysis. It subsumes the previous shouldSendToAI severity/rule-list gate — env-based filters (AI_MIN_SEVERITY, AI_INCLUDE_RULES, AI_EXCLUDE_RULES) run first.
func ValidateProvider ¶
ValidateProvider checks if the provider is supported
Types ¶
type AISummary ¶
type AISummary struct {
TotalAnalyzed int `json:"total_analyzed"`
SuccessfullyAnalyzed int `json:"successfully_analyzed"`
AnalysisErrors int `json:"analysis_errors"`
LikelyFalsePositives int `json:"likely_false_positives"`
LikelyTruePositives int `json:"likely_true_positives"`
HighConfidence int `json:"high_confidence"` // >= 0.8
MediumConfidence int `json:"medium_confidence"` // >= 0.6 && < 0.8
LowConfidence int `json:"low_confidence"` // < 0.6
SkippedByFilter int `json:"skipped_by_filter"`
}
AISummary provides statistics about AI analysis results
func GetSummary ¶
func GetSummary(enhancedFindings []EnhancedFinding) AISummary
GetSummary returns a summary of AI analysis results
type Analyzer ¶
type Analyzer struct {
// contains filtered or unexported fields
}
Analyzer handles AI-powered analysis of findings
func NewAnalyzer ¶
NewAnalyzer creates a new AI analyzer with default options.
func NewAnalyzerWithOptions ¶ added in v2.1.0
NewAnalyzerWithOptions creates a new AI analyzer.
func (*Analyzer) AnalyzeFindings ¶
func (a *Analyzer) AnalyzeFindings(ctx context.Context, findings []rules.Finding) ([]EnhancedFinding, error)
AnalyzeFindings analyzes multiple findings using AI
func (*Analyzer) AnalyzeSingleFinding ¶
func (a *Analyzer) AnalyzeSingleFinding(ctx context.Context, finding rules.Finding) (*EnhancedFinding, error)
AnalyzeSingleFinding analyzes a single finding using AI
type BatchVerificationResult ¶
type BatchVerificationResult struct {
Index int `json:"index"`
Result *VerificationResult `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
BatchVerificationResult is one result from a VerifyBatch call. Index echoes the input finding's position for correct attribution.
type ClaudeClient ¶
type ClaudeClient struct {
// contains filtered or unexported fields
}
ClaudeClient implements the Client interface for Anthropic Claude API
func NewClaudeClient ¶
func NewClaudeClient(config Config) (*ClaudeClient, error)
NewClaudeClient creates a new Claude client
func (*ClaudeClient) GetProvider ¶
func (c *ClaudeClient) GetProvider() Provider
GetProvider returns the provider name
func (*ClaudeClient) VerifyBatch ¶
func (c *ClaudeClient) VerifyBatch(ctx context.Context, class string, findings []ContextualFinding) ([]BatchVerificationResult, error)
VerifyBatch analyzes a batch of findings of the same class using Claude.
func (*ClaudeClient) VerifyFinding ¶
func (c *ClaudeClient) VerifyFinding(ctx context.Context, finding rules.Finding) (*VerificationResult, error)
VerifyFinding analyzes a finding using Claude
type Client ¶
type Client interface {
// VerifyFinding analyzes a security finding and determines if it's likely a false positive
VerifyFinding(ctx context.Context, finding rules.Finding) (*VerificationResult, error)
// VerifyBatch analyses up to 5 findings of the same class in one API call.
VerifyBatch(ctx context.Context, class string, findings []ContextualFinding) ([]BatchVerificationResult, error)
// GetProvider returns the provider name
GetProvider() Provider
// Close cleans up any resources
Close() error
}
Client interface for AI providers
type Config ¶
type Config struct {
Provider Provider `yaml:"provider"`
APIKey string `yaml:"api_key"`
BaseURL string `yaml:"base_url,omitempty"` // Custom endpoint for self-hosted models
Model string `yaml:"model,omitempty"` // Specific model to use
// Request configuration
MaxTokens int `yaml:"max_tokens,omitempty"`
Temperature float64 `yaml:"temperature,omitempty"`
Timeout int `yaml:"timeout,omitempty"` // seconds
}
Config holds configuration for AI clients
type ContextProvider ¶ added in v2.1.0
type ContextProvider struct {
// contains filtered or unexported fields
}
ContextProvider resolves findings back to the workflow they came from.
func NewContextProvider ¶ added in v2.1.0
func NewContextProvider(files []parser.WorkflowFile) *ContextProvider
NewContextProvider indexes the scanned workflows for lookup by path.
func (*ContextProvider) For ¶ added in v2.1.0
func (p *ContextProvider) For(f rules.Finding) FindingContext
For returns the context for a finding. A finding whose workflow cannot be resolved yields a zero context rather than an error: the analysis should still run, just with less evidence.
type ContextualFinding ¶ added in v2.1.0
type ContextualFinding struct {
Finding rules.Finding
Context FindingContext
}
ContextualFinding pairs a finding with the workflow evidence needed to judge it. Findings are never sent to a model without this.
type EnhancedFinding ¶
type EnhancedFinding struct {
rules.Finding
AIVerification *VerificationResult `json:"ai_verification,omitempty"`
AIError string `json:"ai_error,omitempty"`
AISkipped bool `json:"ai_skipped,omitempty"`
AISkipReason string `json:"ai_skip_reason,omitempty"`
}
EnhancedFinding represents a finding enhanced with AI verification
type FindingContext ¶ added in v2.1.0
type FindingContext struct {
// Snippet is the workflow source around the finding, with line numbers.
Snippet string
// WorkflowTriggers lists the events that can start this workflow, which
// determines whether an untrusted actor can reach the finding at all.
WorkflowTriggers []string
// WorkflowPermissions and JobPermissions describe the credentials in scope.
// "not set" and "default" are meaningfully different, so both are rendered
// explicitly rather than left empty.
WorkflowPermissions string
JobPermissions string
// JobNeeds records upstream jobs, since data can arrive through them.
JobNeeds []string
// JobRunsOn distinguishes hosted from self-hosted runners.
JobRunsOn string
// StepUses and StepRun are the full step definition, not the truncated
// evidence fragment.
StepUses string
StepRun string
}
FindingContext is the workflow evidence a model needs in order to judge a finding.
Without it a model is asked, for example, whether an action runs "in a privileged job" while being told nothing about the job's permissions. It can only guess, and a guessing model that is also asked for a confidence score produces confident fabrication. Every field here exists because one of the prompts depends on it.
type GeminiClient ¶
type GeminiClient struct {
// contains filtered or unexported fields
}
GeminiClient implements the Client interface for Google Gemini API
func NewGeminiClient ¶
func NewGeminiClient(config Config) (*GeminiClient, error)
NewGeminiClient creates a new Gemini client
func (*GeminiClient) GetProvider ¶
func (c *GeminiClient) GetProvider() Provider
GetProvider returns the provider name
func (*GeminiClient) VerifyBatch ¶
func (c *GeminiClient) VerifyBatch(ctx context.Context, class string, findings []ContextualFinding) ([]BatchVerificationResult, error)
VerifyBatch analyzes a batch of findings of the same class using Gemini.
func (*GeminiClient) VerifyFinding ¶
func (c *GeminiClient) VerifyFinding(ctx context.Context, finding rules.Finding) (*VerificationResult, error)
VerifyFinding analyzes a finding using Gemini
type GrokClient ¶
type GrokClient struct {
// contains filtered or unexported fields
}
GrokClient implements the Client interface for xAI Grok API
func NewGrokClient ¶
func NewGrokClient(config Config) (*GrokClient, error)
NewGrokClient creates a new Grok client
func (*GrokClient) GetProvider ¶
func (c *GrokClient) GetProvider() Provider
GetProvider returns the provider name
func (*GrokClient) VerifyBatch ¶
func (c *GrokClient) VerifyBatch(ctx context.Context, class string, findings []ContextualFinding) ([]BatchVerificationResult, error)
VerifyBatch analyzes a batch of findings of the same class using Grok.
func (*GrokClient) VerifyFinding ¶
func (c *GrokClient) VerifyFinding(ctx context.Context, finding rules.Finding) (*VerificationResult, error)
VerifyFinding analyzes a finding using Grok
type OpenAIClient ¶
type OpenAIClient struct {
// contains filtered or unexported fields
}
OpenAIClient implements the Client interface for OpenAI API
func NewOpenAIClient ¶
func NewOpenAIClient(config Config) (*OpenAIClient, error)
NewOpenAIClient creates a new OpenAI client
func (*OpenAIClient) GetProvider ¶
func (c *OpenAIClient) GetProvider() Provider
GetProvider returns the provider name
func (*OpenAIClient) VerifyBatch ¶
func (c *OpenAIClient) VerifyBatch(ctx context.Context, class string, findings []ContextualFinding) ([]BatchVerificationResult, error)
VerifyBatch analyzes a batch of findings of the same class using OpenAI.
func (*OpenAIClient) VerifyFinding ¶
func (c *OpenAIClient) VerifyFinding(ctx context.Context, finding rules.Finding) (*VerificationResult, error)
VerifyFinding analyzes a finding using OpenAI
type Options ¶ added in v2.1.0
type Options struct {
// RequestTimeout bounds a single provider request. Defaults to 30s.
RequestTimeout time.Duration
// TotalTimeout optionally bounds the whole analysis. Zero means unbounded.
TotalTimeout time.Duration
// Workers is the number of batches dispatched concurrently. Defaults to 4,
// which keeps throughput high without tripping provider rate limits.
Workers int
// Contexts supplies workflow evidence for each finding. May be nil, in
// which case findings are sent without surrounding context.
Contexts *ContextProvider
}
Options configures an Analyzer.
type PerplexityClient ¶
type PerplexityClient struct {
// contains filtered or unexported fields
}
PerplexityClient implements the Client interface for Perplexity AI API
func NewPerplexityClient ¶
func NewPerplexityClient(config Config) (*PerplexityClient, error)
NewPerplexityClient creates a new Perplexity client
func (*PerplexityClient) GetProvider ¶
func (c *PerplexityClient) GetProvider() Provider
GetProvider returns the provider name
func (*PerplexityClient) VerifyBatch ¶
func (c *PerplexityClient) VerifyBatch(ctx context.Context, class string, findings []ContextualFinding) ([]BatchVerificationResult, error)
VerifyBatch analyzes a batch of findings of the same class using Perplexity.
func (*PerplexityClient) VerifyFinding ¶
func (c *PerplexityClient) VerifyFinding(ctx context.Context, finding rules.Finding) (*VerificationResult, error)
VerifyFinding analyzes a finding using Perplexity
type VerificationResult ¶
type VerificationResult struct {
IsLikelyFalsePositive bool `json:"is_likely_false_positive"`
Confidence float64 `json:"confidence"` // 0.0 to 1.0
Reasoning string `json:"reasoning"`
Severity string `json:"suggested_severity,omitempty"`
Remediation string `json:"remediation,omitempty"`
}
VerificationResult represents the AI's assessment of a finding