Documentation
¶
Index ¶
- Variables
- type App
- type BaseEvent
- type ConfigAware
- type ConfigFile
- type ConfigOps
- type CurlProvider
- type FilterBypasser
- type Handler
- type InteractionEvent
- type Notifier
- type NotifierBase
- type NotifierChat
- type NotifierWebhook
- type NotifySuppressor
- type Persistable
- type Seeder
- type SinkHitProvider
- type Worker
- type WorkerStatus
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownWorker = errors.New("unknown worker")
ErrUnknownWorker is returned when a run is requested for a name that is not configured.
var ErrWorkerBusy = errors.New("worker is already running")
ErrWorkerBusy is returned when a run is requested while one is already in flight for that worker. Workers are not safe to overlap with themselves.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App interface {
Run()
RegisterNotificationHandler(Notifier)
GetTemplateData() map[string]string
Reload() error
// WorkerStatus reports every configured Worker and the outcome of its most
// recent run. Empty when no workers are configured.
WorkerStatus() []WorkerStatus
// TriggerWorker starts an out-of-schedule run of the named worker. It
// returns as soon as the run is accepted, not when it finishes — a purge
// with a vacuum can take minutes — so poll WorkerStatus for the result.
// Returns ErrUnknownWorker or ErrWorkerBusy when the run is refused.
TriggerWorker(name string) error
}
type BaseEvent ¶
type BaseEvent struct {
RemoteAddr string
RemotePortNumber int
UserAgentString string
RawData []byte
}
func (*BaseEvent) Dispatch ¶
func (e *BaseEvent) Dispatch(cc chan InteractionEvent)
func (*BaseEvent) FilterString ¶ added in v0.0.24
FilterString is the fallback match target for events that don't override it. Concrete handler events replace this with a canonical "HANDLER ACTION DETAIL from IP" string; the base default just exposes the raw data and source IP so a bare event is still filterable.
func (*BaseEvent) RemotePort ¶
type ConfigAware ¶ added in v0.1.3
type ConfigAware interface {
SetConfigOps(ConfigOps)
}
ConfigAware is implemented by handlers that expose a config management API. The app injects a ConfigOps after construction.
type ConfigFile ¶ added in v0.1.3
type ConfigFile struct {
Defaults map[string]string `yaml:"defaults" json:"defaults"`
Handlers []map[string]string `yaml:"handlers" json:"handlers"`
Notifiers []map[string]string `yaml:"notifiers" json:"notifiers"`
Workers []map[string]string `yaml:"workers" json:"workers"`
}
ConfigFile is the deserialized YAML config. It lives in types so packages on both sides of the handler↔app boundary can reference it without cycles.
type ConfigOps ¶ added in v0.1.3
type ConfigOps interface {
FilePath() string
Read() (*ConfigFile, error)
Write(cf *ConfigFile) error
Validate(cf *ConfigFile) []string
HandlerNames() []string
NotifierNames() []string
WorkerNames() []string
}
ConfigOps provides config file operations to handlers that expose a management API (the HTTPX admin console). Implemented by the xodbox package and injected into the handler at construction time.
type CurlProvider ¶ added in v0.0.24
type CurlProvider interface {
CurlCommand() string
}
CurlProvider is an optional interface implemented by events that can render a curl command reproducing the captured request (currently HTTP). Notifiers type-assert to it to append a copy-pasteable replay command — useful for turning an SSRF callback into a request you can re-run from the CLI. Events that don't implement it are simply rendered without one.
type FilterBypasser ¶ added in v0.1.6
type FilterBypasser interface {
BypassFilter() bool
}
FilterBypasser is an optional interface implemented by events that should skip the notifier's regex filter. Sink-hit events implement this because the user explicitly opted in by enabling notifications on the sink — the notifier filter is for routing the general event stream, not for gating explicit opt-in delivery.
type Handler ¶
type Handler interface {
Name() string
Start(App, chan InteractionEvent) error
Stop(ctx context.Context) error
}
Handler is a listening protocol implementation (HTTP, SMTP, DNS, ...). Start blocks serving requests; Stop should release the listening socket and any goroutines the handler owns. ctx provides a deadline for in-flight requests to drain. Stop must be safe to call even if Start was never invoked or has already returned.
type InteractionEvent ¶
type InteractionEvent interface {
Details() string
RemoteIP() string
RemotePort() int
UserAgent() string
Data() string
// FilterString returns the canonical, handler-labelled string a
// notifier's Filter regex is matched against. It has the shape
// "HANDLER ACTION DETAIL from IP[,IP...]" (e.g. "SMB Auth CORP\\alice
// from 10.0.0.5"), so a single regex can select across every handler
// (e.g. "^SMB Auth", "^DNS (A|AAAA) .*\\.evil\\.com"). The trailing IP
// list is the unique source chain (X-Forwarded-For + peer for HTTP).
FilterString() string
Dispatch(cc chan InteractionEvent)
}
type Notifier ¶
type Notifier interface {
Name() string
Send(InteractionEvent) error
Filter() *regexp.Regexp
}
type NotifierBase ¶
type NotifierChat ¶
type NotifierChat struct {
NotifierWebhook
Channel string
User string
UserImage string
}
type NotifierWebhook ¶
type NotifierWebhook struct {
NotifierBase
URL string
}
type NotifySuppressor ¶ added in v0.1.0
type NotifySuppressor interface {
NotifySuppressed() bool
}
NotifySuppressor is implemented by events that should still be persisted but skip notifier delivery. httpx uses this to suppress suspected bots (high request volume): the traffic is still recorded in the DB / Events log, but notifiers stay quiet so a scanner doesn't flood Slack/webhooks.
type Persistable ¶ added in v0.1.0
type Persistable interface {
Interaction() *model.Interaction
}
Persistable is implemented by interaction events that can be stored as a model.Interaction. The application's event loop persists every event that implements this interface (see pkg/xodbox), so a handler only has to build the record — it never touches the database directly. Returning nil skips persistence for that particular event.
type Seeder ¶ added in v0.0.22
type Seeder interface {
Seed() error
}
Seeder is an optional interface implemented by handlers that need to populate their own database state (e.g. payload templates) before any requests are served. App.Run calls Seed on each implementing handler exactly once, after the DB is connected and before any Start. Seed must be idempotent.
type SinkHitProvider ¶ added in v0.1.5
SinkHitProvider is an optional interface implemented by events that represent a sink hit — an inbound interaction matching a notify-enabled sink. Notifiers type-assert to it for enriched formatting (sink slug, description, and a link to the sink).
type Worker ¶ added in v0.1.3
Worker is a periodic background job managed by the workflow engine. Schedule is a robfig/cron v3 expression: standard 5-field cron ("0 2 * * *"), shorthand ("@daily"), or interval ("@every 1h"). Run is called once per tick; ctx is cancelled on shutdown. An error is logged but does not stop future ticks.
type WorkerStatus ¶ added in v0.1.8
type WorkerStatus struct {
Name string `json:"name"`
Schedule string `json:"schedule"`
// Running reports whether a run (scheduled or manual) is in flight.
Running bool `json:"running"`
// LastRun is when the most recent run started; nil if it has never run.
LastRun *time.Time `json:"last_run,omitempty"`
// LastDurationMS is how long the most recent completed run took.
LastDurationMS int64 `json:"last_duration_ms,omitempty"`
// LastError is the most recent run's error, empty when it succeeded.
LastError string `json:"last_error,omitempty"`
// NextRun is the next scheduled fire time; nil when unscheduled.
NextRun *time.Time `json:"next_run,omitempty"`
}
WorkerStatus is a point-in-time view of one Worker for the management API and CLI: what it is, when it last ran, and how that went.