feat(honeypot/naive): attempt to automatically filter out based on crawling

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2025-12-16 01:22:13 -05:00
parent e0f4468b03
commit 958daba4a1
5 changed files with 407 additions and 59 deletions
+20
View File
@@ -179,6 +179,26 @@ func New(opts Options) (*Server, error) {
bsgen, err := naive.New(result.store, result.logger)
if err == nil {
registerWithPrefix(anubis.APIPrefix+"honeypot/{id}/{stage}", bsgen, http.MethodGet)
opts.Policy.Bots = append(
opts.Policy.Bots,
policy.Bot{
Rules: bsgen.CheckNetwork(),
Action: config.RuleWeigh,
Weight: &config.Weight{
Adjust: 30,
},
Name: "honeypot/network",
},
policy.Bot{
Rules: bsgen.CheckUA(),
Action: config.RuleWeigh,
Weight: &config.Weight{
Adjust: 30,
},
Name: "honeypot/user-agent",
},
)
} else {
result.logger.Error("can't init honeypot subsystem", "err", err)
}
+8
View File
@@ -14,6 +14,14 @@ type Impl interface {
Hash() string
}
type Func func(*http.Request) (bool, error)
func (f Func) Check(r *http.Request) (bool, error) {
return f(r)
}
func (f Func) Hash() string { return internal.FastHash(fmt.Sprintf("%#v", f)) }
type List []Impl
// Check runs each checker in the list against the request.