mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
* feat(web): report value-free header names in the api-surface view The api-surface view could only say that a group had query names. Analysts asking which endpoints are signed or session-bearing had to page complete capture records and compare header values by eye, which copies the values into the agent's context. Add an opt-in include_request_header_names facet that lists the request header, cookie and set-cookie names recorded for each group, with the records that presented them. Values are never read: the reader walks only name members, tolerates malformed members without dropping the rest, and reserves its scratch before collecting anything. Omitting the option leaves group output byte-identical, and the existing sensitive-parent refusal still applies. * style(web): format the route template view The branch's own change to `webNetworkRouteTemplates.ts` did not match oxfmt, which is what failed `Static checks` on this PR independently of the main-side formatting break. Merged current main and formatted the file. * fix(analysis): reserve header name lists before copying them readRecordedHeaderNames derived the request, cookie and set-cookie names with Array.map before the temporary-byte reservation, so a capture whose arrays exceed the projection allowance still allocated three input-sized arrays. Charge each array's names from the borrowed members first, then materialize the lists only once the reservation succeeds. Keep a recorded empty name: the pinned HAR schema accepts any string name, so dropping it made a recorded empty spelling indistinguishable from an omitted member. Report a member whose name is not a string as an explicit unknown instead. * fix(analysis): report a malformed header collection as an unreadable member When a recorded request.headers, request.cookies or response.cookies member is present but not an array, memberNames collapsed it to an empty list and only the per-member scan could flag the record. A record whose collections are all malformed therefore produced a complete-looking empty name list with no unknown, while only an omitted collection is observed absence. Track a non-array collection as unreadable so the name list is reported incomplete. * test(web): compare unreadable header-name unknowns with their owner Three regressions repeated the accumulator's unknown sentence, so a wording change would fail them while the reported facts stay correct. Export the sentence from the accumulator and assert against it. Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> --------- Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com> Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
79 lines
2.4 KiB
TypeScript
79 lines
2.4 KiB
TypeScript
import { z } from "zod";
|
|
import { ROUTE_RULES } from "./webNetworkRouteTemplates.js";
|
|
|
|
export const apiSurfaceViewSchema = z.strictObject({
|
|
kind: z.literal("api-surface"),
|
|
offset: z.int().nonnegative().default(0),
|
|
limit: z.int().positive().default(50),
|
|
include_query_parameter_names: z
|
|
.boolean()
|
|
.optional()
|
|
.describe(
|
|
"Include distinct observed query parameter names and their original record ordinals; names do not establish required parameters or a complete API schema.",
|
|
),
|
|
include_request_header_names: z
|
|
.boolean()
|
|
.optional()
|
|
.describe(
|
|
"Include the request, cookie and set-cookie header names recorded for each group, with the records that presented them. No header, cookie or set-cookie value is copied, and no name establishes authentication, session semantics or a complete header schema.",
|
|
),
|
|
});
|
|
const ruleSchema = z.enum(ROUTE_RULES);
|
|
const nameOrdinalsSchema = z.array(
|
|
z.strictObject({
|
|
name: z.string(),
|
|
record_ordinals: z.array(z.int().nonnegative()),
|
|
}),
|
|
);
|
|
const requestHeaderNamesSchema = z.strictObject({
|
|
request_headers: nameOrdinalsSchema,
|
|
cookie_names: nameOrdinalsSchema,
|
|
set_cookie_names: nameOrdinalsSchema,
|
|
});
|
|
const groupSchema = z.strictObject({
|
|
method: z.string(),
|
|
origin: z.string(),
|
|
path_template: z.string(),
|
|
templated_segments: z.array(
|
|
z.strictObject({
|
|
segment_index: z.int().nonnegative(),
|
|
rule: ruleSchema,
|
|
basis: z.literal("inferred"),
|
|
observed_values: z.array(z.string()),
|
|
}),
|
|
),
|
|
record_ordinals: z.array(z.int().nonnegative()),
|
|
statuses: z.array(z.number()),
|
|
content_types: z.array(z.string()),
|
|
query_parameter_names: nameOrdinalsSchema.optional(),
|
|
request_header_names: requestHeaderNamesSchema.optional(),
|
|
flags: z.array(
|
|
z.enum(["single-sample", "mixed-statuses", "mixed-content-types"]),
|
|
),
|
|
});
|
|
export const apiSurfaceFields = {
|
|
records: z.strictObject({
|
|
examined: z.int().nonnegative(),
|
|
total: z.int().nonnegative(),
|
|
excluded: z.int().nonnegative(),
|
|
}),
|
|
templated_groups: z
|
|
.int()
|
|
.nonnegative()
|
|
.describe(
|
|
"Groups across every page that carry at least one templated segment.",
|
|
),
|
|
groups: z.array(groupSchema),
|
|
excluded_records: z.array(
|
|
z.strictObject({
|
|
ordinal: z.int().nonnegative(),
|
|
reason: z.enum([
|
|
"url-redacted",
|
|
"url-unparseable",
|
|
"request-unavailable",
|
|
"method-unavailable",
|
|
]),
|
|
}),
|
|
),
|
|
};
|