secrets

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultReportPath

func DefaultReportPath(attestDir string) string

func Redact

func Redact(v string) string

func RedactText

func RedactText(line string) string

RedactText removes secret-like substrings from a line of text using the default rules.

func RedactTextWithRules

func RedactTextWithRules(line string, rules CompiledRules) string

RedactTextWithRules removes secret-like substrings from a line of text using configured rules.

func WriteReport

func WriteReport(path string, report *Report) error

Types

type ApplyTo

type ApplyTo string
const (
	ApplyBuildArgName  ApplyTo = "build_arg_name"
	ApplyBuildArgValue ApplyTo = "build_arg_value"
	ApplyOCIPath       ApplyTo = "oci_path"
	ApplyOCIContent    ApplyTo = "oci_content"
	ApplyLogLine       ApplyTo = "log_line"
	ApplySourceScalar  ApplyTo = "source_scalar"
	ApplyRenderScalar  ApplyTo = "render_scalar"
)

type CompiledRule

type CompiledRule struct {
	Rule
	// contains filtered or unexported fields
}

func (CompiledRule) Applies

func (cr CompiledRule) Applies(target ApplyTo) bool

func (CompiledRule) FindAllString added in v1.0.7

func (cr CompiledRule) FindAllString(value string) []string

func (CompiledRule) MatchString added in v1.0.7

func (cr CompiledRule) MatchString(value string) bool

type CompiledRules

type CompiledRules struct {
	Rules []CompiledRule
}

func CompileConfig

func CompileConfig(cfg Config) (CompiledRules, error)

type Config

type Config struct {
	Version string `json:"version" yaml:"version"`
	Rules   []Rule `json:"rules" yaml:"rules"`
}

func DefaultConfig

func DefaultConfig() Config

func LoadConfig

func LoadConfig(ctx context.Context, ref string) (Config, error)

func MergeConfig

func MergeConfig(base Config, override Config) Config

type Finding

type Finding struct {
	Severity Severity `json:"severity"`
	Source   Source   `json:"source"`
	Rule     string   `json:"rule"`
	Message  string   `json:"message"`
	Key      string   `json:"key,omitempty"`
	Location string   `json:"location,omitempty"`
	Match    string   `json:"match,omitempty"`
}

func DetectBuildArgs

func DetectBuildArgs(buildArgs []string) []Finding

func DetectBuildArgsWithRules

func DetectBuildArgsWithRules(buildArgs []string, rules CompiledRules) []Finding

func MatchKeyValueWithRules

func MatchKeyValueWithRules(key, value string, rules CompiledRules, source Source, location string) []Finding

func MatchTextWithRules

func MatchTextWithRules(text string, rules CompiledRules, source Source, location string) []Finding

func ScanDockerfileForSecretsWithRules

func ScanDockerfileForSecretsWithRules(path string, rules CompiledRules) ([]Finding, error)

func ScanOCIForSecrets

func ScanOCIForSecrets(ociLayoutDir string, byteLimit int64) ([]Finding, error)

func ScanOCIForSecretsWithRules

func ScanOCIForSecretsWithRules(ociLayoutDir string, byteLimit int64, rules CompiledRules) ([]Finding, error)

type Mode

type Mode string
const (
	ModeWarn  Mode = "warn"
	ModeBlock Mode = "block"
	ModeOff   Mode = "off"
)

type Report

type Report struct {
	Mode        Mode      `json:"mode"`
	Passed      bool      `json:"passed"`
	Blocked     bool      `json:"blocked"`
	Findings    []Finding `json:"findings,omitempty"`
	EvaluatedAt time.Time `json:"evaluatedAt"`
}

type Rule

type Rule struct {
	ID        string    `json:"id" yaml:"id"`
	Enabled   *bool     `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Severity  Severity  `json:"severity" yaml:"severity"`
	AppliesTo []ApplyTo `json:"applies_to,omitempty" yaml:"applies_to,omitempty"`
	Regex     string    `json:"regex,omitempty" yaml:"regex,omitempty"`
	Message   string    `json:"message,omitempty" yaml:"message,omitempty"`
	Suggest   string    `json:"suggestion,omitempty" yaml:"suggestion,omitempty"`
}

type Severity

type Severity string
const (
	SeverityWarn  Severity = "warn"
	SeverityBlock Severity = "block"
)

type Source

type Source string
const (
	SourceBuildArg   Source = "build-arg"
	SourceOCI        Source = "oci-layer"
	SourceDockerfile Source = "dockerfile"
	SourceCompose    Source = "compose"
)

Jump to

Keyboard shortcuts

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