finding

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package finding defines the Leakwatch finding model. This package is public and can be consumed by external tools such as CI plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finding

type Finding struct {
	ID             string             `json:"id"`
	DetectorID     string             `json:"detector_id"`
	Severity       Severity           `json:"severity"`
	Raw            string             `json:"-"`
	Redacted       string             `json:"redacted"`
	SourceMetadata SourceMetadata     `json:"source"`
	Verification   VerificationResult `json:"verification"`
	Remediation    *Remediation       `json:"remediation,omitempty"`
	DetectedAt     time.Time          `json:"detected_at"`
	Entropy        float64            `json:"entropy,omitempty"`
	ExtraData      map[string]string  `json:"extra_data,omitempty"`
}

Finding represents a fully enriched secret finding.

The Raw field holds the unredacted secret. It carries a json:"-" tag so that the standard library NEVER serializes it: any external consumer that marshals a Finding cannot accidentally leak the secret. Output formatters that support an explicit opt-in (e.g. --show-raw) re-add the value via a dedicated wire type rather than relying on this struct's tags.

type Remediation

type Remediation struct {
	Title      string   `json:"title"`
	Steps      []string `json:"steps"`
	DocURL     string   `json:"doc_url,omitempty"`
	ConsoleURL string   `json:"console_url,omitempty"`
	Urgency    string   `json:"urgency"`
	Checklist  []string `json:"checklist,omitempty"`
}

Remediation provides actionable guidance for rotating or revoking a detected secret.

type Severity

type Severity int

Severity represents the finding severity level.

const (
	SeverityLow      Severity = iota // Low
	SeverityMedium                   // Medium
	SeverityHigh                     // High
	SeverityCritical                 // Critical
)

func (Severity) MarshalJSON

func (s Severity) MarshalJSON() ([]byte, error)

MarshalJSON serializes Severity as a JSON string.

func (Severity) String

func (s Severity) String() string

String returns the human-readable representation of Severity.

func (*Severity) UnmarshalJSON

func (s *Severity) UnmarshalJSON(data []byte) error

UnmarshalJSON parses a Severity value from a JSON string.

type SourceMetadata

type SourceMetadata struct {
	SourceType string `json:"source_type"`

	// Git-specific fields
	Repository string    `json:"repository,omitempty"`
	Commit     string    `json:"commit,omitempty"`
	Author     string    `json:"author,omitempty"`
	Email      string    `json:"email,omitempty"`
	Date       time.Time `json:"date,omitempty"`
	Branch     string    `json:"branch,omitempty"`

	// File-specific fields
	FilePath string `json:"file_path,omitempty"`
	Line     int    `json:"line,omitempty"`

	// Container-specific fields
	Image    string `json:"image,omitempty"`
	Layer    string `json:"layer,omitempty"`
	LayerIdx int    `json:"layer_idx,omitempty"`

	// Slack-specific fields
	Channel     string `json:"channel,omitempty"`
	ChannelName string `json:"channel_name,omitempty"`
	MessageUser string `json:"message_user,omitempty"`
	MessageTS   string `json:"message_ts,omitempty"`
	ThreadTS    string `json:"thread_ts,omitempty"`
}

SourceMetadata describes the origin of a finding.

type VerificationResult

type VerificationResult struct {
	Status    VerificationStatus `json:"status"`
	Message   string             `json:"message,omitempty"`
	ExtraData map[string]string  `json:"extra_data,omitempty"`
}

VerificationResult represents the outcome of a verification attempt.

type VerificationStatus

type VerificationStatus int

VerificationStatus represents the verification state.

const (
	StatusUnverified       VerificationStatus = iota // Not verified
	StatusVerifiedActive                             // Verified: secret is active
	StatusVerifiedInactive                           // Verified: secret is inactive
	StatusVerifyError                                // Verification error
)

func (VerificationStatus) MarshalJSON

func (v VerificationStatus) MarshalJSON() ([]byte, error)

MarshalJSON serializes VerificationStatus as a JSON string.

func (VerificationStatus) String

func (v VerificationStatus) String() string

String returns the human-readable representation of VerificationStatus.

func (*VerificationStatus) UnmarshalJSON

func (v *VerificationStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON parses a VerificationStatus value from a JSON string.

Jump to

Keyboard shortcuts

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