mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-20 23:26:40 +00:00
feat(honeypot/naive): attempt to automatically filter out based on crawling
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user