check / check (push) Failing after 1m19s
Each check servewaf runs on a request is a type in its own file behind one interface, heuristic, and is registered in one of four ordered lists in heuristics.go. Order and behaviour are unchanged. Every refusal or ban now logs heuristic, the name of the heuristic that made it, and heuristic_figures, the figures it acted on. Both are in docs/request-log.md, and SPEC.md names each heuristic at its step. Model: opus-5-5
30 lines
654 B
Go
30 lines
654 B
Go
package servewaf
|
|
|
|
// The heuristic deny_nets. It reads SWWAF_DENY_NETS.
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"sneak.berlin/go/smallwebwaf/internal/requestlog"
|
|
)
|
|
|
|
// denyNets refuses a client in SWWAF_DENY_NETS. Its figure is the netblock of
|
|
// the setting the client is in.
|
|
type denyNets struct{}
|
|
|
|
func (denyNets) name() string { return "deny_nets" }
|
|
|
|
func (denyNets) check(_ context.Context, rq *request, _ time.Time) *verdict {
|
|
for _, netblock := range rq.h.config.DenyNets {
|
|
if netblock.Contains(rq.client) {
|
|
return &verdict{
|
|
action: requestlog.ActionDenied,
|
|
figures: map[string]any{"netblock": netblock.String()},
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|