@fuzdev/fuz_app 0.164.0 → 0.166.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +2 -2
- package/dist/actions/action_event_data.d.ts +1 -1
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +24 -15
- package/dist/actions/action_spec.d.ts +2 -2
- package/dist/actions/perform_action.d.ts +2 -1
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/auth/account_action_specs.d.ts +8 -8
- package/dist/auth/account_route_schema.d.ts +197 -164
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +19 -17
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +285 -294
- package/dist/auth/admin_action_specs.d.ts +64 -64
- package/dist/auth/audit_log_route_schema.d.ts +16 -8
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_route_schema.js +4 -3
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +112 -111
- package/dist/auth/audit_log_schema.d.ts +22 -22
- package/dist/auth/bootstrap_route_schema.d.ts +46 -69
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +8 -7
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +100 -98
- package/dist/auth/role_grant_offer_action_specs.d.ts +4 -4
- package/dist/auth/signup_route_schema.d.ts +9 -4
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +5 -3
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +170 -170
- package/dist/http/CLAUDE.md +50 -4
- package/dist/http/common_routes.d.ts +1 -1
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +13 -11
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +25 -28
- package/dist/http/error_schemas.d.ts +5 -1
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +5 -1
- package/dist/http/route_error_check.d.ts +21 -0
- package/dist/http/route_error_check.d.ts.map +1 -1
- package/dist/http/route_error_check.js +37 -1
- package/dist/http/route_result.d.ts +101 -0
- package/dist/http/route_result.d.ts.map +1 -0
- package/dist/http/route_result.js +56 -0
- package/dist/http/route_spec.d.ts +110 -6
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +82 -14
- package/dist/http/schema_helpers.d.ts +15 -1
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +12 -3
- package/dist/rate_limiter.d.ts +0 -9
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +0 -15
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +23 -21
- package/dist/server/surface_route.d.ts +1 -1
- package/dist/server/surface_route.d.ts.map +1 -1
- package/dist/server/surface_route.js +4 -2
- package/dist/testing/CLAUDE.md +80 -28
- package/dist/testing/admin_integration.js +1 -1
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +13 -8
- package/dist/testing/adversarial_input.js +2 -2
- package/dist/testing/assertions.d.ts +13 -3
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +21 -4
- package/dist/testing/attack_surface.d.ts +12 -0
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +8 -5
- package/dist/testing/cross_backend/in_process_setup.d.ts +7 -3
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +11 -4
- package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
- package/dist/testing/cross_backend/login_security.js +3 -2
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +2 -6
- package/dist/testing/cross_backend/spine_suites.d.ts +3 -2
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +5 -2
- package/dist/testing/cross_backend/standard.d.ts +31 -0
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.js +9 -3
- package/dist/testing/data_exposure.d.ts +7 -0
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +3 -3
- package/dist/testing/error_coverage.d.ts +35 -33
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +53 -43
- package/dist/testing/integration.d.ts +28 -1
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +51 -18
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +4 -15
- package/dist/testing/middleware_gate_probes.d.ts +90 -0
- package/dist/testing/middleware_gate_probes.d.ts.map +1 -0
- package/dist/testing/middleware_gate_probes.js +179 -0
- package/dist/testing/round_trip.d.ts +7 -0
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +3 -2
- package/dist/testing/schema_generators.d.ts +31 -9
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +53 -11
- package/dist/testing/stubs.d.ts +14 -3
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +21 -6
- package/dist/testing/transports/raw_http.d.ts +10 -2
- package/dist/testing/transports/raw_http.d.ts.map +1 -1
- package/dist/testing/transports/raw_http.js +10 -4
- package/package.json +1 -1
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
import { array, literal, loose_object, object } from '@fuzdev/fuz_schema/schema.ts';
|
|
11
|
+
import { define_route } from '../http/route_spec.js';
|
|
12
|
+
import { route_ok } from '../http/route_result.js';
|
|
11
13
|
import { ActingActor } from '../primitive_schemas_fuz.js';
|
|
12
14
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
13
15
|
/**
|
|
@@ -24,7 +26,7 @@ import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
|
24
26
|
* @param options - the surface to serve
|
|
25
27
|
* @returns the `GET /api/surface` route spec
|
|
26
28
|
*/
|
|
27
|
-
export const create_surface_route_spec = (options) => ({
|
|
29
|
+
export const create_surface_route_spec = (options) => define_route({
|
|
28
30
|
method: 'GET',
|
|
29
31
|
path: '/api/surface',
|
|
30
32
|
auth: {
|
|
@@ -35,7 +37,7 @@ export const create_surface_route_spec = (options) => ({
|
|
|
35
37
|
// gets none of it
|
|
36
38
|
required_scope: 'surface:app_surface'
|
|
37
39
|
},
|
|
38
|
-
handler: (
|
|
40
|
+
handler: () => route_ok(options.surface),
|
|
39
41
|
description: 'Application surface (routes, middleware, schemas) — admin only',
|
|
40
42
|
query: object({ acting: ActingActor }),
|
|
41
43
|
input: literal(null),
|
package/dist/testing/CLAUDE.md
CHANGED
|
@@ -30,7 +30,8 @@ time (never runtime), where a throwing guard would break `vite build`.
|
|
|
30
30
|
- `create_noop_stub<T>(label, overrides?)` — Proxy whose every method returns `async () => undefined`; `overrides` pins specific props.
|
|
31
31
|
- `stub` — pre-built throwing stub labelled `'stub'`.
|
|
32
32
|
- `create_stub_db()` — real `Db` whose `client.query` yields `{rows: []}` and `transaction(fn)` synchronously calls `fn(inner_stub_db)`. Safe for `apply_route_specs`'s declarative transaction wrapper.
|
|
33
|
-
- `stub_handler()` — fresh `Response('stub')
|
|
33
|
+
- `stub_handler()` — a fresh `Response('stub')` as a `route_raw` result, a handler that fits any route (`attach_route_handler(shape, stub_handler)`).
|
|
34
|
+
- `stub_route_spec(shape)` — a spec for a surface that is described and never served: `shape` with a handler that throws when run (the spine routes of `create_rust_spine_consumer_surface_spec`).
|
|
34
35
|
- `stub_mw` — pass-through middleware (`async (_c, next) => next()`).
|
|
35
36
|
- `create_stub_app_deps()` — factory: fresh `AppDeps` with no-op keyring/password/`delete_file`, a `read_secure_file` that throws ENOENT (the no-token-file state), a `create_noop_stub` DB, silent `Logger`, no-op `audit`, an empty `connection_closer`.
|
|
36
37
|
- `create_test_audit_emitter()` — no-op `AuditEmitter`; `emit` / `emit_role_grant_target` / `emit_pool` resolve immediately, `notify` no-op, `add_listener` throws (use `create_recording_audit_emitter` for a listener-accepting emitter), `listener_count` returns 0, `drain_inflight` resolves immediately, `is_tracking_inflight` returns `false`.
|
|
@@ -416,7 +417,7 @@ or Postgres and runs in the `cross-ts` CI job.
|
|
|
416
417
|
- `assert_surface_matches_snapshot(surface, path)` — compares live `AppSurface` against a committed JSON snapshot; failure message instructs `gro gen`.
|
|
417
418
|
- `assert_surface_deterministic(build_surface)` — build twice, `deepStrictEqual` results; catches nondeterminism in surface generation.
|
|
418
419
|
- `assert_only_expected_public_routes(surface, list)` — bidirectional: no unexpected public routes, no missing expected ones. Format: `['GET /health', 'POST /api/account/login']`.
|
|
419
|
-
- `assert_full_middleware_stack(surface, prefix, mws)` — every route under `prefix` has exactly `mws` as its middleware chain.
|
|
420
|
+
- `assert_full_middleware_stack(surface, prefix, mws)` — every route under `prefix` has exactly `mws` as its middleware chain, less each layer that carves it out (a layer whose `path` and one of whose `carve_outs` apply to the route, `middleware_carves_out`, with no other layer of its name running there) — the rule `applicable_middleware` and the route error map read. A route missing a layer no carve-out explains fails, and so does a carved-out route still listing it.
|
|
420
421
|
- `get_route_error_schema(lookup, route, status)` — reads the route's error map (`lookup` is `AppSurfaceSpec.route_error_maps`) at a status, a fuz_schema schema.
|
|
421
422
|
- `assert_error_schema_valid(lookup, route, status, body)` — assert the route declares the status, and the body parses against the status's schema (`parse_any`), a union of its definitions' `literal(code)` bodies, so a code the route doesn't declare at the status fails the parse; a mismatch throws an `Error` carrying the issues. Every adversarial refusal runs through it.
|
|
422
423
|
- `assert_error_response_declared(errors, jsonrpc, response, label)` — a JSON error response (400 and up) is one the route's map declares, by `check_route_error` (the DEV error check's rule: 500 `internal_error` / 503 `service_unavailable` always accepted, a JSON-RPC envelope on a `jsonrpc` route skipped, a success or non-JSON response passing); what the attack-surface suite's `correct auth passes guard` holds each answer to.
|
|
@@ -473,15 +474,22 @@ each code of each route's error map (`resolve_route_error_map`), one path per
|
|
|
473
474
|
takes the maps (`AppSurfaceSpec.route_error_maps`, middleware included); without
|
|
474
475
|
them a route's own map is read. The standard suites pass
|
|
475
476
|
`surface_source.route_error_maps`.
|
|
476
|
-
Observations live in a `Set<string>` keyed by `"METHOD /spec-path:STATUS"`
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
477
|
+
Observations live in a `Set<string>` keyed by `"METHOD /spec-path:STATUS:CODE"`
|
|
478
|
+
for an observation with a code, which covers that path alone (a
|
|
479
|
+
`forbidden_origin` 403 leaves `credential_type_required` uncovered), or
|
|
480
|
+
`"METHOD /spec-path:STATUS"` for one recorded with a `null` code (a response
|
|
481
|
+
that carries none), which satisfies the "any-code" rule for every code declared
|
|
482
|
+
at that status — asked for explicitly, never had by omission.
|
|
480
483
|
|
|
481
484
|
Methods:
|
|
482
485
|
|
|
483
|
-
- `record(specs, method, path, status, code
|
|
484
|
-
|
|
486
|
+
- `record(specs, method, path, status, code: string | null)` — resolves concrete
|
|
487
|
+
paths back to spec templates (e.g. `/api/accounts/abc` → `/api/accounts/:id`);
|
|
488
|
+
`code` is the body's `error`, `null` only for a response that has none.
|
|
489
|
+
- `assert_and_record(specs, method, path, response, code?)` — wraps
|
|
490
|
+
`assert_response_matches_spec` and reads `body.error` from the JSON body via
|
|
491
|
+
`response.clone()` (`null` when there is none). Pass `code` when the body was
|
|
492
|
+
already consumed; without it a consumed body throws.
|
|
485
493
|
- `uncovered(specs, options?)` — one `{method, path, status, code}` row per declared code never observed.
|
|
486
494
|
|
|
487
495
|
Support functions:
|
|
@@ -502,7 +510,7 @@ naming it.
|
|
|
502
510
|
- `detect_format(field_schema)` — `detect_json_schema_format` over `to_field_json_schema`: the `format`, `'pattern'` for a regex, or `null`.
|
|
503
511
|
- `generate_valid_value(field, field_schema)` — base-type switch producing a valid sample (UUIDs → nil UUID, strings → `'xxxxxxxxxx'`, numbers → `1`, objects → `generate_valid_object` against the field schema, so a nested refinement is satisfied too, enums → first entry, records → `{}`, a void field → `undefined`, etc.). For branded-string refinements, walks a fallback chain synthesized from the `pattern` string the JSON Schema representation exposes: fixed-length hex (`^[0-9a-f]{N}$` — blake3 / sha256 / md5 digests; `0`.repeat(N)), prefix-lengthed slug (`^<prefix>_[A-Za-z0-9_-]{N}$` — `ApiTokenId`-style ids; `<prefix>_` + `x`.repeat(N)), absolute path prefix, URL prefix, two `/`-joined segments (an `owner/name` slug). First candidate the field accepts is used.
|
|
504
512
|
- `generate_valid_string_param(field, field_schema)` — a string a URL-sourced field (route param, query value) accepts: the nil UUID for a UUID field, else the first of `test_value`, the generated valid value as a string, `1`, `0`, `true`, `false`, the field's JSON Schema `default` or lower bound as a string (a preprocessed integer whose minimum is above one) and a synthesized string the field accepts; `null` when none does. The params and query case generators build their base from it.
|
|
505
|
-
- `resolve_valid_path(path, params_schema?)` — swaps each whole param segment (`:name`, `:name{re}`, optional or not, read as Hono reads a template: `split_route_template` / `parse_route_param`) for a value the params schema accepts; a `:` inside a literal segment (`files:upload`) stays. Prefers `test_<name>` wherever the field schema admits it (the param name keeps failure messages readable); otherwise a UUID param takes the nil UUID and anything else is synthesized from the schema, percent-encoded. A synthesized value containing `/` is refused (it would route elsewhere) and falls back to `test_<name>`.
|
|
513
|
+
- `resolve_valid_path(path, params_schema?, param_values?)` — swaps each whole param segment (`:name`, `:name{re}`, optional or not, read as Hono reads a template: `split_route_template` / `parse_route_param`) for a value the params schema accepts; a `:` inside a literal segment (`files:upload`) stays. Prefers `test_<name>` wherever the field schema admits it (the param name keeps failure messages readable); otherwise a UUID param takes the nil UUID and anything else is synthesized from the schema, percent-encoded. A synthesized value containing `/` is refused (it would route elsewhere) and falls back to `test_<name>`. A value in `param_values` (the route's entry of `RouteParamValues`, `'METHOD /path'` → param name → value, the option the path-resolving suites take) comes first, percent-encoded like the rest. A `:name{re}` param's value, supplied or generated, must match its pattern grouped and anchored, `^(?:re)$` (`compile_route_param_pattern`, over the value as Hono decodes it, `decode_route_path`) — Hono's RegExpRouter reading, the stricter of its routers', as TrieRouter leaves a top-level alternation ungrouped — else it throws naming the route and the param and pointing at `param_values`: no value is guessed from the pattern, and no route is skipped silently. A `param_values` entry naming no param of the path throws too, and so does a supplied `''`, `.` or `..` (the URL normalizes it away) or a lone surrogate. Supplied values are always encoded, so a `{re}` needing a literal `/` can't be met by one.
|
|
506
514
|
- `to_route_content_type(route)` — the `Content-Type` a well-formed request to the route sends: `application/json`, or `application/octet-stream` for a `raw_body` route. Every `POST` route refuses anything else with 415 before its other gates, so every probe in the harnesses (auth, params and query fuzz, 404, data exposure, round trip) sends it, body or not.
|
|
507
515
|
- `generate_valid_object(object_schema, schema) => {value, result}` — required and defaulted fields; when `schema` (refinements included) refuses those, each optional field alone in declaration order, the first that parses; failing that, the optional fields added cumulatively until it parses. Covers a `.refine()` over optional fields (at least one of, exactly one of, both of) at any depth, and, where one optional field suffices, keeps the others (an `acting` declared first) out. Returns the last `parse_any` result (`GeneratedObject`) and leaves the throw to the caller, which renders its issues with `format_issues` (`schema_issues.ts`).
|
|
508
516
|
- `generate_valid_object_with_field(object_schema, schema, base, field)` — a valid object carrying `field`, built from the valid `base`: `base` itself when it carries the field; else the field joins `base`, with the optional fields `base` omits filled as `generate_valid_object` fills them (a pair rule: `scope_kind` needs `scope_id`); failing that, the field replaces `base`'s optional fields, refilled around it (exactly one of: adding `slug` drops `id`). `null` when no object the generator builds carries the field. The body a single-fault case on a field the base omits changes.
|
|
@@ -534,7 +542,7 @@ case per route):
|
|
|
534
542
|
4. **adversarial input validation** — delegated to `describe_adversarial_input`.
|
|
535
543
|
5. **adversarial 404 response validation** — delegated to `describe_adversarial_404`.
|
|
536
544
|
|
|
537
|
-
Options: `{build: () => AppSurfaceSpec, snapshot_path, expected_public_routes, expected_api_middleware, roles, api_path_prefix?, security_policy?, skip_routes?}`.
|
|
545
|
+
Options: `{build: () => AppSurfaceSpec, snapshot_path, expected_public_routes, expected_api_middleware, roles, api_path_prefix?, security_policy?, skip_routes?, param_values?}`.
|
|
538
546
|
|
|
539
547
|
`skip_routes` is a list of `'METHOD /path'` surface keys the three
|
|
540
548
|
adversarial sub-suites drop, forwarded to each of them (it also sits on
|
|
@@ -543,7 +551,9 @@ adversarial sub-suites drop, forwarded to each of them (it also sits on
|
|
|
543
551
|
escape hatch for a route that cannot be driven generically at all — a
|
|
544
552
|
handler needing real seeded state, a path segment no schema describes. A
|
|
545
553
|
route whose params merely carry a format needs no entry: `resolve_valid_path`
|
|
546
|
-
synthesizes a segment the route accepts.
|
|
554
|
+
synthesizes a segment the route accepts. A `{re}` param whose pattern refuses
|
|
555
|
+
every generated value takes a `param_values` entry instead, forwarded the same
|
|
556
|
+
way (`RouteParamValues`).
|
|
547
557
|
|
|
548
558
|
Also exported: `describe_adversarial_auth(options)` (group 3 on its own).
|
|
549
559
|
|
|
@@ -636,7 +646,7 @@ For every route spec, fires a valid request with matching auth and validates
|
|
|
636
646
|
the response against declared schemas. DB-backed via `create_test_app`.
|
|
637
647
|
Per-route test (`test.each`) — one line per route in the vitest output.
|
|
638
648
|
|
|
639
|
-
Options: `{setup_test, surface_source, skip_routes?, input_overrides?, success_fixtures?}`.
|
|
649
|
+
Options: `{setup_test, surface_source, skip_routes?, input_overrides?, success_fixtures?, param_values?}`.
|
|
640
650
|
Principals and the 401 check are the RPC round-trip's (`pick_auth_principal`;
|
|
641
651
|
`assert_route_authenticated` over `is_unauthenticated_refusal`, reading the
|
|
642
652
|
flat `error`), and a non-`GET` route called as the authed
|
|
@@ -793,7 +803,7 @@ has no JSON Schema form and a field inside a transformed subtree shows only
|
|
|
793
803
|
there. The input side is a superset, so a transform that deliberately drops a
|
|
794
804
|
blocklisted field is flagged too — skip that output by its key.
|
|
795
805
|
|
|
796
|
-
Options: `{setup_test, surface_source, sensitive_fields?, admin_only_fields?, skip_routes?}`.
|
|
806
|
+
Options: `{setup_test, surface_source, sensitive_fields?, admin_only_fields?, skip_routes?, param_values?}`.
|
|
797
807
|
`skip_routes` keys a route as `'METHOD /path'`, an RPC or WS method output
|
|
798
808
|
as `'/path method_name'`, and pushed WS params as `'/path method_name params'`
|
|
799
809
|
(the schema-level checks only).
|
|
@@ -839,20 +849,54 @@ these thematic areas:
|
|
|
839
849
|
9. Token revocation + cross-account isolation
|
|
840
850
|
10. Response body schema validation + error-response information leakage
|
|
841
851
|
11. Signup invite edge cases + expired credential rejection + error-coverage breadth
|
|
852
|
+
12. Middleware gates — one test per gate each counted route's error map declares (`middleware_gate_probes.ts`, below)
|
|
842
853
|
|
|
843
854
|
An `ErrorCoverageCollector` runs across groups; `afterAll` filters to
|
|
844
|
-
|
|
845
|
-
and asserts `DEFAULT_INTEGRATION_ERROR_COVERAGE` (20%). Bootstrap is
|
|
855
|
+
the routes it counts — login, logout, password, signup (when wired) and the
|
|
856
|
+
RPC path — and asserts `DEFAULT_INTEGRATION_ERROR_COVERAGE` (20%). Bootstrap is
|
|
846
857
|
excluded because no describe block in this suite drives it — its declared
|
|
847
858
|
codes would always be uncovered. Consumer-specific routes aren't exercised
|
|
848
859
|
here either — they don't count against the baseline. The declared paths are
|
|
849
860
|
the route error maps of `surface_source`, middleware included (the origin
|
|
850
|
-
check's 403, the body limit's 413 and 400
|
|
861
|
+
check's 403, the body limit's 413 and 400, and the Rust spine's host gate's
|
|
862
|
+
403 where the surface declares it), counted per (route, status, code), so
|
|
863
|
+
every error response a test asserts is recorded, and the middleware-gate group
|
|
864
|
+
probes each gate on each counted route. Override with
|
|
851
865
|
`error_coverage_min?: number` (set to `0` to skip the assertion — useful for
|
|
852
866
|
minimal route sets whose declared error codes outpace the suite's
|
|
853
867
|
denial-path drivers).
|
|
854
868
|
|
|
855
|
-
Options: `{setup_test, surface_source, session_options, rpc_endpoints,
|
|
869
|
+
Options: `{setup_test, surface_source, session_options, rpc_endpoints, base_url,
|
|
870
|
+
max_body_bytes?, rpc_max_body_bytes?, error_coverage_min?,
|
|
871
|
+
check_uncovered_errors?}`; the last is called with the declared paths left
|
|
872
|
+
uncovered before the floor is asserted, which fuz_app's own wirings hold to an
|
|
873
|
+
exact set. `base_url` is the
|
|
874
|
+
backend's socket, `null` in-process (`default_in_process_suite_options` gives
|
|
875
|
+
`null`, and `max_body_bytes` from `app_options.max_body_size`); the caps
|
|
876
|
+
default to `SPINE_BODY_LIMIT_DEFAULT_BYTES`, the RPC endpoint's to
|
|
877
|
+
`max_body_bytes`.
|
|
878
|
+
|
|
879
|
+
### `middleware_gate_probes.ts` — the integration suite's gate probes
|
|
880
|
+
|
|
881
|
+
`plan_middleware_gate_probes({route_specs, route_error_maps, base_url,
|
|
882
|
+
max_body_bytes?, rpc_path, rpc_max_body_bytes?})` plans one
|
|
883
|
+
`MiddlewareGateProbe` per gate a route's error map declares, so a carved-out
|
|
884
|
+
route or a backend without the layer gets none: a foreign `Origin`
|
|
885
|
+
(`GATE_PROBE_FOREIGN_ORIGIN`) → 403 `forbidden_origin`; a foreign `Host`
|
|
886
|
+
(`GATE_PROBE_FOREIGN_HOST`) → 403 `forbidden_host`; a declared
|
|
887
|
+
`Content-Length` one over the route's cap → 413 `payload_too_large`; and,
|
|
888
|
+
in-process only, an unreadable `Content-Length` → 400 `invalid_content_length`
|
|
889
|
+
(over a socket Node's parser and hyper answer that one themselves with a
|
|
890
|
+
bodiless 400, and `fetch` can't send it). Each probe is a request head with no
|
|
891
|
+
body and no credential, refused before auth, rate limiting and body parsing;
|
|
892
|
+
in-process the probes share one fixture. A route whose path has a param or
|
|
893
|
+
wildcard segment throws rather than be probed at its literal template.
|
|
894
|
+
`send_middleware_gate_probe(probe, base_url, transport)` writes it to the socket
|
|
895
|
+
with `raw_http_send_head` (`fetch` replaces a caller's `Host` and
|
|
896
|
+
`Content-Length`), or in-process through the transport, whose `Request` keeps
|
|
897
|
+
both. `assert_middleware_gate_refusal(probe, response, collector, route_specs)`
|
|
898
|
+
asserts the declared status and code, then `assert_and_record`s it.
|
|
899
|
+
`format_middleware_gate_probe` names a probe's test.
|
|
856
900
|
|
|
857
901
|
### `admin_integration.ts` — `describe_standard_admin_integration_tests`
|
|
858
902
|
|
|
@@ -1208,12 +1252,16 @@ the in-process backend exposes; wire-level audit observability lives in the
|
|
|
1208
1252
|
consumer's own audit `.cross.test.ts`). The omission rationale lives in the
|
|
1209
1253
|
module doc once instead of repeating in each consumer's `*.cross.test.ts`.
|
|
1210
1254
|
|
|
1255
|
+
`base_url` (required — the integration suite's middleware-gate probes write
|
|
1256
|
+
to the socket), `max_body_bytes` and `rpc_max_body_bytes` forward to the
|
|
1257
|
+
integration suite;
|
|
1211
1258
|
`rpc_success_fixtures`, `rpc_skip_methods` and `rpc_input_overrides`
|
|
1212
1259
|
forward to the RPC round-trip's `success_fixtures`, `skip_methods` and
|
|
1213
1260
|
`input_overrides` (`describe_spine_cross_suites` also forwards
|
|
1214
1261
|
`rpc_input_overrides` to `rpc_adversarial`) — `rpc_skip_methods` is the
|
|
1215
1262
|
consumer escape hatch for a method the generic round-trip can't drive in its
|
|
1216
|
-
test wiring.
|
|
1263
|
+
test wiring. `param_values` (`RouteParamValues`) forwards to both the
|
|
1264
|
+
round-trip and data exposure, the two that resolve route paths.
|
|
1217
1265
|
|
|
1218
1266
|
Hard-codes the cross-process-safe set with no `skip` knob; if a future
|
|
1219
1267
|
consumer needs partial opt-out, add the knob then.
|
|
@@ -1272,7 +1320,8 @@ here never reaches it.
|
|
|
1272
1320
|
request-body cap on `rpc_path` and its inbound WS message cap, when they
|
|
1273
1321
|
aren't the spine defaults (`SPINE_BODY_LIMIT_DEFAULT_BYTES`,
|
|
1274
1322
|
`DEFAULT_WS_MAX_MESSAGE_BYTES`). The first reaches `body_size`,
|
|
1275
|
-
`body_size_smuggling
|
|
1323
|
+
`body_size_smuggling`, `transport_composition`'s RPC over-cap row and the
|
|
1324
|
+
standard bundle's middleware-gate probes of the RPC endpoint (each
|
|
1276
1325
|
takes it as `rpc_max_body_bytes`), the second `ws_round_trip`'s
|
|
1277
1326
|
`max_message_bytes` — one value per limit for every suite probing it.
|
|
1278
1327
|
- **`exclude`** — `{[suite]: reason}`; the reason is required and shows in the
|
|
@@ -2163,13 +2212,15 @@ are `src/test/auth/cell_crud_parity.db.test.ts`
|
|
|
2163
2212
|
`raw_http_parse_json` (a body's JSON, `undefined` when it isn't), and
|
|
2164
2213
|
`RAW_HTTP_READ_TIMEOUT_MS`, the suites' default read window.
|
|
2165
2214
|
`raw_http_send_head(base_url, {method?, path, headers, content_length,
|
|
2166
|
-
read_timeout_ms?})` (`RawHttpHeadRequest`) is the over-cap probe
|
|
2167
|
-
them: the request head alone, declaring `content_length` body
|
|
2168
|
-
sending none, read until one whole response — so a server that
|
|
2169
|
-
the declared length answers and one that reads the body first
|
|
2170
|
-
read timeout. It writes `Host`
|
|
2171
|
-
`
|
|
2172
|
-
|
|
2215
|
+
host?, read_timeout_ms?})` (`RawHttpHeadRequest`) is the over-cap probe
|
|
2216
|
+
built on them: the request head alone, declaring `content_length` body
|
|
2217
|
+
bytes and sending none, read until one whole response — so a server that
|
|
2218
|
+
refuses on the declared length answers and one that reads the body first
|
|
2219
|
+
fails on the read timeout. It writes `Host` (`host`, default the base URL's)
|
|
2220
|
+
and `Content-Length` itself (naming either in `headers` throws), defaults
|
|
2221
|
+
nothing else, and throws on a CR or LF in the host or a header name or value,
|
|
2222
|
+
and when no whole response arrives. The middleware-gate probes and the
|
|
2223
|
+
body-size, body-size smuggling, credential-header,
|
|
2173
2224
|
origin-scope and transport-composition suites share this module; they take
|
|
2174
2225
|
the 1 MiB cap they probe from `SPINE_BODY_LIMIT_DEFAULT_BYTES`
|
|
2175
2226
|
(`spine_surface_constants.ts`).
|
|
@@ -2758,8 +2809,9 @@ over real HTTP on both spines:
|
|
|
2758
2809
|
- **per-IP limit fires** — `default_login_ip_rate_limit.max_attempts` (5, the
|
|
2759
2810
|
shared cap on both impls) failed logins from one forwarded IP → 401, the next →
|
|
2760
2811
|
`429` with the canonical `{error: "rate_limit_exceeded", retry_after}` body +
|
|
2761
|
-
`Retry-After: ceil(retry_after)` header (TS
|
|
2762
|
-
|
|
2812
|
+
`Retry-After: ceil(retry_after)` header (TS
|
|
2813
|
+
`route_fail(REST_RATE_LIMIT_EXCEEDED, {retry_after})` ↔ Rust
|
|
2814
|
+
`route_response::rate_limit_exceeded`).
|
|
2763
2815
|
- **XFF keying** — exhaust one forwarded IP to 429, then a _distinct_ forwarded IP
|
|
2764
2816
|
→ 401 (not 429), proving the limiter keys on the resolved `X-Forwarded-For` IP,
|
|
2765
2817
|
not the loopback TCP peer (a backend ignoring XFF would 429 the fresh IP too).
|
|
@@ -869,7 +869,7 @@ export const describe_standard_admin_integration_tests = (options) => {
|
|
|
869
869
|
headers: { host: 'localhost', 'content-type': to_route_content_type(route) }
|
|
870
870
|
});
|
|
871
871
|
if (res.status === 401 || res.status === 403) {
|
|
872
|
-
error_collector.
|
|
872
|
+
await error_collector.assert_and_record(route_specs, route.method, route.path, res);
|
|
873
873
|
}
|
|
874
874
|
}
|
|
875
875
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adversarial_404.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/adversarial_404.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"adversarial_404.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/adversarial_404.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAuB7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAOlE;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,sBAAsB,KAAG,IAkF1E,CAAC"}
|
|
@@ -11,6 +11,7 @@ import './assert_dev_env.js';
|
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
13
13
|
import { test, assert, describe } from 'vitest';
|
|
14
|
+
import { route_fail } from '../http/route_result.js';
|
|
14
15
|
import { format_route_key } from '../http/surface_query.js';
|
|
15
16
|
import { is_null_schema } from '../http/schema_helpers.js';
|
|
16
17
|
import { assert_error_schema_valid } from './assertions.js';
|
|
@@ -51,31 +52,35 @@ export const describe_adversarial_404 = (options) => {
|
|
|
51
52
|
const not_found = spec.errors?.find((def) => def.status === 404);
|
|
52
53
|
if (!not_found)
|
|
53
54
|
continue;
|
|
54
|
-
testable.push({ key,
|
|
55
|
+
testable.push({ key, not_found, spec });
|
|
55
56
|
}
|
|
56
57
|
if (testable.length === 0)
|
|
57
58
|
return;
|
|
58
59
|
describe('adversarial 404 response validation', () => {
|
|
59
60
|
// Create stub specs: replace handlers for testable routes with 404 stubs
|
|
60
|
-
const
|
|
61
|
+
const not_found_by_key = new Map();
|
|
61
62
|
for (const entry of testable) {
|
|
62
|
-
|
|
63
|
+
not_found_by_key.set(entry.key, entry.not_found);
|
|
63
64
|
}
|
|
64
65
|
const stub_specs = route_specs.map((spec) => {
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
66
|
+
const not_found = not_found_by_key.get(format_route_key(spec));
|
|
67
|
+
if (!not_found)
|
|
67
68
|
return spec;
|
|
68
69
|
return {
|
|
69
70
|
...spec,
|
|
70
|
-
|
|
71
|
+
// the code alone, `{error}` at 404: a stub has no fields to give
|
|
72
|
+
handler: () =>
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-generated-empty-object-type
|
|
74
|
+
route_fail(not_found)
|
|
71
75
|
};
|
|
72
76
|
});
|
|
73
77
|
const apps = create_auth_test_apps(stub_specs, roles);
|
|
74
|
-
for (const { key,
|
|
78
|
+
for (const { key, not_found, spec } of testable) {
|
|
79
|
+
const error_code = not_found.code;
|
|
75
80
|
test(key, async () => {
|
|
76
81
|
const route = surface.routes.find((r) => format_route_key(r) === key);
|
|
77
82
|
const app = select_auth_app(apps, route.auth);
|
|
78
|
-
const url = resolve_valid_path(route.path, spec.params);
|
|
83
|
+
const url = resolve_valid_path(route.path, spec.params, options.param_values?.[key]);
|
|
79
84
|
const request_init = {
|
|
80
85
|
method: route.method,
|
|
81
86
|
headers: { 'content-type': to_route_content_type(spec) }
|
|
@@ -75,7 +75,7 @@ export const describe_adversarial_input = (options) => {
|
|
|
75
75
|
continue;
|
|
76
76
|
input_test_count += test_cases.length;
|
|
77
77
|
const app = select_auth_app(apps, route.auth);
|
|
78
|
-
const base_url = resolve_valid_path(route.path, spec.params);
|
|
78
|
+
const base_url = resolve_valid_path(route.path, spec.params, options.param_values?.[key]);
|
|
79
79
|
const is_get = route.method === 'GET';
|
|
80
80
|
describe(key, () => {
|
|
81
81
|
for (const tc of test_cases) {
|
|
@@ -167,7 +167,7 @@ export const describe_adversarial_input = (options) => {
|
|
|
167
167
|
continue;
|
|
168
168
|
query_test_count += test_cases.length;
|
|
169
169
|
const app = select_auth_app(apps, route.auth);
|
|
170
|
-
const base_url = resolve_valid_path(route.path, spec.params);
|
|
170
|
+
const base_url = resolve_valid_path(route.path, spec.params, options.param_values?.[key]);
|
|
171
171
|
describe(key, () => {
|
|
172
172
|
for (const tc of test_cases) {
|
|
173
173
|
test(tc.label, async () => {
|
|
@@ -84,13 +84,23 @@ export declare const assert_error_schema_valid: (lookup: ReadonlyMap<string, Rou
|
|
|
84
84
|
*/
|
|
85
85
|
export declare const assert_error_response_declared: (errors: RouteErrorMap, jsonrpc: boolean, response: Response, label: string) => Promise<void>;
|
|
86
86
|
/**
|
|
87
|
-
* Verify every route under a path prefix has the exact expected middleware
|
|
87
|
+
* Verify every route under a path prefix has the exact expected middleware
|
|
88
|
+
* stack, less the layers that carve it out.
|
|
89
|
+
*
|
|
90
|
+
* A route's expected stack is `expected_middleware` in order, without each
|
|
91
|
+
* name whose surface layers carve the route out: a layer of that name whose
|
|
92
|
+
* `path` applies to the route and one of whose `carve_outs` does too
|
|
93
|
+
* (`middleware_carves_out`), with no other layer of the name running on it
|
|
94
|
+
* (`middleware_spec_applies`) — the rule the surface's `applicable_middleware`
|
|
95
|
+
* and the route error map read. Anything else is held exactly: a route
|
|
96
|
+
* missing a name no carve-out explains fails, and so does a carved-out route
|
|
97
|
+
* still listing the name.
|
|
88
98
|
*
|
|
89
99
|
* @param surface - the app surface to check
|
|
90
100
|
* @param path_prefix - prefix to filter routes (e.g. `'/api/'`)
|
|
91
|
-
* @param expected_middleware - the
|
|
101
|
+
* @param expected_middleware - the full middleware names in order
|
|
92
102
|
* @throws AssertionError if no routes match `path_prefix`, or if any matching
|
|
93
|
-
* route's `applicable_middleware` does not deep-equal
|
|
103
|
+
* route's `applicable_middleware` does not deep-equal its expected stack
|
|
94
104
|
*/
|
|
95
105
|
export declare const assert_full_middleware_stack: (surface: AppSurface, path_prefix: string, expected_middleware: Array<string>) => void;
|
|
96
106
|
//# sourceMappingURL=assertions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/assertions.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAe7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/assertions.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAe7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAgB7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,EAAE,iBAAiB,MAAM,KAAG,MACtB,CAAC;AAE5D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,+BAA+B,GAC3C,SAAS,UAAU,EACnB,eAAe,MAAM,KACnB,IAOF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,GAAI,eAAe,MAAM,UAAU,KAAG,IAE9E,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kCAAkC,GAC9C,SAAS,UAAU,EACnB,iBAAiB,KAAK,CAAC,MAAM,CAAC,KAC5B,IAWF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GAClC,QAAQ,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,OAAO,eAAe,EACtB,QAAQ,MAAM,KACZ,SAAS,GAAG,SAEd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,yBAAyB,GACrC,QAAQ,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,OAAO,eAAe,EACtB,QAAQ,MAAM,EACd,MAAM,OAAO,KACX,IAUF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,8BAA8B,GAC1C,QAAQ,aAAa,EACrB,SAAS,OAAO,EAChB,UAAU,QAAQ,EAClB,OAAO,MAAM,KACX,OAAO,CAAC,IAAI,CAiBd,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,UAAU,EACnB,aAAa,MAAM,EACnB,qBAAqB,KAAK,CAAC,MAAM,CAAC,KAChC,IAsBF,CAAC"}
|
|
@@ -15,6 +15,7 @@ import { format_route_key } from '../http/surface_query.js';
|
|
|
15
15
|
import { is_public_auth } from '../http/auth_shape.js';
|
|
16
16
|
import { parse_any } from '../schema_issues.js';
|
|
17
17
|
import { check_route_error, format_route_error_check, is_error_status, is_json_response } from '../http/route_error_check.js';
|
|
18
|
+
import { middleware_applies, middleware_carves_out, middleware_spec_applies } from '../http/schema_helpers.js';
|
|
18
19
|
/**
|
|
19
20
|
* Resolve an absolute path relative to the caller's module.
|
|
20
21
|
*
|
|
@@ -137,18 +138,34 @@ export const assert_error_response_declared = async (errors, jsonrpc, response,
|
|
|
137
138
|
}
|
|
138
139
|
};
|
|
139
140
|
/**
|
|
140
|
-
* Verify every route under a path prefix has the exact expected middleware
|
|
141
|
+
* Verify every route under a path prefix has the exact expected middleware
|
|
142
|
+
* stack, less the layers that carve it out.
|
|
143
|
+
*
|
|
144
|
+
* A route's expected stack is `expected_middleware` in order, without each
|
|
145
|
+
* name whose surface layers carve the route out: a layer of that name whose
|
|
146
|
+
* `path` applies to the route and one of whose `carve_outs` does too
|
|
147
|
+
* (`middleware_carves_out`), with no other layer of the name running on it
|
|
148
|
+
* (`middleware_spec_applies`) — the rule the surface's `applicable_middleware`
|
|
149
|
+
* and the route error map read. Anything else is held exactly: a route
|
|
150
|
+
* missing a name no carve-out explains fails, and so does a carved-out route
|
|
151
|
+
* still listing the name.
|
|
141
152
|
*
|
|
142
153
|
* @param surface - the app surface to check
|
|
143
154
|
* @param path_prefix - prefix to filter routes (e.g. `'/api/'`)
|
|
144
|
-
* @param expected_middleware - the
|
|
155
|
+
* @param expected_middleware - the full middleware names in order
|
|
145
156
|
* @throws AssertionError if no routes match `path_prefix`, or if any matching
|
|
146
|
-
* route's `applicable_middleware` does not deep-equal
|
|
157
|
+
* route's `applicable_middleware` does not deep-equal its expected stack
|
|
147
158
|
*/
|
|
148
159
|
export const assert_full_middleware_stack = (surface, path_prefix, expected_middleware) => {
|
|
149
160
|
const routes = surface.routes.filter((r) => r.path.startsWith(path_prefix));
|
|
150
161
|
assert.ok(routes.length > 0, `No routes found under ${path_prefix}`);
|
|
162
|
+
const is_carved_out = (name, route_path) => {
|
|
163
|
+
const layers = surface.middleware.filter((m) => m.name === name);
|
|
164
|
+
return (layers.some((m) => middleware_applies(m.path, route_path) && middleware_carves_out(m, route_path)) && !layers.some((m) => middleware_spec_applies(m, route_path)));
|
|
165
|
+
};
|
|
151
166
|
for (const route of routes) {
|
|
152
|
-
|
|
167
|
+
const carved = expected_middleware.filter((name) => is_carved_out(name, route.path));
|
|
168
|
+
const expected = expected_middleware.filter((name) => !carved.includes(name));
|
|
169
|
+
assert.deepStrictEqual(route.applicable_middleware, expected, `${route.method} ${route.path} has wrong middleware stack${carved.length > 0 ? ` (carved out of ${carved.join(', ')})` : ''}`);
|
|
153
170
|
}
|
|
154
171
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
2
|
import { type SurfaceSecurityPolicyOptions } from './surface_invariants.js';
|
|
3
|
+
import { type RouteParamValues } from './schema_generators.js';
|
|
3
4
|
import type { AppSurfaceSpec } from '../http/surface.js';
|
|
4
5
|
/** Options for adversarial test runners (auth enforcement and input validation). */
|
|
5
6
|
export interface AdversarialTestOptions {
|
|
@@ -15,6 +16,12 @@ export interface AdversarialTestOptions {
|
|
|
15
16
|
* merely have a format is handled by the synthesizer.
|
|
16
17
|
*/
|
|
17
18
|
skip_routes?: Array<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Path param values for specific routes (`'METHOD /path'` → param name →
|
|
21
|
+
* value), used before the generated ones — needed for a `{re}` param whose
|
|
22
|
+
* pattern refuses the generated value. See `RouteParamValues`.
|
|
23
|
+
*/
|
|
24
|
+
param_values?: RouteParamValues;
|
|
18
25
|
}
|
|
19
26
|
/**
|
|
20
27
|
* Generate adversarial HTTP auth enforcement test suites.
|
|
@@ -53,6 +60,11 @@ export interface StandardAttackSurfaceOptions {
|
|
|
53
60
|
* handled by the params-schema-aware synthesizer.
|
|
54
61
|
*/
|
|
55
62
|
skip_routes?: Array<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Path param values for the three adversarial sub-suites, by route key and
|
|
65
|
+
* then param name. See `AdversarialTestOptions.param_values`.
|
|
66
|
+
*/
|
|
67
|
+
param_values?: RouteParamValues;
|
|
56
68
|
}
|
|
57
69
|
/**
|
|
58
70
|
* Run the standard attack surface test suite.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attack_surface.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/attack_surface.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAoB7B,OAAO,EAIN,KAAK,4BAA4B,EACjC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"attack_surface.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/attack_surface.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAoB7B,OAAO,EAIN,KAAK,4BAA4B,EACjC,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,wBAAwB,CAAC;AAWhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAgCzD,oFAAoF;AACpF,MAAM,WAAW,sBAAsB;IACtC,+EAA+E;IAC/E,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,sBAAsB,KAAG,IA6K3E,CAAC;AAIF,0DAA0D;AAC1D,MAAM,WAAW,4BAA4B;IAC5C,+EAA+E;IAC/E,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,aAAa,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,sBAAsB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC,iIAAiI;IACjI,uBAAuB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvC,yDAAyD;IACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,eAAe,CAAC,EAAE,4BAA4B,CAAC;IAC/C;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B;;;OAGG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,sCAAsC,GAClD,SAAS,4BAA4B,KACnC,IAqDF,CAAC"}
|
|
@@ -67,7 +67,10 @@ export const describe_adversarial_auth = (options) => {
|
|
|
67
67
|
// validation accepts. Otherwise the generated request 400s on the path
|
|
68
68
|
// before ever reaching the 401 / 403 gate the case is asserting.
|
|
69
69
|
const spec_lookup = build_route_spec_lookup(route_specs);
|
|
70
|
-
const test_path = (route) =>
|
|
70
|
+
const test_path = (route) => {
|
|
71
|
+
const key = format_route_key(route);
|
|
72
|
+
return resolve_valid_path(route.path, spec_lookup.get(key)?.params, options.param_values?.[key]);
|
|
73
|
+
};
|
|
71
74
|
const apps = create_auth_test_apps(route_specs, roles);
|
|
72
75
|
// every probe carries the content type a real client sends, so the
|
|
73
76
|
// per-route content-type check (415) never answers ahead of the auth gate
|
|
@@ -213,7 +216,7 @@ export const describe_adversarial_auth = (options) => {
|
|
|
213
216
|
* any project-specific assertions in additional `describe` blocks.
|
|
214
217
|
*/
|
|
215
218
|
export const describe_standard_attack_surface_tests = (options) => {
|
|
216
|
-
const { build, snapshot_path, expected_public_routes, expected_api_middleware, roles, api_path_prefix = '/api/', security_policy, skip_routes } = options;
|
|
219
|
+
const { build, snapshot_path, expected_public_routes, expected_api_middleware, roles, api_path_prefix = '/api/', security_policy, skip_routes, param_values } = options;
|
|
217
220
|
const built = build();
|
|
218
221
|
const { surface } = built;
|
|
219
222
|
describe('attack surface snapshot', () => {
|
|
@@ -241,7 +244,7 @@ export const describe_standard_attack_surface_tests = (options) => {
|
|
|
241
244
|
assert_surface_security_policy(surface, security_policy);
|
|
242
245
|
});
|
|
243
246
|
});
|
|
244
|
-
describe_adversarial_auth({ build: () => built, roles, skip_routes });
|
|
245
|
-
describe_adversarial_input({ build: () => built, roles, skip_routes });
|
|
246
|
-
describe_adversarial_404({ build: () => built, roles, skip_routes });
|
|
247
|
+
describe_adversarial_auth({ build: () => built, roles, skip_routes, param_values });
|
|
248
|
+
describe_adversarial_input({ build: () => built, roles, skip_routes, param_values });
|
|
249
|
+
describe_adversarial_404({ build: () => built, roles, skip_routes, param_values });
|
|
247
250
|
};
|
|
@@ -115,9 +115,11 @@ export interface DefaultInProcessSuiteOptions {
|
|
|
115
115
|
* Build the full in-process suite bundle in a single helper invocation.
|
|
116
116
|
* Output covers `{setup_test, surface_source, capabilities}` plus every
|
|
117
117
|
* factory input the Tier 1 suites read at their top level
|
|
118
|
-
* (`session_options`, `create_route_specs`, `rpc_endpoints`)
|
|
119
|
-
*
|
|
120
|
-
* (`
|
|
118
|
+
* (`session_options`, `create_route_specs`, `rpc_endpoints`), and the
|
|
119
|
+
* integration suite's `base_url` (`null`, no socket) and `max_body_bytes`
|
|
120
|
+
* (`app_options.max_body_size`) — so the call site spreads once and adds
|
|
121
|
+
* only suite-specific extras (`roles`, `skip_routes`, `input_overrides`,
|
|
122
|
+
* `db_factories`, ...).
|
|
121
123
|
*
|
|
122
124
|
* ```ts
|
|
123
125
|
* // Suite-extras-free call: helper output is the entire options bag.
|
|
@@ -149,5 +151,7 @@ export declare const default_in_process_suite_options: <const O extends DefaultI
|
|
|
149
151
|
session_options: O["session_options"];
|
|
150
152
|
create_route_specs: O["create_route_specs"];
|
|
151
153
|
rpc_endpoints: O["rpc_endpoints"];
|
|
154
|
+
base_url: null;
|
|
155
|
+
max_body_bytes: number | undefined;
|
|
152
156
|
};
|
|
153
157
|
//# sourceMappingURL=in_process_setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in_process_setup.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/in_process_setup.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqB9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,eAAe,EAEpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAGN,KAAK,uBAAuB,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA2B,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEtF,OAAO,EAGN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,MAAM,YAAY,CAAC;AAepB;;;;;GAKG;AACH,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IAClE;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1D;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,kCAAkC,CAAC,EAAE,OAAO,CAAC;CACtD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,qBAAqB,KAAG,SAuEjC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,WAAW,4BAA4B;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACjD;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C;;;;;OAKG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAWD
|
|
1
|
+
{"version":3,"file":"in_process_setup.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/in_process_setup.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqB9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,eAAe,EAEpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAGN,KAAK,uBAAuB,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA2B,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEtF,OAAO,EAGN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,MAAM,YAAY,CAAC;AAepB;;;;;GAKG;AACH,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IAClE;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1D;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,kCAAkC,CAAC,EAAE,OAAO,CAAC;CACtD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,qBAAqB,KAAG,SAuEjC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,WAAW,4BAA4B;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACjD;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C;;;;;OAKG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,gCAAgC,GAAI,KAAK,CAAC,CAAC,SAAS,4BAA4B,EAC5F,SAAS,CAAC,KACR;IACF,UAAU,EAAE,SAAS,CAAC;IACtB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,mBAAmB,CAAC;IAClC,eAAe,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACtC,kBAAkB,EAAE,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC5C,aAAa,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC;IAClC,QAAQ,EAAE,IAAI,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CAoClC,CAAC"}
|
|
@@ -113,9 +113,11 @@ export const default_in_process_setup = (options) => async () => {
|
|
|
113
113
|
* Build the full in-process suite bundle in a single helper invocation.
|
|
114
114
|
* Output covers `{setup_test, surface_source, capabilities}` plus every
|
|
115
115
|
* factory input the Tier 1 suites read at their top level
|
|
116
|
-
* (`session_options`, `create_route_specs`, `rpc_endpoints`)
|
|
117
|
-
*
|
|
118
|
-
* (`
|
|
116
|
+
* (`session_options`, `create_route_specs`, `rpc_endpoints`), and the
|
|
117
|
+
* integration suite's `base_url` (`null`, no socket) and `max_body_bytes`
|
|
118
|
+
* (`app_options.max_body_size`) — so the call site spreads once and adds
|
|
119
|
+
* only suite-specific extras (`roles`, `skip_routes`, `input_overrides`,
|
|
120
|
+
* `db_factories`, ...).
|
|
119
121
|
*
|
|
120
122
|
* ```ts
|
|
121
123
|
* // Suite-extras-free call: helper output is the entire options bag.
|
|
@@ -162,11 +164,16 @@ export const default_in_process_suite_options = (options) => ({
|
|
|
162
164
|
// and live app stay in sync by construction.
|
|
163
165
|
bootstrap: options.bootstrap,
|
|
164
166
|
surface_route: options.app_options?.surface_route,
|
|
167
|
+
max_body_size: options.app_options?.max_body_size,
|
|
168
|
+
origin_carve_outs: options.app_options?.origin_carve_outs,
|
|
165
169
|
// `create_test_app` always passes a `daemon_token_state`
|
|
166
170
|
daemon_token: true
|
|
167
171
|
}),
|
|
168
172
|
capabilities: in_process_capabilities,
|
|
169
173
|
session_options: options.session_options,
|
|
170
174
|
create_route_specs: options.create_route_specs,
|
|
171
|
-
rpc_endpoints: options.rpc_endpoints
|
|
175
|
+
rpc_endpoints: options.rpc_endpoints,
|
|
176
|
+
// in-process: no socket, and the limit `create_app_server` mounts
|
|
177
|
+
base_url: null,
|
|
178
|
+
max_body_bytes: options.app_options?.max_body_size ?? undefined
|
|
172
179
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login_security.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/login_security.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"login_security.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/login_security.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAuF9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAO5C,mDAAmD;AACnD,MAAM,WAAW,6BAA6B;IAC7C,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAmDD,eAAO,MAAM,mCAAmC,GAC/C,SAAS,6BAA6B,KACpC,IA4VF,CAAC"}
|
|
@@ -16,8 +16,9 @@ import '../assert_dev_env.js';
|
|
|
16
16
|
* failed logins from one forwarded IP each return `401`, and the next
|
|
17
17
|
* returns `429` with the canonical `{error: "rate_limit_exceeded",
|
|
18
18
|
* retry_after}` body **and** a `Retry-After: ceil(retry_after)` header. The
|
|
19
|
-
* 429 wire shape is the cross-impl contract — TS
|
|
20
|
-
*
|
|
19
|
+
* 429 wire shape is the cross-impl contract — TS
|
|
20
|
+
* `route_fail(REST_RATE_LIMIT_EXCEEDED, {retry_after})` and Rust
|
|
21
|
+
* `route_response::rate_limit_exceeded` must agree.
|
|
21
22
|
* - **trusted-proxy / XFF resolution is honored** — distinct
|
|
22
23
|
* `X-Forwarded-For` IPs get independent buckets: after exhausting one
|
|
23
24
|
* forwarded IP to `429`, a *different* forwarded IP is unaffected (`401`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rust_spine_consumer_surface.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/rust_spine_consumer_surface.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAA6B,MAAM,8BAA8B,CAAC;AAM/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAOnE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAI3E;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,wDAAyD,CAAC;
|
|
1
|
+
{"version":3,"file":"rust_spine_consumer_surface.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/rust_spine_consumer_surface.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAA6B,MAAM,8BAA8B,CAAC;AAM/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAOnE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAI3E;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,wDAAyD,CAAC;AAK3F,8DAA8D;AAC9D,MAAM,WAAW,oCAAoC;IACpD;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAC7D;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IACzE,yFAAyF;IACzF,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACjD,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,6DAA6D;AAC7D,MAAM,WAAW,mCAAoC,SAAQ,oCAAoC;IAChG,gEAAgE;IAChE,QAAQ,CAAC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACjD;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wCAAwC,GACpD,SAAS,oCAAoC,KAC3C,CAAC,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,eAAe,CAAC,CA+BpD,CAAC;AAiCF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uCAAuC,GACnD,SAAS,mCAAmC,KAC1C,cAoBA,CAAC"}
|