-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeforerun.go
More file actions
53 lines (44 loc) · 1.52 KB
/
Copy pathbeforerun.go
File metadata and controls
53 lines (44 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Package beforerun provides a reusable API for statically inspecting
// untrusted repositories before project-controlled code is executed.
package beforerun
import (
"github.com/theworker02/beforerun/internal/model"
"github.com/theworker02/beforerun/internal/scanner"
)
// Severity describes the impact of a finding.
type Severity = model.Severity
const (
SeverityInfo = model.SeverityInfo
SeverityLow = model.SeverityLow
SeverityMedium = model.SeverityMedium
SeverityHigh = model.SeverityHigh
SeverityCritical = model.SeverityCritical
)
// Finding describes one detected repository risk.
type Finding = model.Finding
// Summary contains the complete result of a scan.
type Summary = model.Summary
// Options controls scan behavior.
type Options struct {
// Threshold determines when Summary.ThresholdMet becomes true.
Threshold Severity
// Ignores contains repository-relative path prefixes to skip.
Ignores []string
}
// Scan statically inspects root without executing repository content or using
// the network.
func Scan(root string, options Options) (Summary, error) {
return scanner.Scan(root, scanner.Options{
Threshold: options.Threshold,
Ignores: options.Ignores,
})
}
// ParseSeverity converts a textual severity into its typed value.
func ParseSeverity(value string) (Severity, bool) {
return model.ParseSeverity(value)
}
// ReadIgnoreFile parses .beforerunignore from root. A missing file is not an
// error.
func ReadIgnoreFile(root string) ([]string, error) {
return scanner.ReadIgnoreFile(root)
}