scanner

package
v0.8.18 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBuffer added in v0.8.0

func GetBuffer() []byte

func GetPatternDir

func GetPatternDir() (string, error)

func GetPatterns

func GetPatterns(dir string) ([]string, error)

func GetResult

func GetResult() *models.Result

func GetToolDir

func GetToolDir() (string, error)

func IsLiteral added in v0.6.7

func IsLiteral(p string) bool

IsLiteral checks if a pattern string is a simple literal (no regex special chars)

func LoadPattern

func LoadPattern(f string) (models.Pattern, error)

func LoadToolFromFile

func LoadToolFromFile(f string) (models.Tool, error)

func LoadTools

func LoadTools() ([]models.Tool, error)

func LoadToolsFrom

func LoadToolsFrom(dirs ...string) ([]models.Tool, error)

func PutBuffer added in v0.8.0

func PutBuffer(b []byte)

func PutResult

func PutResult(r *models.Result)

Types

type BaseEngine

type BaseEngine struct {
	BinaryPath string
}

BaseEngine provides common functionality for engines.

type CSVParser added in v0.5.0

type CSVParser struct {
	Config models.InputConfig
}

CSVParser handles CSV files

func (*CSVParser) GetRecords added in v0.5.0

func (p *CSVParser) GetRecords(ctx context.Context, reader io.Reader, path string) (<-chan ScanRecord, error)

func (*CSVParser) GetRecordsParallel added in v0.8.2

func (p *CSVParser) GetRecordsParallel(ctx context.Context, data []byte, path string, concurrency int) (<-chan ScanRecord, error)

type CompiledPattern added in v0.7.0

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

type Engine

type Engine interface {
	Execute(ctx context.Context, p models.Pattern, targets ...string) (<-chan *models.Result, error)
}

Engine defines the interface for a pattern matching engine.

type FastJSONParser added in v0.6.7

type FastJSONParser struct {
	Config models.InputConfig
}

FastJSONParser uses buger/jsonparser for lightning-fast field extraction without full unmarshal

func (*FastJSONParser) GetRecords added in v0.6.7

func (p *FastJSONParser) GetRecords(ctx context.Context, reader io.Reader, path string) (<-chan ScanRecord, error)

func (*FastJSONParser) GetRecordsParallel added in v0.8.2

func (p *FastJSONParser) GetRecordsParallel(ctx context.Context, data []byte, path string, concurrency int) (<-chan ScanRecord, error)

type GrepEngine

type GrepEngine struct {
	BaseEngine
}

GrepEngine uses 'grep' for pattern matching.

func NewGrepEngine

func NewGrepEngine() (*GrepEngine, error)

func (*GrepEngine) Execute

func (e *GrepEngine) Execute(ctx context.Context, p models.Pattern, targets ...string) (<-chan *models.Result, error)

type HitCounter added in v0.6.8

type HitCounter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

type LiteralMatcher added in v0.6.7

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

LiteralMatcher uses Aho-Corasick for fast multi-pattern literal matching

func NewLiteralMatcher added in v0.6.7

func NewLiteralMatcher(literals map[string]string) *LiteralMatcher

func (*LiteralMatcher) Match added in v0.6.7

func (m *LiteralMatcher) Match(content string) []MatchResult

type MatchResult added in v0.6.7

type MatchResult struct {
	Name    string
	Literal string
}

type Parser added in v0.5.0

type Parser interface {
	GetRecords(ctx context.Context, reader io.Reader, path string) (<-chan ScanRecord, error)
	GetRecordsParallel(ctx context.Context, data []byte, path string, concurrency int) (<-chan ScanRecord, error)
}

Parser defines the interface for different input formats

type PreFilter added in v0.7.5

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

PreFilter uses a Bloom Filter to quickly discard lines that definitely don't match any pattern

func NewPreFilter added in v0.7.5

func NewPreFilter(patterns []models.Pattern) *PreFilter

func (*PreFilter) MayMatch added in v0.7.5

func (pf *PreFilter) MayMatch(content []byte) bool

type RipgrepEngine

type RipgrepEngine struct {
	BaseEngine
}

RipgrepEngine uses 'rg' for pattern matching.

func NewRipgrepEngine

func NewRipgrepEngine() (*RipgrepEngine, error)

func (*RipgrepEngine) Execute

func (e *RipgrepEngine) Execute(ctx context.Context, p models.Pattern, targets ...string) (<-chan *models.Result, error)

type ScanRecord added in v0.5.0

type ScanRecord struct {
	Content   []byte
	ID        string
	Line      int
	File      string
	RawLength int // Number of bytes to increment the progress bar
}

ScanRecord represents a single unit of work

type ScannerOptions

type ScannerOptions struct {
	TargetPaths      []string
	Patterns         []string
	Tags             []string
	ToolIDs          []string
	SmartMode        bool
	EntropyMode      bool
	Unique           bool
	Incremental      bool
	GlobalDedupe     bool
	ResumeFile       string
	Silent           bool
	Concurrency      int
	Notify           bool
	NotifyInterval   int
	CooldownEvery    int
	CooldownTime     string
	ThermalThreshold float64
	MaxRAMThreshold  float64
	AutoScale        bool
	UsePcre          bool
	UseMmap          bool
	UseBloom         bool
	Quiet            bool
	NoColor          bool
	Webhook          string
	WebhookType      string
	WebhookLevel     string
	StateDB          *state.DB
	ResultHook       func(*models.Result)
}

type ScannerService

type ScannerService struct {
	Engine     Engine
	Fallback   Engine
	Config     models.Config
	Classifier *classifier.Classifier
	Tools      []models.Tool
	Parser     Parser

	Resume models.ResumeConfig
	// contains filtered or unexported fields
}

func NewScannerService

func NewScannerService(cfg models.Config) (*ScannerService, error)

func (*ScannerService) DiagnoseLine added in v0.1.5

func (s *ScannerService) DiagnoseLine(line string, patterns []string) []string

func (*ScannerService) FilterPatternsByTag added in v0.1.8

func (s *ScannerService) FilterPatternsByTag(tags []string) []string

func (*ScannerService) LoadResumeState added in v0.1.8

func (s *ScannerService) LoadResumeState(file string) error

func (*ScannerService) ProcessResults

func (s *ScannerService) ProcessResults(ctx context.Context, resultsFile string, toolIDs []string) (<-chan *models.Result, error)

func (*ScannerService) RunScan

func (s *ScannerService) RunScan(ctx context.Context, opts ScannerOptions) (<-chan *models.Result, error)

func (*ScannerService) SaveResumeState added in v0.1.8

func (s *ScannerService) SaveResumeState(file string) error

type TextParser added in v0.5.0

type TextParser struct {
	Config models.InputConfig
}

TextParser handles raw text files

func (*TextParser) GetRecords added in v0.5.0

func (p *TextParser) GetRecords(ctx context.Context, reader io.Reader, path string) (<-chan ScanRecord, error)

func (*TextParser) GetRecordsParallel added in v0.8.2

func (p *TextParser) GetRecordsParallel(ctx context.Context, data []byte, path string, concurrency int) (<-chan ScanRecord, error)

Jump to

Keyboard shortcuts

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