Skip to content

gate-3 caller-identity-ignored: no interface awareness — flags every implementation of a strategy interface that mandates $userId #299

Open

Description

@rubenvdlinde

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:

  1. 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.
  2. Drop $userId from the interface and have RoleGuard/MandaatGuard read IUserSession — 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.
  3. 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 implements clause, 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions