Debian Codegraph @

pkg/secrets/types.go

raw symbols SCIP
1 package secrets
2
3 import (
4 "io"
5
6 "github.com/DefangLabs/secret-detector/pkg/dataformat"
7 )
8
9 type Detector interface {
10 // Scan scans secrets from the given string.
11 // Input structure is unexpected, and may contain multiple secrets.
12 Scan(in string) ([]DetectedSecret, error)
13 // ScanMap scans secrets from the given key-value pairs.
14 ScanMap(keyValueMap map[string]string) ([]DetectedSecret, error)
15 // SecretType returns a human-readable string that describes the type of secret that is detected by this Detector.
16 // This string should be returned as DetectedSecret.Type when detecting a secret.
17 SecretType() string
18 }
19
20 type Transformer interface {
21 Transform(in string) (map[string]string, bool)
22 SupportedFormats() []dataformat.DataFormat
23 SupportFiles() bool
24 }
25
26 type Scanner interface {
27 ScanFile(path string) ([]DetectedSecret, error)
28 ScanFileReader(in io.Reader, path string, size int64) ([]DetectedSecret, error)
29 ScanWithFormat(in io.Reader, format dataformat.DataFormat) ([]DetectedSecret, error)
30 ScanStringWithFormat(inStr string, format dataformat.DataFormat) ([]DetectedSecret, error)
31 ScanReader(in io.Reader) ([]DetectedSecret, error)
32 Scan(in string) ([]DetectedSecret, error)
33 }
34
35 // DetectedSecret represents a secret detected by the engine.
36 type DetectedSecret struct {
37 // Type is the type of the detector that detected the secret
38 Type string
39 // Key is the key of the detected secret.
40 // Key can be empty if a secret was detected without one.
41 Key string
42 // Value is the value of the detected secret
43 Value string
44 }