diff --git a/botfilter.go b/botfilter.go index 7bb5d337..aea6d8f6 100644 --- a/botfilter.go +++ b/botfilter.go @@ -1,6 +1,6 @@ // Package traefik_botfilter is a Traefik middleware plugin that blocks known scans // and applies a bounded, in-memory per-IP suspicion score. -package botfilter +package traefik_botfilter import ( "bufio" diff --git a/botfilter_test.go b/botfilter_test.go index 1e885bc6..d6ed5e05 100644 --- a/botfilter_test.go +++ b/botfilter_test.go @@ -1,4 +1,4 @@ -package botfilter +package traefik_botfilter import ( "context" @@ -73,6 +73,10 @@ func TestEncodedScanPathBansBeforeUpstream(t *testing.T) { cfg := CreateConfig() cfg.RequireUserAgent = false cfg.RequireAccept = false + // Blocked paths are opt-in, so the test must configure the rule it expects to + // match; the point under test is that the encoded traversal form normalises + // onto that rule instead of slipping past it. + cfg.BlockedPaths = []string{"/.env"} nextCalls := 0 handler, err := New(context.Background(), http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { nextCalls++ diff --git a/cache.go b/cache.go index a5bee7d2..f08ba49e 100644 --- a/cache.go +++ b/cache.go @@ -1,4 +1,4 @@ -package botfilter +package traefik_botfilter import ( "sync" diff --git a/config.go b/config.go index bfe9f4fa..23752f98 100644 --- a/config.go +++ b/config.go @@ -1,4 +1,4 @@ -package botfilter +package traefik_botfilter import ( "fmt" diff --git a/logger.go b/logger.go index df928304..23e630fb 100644 --- a/logger.go +++ b/logger.go @@ -1,4 +1,4 @@ -package botfilter +package traefik_botfilter import "log" diff --git a/matcher.go b/matcher.go index 793147d1..a4e894cd 100644 --- a/matcher.go +++ b/matcher.go @@ -1,4 +1,4 @@ -package botfilter +package traefik_botfilter import ( "net/http" diff --git a/util.go b/util.go index 7a80ec94..f0f62d47 100644 --- a/util.go +++ b/util.go @@ -1,4 +1,4 @@ -package botfilter +package traefik_botfilter import ( "net"