Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions internal/server/guard_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import (

var logGuardInit = logger.New("server:guard_init")

func newNoopGuard() guard.Guard {
return guard.NewNoopGuard()
}

// legacyPolicySource is returned by resolveGuardPolicy when no explicit policy
// is configured and the caller should fall back to legacy session-label semantics.
const legacyPolicySource = "legacy"
Expand Down Expand Up @@ -81,20 +85,20 @@ func (us *UnifiedServer) registerGuard(serverID string) error {
g, err = us.createGuardFromConfig(guardName, guardCfg)
if err != nil {
logger.LogWarnToServer(serverID, "difc", "Failed to create guard '%s': %v (falling back to noop)", guardName, err)
g = guard.NewNoopGuard()
g = newNoopGuard()
}
} else {
// Guard name specified but no config found - try registered guard types
var err error
g, err = guard.CreateGuard(guardName)
if err != nil {
logger.LogWarnToServer(serverID, "difc", "Guard '%s' not found: %v (falling back to noop)", guardName, err)
g = guard.NewNoopGuard()
g = newNoopGuard()
}
}
} else {
// No guard configured - use noop
g = guard.NewNoopGuard()
g = newNoopGuard()
}
}

Expand Down Expand Up @@ -130,7 +134,7 @@ func (us *UnifiedServer) requireGuardPolicyIfGuardEnabled(serverID string, g gua
}

logger.LogWarnToServer(serverID, "difc", "Guard '%s' is available but no guard policy is set; falling back to noop guard", g.Name())
return guard.NewNoopGuard(), nil
return newNoopGuard(), nil
}

return g, nil
Expand Down Expand Up @@ -211,7 +215,7 @@ func (us *UnifiedServer) logWASMGuardsDirConfiguration() {
func (us *UnifiedServer) createGuardFromConfig(name string, cfg *config.GuardConfig) (guard.Guard, error) {
switch cfg.Type {
case "noop", "":
return guard.NewNoopGuard(), nil
return newNoopGuard(), nil

case "wasm":
// WASM guard loading - requires path
Expand Down
Loading