Documentation
¶
Overview ¶
Package scan runs the detector over every object of a repository and attributes what it finds to commits, paths and refs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SortFindings ¶
func SortFindings(fs []Finding)
SortFindings orders active tokens first, then by kind and fingerprint.
Types ¶
type Finding ¶
type Finding struct {
Kind detect.Kind `json:"kind"`
Fingerprint string `json:"fingerprint"`
Token string `json:"-"`
Redacted string `json:"token"`
ChecksumVerified bool `json:"checksum_verified"`
Verification *detect.Verification `json:"verification,omitempty"`
Locations []Location `json:"locations"`
Occurrences int `json:"occurrences"`
}
Finding is one distinct token and everywhere it appears.
type Location ¶
type Location struct {
Repo string `json:"repo"`
Object string `json:"object"`
ObjectType string `json:"object_type"`
Path string `json:"path,omitempty"`
Line int `json:"line"`
Commit *gitrepo.Commit `json:"commit,omitempty"`
// Refs contains the refs whose history includes the commit.
Refs []string `json:"refs,omitempty"`
// Orphaned is true when no ref reaches the commit anymore.
Orphaned bool `json:"orphaned"`
// Rewrite explains how the commit went unreachable on the server, when known.
Rewrite string `json:"rewrite,omitempty"`
}
Location is one place a token was found.
type Options ¶
type Options struct {
// Workers is the number of parallel `git cat-file` readers.
Workers int
// MaxObject skips objects larger than this many bytes.
MaxObject int64
// Ignore holds token fingerprints to leave out of the results.
Ignore map[string]bool
// Verifier, when set, checks each token against the GitHub API.
Verifier *detect.Verifier
}
Options tune a repository scan.
type Result ¶
type Result struct {
Target string `json:"target"`
Findings []Finding `json:"findings"`
Stats Stats `json:"stats"`
Notes []string `json:"notes,omitempty"`
Err error `json:"-"`
Error string `json:"error,omitempty"`
Skipped bool `json:"skipped,omitempty"`
}
Result is the outcome for one target.
type Rewrite ¶
Rewrite names a commit that was fetched by SHA because a server-side ref update (force push, branch deletion) had made it unreachable.
type RunOptions ¶
type RunOptions struct {
Options
// Cache holds the mirrors of GitHub targets.
Cache *disk.Cache
// Keep leaves mirrors in the cache after the scan for faster re-runs.
Keep bool
// Auth is used for HTTPS clones; nil for anonymous.
Auth *gitrepo.Auth
// GitHub is needed for the activity feed; nil disables it.
GitHub *github.Client
// Rewrites fetches commits the activity feed reports as force-pushed or deleted.
Rewrites bool
// ActivityPages caps the activity feed pages read per type and repository.
ActivityPages int
// Parallel is the number of repositories processed at once.
Parallel int
// Progress receives phase messages; may be nil.
Progress func(target, msg string)
}
RunOptions configure a run over many targets.
type Stats ¶
type Stats struct {
Objects int `json:"objects"`
Scanned int `json:"scanned"`
Skipped int `json:"skipped_large"`
Bytes int64 `json:"bytes"`
Refs int `json:"refs"`
Orphaned int `json:"orphaned_commits"`
Rewrites int `json:"rewrites_fetched"`
Disk int64 `json:"disk_bytes,omitempty"`
Duration time.Duration `json:"-"`
}
Stats summarises one repository scan.
Click to show internal directories.
Click to hide internal directories.