mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-23 16:46:40 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d0b8d9abc8 |
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Fix CEL internal errors when iterating `headers`/`query` map wrappers by implementing map iterators for `HTTPHeaders` and `URLValues` ([#1465](https://github.com/TecharoHQ/anubis/pull/1465)).
|
- Fix CEL internal errors when iterating `headers`/`query` map wrappers by implementing map iterators for `HTTPHeaders` and `URLValues` ([#1465](https://github.com/TecharoHQ/anubis/pull/1465)).
|
||||||
- Enable [metrics serving via TLS](./admin/policies.mdx#tls), including [mutual TLS (mTLS)](./admin/policies.mdx#mtls).
|
- Enable [metrics serving via TLS](./admin/policies.mdx#tls), including [mutual TLS (mTLS)](./admin/policies.mdx#mtls).
|
||||||
- Enable [HTTP basic auth](./admin/policies.mdx#http-basic-authentication) for the metrics server.
|
- Enable [HTTP basic auth](./admin/policies.mdx#http-basic-authentication) for the metrics server.
|
||||||
|
- Fix a bug in the dataset poisoning maze that could allow denial of service [#1580](https://github.com/TecharoHQ/anubis/issues/1580).
|
||||||
|
|
||||||
## v1.25.0: Necron
|
## v1.25.0: Necron
|
||||||
|
|
||||||
|
|||||||
@@ -76,13 +76,6 @@ type Impl struct {
|
|||||||
affirmation, body, title spintax.Spintax
|
affirmation, body, title spintax.Spintax
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Impl) incrementUA(ctx context.Context, userAgent string) int {
|
|
||||||
result, _ := i.uaWeight.Get(ctx, internal.SHA256sum(userAgent))
|
|
||||||
result++
|
|
||||||
i.uaWeight.Set(ctx, internal.SHA256sum(userAgent), result, time.Hour)
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *Impl) incrementNetwork(ctx context.Context, network string) int {
|
func (i *Impl) incrementNetwork(ctx context.Context, network string) int {
|
||||||
result, _ := i.networkWeight.Get(ctx, internal.SHA256sum(network))
|
result, _ := i.networkWeight.Get(ctx, internal.SHA256sum(network))
|
||||||
result++
|
result++
|
||||||
@@ -90,20 +83,19 @@ func (i *Impl) incrementNetwork(ctx context.Context, network string) int {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Impl) CheckUA() checker.Impl {
|
|
||||||
return checker.Func(func(r *http.Request) (bool, error) {
|
|
||||||
result, _ := i.uaWeight.Get(r.Context(), internal.SHA256sum(r.UserAgent()))
|
|
||||||
if result >= 25 {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return false, nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *Impl) CheckNetwork() checker.Impl {
|
func (i *Impl) CheckNetwork() checker.Impl {
|
||||||
return checker.Func(func(r *http.Request) (bool, error) {
|
return checker.Func(func(r *http.Request) (bool, error) {
|
||||||
result, _ := i.uaWeight.Get(r.Context(), internal.SHA256sum(r.UserAgent()))
|
realIP, _ := internal.RealIP(r)
|
||||||
|
if !realIP.IsValid() {
|
||||||
|
realIP = netip.MustParseAddr(r.Header.Get("X-Real-Ip"))
|
||||||
|
}
|
||||||
|
|
||||||
|
network, ok := internal.ClampIP(realIP)
|
||||||
|
if !ok {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
result, _ := i.networkWeight.Get(r.Context(), internal.SHA256sum(network.String()))
|
||||||
if result >= 25 {
|
if result >= 25 {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
@@ -164,7 +156,6 @@ func (i *Impl) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
networkCount := i.incrementNetwork(r.Context(), network.String())
|
networkCount := i.incrementNetwork(r.Context(), network.String())
|
||||||
uaCount := i.incrementUA(r.Context(), r.UserAgent())
|
|
||||||
|
|
||||||
stage := r.PathValue("stage")
|
stage := r.PathValue("stage")
|
||||||
|
|
||||||
@@ -172,8 +163,8 @@ func (i *Impl) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
lg.Debug("found new entrance point", "id", id, "stage", stage, "userAgent", r.UserAgent(), "clampedIP", network)
|
lg.Debug("found new entrance point", "id", id, "stage", stage, "userAgent", r.UserAgent(), "clampedIP", network)
|
||||||
} else {
|
} else {
|
||||||
switch {
|
switch {
|
||||||
case networkCount%256 == 0, uaCount%256 == 0:
|
case networkCount%256 == 0:
|
||||||
lg.Warn("found possible crawler", "id", id, "network", network)
|
lg.Warn("found possible crawler", "id", id, "network", network, "userAgent", r.UserAgent())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -190,14 +190,6 @@ func New(opts Options) (*Server, error) {
|
|||||||
},
|
},
|
||||||
Name: "honeypot/network",
|
Name: "honeypot/network",
|
||||||
},
|
},
|
||||||
policy.Bot{
|
|
||||||
Rules: mazeGen.CheckUA(),
|
|
||||||
Action: config.RuleWeigh,
|
|
||||||
Weight: &config.Weight{
|
|
||||||
Adjust: 30,
|
|
||||||
},
|
|
||||||
Name: "honeypot/user-agent",
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
result.logger.Error("can't init honeypot subsystem", "err", err)
|
result.logger.Error("can't init honeypot subsystem", "err", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user