scanner

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseGitleaksConfig

func ParseGitleaksConfig(rawConfig string) (glc *gitleaksconfig.Config, err error)

ParseGitleaksConfig takes a gitleaks config string and returns a config object

Types

type Backend

type Backend interface {
	Name() string
	Scan(resource resource.Resource) ([]*response.Result, error)
}

Backend is an interface for a scanner backend leveraged by leaktk

type Gitleaks

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

Gitleaks wraps gitleaks as a scanner backend

func NewGitleaks

func NewGitleaks(maxDecodeDepth uint16, patterns *Patterns) *Gitleaks

NewGitleaks returns a configured gitleaks backend instance

func (*Gitleaks) Name

func (g *Gitleaks) Name() string

Name returns the human readable name of the backend for logging details

func (*Gitleaks) Scan

func (g *Gitleaks) Scan(scanResource resource.Resource) ([]*response.Result, error)

Scan does the gitleaks scan on the resource

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient provides an interface for working with Go's http client or swapping it out with other types for testing

type Patterns

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

Patterns acts as an abstraction for fetching different scanner patterns and keeping them up to date and cached

func NewPatterns

func NewPatterns(cfg *config.Patterns, client HTTPClient) *Patterns

NewPatterns returns a configured instance of Patterns

func (*Patterns) Gitleaks

func (p *Patterns) Gitleaks() (*gitleaksconfig.Config, error)

Gitleaks returns a Gitleaks config object if it's able to

func (*Patterns) GitleaksConfigHash added in v0.0.2

func (p *Patterns) GitleaksConfigHash() string

GitleaksConfigHash returns the sha256 hash for the current gitleaks config

type Request

type Request struct {
	ID string
	// Thing to scan (e.g. URL, snippet of text, etc)
	Resource resource.Resource
}

Request to the scanner to scan some resource

func (*Request) Priority added in v0.0.6

func (r *Request) Priority() int

Priority of this request

func (*Request) UnmarshalJSON

func (r *Request) UnmarshalJSON(data []byte) error

UnmarshalJSON sets r to a copy of data

type Scanner

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

Scanner holds the config and state for the scanner processes

func NewScanner

func NewScanner(cfg *config.Config) *Scanner

NewScanner returns a initialized and listening scanner instance that should be closed when it's no longer needed.

func (*Scanner) Recv added in v0.0.6

func (s *Scanner) Recv(fn func(*response.Response))

Recv sends scan responses to a callback function

func (*Scanner) Send

func (s *Scanner) Send(request *Request)

Send accepts a request for scanning and puts it in the queues

Jump to

Keyboard shortcuts

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