Repository navigation
Description
Summary
gate-3's caller-identity-ignored rule has no interface awareness, so it reports a false positive on every implementation of a shared strategy interface that mandates a caller-identity parameter, even when sibling implementations use it. Same shape as the gate-6 corpus gap in #290.
Measured on ConductionNL/procest@development (gate package 651e5c5bb3ba8764903e5d6fc5bac5a208bd67fc), where it accounts for all 3 of the repo's gate-3 findings:
lib/Service/Transitions/ChecklistGuard.php:65 method=evaluate rule=caller-identity-ignored param=$userId
lib/Service/Transitions/RequiredDocumentGuard.php:50 method=evaluate rule=caller-identity-ignored param=$userId
lib/Service/Transitions/RequiredFieldGuard.php:48 method=evaluate rule=caller-identity-ignored param=$userId
Why these are false positives
The parameter is mandated by an interface, not chosen by the method:
// lib/Service/Transitions/GuardEvaluatorInterface.php:47
public function evaluate(array $guardConfig, array $case, string $userId): GuardResult;All five implementations must accept $userId. Two of them genuinely use it; three are preconditions for which caller identity is irrelevant:
| implementation | implements the interface | $userId occurrences in evaluate() |
|---|---|---|
RoleGuard |
yes | 4 |
MandaatGuard |
yes | 2 |
ChecklistGuard |
yes | 1 (signature only) |
RequiredDocumentGuard |
yes | 1 (signature only) |
RequiredFieldGuard |
yes | 1 (signature only) |
RequiredFieldGuard::evaluate() reads one key off the case array and returns pass/fail. There is no correct behaviour that consults the caller — authorization is a different guard in the same registry.
Why the rule's own intent excludes them
The rule is documented in run-hydra-gates.sh (~line 1550) as the decidesk#45 pattern: "the builder's fix-mode created empty-stub authorize*() methods that accept $uid but never reference it". That is stub auth. These are not auth methods and are not stubs — they are complete precondition evaluators whose signature is fixed by a contract.
Why there is no honest local fix
Every available remedy is worse than the finding:
- Use the parameter anyway (e.g. stuff the uid into
GuardResult::details) — comment-satisfaction; it does not change the decision and exists only to move the matcher. - Drop
$userIdfrom the interface and haveRoleGuard/MandaatGuardreadIUserSession— actively wrong.GuardRegistry::evaluateAll()is called with an explicit uid, including from background jobs and system transitions where there is no session; reaching for the session would break exactly those callers. - Rename the parameter so the regex stops matching — the definition of gaming the gate.
So the repo leaves them red, which costs a permanently-red gate for a correct design.
Suggested fix
Skip a method when both hold:
- the declaring class has an
implementsclause, and - at least one other implementation of that interface, in the same repo, references the parameter in its own body.
That preserves the decidesk#45 catch (a lone stub authorize*() still fails, since no sibling uses it) while clearing interface-parity parameters. A cheaper approximation, if cross-class analysis is unwanted: skip when the method's name matches an interface method the class declares it implements.
Either way, the finding text should distinguish "accepts identity and ignores it" from "is contractually required to accept identity" — currently a correct design and an unfinished stub are indistinguishable in the log.
Related
- gate-6 (orphan-auth) reports every router-invoked controller action as an orphan — appinfo/routes.php is not in its caller corpus #290 — gate-6's caller corpus omits
appinfo/routes.php, so router-invoked actions read as orphaned. Same class of defect: a rule whose evidence corpus is narrower than the language feature it judges.
Activity