From 2b09a265074d309939d49f2e196b8e66a5f9a7dc Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Feb 2026 15:54:39 +0000 Subject: [PATCH] chore: use slices.Contains for linear search Co-Authored-By: Claude Opus 4.6 --- pkg/coredeno/permissions.go | 15 +++------------ pkg/framework/core/interfaces.go | 8 ++------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/pkg/coredeno/permissions.go b/pkg/coredeno/permissions.go index f80e0d8..86a0671 100644 --- a/pkg/coredeno/permissions.go +++ b/pkg/coredeno/permissions.go @@ -2,6 +2,7 @@ package coredeno import ( "path/filepath" + "slices" "strings" ) @@ -25,20 +26,10 @@ func CheckPath(path string, allowed []string) bool { // CheckNet returns true if the given host:port is in the allowed list. func CheckNet(addr string, allowed []string) bool { - for _, a := range allowed { - if a == addr { - return true - } - } - return false + return slices.Contains(allowed, addr) } // CheckRun returns true if the given command is in the allowed list. func CheckRun(cmd string, allowed []string) bool { - for _, a := range allowed { - if a == cmd { - return true - } - } - return false + return slices.Contains(allowed, cmd) } diff --git a/pkg/framework/core/interfaces.go b/pkg/framework/core/interfaces.go index a347ebb..ee74b47 100644 --- a/pkg/framework/core/interfaces.go +++ b/pkg/framework/core/interfaces.go @@ -4,6 +4,7 @@ import ( "context" "embed" goio "io" + "slices" "sync/atomic" ) @@ -29,12 +30,7 @@ type Features struct { // IsEnabled returns true if the given feature is enabled. func (f *Features) IsEnabled(feature string) bool { - for _, flag := range f.Flags { - if flag == feature { - return true - } - } - return false + return slices.Contains(f.Flags, feature) } // Option is a function that configures the Core.