detect

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirExists

func DirExists(root, rel string) bool

func DirExistsWithinRoot added in v1.1.0

func DirExistsWithinRoot(detectorID, root, rel string) (bool, *model.ParseError)

func FileExists

func FileExists(root, rel string) bool

func FileExistsWithinRoot added in v1.0.9

func FileExistsWithinRoot(detectorID, root, rel string) (bool, *model.ParseError)

func Glob

func Glob(root, pattern string) ([]string, error)

func IsLocalMachineScope added in v1.0.8

func IsLocalMachineScope(scope Scope) bool

func OpenFileWithinRoot added in v1.0.9

func OpenFileWithinRoot(detectorID, root, rel string) (*os.File, *model.ParseError)

func ParseErrorAsError added in v1.1.0

func ParseErrorAsError(parseErr *model.ParseError) error

func ParseJSONFile

func ParseJSONFile(detectorID, root, rel string, dst any) *model.ParseError

func ParseJSONFileAllowUnknownFields added in v1.0.8

func ParseJSONFileAllowUnknownFields(detectorID, root, rel string, dst any) *model.ParseError

func ParseTOMLFile

func ParseTOMLFile(detectorID, root, rel string, dst any) *model.ParseError

func ParseTOMLFileAllowUnknownFields added in v1.0.8

func ParseTOMLFileAllowUnknownFields(detectorID, root, rel string, dst any) *model.ParseError

func ParseYAMLFile

func ParseYAMLFile(detectorID, root, rel string, dst any) *model.ParseError

func ParseYAMLFileAllowUnknownFields added in v1.0.8

func ParseYAMLFileAllowUnknownFields(detectorID, root, rel string, dst any) *model.ParseError

func ReadFileWithinRoot added in v1.0.9

func ReadFileWithinRoot(detectorID, root, rel string) ([]byte, *model.ParseError)

func ValidateScopeRoot added in v1.0.8

func ValidateScopeRoot(root string) error

ValidateScopeRoot ensures detector scope roots are valid directories.

func WalkFiles

func WalkFiles(root string) ([]string, error)

Types

type Detector

type Detector interface {
	ID() string
	Detect(context.Context, Scope, Options) ([]model.Finding, error)
}

Detector emits canonical findings for one repo scope.

type DetectorError added in v1.0.8

type DetectorError struct {
	Detector string `json:"detector"`
	Org      string `json:"org"`
	Repo     string `json:"repo"`
	Code     string `json:"code"`
	Class    string `json:"class"`
	Message  string `json:"message"`
}

DetectorError captures a non-fatal detector failure tied to one scope.

type Options

type Options struct {
	Enrich bool
}

Options toggles optional detector behavior.

type Registry

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

Registry stores detectors with deterministic execution order.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Register

func (r *Registry) Register(detector Detector) error

func (*Registry) Run

func (r *Registry) Run(ctx context.Context, scopes []Scope, options Options) (RunResult, error)

type RunResult added in v1.0.8

type RunResult struct {
	Findings       []model.Finding `json:"findings"`
	DetectorErrors []DetectorError `json:"detector_errors,omitempty"`
}

RunResult contains deterministic findings and non-fatal detector errors.

type Scope

type Scope struct {
	Org        string
	Repo       string
	Root       string
	TargetMode string
}

Scope is one deterministic repository scan input.

Jump to

Keyboard shortcuts

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