logging

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

HitLevel defines a custom log level for security finding hits. Implemented as WarnLevel but transformed to "hit" in output.

Variables

This section is empty.

Functions

func ParseLevel

func ParseLevel(levelStr string) (zerolog.Level, error)

ParseLevel extends zerolog's ParseLevel to support "hit" level.

func RegisterStatusHook

func RegisterStatusHook(hook ShortcutStatusFN)

func SetGlobalHitWriter

func SetGlobalHitWriter(writer *HitLevelWriter)

SetGlobalHitWriter sets the global HitLevelWriter (for testing only).

func SetLogLevel

func SetLogLevel(verbose bool)

func ShortcutListeners

func ShortcutListeners(status ShortcutStatusFN)

Types

type HitEvent

type HitEvent struct {
	// contains filtered or unexported fields
}

HitEvent wraps a zerolog.Event for hit-level logging with "level":"hit" output.

func Hit

func Hit() *HitEvent

Hit creates a hit-level log event for security findings. Always emitted regardless of global log level. Example: logging.Hit().Str("rule", "secret-key").Msg("HIT")

func (*HitEvent) Bool

func (h *HitEvent) Bool(key string, val bool) *HitEvent

func (*HitEvent) Err

func (h *HitEvent) Err(err error) *HitEvent

func (*HitEvent) Int

func (h *HitEvent) Int(key string, val int) *HitEvent

func (*HitEvent) Msg

func (h *HitEvent) Msg(msg string)

func (*HitEvent) Str

func (h *HitEvent) Str(key, val string) *HitEvent

type HitLevelWriter

type HitLevelWriter struct {
	// contains filtered or unexported fields
}

HitLevelWriter wraps an io.Writer to transform logs with "level":"warn" to "level":"hit".

func NewHitLevelWriter

func NewHitLevelWriter(out io.Writer) *HitLevelWriter

NewHitLevelWriter creates a new HitLevelWriter wrapping the given io.Writer.

func (*HitLevelWriter) SetOutput

func (w *HitLevelWriter) SetOutput(out io.Writer)

func (*HitLevelWriter) Write

func (w *HitLevelWriter) Write(p []byte) (n int, err error)

type SecretType

type SecretType string

SecretType defines the source type of a detected secret.

const (
	// SecretTypeLog indicates a secret found in CI/CD logs.
	SecretTypeLog SecretType = "log"
	// SecretTypeArchive indicates a secret found in an archive/artifact.
	SecretTypeArchive SecretType = "archive"
	// NestedArchive indicates a secret found in a nested archive.
	SecretTypeNestedArchive SecretType = "nested-archive"
	// SecretTypeDotenv indicates a secret found in a dotenv file.
	SecretTypeDotenv SecretType = "dotenv"
)

type ShortcutStatusFN

type ShortcutStatusFN func() *zerolog.Event

func GetStatusHook

func GetStatusHook() ShortcutStatusFN

Jump to

Keyboard shortcuts

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