Harden NoActor check with runtime environment guard

Add Mix.env() check to match?/3 for defense in depth.
Document NoActor pattern in CODE_GUIDELINES.md.
This commit is contained in:
Moritz 2026-01-22 21:36:09 +01:00
parent 5506b5b2dc
commit 93216f3ee6
3 changed files with 128 additions and 1 deletions

View file

@ -58,7 +58,8 @@ defmodule Mv.Authorization.Checks.NoActor do
@impl true
def match?(nil, _context, _opts) do
# Actor is nil
if @allow_no_actor_bypass do
# Double-check: compile-time AND runtime environment
if @allow_no_actor_bypass and Mix.env() == :test do
# Test environment: Allow all operations
true
else