engine

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package engine contains the core scanning logic for Redactyl. It traverses target files, runs detectors, and returns structured findings. This package is internal; external consumers should use the stable facade in pkg/core.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountTargets

func CountTargets(cfg Config) (int, error)

func DetectorIDs

func DetectorIDs() []string

DetectorIDs returns the list of available Gitleaks detector IDs. This is a representative list of common Gitleaks rules for UI purposes. The actual detection is performed by Gitleaks with its full rule set.

func Scan

func Scan(cfg Config) ([]types.Finding, error)

Scan runs a scan and returns only findings (without stats).

func Walk

func Walk(ctx context.Context, cfg Config, ign ignore.Matcher, handle func(path string, data []byte)) error

Walk traverses the working tree and invokes handle for each eligible file.

Types

type Config

type Config struct {
	Root             string
	IncludeGlobs     string
	ExcludeGlobs     string
	MaxBytes         int64
	ScanStaged       bool
	HistoryCommits   int
	BaseBranch       string
	Threads          int
	EnableDetectors  string
	DisableDetectors string
	MinConfidence    float64
	DryRun           bool
	NoColor          bool
	DefaultExcludes  bool
	NoCache          bool
	Progress         func()

	// Deep artifact scanning (optional)
	ScanArchives         bool
	ScanContainers       bool
	ScanIaC              bool
	ScanHelm             bool     // Scan Helm charts
	ScanK8s              bool     // Scan Kubernetes manifests
	RegistryImages       []string // Remote registry images to scan (e.g. gcr.io/proj/img:tag)
	MaxArchiveBytes      int64
	MaxEntries           int
	MaxDepth             int
	ScanTimeBudget       time.Duration
	GlobalArtifactBudget time.Duration

	// Gitleaks configuration (for scanner integration)
	GitleaksConfig config.GitleaksConfig
}

Config controls scanning behavior including scope, performance, and filters.

type DeepStats

type DeepStats struct {
	AbortedByBytes   int
	AbortedByEntries int
	AbortedByDepth   int
	AbortedByTime    int
}

DeepStats summarizes artifact scanning abort reasons.

type Result

type Result struct {
	Findings       []types.Finding
	FilesScanned   int
	Duration       time.Duration
	ArtifactStats  DeepStats
	ArtifactErrors []error
}

Result contains findings and basic scan statistics.

func ScanWithStats

func ScanWithStats(cfg Config) (Result, error)

ScanWithStats runs a scan and returns findings along with timing and counts.

Jump to

Keyboard shortcuts

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