test(server): fail-closed HTTP roster also covers switch-case, logical and conditional routing forms

Open
#9,124 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
testing

Research direction

Start in packages/server/tests/helpers/http-auth-inventory.js, where the AST visitor decides unplaced entries, and read tests/principal-http-roster.test.js to see how the inventory and fixture count are asserted. Add detection for LogicalExpression, ConditionalExpression and SwitchCase test subtrees that mention req.url or URL-derived names, plus alias-computed header keys and computed or destructured grant access. Add one mutation fixture per new form and update the fixture count; done when each fixture reports an explicit finding and the real http-routes.js control stays clean.

Written by the indexing model from the issue text.

Description

enhancement security server

Context

Identified during the final delta review of PR #9123 (S1 of #9112). The review approved the PR, and these are non-blocking hardening items for a test guard.

Location: packages/server/tests/helpers/http-auth-inventory.js. This is the AST inventory behind tests/principal-http-roster.test.js.

Description

The roster refuses principal tokens on every HTTP route by inventorying routes and bearer reads from the AST. It fails closed on request aliases, switch discriminants derived from req.url, computed header keys and compound assignments. Three routing forms in future code would still go unreported, because they use no req.method check and no if statement:

  • switch (true) { case p === '/b': … }. Only the discriminant is inspected, not the SwitchCase tests.
  • p === '/c' && res.end(), a LogicalExpression.
  • p === '/d' ? res.end() : null, a ConditionalExpression.

A probe confirmed that none of these produces an unplaced entry. Two smaller gaps:

  • const h = req.headers; h[k] is caught only through the pinned whole-headers escape count, not as a computed header key.
  • The no-.grant() mint scan does not cover store['grant'] or a destructured grant. The method still refuses at runtime.

The real http-routes.js classifies cleanly today, so no current route escapes. These are future-code gaps.

Acceptance Criteria

  • Any LogicalExpression, ConditionalExpression or SwitchCase test whose subtree mentions req.url or a URL-derived name outside a classified route is reported as unplaced. A mutation fixture for each of the three forms must produce an explicit finding.
  • A computed key on an alias of req.headers is reported as a computed header read, not only through the escape count.
  • The mint scan also rejects computed or destructured grant access in src/.
  • The real http-routes.js positive control stays clean, and the fixture count assertion is updated.
Dominant language
JavaScript
Stars
7
Forks
1
Avg merge
2h 3m
Merged PRs (30d)
333

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from blamechris/chroxy

All issues in blamechris/chroxy

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.