notify

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateFilename

func GenerateFilename(moduleID, host, ext string) string

GenerateFilename creates a filename for attachments. Format: {moduleID}_{host}_{timestamp}.{ext}

func SanitizeFilename

func SanitizeFilename(name string) string

SanitizeFilename replaces invalid filename characters with underscores.

func Truncate

func Truncate(s string, maxLen int) string

Truncate truncates a string to maxLen with ellipsis "...".

func TruncateWithIndicator

func TruncateWithIndicator(s string, maxLen int) string

TruncateWithIndicator truncates a string and adds "[see attachment]".

Types

type Backend

type Backend interface {
	// Send sends a scan result notification.
	Send(result *output.ResultEvent) error

	// SendRaw sends a raw text message (for panics, errors).
	SendRaw(msg string) error

	// Close releases any resources held by the backend.
	Close()
}

Backend is the interface for notification backends. Each backend handles its own formatting, escaping, length limits, and file uploads.

type Config

type Config struct {
	// Backends to send notifications to
	Backends []Backend

	// AllowedSeverities filters which severities to notify.
	// Use "all" to notify all severities.
	AllowedSeverities []string

	// QueueSize is the notification queue buffer size.
	// Default: 1000
	QueueSize int

	// ShutdownTimeout is how long to wait for pending notifications on Close.
	// Default: 30s
	ShutdownTimeout time.Duration
}

Config configures the notification Manager.

type Manager

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

Manager manages async notification queue and multiple backends.

func New

func New(cfg Config) *Manager

New creates a new notification Manager.

func (*Manager) Close

func (m *Manager) Close()

Close waits for all pending notifications to be sent, then closes all backends.

func (*Manager) Send

func (m *Manager) Send(result *output.ResultEvent) error

Send queues a scan result notification (non-blocking). Returns immediately after queueing.

func (*Manager) SendRaw

func (m *Manager) SendRaw(msg string) error

SendRaw queues a raw text message (non-blocking).

Directories

Path Synopsis
Package webhook fires a single HTTP POST when a scan reaches a terminal state (completed or failed).
Package webhook fires a single HTTP POST when a scan reaches a terminal state (completed or failed).

Jump to

Keyboard shortcuts

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