internal

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDecodeFailure = errors.New("failed to decode .trufflehog3.yml configuration file")

Functions

func ForceOverwriteTrufflehogConfig added in v0.3.0

func ForceOverwriteTrufflehogConfig(configFilePath string, config Config) error

ForceOverwriteTrufflehogConfig forcefully overwrites the existing configuration with the provided configuration.

func HandleScannerConfig added in v0.3.0

func HandleScannerConfig(logger hclog.Logger, excludePaths []string, targetFolder string, writeDefaultIfMissing bool, forceOverwrite bool) error

HandleScannerConfig processes the scanner configuration, including writing default configs or overwriting existing ones.

func JsonToPlainReport added in v0.3.0

func JsonToPlainReport(filePath string) (string, error)

JsonToPlainReport converts a Trufflehog3 JSON report to a plain text format.

func JsonToSarifReport added in v0.3.0

func JsonToSarifReport(filePath string) (string, error)

JsonToSarifReport converts a Trufflehog3 JSON report to SARIF format.

func SaveConfig added in v0.3.0

func SaveConfig(path string, config Config) error

SaveConfig saves the YAML configuration to the specified file.

func WrapDecodeFailure added in v0.3.0

func WrapDecodeFailure(err error) error

WrapDecodeFailure adds context to ErrDecodeFailure

func WriteDefaultTrufflehogConfigIfMissing added in v0.3.0

func WriteDefaultTrufflehogConfigIfMissing(logger hclog.Logger, configFilePath string) error

WriteDefaultTrufflehogConfigIfMissing writes the default configuration if the file is missing.

Types

type Config added in v0.3.0

type Config struct {
	Exclude        []*Exclude `yaml:"exclude"`
	Severity       string     `yaml:"severity,omitempty"`
	IgnoreNoSecret bool       `yaml:"ignore_nosecret,omitempty"`
	NoEntropy      bool       `yaml:"no_entropy,omitempty"`
	NoPattern      bool       `yaml:"no_pattern,omitempty"`
	Branch         string     `yaml:"branch,omitempty"`
	Depth          int        `yaml:"depth,omitempty"`
	Since          string     `yaml:"since,omitempty"`
	NoCurrent      bool       `yaml:"no_current,omitempty"`
	NoHistory      bool       `yaml:"no_history,omitempty"`
	Context        int        `yaml:"context,omitempty"`
}

Config represents the entire YAML configuration.

func DefaultConfig added in v0.3.0

func DefaultConfig() Config

DefaultConfig returns the default configuration for Trufflehog3. TODO: move fetching default from a file

func LoadConfig added in v0.3.0

func LoadConfig(path string) (Config, error)

LoadConfig loads the YAML configuration from the specified file.

type Exclude added in v0.3.0

type Exclude struct {
	Message string   `yaml:"message"`
	Paths   []string `yaml:"paths,omitempty"`
	Pattern string   `yaml:"pattern,omitempty"`
	ID      string   `yaml:"id,omitempty"`
}

Exclude represents each exclusion rule in the configuration.

type Trufflehog3Issue

type Trufflehog3Issue struct {
	Rule   *Trufflehog3Rule `json:"rule"`
	Path   string           `json:"path"`
	Line   string           `json:"line"`
	Secret string           `json:"secret"`
	ID     string           `json:"id,omitempty"`
	Branch string           `json:"branch,omitempty"`
	Commit string           `json:"commit,omitempty"`
	Author string           `json:"author,omitempty"`
	Date   string           `json:"date,omitempty"`
}

Trufflehog3Issue represents a single issue found by Trufflehog3.

type Trufflehog3Report

type Trufflehog3Report []*Trufflehog3Issue

Trufflehog3Report represents a collection of Trufflehog3 issues.

func (Trufflehog3Report) Deduplicate added in v0.3.0

func (report Trufflehog3Report) Deduplicate() Trufflehog3Report

Deduplicate removes duplicate issues from the report.

func (Trufflehog3Report) Render

func (report Trufflehog3Report) Render() string

Render produces a human-readable report of the Trufflehog3 issues.

type Trufflehog3Rule

type Trufflehog3Rule struct {
	ID       string `json:"id"`
	Message  string `json:"message"`
	Pattern  string `json:"pattern"`
	Severity string `json:"severity"`
}

Trufflehog3Rule represents the rule that triggered an issue.

Jump to

Keyboard shortcuts

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