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 committed by Simon
parent cbc85f8bb8
commit 298a13c2e4
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
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