Documentation
¶
Overview ¶
Package urlhaus adds an abuse.ch URLhaus lookup to yarad: URLs pulled from a message (and from the decompressed VBA/RTF the extract package surfaces) are checked against a locally-cached feed of known malware-distribution URLs.
Design (matches the high-volume constraints):
- The feed is downloaded ONCE per refresh interval (>=5 min, fair-use) into an in-memory set; lookups are pure local map hits, never a per-message remote API call.
- A failed refresh keeps the previous set (fail-static) and is counted.
- Cheap, bounded defanging ("hxxp", "[.]", "(dot)") catches URLs hidden in document code; a hit found only after defanging is flagged Deobf.
- Matching is most-specific-wins: exact normalized URL (high confidence) else the hostname (a known-bad host). Per-message URL count is bounded.
Requires an abuse.ch Auth-Key (free, https://auth.abuse.ch/), sent as the Auth-Key header. With no key the checker is disabled (New returns nil).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker holds the cached feed and serves lookups. The zero value is not usable; use New.
func New ¶
New builds a Checker and starts its background refresher. It returns nil when key is empty (feature disabled), so callers can guard on `c != nil`. refresh is clamped to the fair-use floor. When cacheDir is non-empty the feed snapshot is persisted there and loaded on startup, so a restart serves immediately from the last-good feed instead of an empty set until the first network refresh.
func (*Checker) Check ¶
Check extracts URLs from data (and from a cheaply-defanged copy) via urlcand.Extract, looks each up in the feed, and returns the matches. maxURLs bounds the work per buffer. It is safe for concurrent use. Delegates to CheckCandidates.
func (*Checker) CheckCandidates ¶
CheckCandidates looks up pre-extracted URL candidates in the feed. cands is produced by urlcand.Extract; maxURLs caps how many candidates are processed. A shared dedup map prevents duplicate normalized URLs across the candidate list. c.hits is incremented if any hit is found.