Skip to content

gate-6 (orphan-auth) reports every router-invoked controller action as an orphan — appinfo/routes.php is not in its caller corpus #290

Open

Description

@rubenvdlinde

Summary

check_orphan_auth.py builds its caller corpus from lib/** + src/** only, and detects a caller with the regex ->\<name\>\s*\(.

A routed controller action has neither. Nextcloud's router invokes it by reflection from the 'name' => 'foo#bar' entry in appinfo/routes.php — a file the corpus never opens. So any controller method whose name begins with one of the gate's verbs is reported as defined-but-never-called even when it is fully live.

Measured — launchpad

[gate-6] orphan-auth: FAIL — 1 orphan method(s)
lib/Controller/LiveTileController.php:186 method=validateSource rule=defined-but-never-called

That method is live on every axis:

evidence location
routed appinfo/routes.php:557 — ['name' => 'liveTile#validateSource', 'url' => '/api/livetile/validate-source', 'verb' => 'POST']
called by the frontend src/services/liveTileClient.js:62 — generateUrl('/apps/launchpad/api/livetile/validate-source')
unit-tested tests/Unit/Controller/LiveTileControllerTest.php:221,232

The frontend calls the URL, not the PHP method name, so it cannot match ->validateSource( either.

I checked the sibling seam before concluding FP

The dangerous reading of "zero callers" is that the orphan is the correct implementation and the live path is missing the guard. It is not the case here:

  • validateSource is pre-save UX validation, delegating to LiveTileService::validateSourceConfig().
  • The live fetch path LiveTileService::fetchFromUrl() independently enforces the same rules: hasValidScheme(), then isHostAllowed() fail-closed, and 'allow_redirects' => false explicitly so a 3xx cannot bypass the allow-list.

So the allow-list is enforced where it matters, and the endpoint is a genuine, reachable, tested convenience API. Neither WIRE nor DELETE is correct — the method is simply live.

Blast radius

Every app in the fleet, for any controller action whose name starts with a gate verb:
authorize* requires* require* ensure* assert* validate* is* check* verify*

These are common controller-action names (validateSource, checkStatus, verifyToken, isAvailable). Each is reported as an unwired auth guard — the same "an unwired guard is identical to no guard" framing the gate uses for real findings — which makes real gate-6 findings harder to trust.

Suggested fix

Add the route table to the caller corpus, and treat a controller method named in it as called:

  1. Include appinfo/routes.php (and appinfo/routes/*.php) in _build_caller_corpus().
  2. For a candidate in lib/Controller/<X>Controller.php, also accept a match on the route-name form — '<lowerCamelX>#<method>' — not just ->method(.

Option 2 alone is enough and is precise: it keys on the exact declaration that makes the method reachable.

A regression fixture should include a routed controller action with a gate-verb name and assert it is not reported — that is the case that currently fails.

Related

Same family as #218 (gate-30 route shape), #220 (gate-31 JSDoc), #222 (gate-37/43) — a checker that cannot see the mechanism by which code is reached, reporting reachable code as dead.

Activity

  1. rubenvdlinde commented on Aug 10, 2026

    @rubenvdlinde
    ContributorAuthor

    Fixed with option 2, which is the precise one.

    Reproduced on launchpad: lib/Controller/LiveTileController.php:187 method=validateSource rule=defined-but-never-called, routed at appinfo/routes.php:557 as 'liveTile#validateSource'.

    _is_routed() now clears a candidate when the router reaches it:

    • '<lowerCamelController>#<method>' in appinfo/routes.php or appinfo/routes/*.php; or
    • a #[Route] / #[ApiRoute] / #[FrontpageRoute] attribute on the method (NC attribute routing needs no route table at all).

    Keyed on the exact declaration that makes the method reachable, so it is evidence rather than a name heuristic.

    Kept narrow

    • the controller and the method must both match — a route table naming liveTile#index does not clear validateSource, and other#validateSource does not clear it either;
    • services are never cleared by the route table — _route_prefix() returns None for anything that is not lib/Controller/*Controller.php. A service is not routable, and letting one match here would be exactly the blanket to avoid: decidesk's isTransitionAllowed / validateQuorum family lives in services and a route entry must never quiet one. That is an explicit test arm.

    Measured

    Fleet 6 → 5. launchpad's single finding is gone; the other five (openregister 1, pipelinq 3, procest 1) are unrouted and untouched.

    ⚠️ A measurement note that cost me a pass: my first sweep filtered repos on [ -d .git ] and silently skipped launchpad, which has no .git in this workspace — i.e. it dropped the very app the issue was measured on and reported "6 → 6, no change". Worth knowing for anyone sweeping this fleet.

    Verification

    7 arms; 3 fail on origin/main. FP: routed action → 0, appinfo/routes/api.php → 0, attribute-routed → 0. TP: no route table → 1; wrong method in the table → 1; wrong controller → 1; a service named in the route table → still 1.


    Fixed in #329.

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