detect

package
v8.23.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 28 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNew added in v8.13.0

func IsNew(finding report.Finding, baseline []report.Finding) bool

func LoadBaseline added in v8.13.0

func LoadBaseline(baselinePath string) ([]report.Finding, error)

Types

type Decoder added in v8.20.0

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

Decoder decodes various types of data in place

func NewDecoder added in v8.20.0

func NewDecoder() *Decoder

NewDecoder creates a default decoder struct

type Detector added in v8.4.0

type Detector struct {
	// Config is the configuration for the detector
	Config config.Config

	// Redact is a flag to redact findings. This is exported
	// so users using gitleaks as a library can set this flag
	// without calling `detector.Start(cmd *cobra.Command)`
	Redact uint

	// verbose is a flag to print findings
	Verbose bool

	// MaxDecodeDepths limits how many recursive decoding passes are allowed
	MaxDecodeDepth int

	// files larger than this will be skipped
	MaxTargetMegaBytes int

	// followSymlinks is a flag to enable scanning symlink files
	FollowSymlinks bool

	// NoColor is a flag to disable color output
	NoColor bool

	// IgnoreGitleaksAllow is a flag to ignore gitleaks:allow comments.
	IgnoreGitleaksAllow bool

	// Sema (https://github.com/fatih/semgroup) controls the concurrency
	Sema *semgroup.Group

	// report-related settings.
	ReportPath string
	Reporter   report.Reporter

	TotalBytes uint64
	// contains filtered or unexported fields
}

Detector is the main detector struct

func NewDetector added in v8.4.0

func NewDetector(cfg config.Config) *Detector

NewDetector creates a new detector with the given config

func NewDetectorDefaultConfig added in v8.4.0

func NewDetectorDefaultConfig() (*Detector, error)

NewDetectorDefaultConfig creates a new detector with the default config

func (*Detector) AddBaseline added in v8.13.0

func (d *Detector) AddBaseline(baselinePath string, source string) error

func (*Detector) AddGitleaksIgnore added in v8.10.0

func (d *Detector) AddGitleaksIgnore(gitleaksIgnorePath string) error

func (*Detector) Detect added in v8.4.0

func (d *Detector) Detect(fragment Fragment) []report.Finding

Detect scans the given fragment and returns a list of findings

func (*Detector) DetectBytes added in v8.4.0

func (d *Detector) DetectBytes(content []byte) []report.Finding

DetectBytes scans the given bytes and returns a list of findings

func (*Detector) DetectFiles added in v8.4.0

func (d *Detector) DetectFiles(paths <-chan sources.ScanTarget) ([]report.Finding, error)

func (*Detector) DetectGit added in v8.4.0

func (d *Detector) DetectGit(gitCmd *sources.GitCmd) ([]report.Finding, error)

func (*Detector) DetectReader added in v8.15.0

func (d *Detector) DetectReader(r io.Reader, bufSize int) ([]report.Finding, error)

DetectReader accepts an io.Reader and a buffer size for the reader in KB

func (*Detector) DetectString added in v8.4.0

func (d *Detector) DetectString(content string) []report.Finding

DetectString scans the given string and returns a list of findings

type EncodedSegment added in v8.20.0

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

EncodedSegment represents a portion of text that is encoded in some way. `decode` supports recusive decoding and can result in "segment trees". There can be multiple segments in the original text, so each can be thought of as its own tree with the root being the original segment.

type Fragment added in v8.4.0

type Fragment struct {
	// Raw is the raw content of the fragment
	Raw string

	Bytes []byte

	// FilePath is the path to the file if applicable
	FilePath    string
	SymlinkFile string

	// CommitSHA is the SHA of the commit if applicable
	CommitSHA string
	// contains filtered or unexported fields
}

Fragment contains the data to be scanned

type Location

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

Location represents a location in a file

Jump to

Keyboard shortcuts

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