bansource

package
v1.230.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package bansource is the single authority that maps a ban's producer context and raw source label to a storage/lifecycle Kind.

⛔ THE ARCHITECTURAL RULE THIS PACKAGE EXISTS TO ENFORCE:

RAW SOURCE STRING != STORAGE POLICY

Before this package, at least four independent predicates interpreted the same source string and disagreed:

nftbackend.isManualSource   exact switch,  unknown -> INTERVAL (feed-owned)
opqueue.GetSourceConfig     map lookup,    unknown -> HASH     (manual)
daemon_init.go              strings.Contains chain, has a botguard arm
daemon_handlers_ban.go      strings.Contains chain, has NO botguard arm

Opposite defaults for the same question. The measured consequence: `loginmon`, `botguard`, `botscan`, `botscan-404`, `portscan-aggregate` and the entire per-service login vocabulary (sshd, dovecot, exim, postfix, vsftpd, proftpd, pureftpd, directadmin, cpanel) all missed the exact-match table, landed in blacklist_ipv4/_ipv6, and were erased by the next feed sync — a detected attacker silently un-banned by an unrelated synchronisation mechanism.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UsesReplaceManagedStorage

func UsesReplaceManagedStorage(k Kind) bool

UsesReplaceManagedStorage reports whether a Kind belongs in the interval sets that bulk synchronisation flushes and repopulates.

⛔ This is the ONLY predicate storage routing may consult. Everything else is provenance.

Types

type Kind

type Kind int

Kind is the storage/lifecycle class of a ban. Routing consumes THIS, never the raw source string.

const (
	// Unclassified means the caller supplied neither a producer context nor a
	// recognised label. It is NOT a lifecycle. Callers must treat it as an error
	// rather than guessing — guessing is exactly the defect this package removes.
	Unclassified Kind = iota

	// DetectorEphemeral — produced by a detector as evidence of observed abuse.
	// Detector-owned/hash-like storage, timeout owned by the detector lifecycle.
	// ⛔ Feed/geoban synchronisation MUST NOT be able to replace or delete these.
	DetectorEphemeral

	// ManualPersistent — an operator decision. Hash-like storage. Not replaced by
	// feed synchronisation. The LABEL IS ARBITRARY: `--source customer-rule` is
	// ManualPersistent because an operator command produced it, not because the
	// string was recognised.
	ManualPersistent

	// ReplaceManaged — owned by a bulk synchronisation authority (feeds, geoban,
	// blacklist.d CIDRs). Interval storage. Replaced ONLY by its owning sync.
	ReplaceManaged
)

func Resolve

func Resolve(raw string, origin Origin) Kind

Resolve maps producer context + raw label to a Kind.

Origin WINS. A recognised label only matters when the caller could not supply one, which is the legacy case this lane is narrowing rather than widening.

func (Kind) String

func (k Kind) String() string

type Origin

type Origin int

Origin is the PRODUCER CONTEXT. It is the primary input, because the producer knows what it is; a string table can only guess.

const (
	// OriginUnspecified — a legacy boundary that carries only a source string.
	// Resolution then falls back to the known-label table below. New call sites
	// should supply a real Origin instead of relying on that fallback.
	OriginUnspecified Origin = iota
	// OriginOperator — an operator command or IPC ban request. ANY label.
	OriginOperator
	// OriginDetector — a detector module or classic detector script. ANY label.
	OriginDetector
	// OriginBulkSync — feeds, geoban, or a blacklist.d CIDR load.
	OriginBulkSync
)

Jump to

Keyboard shortcuts

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