Documentation
¶
Overview ¶
Package classifier provides snippet classification using carrier maps
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SaveBatchResult ¶
func SaveBatchResult(result *BatchResult, path string) error
SaveBatchResult saves batch results to a JSON file
Types ¶
type BatchInput ¶
BatchInput represents input for batch classification
func LoadBatchInput ¶
func LoadBatchInput(path string) ([]BatchInput, error)
LoadBatchInput loads batch input from a JSON file (PatchLeaks format)
func LoadSimpleBatchInput ¶
func LoadSimpleBatchInput(path string) ([]BatchInput, error)
LoadSimpleBatchInput loads batch input from a simple JSON array of strings
type BatchResult ¶
type BatchResult struct {
AnalyzedAt string `json:"analyzed_at"`
CarrierMapPath string `json:"carrier_map_path,omitempty"`
Framework string `json:"framework,omitempty"`
TotalFindings int `json:"total_findings"`
TotalSnippets int `json:"total_snippets"`
WithUserInput int `json:"with_user_input"`
WithoutUserInput int `json:"without_user_input"`
NeedsTracing int `json:"needs_tracing"`
BySourceType map[string]int `json:"by_source_type"`
Findings []FindingResult `json:"findings"`
}
BatchResult contains results for batch classification
func (*BatchResult) Summary ¶
func (r *BatchResult) Summary() string
Summary returns a human-readable summary of batch results
type ClassificationResult ¶
type ClassificationResult struct {
Snippet string `json:"snippet"`
HasUserInput bool `json:"has_user_input"`
NeedsTracing bool `json:"needs_tracing"`
Expressions []ExpressionResult `json:"expressions"`
Summary ClassificationSummary `json:"summary"`
}
ClassificationResult contains the complete analysis of a snippet
type ClassificationSummary ¶
type ClassificationSummary struct {
TotalExpressions int `json:"total_expressions"`
UserInputCount int `json:"user_input_count"`
NeedsTracingCount int `json:"needs_tracing_count"`
SourceTypesSeen []string `json:"source_types_seen"`
}
ClassificationSummary provides statistics about the classification
type Classifier ¶
type Classifier struct {
// contains filtered or unexported fields
}
Classifier classifies code snippets for user input
func NewClassifier ¶
func NewClassifier(carrierMap *discovery.CarrierMap) *Classifier
NewClassifier creates a classifier with a carrier map
func NewDirectClassifier ¶
func NewDirectClassifier() *Classifier
NewDirectClassifier creates a classifier for superglobals-only (no carrier map)
func (*Classifier) ClassifyBatch ¶
func (c *Classifier) ClassifyBatch(inputs []BatchInput) *BatchResult
ClassifyBatch analyzes multiple findings with snippets
func (*Classifier) ClassifySnippet ¶
func (c *Classifier) ClassifySnippet(snippet string) *ClassificationResult
ClassifySnippet analyzes a single code snippet
type ExpressionResult ¶
type ExpressionResult struct {
Expression string `json:"expression"`
SourceTypes []string `json:"source_types,omitempty"`
Key string `json:"key,omitempty"`
MatchedCarrier string `json:"matched_carrier,omitempty"`
NeedsTracing bool `json:"needs_tracing"`
IsSuperglobal bool `json:"is_superglobal"`
IsEscaped bool `json:"is_escaped,omitempty"`
}
ExpressionResult contains the classification of a single expression
type FindingResult ¶
type FindingResult struct {
FindingID string `json:"finding_id"`
Filename string `json:"filename,omitempty"`
TotalSnippets int `json:"total_snippets"`
WithUserInput int `json:"with_user_input"`
Snippets []ClassificationResult `json:"snippets"`
}
FindingResult contains results for a single finding