context

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package context provides contextual validation for PI findings. It analyzes the surrounding code context to determine if a potential PI match is a true positive or a false positive based on usage patterns, variable names, and code structure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodePatternAnalyzer

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

CodePatternAnalyzer analyzes code patterns

func NewCodePatternAnalyzer

func NewCodePatternAnalyzer() *CodePatternAnalyzer

NewCodePatternAnalyzer creates a new code pattern analyzer

func (*CodePatternAnalyzer) AnalyzePattern

func (cpa *CodePatternAnalyzer) AnalyzePattern(finding detection.Finding, content string) PatternResult

AnalyzePattern analyzes if a finding matches common false positive patterns

type ContextValidator

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

ContextValidator provides code-aware validation to reduce false positives

func NewContextValidator

func NewContextValidator() *ContextValidator

NewContextValidator creates a new context validator

func (*ContextValidator) Validate

func (cv *ContextValidator) Validate(ctx context.Context, finding detection.Finding, fileContent string) (*ValidationResult, error)

Validate performs context-aware validation of a finding

type PatternResult

type PatternResult struct {
	IsLikelyFalsePositive bool   `json:"is_likely_false_positive"`
	Reason                string `json:"reason"`
	Pattern               string `json:"pattern"`
}

PatternResult represents the result of pattern analysis

type ProximityAnalyzer

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

ProximityAnalyzer analyzes proximity to contextual indicators

func NewProximityAnalyzer

func NewProximityAnalyzer() *ProximityAnalyzer

NewProximityAnalyzer creates a new proximity analyzer

func (*ProximityAnalyzer) HasValidContext

func (pa *ProximityAnalyzer) HasValidContext(finding detection.Finding, content string) bool

HasValidContext checks if the finding has valid contextual indicators nearby

type SyntaxContext

type SyntaxContext struct {
	InComment bool   `json:"in_comment"`
	InString  bool   `json:"in_string"`
	Language  string `json:"language"`
}

SyntaxContext represents syntax context information

type SyntaxContextAnalyzer

type SyntaxContextAnalyzer struct{}

SyntaxContextAnalyzer analyzes syntax context

func NewSyntaxContextAnalyzer

func NewSyntaxContextAnalyzer() *SyntaxContextAnalyzer

NewSyntaxContextAnalyzer creates a new syntax context analyzer

func (*SyntaxContextAnalyzer) AnalyzeContext

func (sca *SyntaxContextAnalyzer) AnalyzeContext(content string, finding detection.Finding) SyntaxContext

AnalyzeContext analyzes the syntax context of a finding

type ValidationResult

type ValidationResult struct {
	IsValid    bool    `json:"is_valid"`
	Confidence float64 `json:"confidence"`
	Reason     string  `json:"reason"`
	IsTestData bool    `json:"is_test_data"`
	IsMockData bool    `json:"is_mock_data"`
	InComment  bool    `json:"in_comment"`
	InString   bool    `json:"in_string"`
	HasContext bool    `json:"has_context"`
}

ValidationResult represents the result of context validation

Jump to

Keyboard shortcuts

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