refactor(tools): remove artificial analysis ceilings
This commit is contained in:
@@ -42,7 +42,23 @@ describe("analysis profile commitments", () => {
|
||||
).toBe(3);
|
||||
});
|
||||
|
||||
it("rejects digest tampering and unbounded parameters", () => {
|
||||
it("commits parameter objects larger than the former byte ceiling", () => {
|
||||
const parameters = Object.fromEntries(
|
||||
Array.from({ length: 5 }, (_, index) => [
|
||||
`parameter-${String(index)}`,
|
||||
"x".repeat(16 * 1024),
|
||||
]),
|
||||
);
|
||||
expect(Buffer.byteLength(JSON.stringify(parameters))).toBeGreaterThan(
|
||||
64 * 1024,
|
||||
);
|
||||
|
||||
const profile = createAnalysisProfile(PROVIDER, parameters);
|
||||
|
||||
expect(analysisProfileSchema.parse(profile)).toEqual(profile);
|
||||
});
|
||||
|
||||
it("rejects digest tampering and structurally unsafe parameters", () => {
|
||||
const profile = createAnalysisProfile(PROVIDER, { loader: "default" });
|
||||
expect(() =>
|
||||
analysisProfileSchema.parse({ ...profile, digest: "0".repeat(64) }),
|
||||
@@ -51,6 +67,6 @@ describe("analysis profile commitments", () => {
|
||||
createAnalysisProfile(PROVIDER, {
|
||||
oversized: "x".repeat(65 * 1024),
|
||||
}),
|
||||
).toThrow(/limit/u);
|
||||
).toThrow(/structural limits/u);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,6 @@ import { z } from "zod";
|
||||
import { isJsonWithinLimits } from "./jsonLimits.js";
|
||||
import { jsonObjectSchema, type JsonValue } from "./jsonValue.js";
|
||||
|
||||
const PROFILE_MAX_BYTES = 64 * 1024;
|
||||
const PROFILE_JSON_LIMITS = Object.freeze({
|
||||
maxDepth: 16,
|
||||
maxStringLength: 16 * 1024,
|
||||
@@ -21,23 +20,9 @@ export const committedProviderSchema = z.object({
|
||||
version: z.string().min(1),
|
||||
});
|
||||
|
||||
const boundedParametersSchema = jsonObjectSchema.superRefine(
|
||||
(parameters, context) => {
|
||||
if (!isJsonWithinLimits(parameters, PROFILE_JSON_LIMITS)) {
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
message: "Analysis profile parameters exceed structural limits",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (
|
||||
Buffer.byteLength(canonicalJson(parameters), "utf8") > PROFILE_MAX_BYTES
|
||||
)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
message: "Analysis profile parameters exceed the byte limit",
|
||||
});
|
||||
},
|
||||
const boundedParametersSchema = jsonObjectSchema.refine(
|
||||
(parameters) => isJsonWithinLimits(parameters, PROFILE_JSON_LIMITS),
|
||||
{ message: "Analysis profile parameters exceed structural limits" },
|
||||
);
|
||||
|
||||
const unsignedAnalysisProfileSchema = z.object({
|
||||
|
||||
@@ -8,13 +8,13 @@ import { evidenceSchema } from "./evidence.js";
|
||||
|
||||
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const boundedPathSchema = z.string().min(1).max(4_096);
|
||||
const pathSchema = z.string().min(1);
|
||||
|
||||
const componentSchema = z.strictObject({
|
||||
path: boundedPathSchema,
|
||||
path: pathSchema,
|
||||
artifact_id: z.string().regex(/^art_[a-f0-9]{64}$/u),
|
||||
sha256: digestSchema,
|
||||
format: z.string().min(1).max(100),
|
||||
format: z.string().min(1),
|
||||
});
|
||||
|
||||
/** Authenticated artifact inventory pages projected as one Apple application. */
|
||||
@@ -28,7 +28,7 @@ export const appleApplicationProjectionResultSchema = z.strictObject({
|
||||
root_sha256: digestSchema,
|
||||
root_format: z.literal("ipa"),
|
||||
source_evidence_ids: z.array(evidenceIdSchema).min(1),
|
||||
application_roots: z.array(boundedPathSchema),
|
||||
application_roots: z.array(pathSchema),
|
||||
components: z.strictObject({
|
||||
bundle_metadata: z.array(componentSchema),
|
||||
executables: z.array(componentSchema),
|
||||
@@ -49,8 +49,8 @@ export const appleApplicationProjectionResultSchema = z.strictObject({
|
||||
),
|
||||
bridge_candidates: z.array(
|
||||
z.strictObject({
|
||||
source_path: boundedPathSchema,
|
||||
native_path: boundedPathSchema,
|
||||
source_path: pathSchema,
|
||||
native_path: pathSchema,
|
||||
basis: z.enum([
|
||||
"javascript-and-native-content",
|
||||
"react-native-convention",
|
||||
@@ -63,7 +63,7 @@ export const appleApplicationProjectionResultSchema = z.strictObject({
|
||||
status: z.enum(["complete-within-inventory", "partial"]),
|
||||
inventory_complete: z.boolean(),
|
||||
}),
|
||||
limitations: z.array(z.string().min(1).max(4_096)),
|
||||
limitations: z.array(z.string().min(1)),
|
||||
});
|
||||
|
||||
export type AppleApplicationProjectionInput = z.infer<
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
type ArtifactNode,
|
||||
type ArtifactOccurrence,
|
||||
} from "./artifactGraph.js";
|
||||
import { evidenceSchema } from "./evidence.js";
|
||||
import {
|
||||
parseArtifactInventoryEvidence,
|
||||
type InventorySet,
|
||||
@@ -39,18 +40,17 @@ const comparisonDimensionSchema = z.enum([
|
||||
"availability",
|
||||
"integrity",
|
||||
]);
|
||||
|
||||
/** Strict Evidence-backed input for deterministic artifact comparison. */
|
||||
export const artifactComparisonInputSchema = z.strictObject({
|
||||
left_evidence_id: evidenceIdSchema,
|
||||
right_evidence_id: evidenceIdSchema,
|
||||
left: evidenceSchema,
|
||||
right: evidenceSchema,
|
||||
});
|
||||
|
||||
/** One path-classified artifact change with citations to both observations. */
|
||||
const artifactChangeSchema = z.object({
|
||||
classification: changeKindSchema,
|
||||
logical_path: z.string().min(1).max(4_096),
|
||||
dimensions: z.array(comparisonDimensionSchema).min(1).max(8),
|
||||
logical_path: z.string().min(1),
|
||||
dimensions: z.array(comparisonDimensionSchema).min(1),
|
||||
left_occurrence_id: z
|
||||
.string()
|
||||
.regex(/^occ_[a-f0-9]{64}$/u)
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { artifactInventoryResultSchema } from "./artifactGraph.js";
|
||||
|
||||
describe("artifact graph path and provenance fields", () => {
|
||||
it("preserves long archive paths and command arguments inline", () => {
|
||||
const path = `${"deep/".repeat(1_000)}resource.bin`;
|
||||
const arguments_ = Array.from({ length: 1_025 }, (_, index) =>
|
||||
index === 0 ? `/${"long/".repeat(1_000)}archive.ipa` : `arg-${index}`,
|
||||
);
|
||||
const artifactId = `art_${"a".repeat(64)}`;
|
||||
const parsed = artifactInventoryResultSchema.parse({
|
||||
manifest: {
|
||||
manifest_id: `agm_${"b".repeat(64)}`,
|
||||
root_artifact_id: artifactId,
|
||||
root_sha256: "c".repeat(64),
|
||||
root_format: "directory",
|
||||
graph_sha256: "d".repeat(64),
|
||||
node_count: 1,
|
||||
occurrence_count: 1,
|
||||
edge_count: 0,
|
||||
},
|
||||
nodes: [
|
||||
{
|
||||
artifact_id: artifactId,
|
||||
kind: "container",
|
||||
format: "directory",
|
||||
sha256: "c".repeat(64),
|
||||
size: 0,
|
||||
media_type: null,
|
||||
architecture: null,
|
||||
executable: false,
|
||||
content_state: "materialized",
|
||||
limitations: [],
|
||||
},
|
||||
],
|
||||
occurrences: [
|
||||
{
|
||||
occurrence_id: `occ_${"e".repeat(64)}`,
|
||||
artifact_id: artifactId,
|
||||
parent_occurrence_id: null,
|
||||
logical_path: path,
|
||||
entry_kind: "file",
|
||||
declared_size: 0,
|
||||
compressed_size: 0,
|
||||
executable: false,
|
||||
encrypted: false,
|
||||
hash_status: "verified",
|
||||
source_location: null,
|
||||
limitations: [],
|
||||
},
|
||||
],
|
||||
edges: [],
|
||||
provenance: [
|
||||
{
|
||||
tool: "archive-reader",
|
||||
arguments: arguments_,
|
||||
tool_version: null,
|
||||
executable_sha256: null,
|
||||
exit_code: 0,
|
||||
effects: ["read"],
|
||||
},
|
||||
],
|
||||
integrity_contradictions: [],
|
||||
limitations: [],
|
||||
});
|
||||
|
||||
expect(parsed.occurrences[0]?.logical_path).toBe(path);
|
||||
expect(parsed.provenance[0]?.arguments).toHaveLength(1_025);
|
||||
expect(parsed.provenance[0]?.arguments[0]).toBe(arguments_[0]);
|
||||
});
|
||||
});
|
||||
@@ -66,17 +66,17 @@ const artifactByteRangeSchema = z.object({
|
||||
length: z.number().int().min(0),
|
||||
});
|
||||
|
||||
/** Bounded external command provenance, including observable side effects. */
|
||||
/** External command provenance, including observable side effects. */
|
||||
const artifactCommandSchema = z.object({
|
||||
tool: z.string().min(1),
|
||||
arguments: z.array(z.string().max(4_096)).max(1_024),
|
||||
arguments: z.array(z.string()),
|
||||
tool_version: z.string().nullable(),
|
||||
executable_sha256: sha256Schema.nullable(),
|
||||
exit_code: z.number().int().nullable(),
|
||||
effects: z.array(z.enum(["read", "write", "mount"])).max(3),
|
||||
effects: z.array(z.enum(["read", "write", "mount"])),
|
||||
});
|
||||
|
||||
/** Parsed bounded artifact-producing command provenance. */
|
||||
/** Parsed artifact-producing command provenance. */
|
||||
export type ArtifactCommand = z.infer<typeof artifactCommandSchema>;
|
||||
|
||||
/** One content-addressed application artifact in deterministic manifest order. */
|
||||
|
||||
@@ -10,14 +10,14 @@ import {
|
||||
import { evidenceSchema, parseEvidence, type Evidence } from "./evidence.js";
|
||||
import { jsonValueSchema } from "./jsonValue.js";
|
||||
|
||||
const boundedTextSchema = z.string().min(1).max(4_096);
|
||||
const textSchema = z.string().min(1);
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const artifactIdSchema = z.string().regex(/^art_[a-f0-9]{64}$/u);
|
||||
|
||||
const inspectionObservationSchema = z.strictObject({
|
||||
observation_id: z.string().regex(/^aio_[a-f0-9]{64}$/u),
|
||||
kind: z.enum(["root-manifest", "artifact", "occurrence", "integrity"]),
|
||||
subject: boundedTextSchema,
|
||||
subject: textSchema,
|
||||
value: jsonValueSchema,
|
||||
evidence_id: evidenceIdSchema,
|
||||
});
|
||||
@@ -36,21 +36,21 @@ const inspectionRelationshipSchema = z.strictObject({
|
||||
source_artifact_id: artifactIdSchema,
|
||||
target_artifact_id: artifactIdSchema,
|
||||
occurrence_id: z.string().regex(/^occ_[a-f0-9]{64}$/u),
|
||||
logical_path: boundedTextSchema.nullable(),
|
||||
logical_path: textSchema.nullable(),
|
||||
evidence_id: evidenceIdSchema,
|
||||
});
|
||||
|
||||
const inspectionHypothesisSchema = z.strictObject({
|
||||
hypothesis_id: z.string().regex(/^aih_[a-f0-9]{64}$/u),
|
||||
statement: boundedTextSchema,
|
||||
statement: textSchema,
|
||||
confidence: z.enum(["medium", "low"]),
|
||||
basis_evidence_ids: z.array(evidenceIdSchema).min(1).max(8),
|
||||
limitation: boundedTextSchema,
|
||||
basis_evidence_ids: z.array(evidenceIdSchema).min(1),
|
||||
limitation: textSchema,
|
||||
});
|
||||
|
||||
const inspectionContradictionSchema = z.strictObject({
|
||||
contradiction_id: z.string().regex(/^aic_[a-f0-9]{64}$/u),
|
||||
statement: boundedTextSchema,
|
||||
statement: textSchema,
|
||||
occurrence_id: z.string().regex(/^occ_[a-f0-9]{64}$/u),
|
||||
declared_sha256: z.string().regex(/^[a-f0-9]{64}$/u),
|
||||
observed_sha256: z.string().regex(/^[a-f0-9]{64}$/u),
|
||||
@@ -58,8 +58,8 @@ const inspectionContradictionSchema = z.strictObject({
|
||||
});
|
||||
|
||||
const nextProbeSchema = z.strictObject({
|
||||
operation: z.string().min(1).max(128),
|
||||
rationale: boundedTextSchema,
|
||||
operation: textSchema,
|
||||
rationale: textSchema,
|
||||
authority: z.enum([
|
||||
"artifact-bytes",
|
||||
"managed-static-analysis",
|
||||
@@ -71,7 +71,7 @@ const nextProbeSchema = z.strictObject({
|
||||
const unexploredBranchSchema = z.strictObject({
|
||||
branch_id: z.string().regex(/^aib_[a-f0-9]{64}$/u),
|
||||
reason: z.enum(["format-specific-analysis-required", "unknown-format"]),
|
||||
detail: boundedTextSchema,
|
||||
detail: textSchema,
|
||||
next_probe: nextProbeSchema.nullable(),
|
||||
evidence_id: evidenceIdSchema,
|
||||
});
|
||||
@@ -83,7 +83,7 @@ export const artifactInspectionResultSchema = z.strictObject({
|
||||
manifest_id: z.string().regex(/^agm_[a-f0-9]{64}$/u),
|
||||
root_artifact_id: artifactIdSchema,
|
||||
root_sha256: z.string().regex(/^[a-f0-9]{64}$/u),
|
||||
root_format: z.string().min(1).max(128),
|
||||
root_format: textSchema,
|
||||
}),
|
||||
substeps: z
|
||||
.array(
|
||||
@@ -117,7 +117,7 @@ export const artifactInspectionResultSchema = z.strictObject({
|
||||
next_probes_omitted: z.number().int().min(0),
|
||||
}),
|
||||
evidence_links: z.array(evidenceIdSchema).min(1),
|
||||
limitations: z.array(boundedTextSchema),
|
||||
limitations: z.array(textSchema),
|
||||
});
|
||||
|
||||
export type ArtifactInspectionResult = z.infer<
|
||||
|
||||
@@ -5,6 +5,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
compareBrowserScenarios,
|
||||
compareBrowserScenariosInputSchema,
|
||||
browserScenarioDiffSchema,
|
||||
} from "./browserScenarioDiff.js";
|
||||
import {
|
||||
browserScenarioCaptureSchema,
|
||||
@@ -113,6 +114,71 @@ describe("browser scenario comparison", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("browser scenario comparison text values", () => {
|
||||
it("accepts long normalization values and comparison diagnostics", () => {
|
||||
const longText = "x".repeat(5_000);
|
||||
const ruleId = "r".repeat(100);
|
||||
const capture = scenarioCapture({});
|
||||
const compared = compareBrowserScenarios(
|
||||
compareBrowserScenariosInputSchema.parse({
|
||||
before_scenario: capture,
|
||||
after_scenario: capture,
|
||||
normalization: {
|
||||
rules: [
|
||||
{
|
||||
rule_id: ruleId,
|
||||
artifacts: ["dom"],
|
||||
match: longText,
|
||||
replacement: longText,
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
);
|
||||
const stepId = "s".repeat(100);
|
||||
const diagnostic = browserScenarioDiffSchema.parse({
|
||||
...compared,
|
||||
alignment: {
|
||||
...compared.alignment,
|
||||
before_only: [stepId],
|
||||
after_only: [stepId],
|
||||
failures: [
|
||||
{
|
||||
code: "missing_before_step",
|
||||
step_id: stepId,
|
||||
reason: longText,
|
||||
},
|
||||
],
|
||||
},
|
||||
steps: compared.steps.map((step) => ({
|
||||
...step,
|
||||
step_id: stepId,
|
||||
artifact_diffs: [
|
||||
{
|
||||
artifact: "dom",
|
||||
status: "unknown",
|
||||
before_state: "missing",
|
||||
after_state: "missing",
|
||||
before_sha256: null,
|
||||
after_sha256: null,
|
||||
reason: longText,
|
||||
},
|
||||
],
|
||||
})),
|
||||
limitations: [longText],
|
||||
});
|
||||
|
||||
expect(diagnostic.normalization.rules[0]).toMatchObject({
|
||||
rule_id: ruleId,
|
||||
match: longText,
|
||||
replacement: longText,
|
||||
});
|
||||
expect(diagnostic.alignment.failures[0]?.reason).toBe(longText);
|
||||
expect(diagnostic.steps[0]?.artifact_diffs[0]?.reason).toBe(longText);
|
||||
expect(diagnostic.limitations).toEqual([longText]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("browser scenario comparison validation", () => {
|
||||
it("does not accept caller limits that would omit difference records", () => {
|
||||
const capture = scenarioCapture({});
|
||||
|
||||
@@ -33,7 +33,6 @@ const normalizationRuleSchema = z.strictObject({
|
||||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.max(64)
|
||||
.describe("Stable rule identity; rules execute in rule_id order."),
|
||||
artifacts: z
|
||||
.array(normalizableArtifactKindSchema)
|
||||
@@ -43,13 +42,11 @@ const normalizationRuleSchema = z.strictObject({
|
||||
match: z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(4_096)
|
||||
.describe(
|
||||
"Exact public literal to replace; regular expressions are not used.",
|
||||
),
|
||||
replacement: z
|
||||
.string()
|
||||
.max(4_096)
|
||||
.describe("Recorded replacement text used in normalized comparison."),
|
||||
});
|
||||
|
||||
@@ -113,7 +110,7 @@ const artifactDiffSchema = z.strictObject({
|
||||
.string()
|
||||
.regex(/^[a-f0-9]{64}$/u)
|
||||
.nullable(),
|
||||
reason: z.string().min(1).max(2_048).nullable(),
|
||||
reason: z.string().min(1).nullable(),
|
||||
});
|
||||
const alignmentFailureSchema = z.strictObject({
|
||||
code: z.enum([
|
||||
@@ -124,8 +121,8 @@ const alignmentFailureSchema = z.strictObject({
|
||||
"action_mismatch",
|
||||
"capture_context_mismatch",
|
||||
]),
|
||||
step_id: z.string().min(1).max(64).nullable(),
|
||||
reason: z.string().min(1).max(2_048),
|
||||
step_id: z.string().min(1).nullable(),
|
||||
reason: z.string().min(1),
|
||||
});
|
||||
const builtInNormalizationSchema = z.enum([
|
||||
"ignore_step_elapsed_ms",
|
||||
@@ -147,17 +144,17 @@ export const browserScenarioDiffSchema = z.strictObject({
|
||||
alignment: z.strictObject({
|
||||
status: z.enum(["aligned", "partial", "failed"]),
|
||||
aligned_steps: z.number().int().min(0),
|
||||
before_only: z.array(z.string().min(1).max(64)),
|
||||
after_only: z.array(z.string().min(1).max(64)),
|
||||
before_only: z.array(z.string().min(1)),
|
||||
after_only: z.array(z.string().min(1)),
|
||||
failures: z.array(alignmentFailureSchema),
|
||||
}),
|
||||
steps: z.array(
|
||||
z.strictObject({
|
||||
step_id: z.string().min(1).max(64),
|
||||
step_id: z.string().min(1),
|
||||
before_step_index: z.number().int().min(0),
|
||||
after_step_index: z.number().int().min(0),
|
||||
before_action: z.string().min(1).max(64),
|
||||
after_action: z.string().min(1).max(64),
|
||||
before_action: z.string().min(1),
|
||||
after_action: z.string().min(1),
|
||||
status: z.enum(["changed", "unchanged", "unknown"]),
|
||||
artifact_diffs: z.array(artifactDiffSchema),
|
||||
}),
|
||||
@@ -165,7 +162,7 @@ export const browserScenarioDiffSchema = z.strictObject({
|
||||
artifact_diffs: z.strictObject({
|
||||
total: z.number().int().min(0),
|
||||
}),
|
||||
limitations: z.array(z.string().min(1).max(2_048)),
|
||||
limitations: z.array(z.string().min(1)),
|
||||
});
|
||||
/** Browser scenario comparison result. */
|
||||
export type BrowserScenarioDiff = z.infer<typeof browserScenarioDiffSchema>;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
bundleComparisonInputSchema,
|
||||
bundleComparisonResultSchema,
|
||||
compareBundles,
|
||||
} from "./bundleComparison.js";
|
||||
@@ -24,6 +25,16 @@ const evidence = (label: string) =>
|
||||
});
|
||||
|
||||
describe("bundle comparison", () => {
|
||||
it("accepts long caller-selected bundle paths", () => {
|
||||
const path = `/${"deep/".repeat(1_000)}bundle.json`;
|
||||
expect(
|
||||
bundleComparisonInputSchema.parse({
|
||||
left_bundle_path: path,
|
||||
right_bundle_path: path,
|
||||
}),
|
||||
).toMatchObject({ left_bundle_path: path, right_bundle_path: path });
|
||||
});
|
||||
|
||||
it("returns unchanged only for equal canonical bundles", () => {
|
||||
const first = evidence("first");
|
||||
const second = evidence("second");
|
||||
|
||||
@@ -22,8 +22,8 @@ const classificationSchema = z.enum([
|
||||
|
||||
/** Strict input for canonical Evidence bundle comparison. */
|
||||
export const bundleComparisonInputSchema = z.strictObject({
|
||||
left_bundle_path: z.string().min(1).max(4_096),
|
||||
right_bundle_path: z.string().min(1).max(4_096),
|
||||
left_bundle_path: z.string().min(1),
|
||||
right_bundle_path: z.string().min(1),
|
||||
record_pairs: z
|
||||
.array(
|
||||
z.object({
|
||||
|
||||
@@ -84,6 +84,17 @@ describe("custom protocol capture", () => {
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts every captured frame without an array ceiling", () => {
|
||||
const frames = Array.from({ length: 100_001 }, (_, sequence) => ({
|
||||
...sampleFrames[0]!,
|
||||
sequence,
|
||||
}));
|
||||
|
||||
expect(
|
||||
customProtocolCaptureSchema.parse({ transport: "tcp", frames }).frames,
|
||||
).toHaveLength(frames.length);
|
||||
});
|
||||
|
||||
it("correlates process identity", () => {
|
||||
expect(correlateProcessIdentity(sampleFrames[0]!, 100)).toBe(true);
|
||||
expect(correlateProcessIdentity(sampleFrames[0]!, 200)).toBe(true);
|
||||
|
||||
@@ -96,7 +96,7 @@ export const customProtocolCaptureSchema = z.strictObject({
|
||||
/** Transport type for this session. */
|
||||
transport: transportTypeSchema,
|
||||
/** Captured frames in order. */
|
||||
frames: z.array(protocolFrameSchema).min(0).max(100_000),
|
||||
frames: z.array(protocolFrameSchema),
|
||||
/** Authentication flow events. */
|
||||
auth_events: z.array(authFlowEventSchema).default([]),
|
||||
/** Whether any frame was truncated. */
|
||||
|
||||
@@ -1,28 +1,14 @@
|
||||
import { isAbsolute } from "node:path";
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
import { browserCompletenessSchema } from "./browserCompleteness.js";
|
||||
import { browserEndpointSchema } from "./browserObservation.js";
|
||||
import { webTextArtifactSchema } from "./webContentArtifact.js";
|
||||
|
||||
/** Absolute operator-approved filesystem roots for Electron file pages. */
|
||||
export const electronFileRootsSchema = z
|
||||
.array(
|
||||
z
|
||||
.string()
|
||||
.min(1)
|
||||
.refine(isAbsolute, "Electron file roots must be absolute paths"),
|
||||
)
|
||||
.min(1)
|
||||
.transform((roots) => [...new Set(roots)].sort());
|
||||
|
||||
const approvedElectronInput = {
|
||||
cdp_endpoint: browserEndpointSchema,
|
||||
allowed_file_roots: electronFileRootsSchema,
|
||||
};
|
||||
|
||||
/** Input for listing root-confined file:// page targets from Electron CDP. */
|
||||
/** Input for listing local file:// page targets from an explicit Electron CDP endpoint. */
|
||||
export const listElectronTargetsInputSchema = z.strictObject({
|
||||
...approvedElectronInput,
|
||||
});
|
||||
@@ -46,20 +32,8 @@ export const inspectElectronPageInputSchema = z.union([
|
||||
include_script_sources: z.literal(true),
|
||||
}),
|
||||
]);
|
||||
export const inspectElectronPageToolInputSchema = z.union([
|
||||
z.strictObject({
|
||||
discovery_evidence_id: z.string().min(1),
|
||||
target_id: z.string().trim().min(1),
|
||||
observation_ms: z.number().int().min(0).default(100),
|
||||
include_script_sources: z.literal(false).default(false),
|
||||
}),
|
||||
z.strictObject({
|
||||
discovery_evidence_id: z.string().min(1),
|
||||
target_id: z.string().trim().min(1),
|
||||
observation_ms: z.number().int().min(0).default(100),
|
||||
include_script_sources: z.literal(true),
|
||||
}),
|
||||
]);
|
||||
export const inspectElectronPageToolInputSchema =
|
||||
inspectElectronPageInputSchema;
|
||||
export type InspectElectronPageInput = z.infer<
|
||||
typeof inspectElectronPageInputSchema
|
||||
>;
|
||||
@@ -79,12 +53,11 @@ const electronTargetSchema = z.object({
|
||||
attached: z.boolean(),
|
||||
});
|
||||
|
||||
/** Complete root-filtered Electron file target inventory. */
|
||||
/** Complete local file target inventory from one Electron CDP endpoint. */
|
||||
export const electronTargetListSchema = z.object({
|
||||
browser: browserVersionSchema,
|
||||
targets: z.array(electronTargetSchema),
|
||||
excluded: z.object({
|
||||
outside_root: z.number().int().min(0),
|
||||
unsupported_url: z.number().int().min(0),
|
||||
non_page: z.number().int().min(0),
|
||||
}),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import { evidenceSchema } from "./evidence.js";
|
||||
|
||||
const comparisonStatusSchema = z.enum([
|
||||
"unchanged",
|
||||
@@ -21,8 +22,8 @@ const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
||||
|
||||
/** Inputs for explicit function-to-function comparison. */
|
||||
export const functionComparisonInputSchema = z.strictObject({
|
||||
left_evidence_id: evidenceIdSchema,
|
||||
right_evidence_id: evidenceIdSchema,
|
||||
left: evidenceSchema,
|
||||
right: evidenceSchema,
|
||||
});
|
||||
|
||||
const textDeltaSchema = z.object({
|
||||
|
||||
@@ -58,7 +58,7 @@ const reconstructionStatisticsSchema = z.strictObject({
|
||||
/** JavaScript application analysis with an authenticated semantic companion. */
|
||||
export const javascriptApplicationAnalysisResultSchema = z
|
||||
.strictObject({
|
||||
input_path: z.string().min(1).max(16_384),
|
||||
input_path: z.string().min(1),
|
||||
format: z.enum(["asar", "directory"]),
|
||||
root_artifact_sha256: digestSchema,
|
||||
inventory_manifest_id: z.string().regex(/^agm_[a-f0-9]{64}$/u),
|
||||
@@ -66,7 +66,7 @@ export const javascriptApplicationAnalysisResultSchema = z
|
||||
graph: javascriptApplicationGraphSchema,
|
||||
summary: electronBoundarySummarySchema,
|
||||
statistics: reconstructionStatisticsSchema,
|
||||
limitations: z.array(z.string().min(1).max(4_096)).max(1_000),
|
||||
limitations: z.array(z.string().min(1)),
|
||||
semantic_graph: javaScriptSemanticGraphSchema,
|
||||
})
|
||||
.superRefine((result, context) => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { JAVASCRIPT_APPLICATION_NODE_KINDS } from "./javascriptApplicationGraphS
|
||||
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const nodeIdSchema = z.string().regex(/^jag_node_[a-f0-9]{64}$/u);
|
||||
const boundedTextSchema = z.string().min(1).max(4_096);
|
||||
const textSchema = z.string().min(1);
|
||||
|
||||
/** Two authenticated application versions and their native observations. */
|
||||
export const compareApplicationVersionsInputSchema = z
|
||||
@@ -94,20 +94,18 @@ const rightAmbiguousMatchSchema = z.strictObject({
|
||||
const comparisonItemContextShape = {
|
||||
item_id: z.string().regex(/^javc_item_[a-f0-9]{64}$/u),
|
||||
node_kind: z.enum(JAVASCRIPT_APPLICATION_NODE_KINDS),
|
||||
dimensions: z
|
||||
.array(
|
||||
z.enum([
|
||||
"content",
|
||||
"location",
|
||||
"properties",
|
||||
"relationships",
|
||||
"availability",
|
||||
"coverage",
|
||||
]),
|
||||
)
|
||||
.max(6),
|
||||
dimensions: z.array(
|
||||
z.enum([
|
||||
"content",
|
||||
"location",
|
||||
"properties",
|
||||
"relationships",
|
||||
"availability",
|
||||
"coverage",
|
||||
]),
|
||||
),
|
||||
evidence_links: z.array(evidenceIdSchema).min(2),
|
||||
limitations: z.array(boundedTextSchema),
|
||||
limitations: z.array(textSchema),
|
||||
};
|
||||
|
||||
const comparisonItemSchema = z.union([
|
||||
@@ -191,7 +189,7 @@ export const applicationVersionComparisonResultSchema = z
|
||||
graph: javascriptApplicationGraphSchema,
|
||||
coverage: comparisonCoverageSchema,
|
||||
evidence_links: z.array(evidenceIdSchema).min(2),
|
||||
limitations: z.array(boundedTextSchema),
|
||||
limitations: z.array(textSchema),
|
||||
})
|
||||
.superRefine((result, context) => {
|
||||
const sourceGraphsComplete =
|
||||
|
||||
@@ -9,6 +9,22 @@ const sha256 = (value: Uint8Array): string =>
|
||||
createHash("sha256").update(value).digest("hex");
|
||||
|
||||
describe("JavaScript export instrumentation", () => {
|
||||
it("retains a long caller-provided artifact path in the manifest", () => {
|
||||
const source = encode("const value = 1;");
|
||||
const path = `/${"deep/".repeat(1_000)}app.js`;
|
||||
const output = instrumentJavaScriptExport(source, {
|
||||
artifact_path: path,
|
||||
artifact_sha256: sha256(source),
|
||||
selection: {
|
||||
byte_start: 14,
|
||||
byte_end: 15,
|
||||
selected_sha256: sha256(encode("1")),
|
||||
export_name: "value",
|
||||
},
|
||||
});
|
||||
expect(output.manifest.artifact_path).toBe(path);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
"plain",
|
||||
|
||||
@@ -5,7 +5,7 @@ import { z } from "zod";
|
||||
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
||||
|
||||
export const javascriptExportInstrumentationInputSchema = z.strictObject({
|
||||
artifact_path: z.string().min(1).max(4_096),
|
||||
artifact_path: z.string().min(1),
|
||||
artifact_sha256: digestSchema,
|
||||
selection: z.strictObject({
|
||||
byte_start: z.number().int().min(0),
|
||||
@@ -17,7 +17,7 @@ export const javascriptExportInstrumentationInputSchema = z.strictObject({
|
||||
|
||||
export const javascriptExportTransformationManifestSchema = z.strictObject({
|
||||
kind: z.literal("commonjs-factory-export-v1"),
|
||||
artifact_path: z.string().min(1).max(4_096),
|
||||
artifact_path: z.string().min(1),
|
||||
original_sha256: digestSchema,
|
||||
original_byte_length: z.number().int().min(0),
|
||||
instrumented_sha256: digestSchema,
|
||||
|
||||
@@ -5,10 +5,10 @@ import { evidenceSchema } from "./evidence.js";
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const graphIdSchema = z.string().regex(/^jag_[a-f0-9]{64}$/u);
|
||||
const nodeIdSchema = z.string().regex(/^jag_node_[a-f0-9]{64}$/u);
|
||||
const boundedTextSchema = z.string().min(1).max(4_096);
|
||||
const selectorTextSchema = z.string().min(1).max(4_096);
|
||||
const textSchema = z.string().min(1);
|
||||
const selectorTextSchema = textSchema;
|
||||
const semanticPrimitiveSchema = z.union([
|
||||
z.string().max(4_096),
|
||||
z.string(),
|
||||
z.number().finite(),
|
||||
z.boolean(),
|
||||
z.null(),
|
||||
@@ -28,7 +28,6 @@ function isJsonPointer(value: string): boolean {
|
||||
|
||||
const jsonPointerSchema = z
|
||||
.string()
|
||||
.max(4_096)
|
||||
.refine(isJsonPointer, "Expected an RFC 6901 JSON Pointer");
|
||||
|
||||
const sourcePointSchema = z.strictObject({
|
||||
@@ -91,7 +90,7 @@ const projectedReturnFieldSchema = z.discriminatedUnion("state", [
|
||||
...projectedReturnFieldShape,
|
||||
state: z.literal("unknown"),
|
||||
value: z.null(),
|
||||
reason: boundedTextSchema,
|
||||
reason: textSchema,
|
||||
}),
|
||||
]);
|
||||
export type ProjectedReturnField = z.infer<typeof projectedReturnFieldSchema>;
|
||||
@@ -150,7 +149,7 @@ export const projectedExportReturnShapesSchema = z
|
||||
semantic_role: z.literal("export-return-shapes"),
|
||||
module_path: selectorTextSchema,
|
||||
exported_name: selectorTextSchema,
|
||||
callable_id: boundedTextSchema,
|
||||
callable_id: textSchema,
|
||||
callable_kind: z.enum(["function", "class", "method"]),
|
||||
static_return_shapes: z.array(projectedReturnShapeSchema),
|
||||
return_shape_coverage: z.strictObject({
|
||||
@@ -220,7 +219,7 @@ const valueAvailabilitySchema = z.discriminatedUnion("availability", [
|
||||
}),
|
||||
z.strictObject({
|
||||
availability: z.literal("unknown"),
|
||||
reason: boundedTextSchema,
|
||||
reason: textSchema,
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -239,10 +238,10 @@ const comparisonChangeSchema = z.strictObject({
|
||||
left_source_range: sourceRangeSchema.nullable(),
|
||||
right_source_range: sourceRangeSchema.nullable(),
|
||||
evidence_links: z.array(evidenceIdSchema).length(2),
|
||||
limitations: z.array(boundedTextSchema),
|
||||
limitations: z.array(textSchema),
|
||||
});
|
||||
|
||||
/** Bounded static export-return comparison with explicit unknown semantics. */
|
||||
/** Static export-return comparison with explicit unknown semantics. */
|
||||
export const javaScriptExportShapeComparisonResultSchema = z.strictObject({
|
||||
comparison_id: z.string().regex(/^jesc_[a-f0-9]{64}$/u),
|
||||
left: selectorResultSchema,
|
||||
@@ -283,7 +282,7 @@ export const javaScriptExportShapeComparisonResultSchema = z.strictObject({
|
||||
omitted_changes: z.number().int().min(0),
|
||||
}),
|
||||
evidence_links: z.array(evidenceIdSchema).length(2),
|
||||
limitations: z.array(boundedTextSchema),
|
||||
limitations: z.array(textSchema),
|
||||
runtime_validation: z.strictObject({
|
||||
recommended_tool: z.literal("run_controlled_replay"),
|
||||
automatically_started: z.literal(false),
|
||||
|
||||
@@ -1,60 +1,17 @@
|
||||
import { isAbsolute, resolve } from "node:path";
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
import {
|
||||
browserEndpointSchema,
|
||||
browserOriginSchema,
|
||||
} from "./browserObservation.js";
|
||||
import { browserEndpointSchema } from "./browserObservation.js";
|
||||
|
||||
const observationTextSchema = z.string().min(1);
|
||||
|
||||
const runtimeFileRootsSchema = z
|
||||
.array(
|
||||
z
|
||||
.string()
|
||||
.min(1)
|
||||
.refine(isAbsolute, "Runtime file roots must be absolute paths")
|
||||
.overwrite(resolve),
|
||||
)
|
||||
.overwrite((roots) => [...new Set(roots)].sort())
|
||||
.default([]);
|
||||
|
||||
const runtimeOriginsSchema = z
|
||||
.array(browserOriginSchema)
|
||||
.overwrite((origins) => [...new Set(origins)].sort())
|
||||
.default([]);
|
||||
|
||||
const runtimeScope = {
|
||||
const runtimeEndpoint = {
|
||||
inspector_endpoint: browserEndpointSchema,
|
||||
allowed_file_roots: runtimeFileRootsSchema,
|
||||
allowed_origins: runtimeOriginsSchema,
|
||||
};
|
||||
|
||||
const requireRuntimeScope = (
|
||||
input: {
|
||||
readonly allowed_file_roots: readonly string[];
|
||||
readonly allowed_origins: readonly string[];
|
||||
},
|
||||
context: z.RefinementCtx,
|
||||
): void => {
|
||||
if (
|
||||
input.allowed_file_roots.length === 0 &&
|
||||
input.allowed_origins.length === 0
|
||||
)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
path: ["allowed_file_roots"],
|
||||
message: "At least one exact file root or HTTP(S) origin is required",
|
||||
});
|
||||
};
|
||||
|
||||
/** Input for listing approved Node/Electron V8 Inspector targets. */
|
||||
export const listJavaScriptRuntimeTargetsInputSchema = z
|
||||
.strictObject({
|
||||
...runtimeScope,
|
||||
})
|
||||
.superRefine(requireRuntimeScope);
|
||||
/** Input for listing targets exposed by an explicit Node/Electron Inspector endpoint. */
|
||||
export const listJavaScriptRuntimeTargetsInputSchema = z.strictObject({
|
||||
...runtimeEndpoint,
|
||||
});
|
||||
export type ListJavaScriptRuntimeTargetsInput = z.infer<
|
||||
typeof listJavaScriptRuntimeTargetsInputSchema
|
||||
>;
|
||||
@@ -70,22 +27,15 @@ const observedJavaScriptRuntimeKindSchema = javascriptRuntimeKindSchema.or(
|
||||
);
|
||||
|
||||
/** Input for one bounded, attach-only V8 Inspector observation. */
|
||||
export const observeJavaScriptRuntimeToolInputSchema = z.strictObject({
|
||||
discovery_evidence_id: z.string().min(1),
|
||||
/** Input for one passive attach-only V8 Inspector observation. */
|
||||
export const observeJavaScriptRuntimeInputSchema = z.strictObject({
|
||||
...runtimeEndpoint,
|
||||
target_id: z.string().trim().min(1),
|
||||
runtime_kind: javascriptRuntimeKindSchema.optional(),
|
||||
observation_ms: z.number().int().min(0).default(100),
|
||||
});
|
||||
|
||||
/** Input after discovery Evidence supplies the authorized target scope. */
|
||||
export const observeJavaScriptRuntimeInputSchema = z
|
||||
.strictObject({
|
||||
...runtimeScope,
|
||||
target_id: z.string().trim().min(1),
|
||||
runtime_kind: javascriptRuntimeKindSchema.optional(),
|
||||
observation_ms: z.number().int().min(0).default(100),
|
||||
})
|
||||
.superRefine(requireRuntimeScope);
|
||||
export const observeJavaScriptRuntimeToolInputSchema =
|
||||
observeJavaScriptRuntimeInputSchema;
|
||||
export type ObserveJavaScriptRuntimeInput = z.infer<
|
||||
typeof observeJavaScriptRuntimeInputSchema
|
||||
>;
|
||||
@@ -123,13 +73,11 @@ const javascriptRuntimeTargetSchema = z.strictObject({
|
||||
location: javascriptRuntimeLocationSchema,
|
||||
});
|
||||
|
||||
/** Complete root/origin-filtered V8 Inspector target inventory. */
|
||||
/** Complete V8 Inspector target inventory exposed by the selected endpoint. */
|
||||
export const javascriptRuntimeTargetListSchema = z.strictObject({
|
||||
runtime: javascriptRuntimeVersionSchema,
|
||||
targets: z.array(javascriptRuntimeTargetSchema),
|
||||
excluded: z.strictObject({
|
||||
outside_file_roots: z.number().int().min(0),
|
||||
outside_origins: z.number().int().min(0),
|
||||
unsupported_location: z.number().int().min(0),
|
||||
unconnectable: z.number().int().min(0),
|
||||
}),
|
||||
@@ -179,8 +127,6 @@ export const javascriptRuntimeObservationSchema = z.strictObject({
|
||||
items: z.array(javascriptRuntimeScriptSchema),
|
||||
observed_total: z.number().int().min(0),
|
||||
excluded: z.strictObject({
|
||||
outside_file_roots: z.number().int().min(0),
|
||||
outside_origins: z.number().int().min(0),
|
||||
unsupported_location: z.number().int().min(0),
|
||||
invalid_protocol_value: z.number().int().min(0),
|
||||
}),
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { isAbsolute } from "node:path";
|
||||
|
||||
import { isPathWithinRoot } from "./localPath.js";
|
||||
import canonicalize from "canonicalize";
|
||||
import { z } from "zod";
|
||||
|
||||
import {
|
||||
browserAllowedOriginsSchema,
|
||||
browserEndpointSchema,
|
||||
browserOriginSchema,
|
||||
webPageInspectionSchema,
|
||||
type WebPageInspection,
|
||||
} from "./browserObservation.js";
|
||||
@@ -17,7 +13,6 @@ import {
|
||||
type BrowserCompleteness,
|
||||
} from "./browserCompleteness.js";
|
||||
import {
|
||||
electronFileRootsSchema,
|
||||
electronPageInspectionSchema,
|
||||
type ElectronPageInspection,
|
||||
} from "./electronObservation.js";
|
||||
@@ -279,8 +274,6 @@ const assertV8RuntimeParameters = (
|
||||
const parameters = z
|
||||
.object({
|
||||
inspector_endpoint: browserEndpointSchema,
|
||||
allowed_file_roots: z.array(z.string().min(1).refine(isAbsolute)),
|
||||
allowed_origins: z.array(browserOriginSchema),
|
||||
target_id: z.string().trim().min(1),
|
||||
runtime_kind: javascriptRuntimeKindSchema.optional(),
|
||||
})
|
||||
@@ -298,17 +291,9 @@ const assertV8RuntimeParameters = (
|
||||
result.target.location,
|
||||
...result.scripts.items.map(({ location }) => location),
|
||||
])
|
||||
if (
|
||||
(location.kind === "file" &&
|
||||
!parameters.allowed_file_roots.some((root) =>
|
||||
isPathWithinRoot(root, location.file_path),
|
||||
)) ||
|
||||
(location.kind === "url" &&
|
||||
!parameters.allowed_origins.includes(location.origin)) ||
|
||||
(location.kind === "builtin" && !location.specifier.startsWith("node:"))
|
||||
)
|
||||
if (location.kind === "builtin" && !location.specifier.startsWith("node:"))
|
||||
throw new TypeError(
|
||||
"Runtime Evidence contains a location outside its recorded scope",
|
||||
"Runtime Evidence contains an invalid builtin location",
|
||||
);
|
||||
};
|
||||
|
||||
@@ -426,13 +411,7 @@ const assertRuntimeParameters = (
|
||||
);
|
||||
return;
|
||||
}
|
||||
const parameters = z
|
||||
.object({
|
||||
...common,
|
||||
allowed_file_roots: electronFileRootsSchema,
|
||||
})
|
||||
.passthrough()
|
||||
.parse(evidence.parameters);
|
||||
const parameters = z.object(common).passthrough().parse(evidence.parameters);
|
||||
if (parameters.target_id !== expected.targetId)
|
||||
throw new TypeError(
|
||||
"Runtime Evidence target disagrees with its captured result",
|
||||
|
||||
@@ -104,7 +104,7 @@ export const collectJavaScriptSemanticFingerprints = (
|
||||
],
|
||||
},
|
||||
limitations: [
|
||||
"The fingerprint is a bounded static candidate and does not prove behavioral equivalence.",
|
||||
"The fingerprint is a static candidate and does not prove behavioral equivalence.",
|
||||
...(parserPartial
|
||||
? ["Incomplete semantic recovery makes this fingerprint partial."]
|
||||
: []),
|
||||
|
||||
@@ -97,12 +97,13 @@ const node = (
|
||||
role: string,
|
||||
properties: Record<string, string | number | boolean | null> = {},
|
||||
functionNodeId: string | null = null,
|
||||
modulePath = "bundle.js",
|
||||
): JavaScriptSemanticGraphNode =>
|
||||
createJavaScriptSemanticGraphNode({
|
||||
kind,
|
||||
identity: {
|
||||
artifact_sha256: SHA,
|
||||
module_path: "bundle.js",
|
||||
module_path: modulePath,
|
||||
source_range: {
|
||||
start: { line: 1, column: role.length },
|
||||
end: { line: 1, column: role.length + 1 },
|
||||
@@ -116,6 +117,13 @@ const node = (
|
||||
evidence: evidence(),
|
||||
});
|
||||
|
||||
it("accepts semantic module paths longer than the former schema ceiling", () => {
|
||||
const modulePath = `${"segment/".repeat(600)}entry.js`;
|
||||
expect(
|
||||
node("module", "long-path", {}, null, modulePath).identity.module_path,
|
||||
).toBe(modulePath);
|
||||
});
|
||||
|
||||
const fixtureGraph = (withUnknown = false): JavaScriptSemanticGraph => {
|
||||
const module = node("module", "module");
|
||||
const literal = node("literal", "literal", { value: "TOKEN" });
|
||||
|
||||
@@ -162,7 +162,6 @@ export const JAVASCRIPT_SEMANTIC_RELATION_FAMILY = {
|
||||
const relativePathSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(4_096)
|
||||
.refine(
|
||||
(path) =>
|
||||
!path.startsWith("/") &&
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
javaScriptSemanticQueryInputSchema,
|
||||
javaScriptSemanticQueryResultSchema,
|
||||
} from "./javascriptSemanticQuerySchemas.js";
|
||||
|
||||
it("accepts long selectors and complete relation and class selections", () => {
|
||||
const longText = "x".repeat(16_385);
|
||||
const result = javaScriptSemanticQueryInputSchema.parse({
|
||||
seed: { kind: "endpoint", value: longText },
|
||||
direction: "forward-influence",
|
||||
allowed_relations: Array(2).fill("calls"),
|
||||
expected: {
|
||||
role: "sink",
|
||||
classes: Array(25).fill("module"),
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.seed).toEqual({ kind: "endpoint", value: longText });
|
||||
expect(result.allowed_relations).toHaveLength(2);
|
||||
expect(result.expected?.classes).toHaveLength(25);
|
||||
});
|
||||
|
||||
it("accepts every reported limitation without a count ceiling", () => {
|
||||
const limitations = Array.from(
|
||||
{ length: 1_001 },
|
||||
(_, index) => `gap-${index}`,
|
||||
);
|
||||
const id = "a".repeat(64);
|
||||
|
||||
const result = javaScriptSemanticQueryResultSchema.parse({
|
||||
query_id: `jsrq_${id}`,
|
||||
source_graph_id: `jsrg_${id}`,
|
||||
seed: { kind: "literal", value: null },
|
||||
direction: "forward-influence",
|
||||
status: "no-match",
|
||||
seed_node_ids: [],
|
||||
nodes: [],
|
||||
relations: [],
|
||||
unknowns: [],
|
||||
expected_match_node_ids: [],
|
||||
summary: {
|
||||
total_seed_matches: 0,
|
||||
traversed_nodes: 0,
|
||||
traversed_relations: 0,
|
||||
traversed_functions: 0,
|
||||
traversed_modules: 0,
|
||||
relevant_unknowns: 0,
|
||||
},
|
||||
coverage: { status: "complete" },
|
||||
limitations,
|
||||
});
|
||||
|
||||
expect(result.limitations).toHaveLength(1_001);
|
||||
});
|
||||
@@ -41,19 +41,19 @@ export const javaScriptSemanticQuerySeedSchema = z.discriminatedUnion("kind", [
|
||||
}),
|
||||
z.strictObject({
|
||||
kind: z.literal("property"),
|
||||
name: z.string().min(1).max(4_096),
|
||||
name: z.string().min(1),
|
||||
}),
|
||||
z.strictObject({
|
||||
kind: z.literal("endpoint"),
|
||||
value: z.string().min(1).max(16_384),
|
||||
value: z.string().min(1),
|
||||
}),
|
||||
z.strictObject({
|
||||
kind: z.literal("event"),
|
||||
name: z.string().min(1).max(4_096),
|
||||
name: z.string().min(1),
|
||||
}),
|
||||
z.strictObject({
|
||||
kind: z.literal("boundary-field"),
|
||||
field: z.string().min(1).max(4_096),
|
||||
field: z.string().min(1),
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -73,13 +73,12 @@ export const javaScriptSemanticQueryInputSchema = z.strictObject({
|
||||
allowed_relations: z
|
||||
.array(z.enum(JAVASCRIPT_SEMANTIC_RELATIONS))
|
||||
.min(1)
|
||||
.max(JAVASCRIPT_SEMANTIC_RELATIONS.length)
|
||||
.optional(),
|
||||
include_ambiguous_dynamic_edges: z.boolean().default(false),
|
||||
expected: z
|
||||
.strictObject({
|
||||
role: z.enum(["source", "sink"]),
|
||||
classes: z.array(z.enum(JAVASCRIPT_SEMANTIC_NODE_KINDS)).min(1).max(24),
|
||||
classes: z.array(z.enum(JAVASCRIPT_SEMANTIC_NODE_KINDS)).min(1),
|
||||
})
|
||||
.nullable()
|
||||
.default(null),
|
||||
@@ -109,7 +108,7 @@ export const javaScriptSemanticQueryResultSchema = z.strictObject({
|
||||
coverage: z.strictObject({
|
||||
status: z.enum(["complete", "partial", "unavailable"]),
|
||||
}),
|
||||
limitations: z.array(z.string().min(1).max(4_096)).max(1_000),
|
||||
limitations: z.array(z.string().min(1)),
|
||||
});
|
||||
|
||||
/** Validated semantic query input. */
|
||||
|
||||
@@ -33,7 +33,7 @@ import {
|
||||
|
||||
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const boundedTextSchema = z.string().min(1).max(4_096);
|
||||
const textSchema = z.string().min(1);
|
||||
|
||||
/** Authenticated managed Evidence records projected into the application graph. */
|
||||
export const projectManagedApplicationGraphInputSchema = z
|
||||
@@ -80,7 +80,7 @@ export const managedApplicationGraphResultSchema = z.strictObject({
|
||||
status: z.enum(["complete-within-inputs", "partial"]),
|
||||
}),
|
||||
evidence_links: z.array(evidenceIdSchema).min(1).max(3),
|
||||
limitations: z.array(boundedTextSchema).max(1_000),
|
||||
limitations: z.array(textSchema),
|
||||
});
|
||||
|
||||
export type ProjectManagedApplicationGraphInput = z.infer<
|
||||
|
||||
@@ -314,7 +314,7 @@ export const managedArtifactInspectionSchema = z.object({
|
||||
machine_hex: z.string().regex(/^0x[0-9a-f]{4}$/u),
|
||||
architecture: z.enum(["x86", "x86_64", "arm", "arm64"]),
|
||||
optional_header: z.enum(["pe32", "pe32-plus"]),
|
||||
section_count: z.number().int().min(1).max(96),
|
||||
section_count: z.number().int().min(1).max(0xffff),
|
||||
characteristics: z.number().int().min(0).max(0xffff),
|
||||
cli: z
|
||||
.object({
|
||||
|
||||
@@ -6,7 +6,7 @@ import { cliMetadataGuidSchema } from "./managedArtifact.js";
|
||||
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const tokenSchema = z.string().regex(/^0x[0-9a-f]{8}$/u);
|
||||
const boundedTextSchema = z.string().min(1).max(4_096);
|
||||
const textSchema = z.string().min(1);
|
||||
|
||||
const nativeSymbolSchema = z.strictObject({
|
||||
evidence_id: evidenceIdSchema,
|
||||
@@ -42,7 +42,7 @@ const pinvokeVerificationContextShape = {
|
||||
declaration_verification: z.literal("managed-declaration-only"),
|
||||
}),
|
||||
evidence_links: z.array(evidenceIdSchema).min(1),
|
||||
limitations: z.array(boundedTextSchema),
|
||||
limitations: z.array(textSchema),
|
||||
};
|
||||
|
||||
const observedCandidatesSchema = z
|
||||
@@ -157,11 +157,11 @@ export const managedNativeVerificationResultSchema = z
|
||||
pinvoke_imports: z.array(pinvokeVerificationSchema),
|
||||
native_implementations: z.strictObject({
|
||||
unresolved: z.number().int().min(0),
|
||||
reason: boundedTextSchema,
|
||||
reason: textSchema,
|
||||
}),
|
||||
coverage: verificationCoverageSchema,
|
||||
evidence_links: z.array(evidenceIdSchema).min(2),
|
||||
limitations: z.array(boundedTextSchema),
|
||||
limitations: z.array(textSchema),
|
||||
})
|
||||
.superRefine((result, context) => {
|
||||
const observedNativeCount =
|
||||
|
||||
@@ -46,4 +46,46 @@ describe("managed reconstruction import input", () => {
|
||||
expect(parsed.decompiler.options).toHaveLength(51);
|
||||
expect(parsed.notes).toHaveLength(101);
|
||||
});
|
||||
|
||||
it("accepts decompiler text and metadata without arbitrary length ceilings", () => {
|
||||
const evidence = createEvidence(
|
||||
undefined,
|
||||
{ id: "fixture", name: "Fixture", version: "1" },
|
||||
{
|
||||
operation: "inspect_managed_members",
|
||||
parameters: {},
|
||||
result: {},
|
||||
},
|
||||
);
|
||||
const text = "x".repeat(65_537);
|
||||
const metadata = "m".repeat(4_097);
|
||||
|
||||
const result = managedReconstructionImportInputSchema.parse({
|
||||
static_members: evidence,
|
||||
decompiler: {
|
||||
name: metadata,
|
||||
version: metadata,
|
||||
family: "other",
|
||||
executable_sha256: null,
|
||||
options: ["o".repeat(513)],
|
||||
},
|
||||
methods: [
|
||||
{
|
||||
token: "0x06000001",
|
||||
signature_sha256: "a".repeat(64),
|
||||
normalized_il_sha256: null,
|
||||
reconstruction: {
|
||||
kind: "semantic-pseudocode",
|
||||
language: "pseudocode",
|
||||
text,
|
||||
source_path: metadata,
|
||||
},
|
||||
},
|
||||
],
|
||||
notes: [metadata],
|
||||
});
|
||||
|
||||
expect(result.methods[0]?.reconstruction.text).toHaveLength(65_537);
|
||||
expect(result.decompiler.name).toHaveLength(4_097);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,15 +14,14 @@ import type { JsonValue } from "./jsonValue.js";
|
||||
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const tokenSchema = z.string().regex(/^0x[0-9a-f]{8}$/u);
|
||||
const boundedTextSchema = z.string().min(1).max(65_536);
|
||||
const boundedLabelSchema = z.string().min(1).max(512);
|
||||
const textSchema = z.string().min(1);
|
||||
|
||||
const decompilerSchema = z.strictObject({
|
||||
name: boundedLabelSchema,
|
||||
version: z.string().min(1).max(128).nullable(),
|
||||
name: textSchema,
|
||||
version: textSchema.nullable(),
|
||||
family: z.enum(["ilspy", "dnspy", "dnlib", "mono-cecil", "other"]),
|
||||
executable_sha256: digestSchema.nullable(),
|
||||
options: z.array(z.string().max(512)).default([]),
|
||||
options: z.array(z.string()).default([]),
|
||||
});
|
||||
|
||||
const managedReconstructionMethodInputSchema = z.strictObject({
|
||||
@@ -32,9 +31,9 @@ const managedReconstructionMethodInputSchema = z.strictObject({
|
||||
reconstruction: z.strictObject({
|
||||
kind: z.enum(["decompiled-csharp", "decompiled-il", "semantic-pseudocode"]),
|
||||
language: z.enum(["csharp", "il", "pseudocode"]),
|
||||
text: boundedTextSchema,
|
||||
text: textSchema,
|
||||
text_sha256: digestSchema.optional(),
|
||||
source_path: z.string().min(1).max(4_096).nullable().optional(),
|
||||
source_path: textSchema.nullable().optional(),
|
||||
start_line: z.number().int().min(1).nullable().optional(),
|
||||
end_line: z.number().int().min(1).nullable().optional(),
|
||||
}),
|
||||
@@ -48,7 +47,7 @@ export const managedReconstructionImportInputSchema = z.strictObject({
|
||||
static_members: evidenceSchema,
|
||||
decompiler: decompilerSchema,
|
||||
methods: z.array(managedReconstructionMethodInputSchema).min(1),
|
||||
notes: z.array(z.string().min(1).max(4_096)).default([]),
|
||||
notes: z.array(textSchema).default([]),
|
||||
});
|
||||
|
||||
const importedMethodSchema = z.strictObject({
|
||||
@@ -62,11 +61,11 @@ const importedMethodSchema = z.strictObject({
|
||||
reconstruction: z.strictObject({
|
||||
kind: z.enum(["decompiled-csharp", "decompiled-il", "semantic-pseudocode"]),
|
||||
language: z.enum(["csharp", "il", "pseudocode"]),
|
||||
text: boundedTextSchema,
|
||||
text: textSchema,
|
||||
text_sha256: digestSchema,
|
||||
text_length: z.number().int().min(1).max(65_536),
|
||||
text_length: z.number().int().min(1),
|
||||
line_count: z.number().int().min(1),
|
||||
source_path: z.string().min(1).max(4_096).nullable(),
|
||||
source_path: textSchema.nullable(),
|
||||
start_line: z.number().int().min(1).nullable(),
|
||||
end_line: z.number().int().min(1).nullable(),
|
||||
}),
|
||||
@@ -102,9 +101,9 @@ export const managedReconstructionImportResultSchema = z.strictObject({
|
||||
total_text_bytes: z.number().int().min(1),
|
||||
}),
|
||||
methods: z.array(importedMethodSchema).min(1),
|
||||
notes: z.array(z.string().min(1).max(4_096)),
|
||||
notes: z.array(textSchema),
|
||||
evidence_links: z.array(evidenceIdSchema).length(1),
|
||||
limitations: z.array(z.string().min(1).max(4_096)),
|
||||
limitations: z.array(textSchema),
|
||||
});
|
||||
|
||||
export type ManagedReconstructionImportInput = z.infer<
|
||||
|
||||
@@ -22,8 +22,6 @@ const nativeCommandInvocationSchema = z.object({
|
||||
}),
|
||||
stdout_bytes: z.number().int().min(0),
|
||||
stderr_bytes: z.number().int().min(0),
|
||||
stdout_truncated: z.boolean(),
|
||||
stderr_truncated: z.boolean(),
|
||||
});
|
||||
|
||||
const architectureSchema = z.object({
|
||||
|
||||
@@ -155,6 +155,23 @@ describe("PE/COFF static inspection", () => {
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts static manifests with more than 96 PE sections", () => {
|
||||
const section = validManifest.sections[0];
|
||||
if (section === undefined) throw new Error("Expected PE section fixture");
|
||||
const sections = Array.from({ length: 97 }, (_, index) => ({
|
||||
...section,
|
||||
name: `section-${String(index)}`,
|
||||
}));
|
||||
|
||||
expect(
|
||||
peManifestSchema.parse({
|
||||
...validManifest,
|
||||
number_of_sections: sections.length,
|
||||
sections,
|
||||
}).sections,
|
||||
).toHaveLength(97);
|
||||
});
|
||||
|
||||
it("detects PDB info", () => {
|
||||
expect(hasPdbInfo(validManifest)).toBe(true);
|
||||
const withoutPdb: PeManifest = {
|
||||
|
||||
@@ -106,7 +106,7 @@ export const peManifestSchema = z.strictObject({
|
||||
/** Subsystem version. */
|
||||
subsystem_version: z.string().nullable(),
|
||||
/** Sections. */
|
||||
sections: z.array(peSectionSchema).min(0).max(96),
|
||||
sections: z.array(peSectionSchema),
|
||||
/** Imports. */
|
||||
imports: z.array(peImportSchema).default([]),
|
||||
/** Exports. */
|
||||
|
||||
@@ -63,7 +63,99 @@ describe("process scenario collection inputs", () => {
|
||||
expect(scenario.idle_timeout_ms).toBe(900_000);
|
||||
expect(scenario.settle_ms).toBe(20_000);
|
||||
});
|
||||
});
|
||||
|
||||
describe("process scenario complete input values", () => {
|
||||
it("accepts long checkpoint and command names", () => {
|
||||
const checkpointName = `c${"k".repeat(1_000)}`;
|
||||
const commandName = `c${"m".repeat(1_000)}`;
|
||||
const scenario = processScenarioSchema.parse({
|
||||
executable: "/bin/echo",
|
||||
working_directory: "/tmp",
|
||||
checkpoints: [{ name: checkpointName, trigger: { type: "root_exit" } }],
|
||||
command_shims: [
|
||||
{
|
||||
name: commandName,
|
||||
routes: [
|
||||
{
|
||||
arguments: [],
|
||||
termination: { type: "exit", code: 0 },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(scenario.checkpoints[0]?.name).toBe(checkpointName);
|
||||
expect(scenario.command_shims[0]?.name).toBe(commandName);
|
||||
});
|
||||
});
|
||||
|
||||
describe("process scenario long delays", () => {
|
||||
it("accepts delayed actions longer than one operating-system timer", () => {
|
||||
const beyondOneTimer = 2_147_483_648;
|
||||
const scenario = processScenarioSchema.parse({
|
||||
executable: "/bin/echo",
|
||||
working_directory: "/tmp",
|
||||
timeout_ms: beyondOneTimer + 1,
|
||||
events: [{ type: "input", at_ms: beyondOneTimer, data: "later" }],
|
||||
checkpoints: [
|
||||
{
|
||||
name: "later",
|
||||
trigger: { type: "time", at_ms: beyondOneTimer },
|
||||
},
|
||||
],
|
||||
command_shims: [
|
||||
{
|
||||
name: "later",
|
||||
routes: [
|
||||
{
|
||||
arguments: [],
|
||||
outputs: [
|
||||
{
|
||||
at_ms: beyondOneTimer,
|
||||
stream: "stdout",
|
||||
data: "later",
|
||||
},
|
||||
],
|
||||
termination: { type: "exit", code: 0 },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
replay: {
|
||||
http: [
|
||||
{
|
||||
method: "GET",
|
||||
path: "/later",
|
||||
status: 200,
|
||||
body: "later",
|
||||
delay_ms: beyondOneTimer,
|
||||
},
|
||||
],
|
||||
websocket_connections: [
|
||||
{
|
||||
messages: [{ data: "later", delay_ms: beyondOneTimer }],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(scenario.events[0]?.at_ms).toBe(beyondOneTimer);
|
||||
expect(scenario.checkpoints[0]?.trigger).toMatchObject({
|
||||
at_ms: beyondOneTimer,
|
||||
});
|
||||
expect(scenario.command_shims[0]?.routes[0]?.outputs[0]?.at_ms).toBe(
|
||||
beyondOneTimer,
|
||||
);
|
||||
expect(scenario.replay.http[0]?.delay_ms).toBe(beyondOneTimer);
|
||||
expect(
|
||||
scenario.replay.websocket_connections[0]?.messages[0]?.delay_ms,
|
||||
).toBe(beyondOneTimer);
|
||||
});
|
||||
});
|
||||
|
||||
describe("process scenario large interaction inputs", () => {
|
||||
it("accepts large interaction and replay descriptions under the run budgets", () => {
|
||||
const environment = Object.fromEntries(
|
||||
Array.from({ length: 65 }, (_, index) => [`APP_VALUE_${index}`, "x"]),
|
||||
|
||||
@@ -9,8 +9,7 @@ import {
|
||||
import { replayMachineSchema } from "./replayMachine.js";
|
||||
|
||||
const positiveBudget = z.number().int().safe().positive();
|
||||
const maximumTimerDelay = 2_147_483_647;
|
||||
const timedEventBase = { at_ms: z.number().int().nonnegative() };
|
||||
const timedEventBase = { at_ms: z.number().int().safe().nonnegative() };
|
||||
const environmentName = z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u);
|
||||
const reservedEnvironment = new Set([
|
||||
"HOME",
|
||||
@@ -32,14 +31,10 @@ export const normalizationSchema = z.object({
|
||||
}),
|
||||
),
|
||||
});
|
||||
const checkpointNameSchema = z
|
||||
.string()
|
||||
.regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/u);
|
||||
const commandNameSchema = z
|
||||
.string()
|
||||
.regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u);
|
||||
const checkpointNameSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/u);
|
||||
const commandNameSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);
|
||||
const outputChunkSchema = z.object({
|
||||
at_ms: z.number().int().safe().nonnegative().max(maximumTimerDelay),
|
||||
at_ms: z.number().int().safe().nonnegative(),
|
||||
stream: z.enum(["stdout", "stderr"]),
|
||||
data: z.string(),
|
||||
});
|
||||
@@ -141,12 +136,7 @@ export const processScenarioSchema = z
|
||||
trigger: z.discriminatedUnion("type", [
|
||||
z.object({
|
||||
type: z.literal("time"),
|
||||
at_ms: z
|
||||
.number()
|
||||
.int()
|
||||
.safe()
|
||||
.nonnegative()
|
||||
.max(maximumTimerDelay),
|
||||
at_ms: z.number().int().safe().nonnegative(),
|
||||
}),
|
||||
z.object({
|
||||
type: z.literal("terminal_literal"),
|
||||
@@ -268,13 +258,7 @@ export const processScenarioSchema = z
|
||||
request_headers: z.record(z.string(), z.string()).default({}),
|
||||
request_body: z.string().optional(),
|
||||
response_headers: z.record(z.string(), z.string()).default({}),
|
||||
delay_ms: z
|
||||
.number()
|
||||
.int()
|
||||
.safe()
|
||||
.nonnegative()
|
||||
.max(maximumTimerDelay)
|
||||
.default(0),
|
||||
delay_ms: z.number().int().safe().nonnegative().default(0),
|
||||
disconnect: z.boolean().default(false),
|
||||
max_calls: positiveBudget.default(1),
|
||||
}),
|
||||
@@ -287,13 +271,7 @@ export const processScenarioSchema = z
|
||||
messages: z.array(
|
||||
z.object({
|
||||
data: z.string(),
|
||||
delay_ms: z
|
||||
.number()
|
||||
.int()
|
||||
.safe()
|
||||
.nonnegative()
|
||||
.max(maximumTimerDelay)
|
||||
.default(0),
|
||||
delay_ms: z.number().int().safe().nonnegative().default(0),
|
||||
}),
|
||||
),
|
||||
disconnect_after: z.boolean().default(false),
|
||||
|
||||
@@ -5,8 +5,8 @@ import { evidenceBundleSchema } from "./evidenceBundle.js";
|
||||
|
||||
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const stableIdSchema = z.string().regex(/^[A-Za-z][A-Za-z0-9._:/-]{0,199}$/u);
|
||||
const boundedTextSchema = z.string().trim().min(1).max(4_096);
|
||||
const stableIdSchema = z.string().regex(/^[A-Za-z][A-Za-z0-9._:/-]*$/u);
|
||||
const textSchema = z.string().trim().min(1);
|
||||
|
||||
export const obligationStatusSchema = z.enum([
|
||||
"unowned",
|
||||
@@ -68,7 +68,7 @@ const obligationTargetSchema = z.strictObject({
|
||||
.string()
|
||||
.regex(/^jsrg_node_[a-f0-9]{64}$/u)
|
||||
.nullable(),
|
||||
location: boundedTextSchema,
|
||||
location: textSchema,
|
||||
});
|
||||
|
||||
const authorityReferenceSchema = z.strictObject({
|
||||
@@ -81,25 +81,25 @@ const authorityReferenceSchema = z.strictObject({
|
||||
"analyst-inference",
|
||||
]),
|
||||
state: z.enum(["candidate", "observed", "reviewed", "unknown"]),
|
||||
location: boundedTextSchema,
|
||||
location: textSchema,
|
||||
});
|
||||
|
||||
const observedCaseSchema = z.strictObject({
|
||||
kind: obligationCaseKindSchema,
|
||||
evidence_id: evidenceIdSchema,
|
||||
location: boundedTextSchema,
|
||||
location: textSchema,
|
||||
});
|
||||
|
||||
const ownerBindingSchema = z.strictObject({
|
||||
module_path: boundedTextSchema,
|
||||
symbol: z.string().trim().min(1).max(1_024),
|
||||
module_path: textSchema,
|
||||
symbol: textSchema,
|
||||
owner_sha256: digestSchema,
|
||||
});
|
||||
|
||||
const parserTypeBindingSchema = z.strictObject({
|
||||
parser: boundedTextSchema,
|
||||
schema: boundedTextSchema,
|
||||
domain_type: boundedTextSchema,
|
||||
parser: textSchema,
|
||||
schema: textSchema,
|
||||
domain_type: textSchema,
|
||||
});
|
||||
|
||||
const fixtureBindingSchema = z.strictObject({
|
||||
@@ -111,13 +111,13 @@ const fixtureBindingSchema = z.strictObject({
|
||||
|
||||
const nondeterminismSchema = z.strictObject({
|
||||
mode: z.enum(["total-order", "partial-order", "finite-traces"]),
|
||||
specification: boundedTextSchema,
|
||||
specification: textSchema,
|
||||
});
|
||||
|
||||
const verifierBindingSchema = z.strictObject({
|
||||
verifier_id: stableIdSchema,
|
||||
claim_id: stableIdSchema,
|
||||
command: boundedTextSchema,
|
||||
command: textSchema,
|
||||
authority: obligationProofAuthoritySchema,
|
||||
status: z.enum(["pass", "fail", "unknown", "unsupported", "skipped"]),
|
||||
result_evidence_id: evidenceIdSchema,
|
||||
@@ -147,9 +147,9 @@ export const reconstructionObligationManifestSchema = z.strictObject({
|
||||
export const reviewedReconstructionObligationSchema = z.strictObject({
|
||||
obligation_id: stableIdSchema,
|
||||
obligation_version: z.number().int().min(1),
|
||||
title: z.string().trim().min(1).max(500),
|
||||
title: textSchema,
|
||||
application_layer: obligationLayerSchema,
|
||||
family: z.string().trim().min(1).max(100),
|
||||
family: textSchema,
|
||||
target: obligationTargetSchema,
|
||||
required: z.boolean(),
|
||||
required_case_kinds: z.array(obligationCaseKindSchema).min(1),
|
||||
@@ -159,8 +159,8 @@ export const reviewedReconstructionObligationSchema = z.strictObject({
|
||||
requires_parser_type: z.boolean(),
|
||||
dependency_obligation_ids: z.array(stableIdSchema),
|
||||
residual_unknown_ids: z.array(stableIdSchema),
|
||||
unavailable_authority: z.array(boundedTextSchema),
|
||||
required_next_evidence: z.array(boundedTextSchema),
|
||||
unavailable_authority: z.array(textSchema),
|
||||
required_next_evidence: z.array(textSchema),
|
||||
disposition: z.enum(["active", "blocked", "out-of-scope"]),
|
||||
review_evidence_ids: z.array(evidenceIdSchema).min(1),
|
||||
});
|
||||
@@ -190,16 +190,16 @@ const diagnosticSchema = z.strictObject({
|
||||
"blocked",
|
||||
"out-of-scope",
|
||||
]),
|
||||
detail: boundedTextSchema,
|
||||
detail: textSchema,
|
||||
});
|
||||
|
||||
export const reconstructionObligationSchema = z.strictObject({
|
||||
obligation_id: stableIdSchema,
|
||||
obligation_version: z.number().int().min(1),
|
||||
title: z.string().trim().min(1).max(500),
|
||||
title: textSchema,
|
||||
origin: z.enum(["generated", "reviewed"]),
|
||||
application_layer: obligationLayerSchema,
|
||||
family: z.string().trim().min(1).max(100),
|
||||
family: textSchema,
|
||||
target: obligationTargetSchema,
|
||||
authority_references: z.array(authorityReferenceSchema).min(1),
|
||||
source_state: z.enum(["candidate", "observed", "reviewed", "unknown"]),
|
||||
@@ -212,8 +212,8 @@ export const reconstructionObligationSchema = z.strictObject({
|
||||
requires_parser_type: z.boolean(),
|
||||
dependency_obligation_ids: z.array(stableIdSchema),
|
||||
residual_unknown_ids: z.array(stableIdSchema),
|
||||
unavailable_authority: z.array(boundedTextSchema),
|
||||
required_next_evidence: z.array(boundedTextSchema),
|
||||
unavailable_authority: z.array(textSchema),
|
||||
required_next_evidence: z.array(textSchema),
|
||||
binding: reconstructionObligationManifestBindingSchema.nullable(),
|
||||
status: obligationStatusSchema,
|
||||
diagnostics: z.array(diagnosticSchema),
|
||||
@@ -262,8 +262,8 @@ export const reconstructionObligationLedgerSchema = z.strictObject({
|
||||
ownership_graph: z.array(
|
||||
z.strictObject({
|
||||
obligation_id: stableIdSchema,
|
||||
module_path: boundedTextSchema,
|
||||
symbol: z.string().trim().min(1).max(1_024),
|
||||
module_path: textSchema,
|
||||
symbol: textSchema,
|
||||
}),
|
||||
),
|
||||
dependency_graph: z.array(
|
||||
@@ -274,7 +274,7 @@ export const reconstructionObligationLedgerSchema = z.strictObject({
|
||||
),
|
||||
obligations: z.array(reconstructionObligationSchema),
|
||||
evidence_links: z.array(evidenceIdSchema),
|
||||
limitations: z.array(boundedTextSchema),
|
||||
limitations: z.array(textSchema),
|
||||
});
|
||||
|
||||
export const reconstructionObligationLedgerInputSchema = z.strictObject({
|
||||
|
||||
@@ -3,8 +3,8 @@ import { z } from "zod";
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const unknownIdSchema = z.string().regex(/^unk_[a-f0-9]{64}$/u);
|
||||
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
||||
const claimIdSchema = z.string().regex(/^[A-Za-z][A-Za-z0-9._-]{0,99}$/u);
|
||||
const titleSchema = z.string().trim().min(1).max(500);
|
||||
const claimIdSchema = z.string().regex(/^[A-Za-z][A-Za-z0-9._-]*$/u);
|
||||
const titleSchema = z.string().trim().min(1);
|
||||
const verificationStatusSchema = z.enum(["pass", "fail", "unknown"]);
|
||||
const commonClaim = {
|
||||
claim_id: claimIdSchema,
|
||||
@@ -56,7 +56,7 @@ const reconstructionClaimSchema = z.discriminatedUnion("kind", [
|
||||
/** Finite, typed behavioral and structural specification. */
|
||||
export const reconstructionSpecificationSchema = z
|
||||
.object({
|
||||
name: z.string().trim().min(1).max(200),
|
||||
name: z.string().trim().min(1),
|
||||
claims: z.array(reconstructionClaimSchema).min(1),
|
||||
})
|
||||
.superRefine((value, context) => {
|
||||
@@ -74,7 +74,7 @@ export const reconstructionSpecificationSchema = z
|
||||
});
|
||||
});
|
||||
|
||||
/** Bounded reconstruction-verification input. */
|
||||
/** Reconstruction-verification input. */
|
||||
export const reconstructionVerificationInputSchema = z.strictObject({
|
||||
specification: reconstructionSpecificationSchema,
|
||||
});
|
||||
@@ -119,8 +119,8 @@ export const reconstructionVerificationResultSchema = z
|
||||
}),
|
||||
recommended_probes: z.array(
|
||||
z.object({
|
||||
operation: z.string().min(1).max(200),
|
||||
rationale: z.string().min(1).max(1_000),
|
||||
operation: z.string().min(1),
|
||||
rationale: z.string().min(1),
|
||||
claim_ids: z.array(claimIdSchema).min(1),
|
||||
unknown_ids: z.array(unknownIdSchema),
|
||||
}),
|
||||
|
||||
@@ -48,15 +48,8 @@ export interface ReferenceSourceImportParseResult {
|
||||
readonly parse_failures: readonly ReferenceSourceParseFailure[];
|
||||
}
|
||||
|
||||
const MAX_REASON_LENGTH = 1_024;
|
||||
|
||||
const codeSourceLanguages = new Set(["JavaScript", "TypeScript", "JSX", "TSX"]);
|
||||
|
||||
const truncateReason = (reason: string): string =>
|
||||
reason.length > MAX_REASON_LENGTH
|
||||
? `${reason.slice(0, MAX_REASON_LENGTH - 3)}...`
|
||||
: reason;
|
||||
|
||||
const safeModuleName = (node: Node | null | undefined): string | undefined => {
|
||||
if (isStringLiteral(node)) return node.value;
|
||||
return undefined;
|
||||
@@ -333,7 +326,7 @@ export const parseReferenceSourceImports = (
|
||||
{
|
||||
path,
|
||||
parser: "babel",
|
||||
reason: truncateReason(reason ?? "Unknown parse failure"),
|
||||
reason: reason ?? "Unknown parse failure",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -59,7 +59,69 @@ describe("replay machine", () => {
|
||||
max_transitions: 2,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("replay machine long identifiers", () => {
|
||||
it("accepts long state, transition, and variable identifiers", () => {
|
||||
const initialState = `s${"t".repeat(255)}`;
|
||||
const terminalState = `s${"f".repeat(255)}`;
|
||||
const transitionId = `t${"r".repeat(255)}`;
|
||||
const variable = `v${"a".repeat(255)}`;
|
||||
const machine = {
|
||||
initial_state: initialState,
|
||||
states: [{ name: initialState }, { name: terminalState, terminal: true }],
|
||||
transitions: [
|
||||
{
|
||||
id: transitionId,
|
||||
from: initialState,
|
||||
to: terminalState,
|
||||
trigger: { protocol: "http", method: "GET", path: "/complete" },
|
||||
captures: [
|
||||
{
|
||||
variable,
|
||||
value: { source: "request_header", name: "x-value" },
|
||||
sensitive: false,
|
||||
},
|
||||
],
|
||||
actions: [{ type: "http_response", status: 200, body: "done" }],
|
||||
max_uses: 1,
|
||||
},
|
||||
],
|
||||
max_transitions: 1,
|
||||
};
|
||||
|
||||
expect(replayMachineSchema.parse(machine)).toMatchObject({
|
||||
initial_state: initialState,
|
||||
states: [{ name: initialState }, { name: terminalState }],
|
||||
transitions: [{ id: transitionId, captures: [{ variable }] }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("replay machine long delays", () => {
|
||||
it("accepts replay delays longer than one operating-system timer", () => {
|
||||
const machine: unknown = {
|
||||
...loginMachine(),
|
||||
transitions: loginMachine().transitions.map((transition, index) =>
|
||||
index === 0
|
||||
? {
|
||||
...transition,
|
||||
actions: [
|
||||
{ type: "delay", duration_ms: 2_147_483_648 },
|
||||
...transition.actions,
|
||||
],
|
||||
}
|
||||
: transition,
|
||||
),
|
||||
};
|
||||
|
||||
expect(
|
||||
replayMachineSchema.parse(machine).transitions[0]?.actions[0],
|
||||
).toEqual({ type: "delay", duration_ms: 2_147_483_648 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("replay machine validation", () => {
|
||||
it.each([
|
||||
[
|
||||
"unreachable state",
|
||||
|
||||
@@ -3,9 +3,7 @@ import { singleSource } from "graphology-shortest-path";
|
||||
import canonicalize from "canonicalize";
|
||||
import { z } from "zod";
|
||||
|
||||
const replayIdentifierSchema = z
|
||||
.string()
|
||||
.regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/u);
|
||||
const replayIdentifierSchema = z.string().regex(/^[A-Za-z][A-Za-z0-9_-]*$/u);
|
||||
const replayPathSchema = z.array(
|
||||
z.union([z.string(), z.number().int().nonnegative()]),
|
||||
);
|
||||
@@ -100,7 +98,7 @@ const replayActionSchema = z.discriminatedUnion("type", [
|
||||
z.strictObject({ type: z.literal("disconnect") }),
|
||||
z.strictObject({
|
||||
type: z.literal("delay"),
|
||||
duration_ms: z.number().int().nonnegative(),
|
||||
duration_ms: z.number().int().safe().nonnegative(),
|
||||
}),
|
||||
]);
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { recordUnknownInputSchema } from "./residualUnknown.js";
|
||||
|
||||
it("accepts complete unknown questions, environment details and probe guidance", () => {
|
||||
const longText = "x".repeat(4_097);
|
||||
const parsed = recordUnknownInputSchema.parse({
|
||||
question: longText,
|
||||
severity: "medium",
|
||||
domain: longText,
|
||||
required_authority: null,
|
||||
required_confidence: "inferred",
|
||||
required_environment: {
|
||||
id: longText,
|
||||
platform: longText,
|
||||
architecture: longText,
|
||||
isolation: "process",
|
||||
},
|
||||
recommended_probes: [{ operation: longText, rationale: longText }],
|
||||
relationships: [],
|
||||
});
|
||||
|
||||
expect(parsed.question).toHaveLength(4_097);
|
||||
expect(parsed.recommended_probes[0]?.operation).toHaveLength(4_097);
|
||||
});
|
||||
@@ -5,18 +5,18 @@ import { z } from "zod";
|
||||
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const unknownIdSchema = z.string().regex(/^unk_[a-f0-9]{64}$/u);
|
||||
const boundedText = z.string().trim().min(1).max(1_000);
|
||||
const text = z.string().trim().min(1);
|
||||
const environmentRequirementSchema = z.object({
|
||||
id: z.string().min(1).max(200).nullable(),
|
||||
platform: z.string().min(1).max(100).nullable(),
|
||||
architecture: z.string().min(1).max(100).nullable(),
|
||||
id: z.string().min(1).nullable(),
|
||||
platform: z.string().min(1).nullable(),
|
||||
architecture: z.string().min(1).nullable(),
|
||||
isolation: z
|
||||
.enum(["none", "process", "container", "virtual-machine"])
|
||||
.nullable(),
|
||||
});
|
||||
const probeSchema = z.object({
|
||||
operation: z.string().min(1).max(200),
|
||||
rationale: boundedText,
|
||||
operation: z.string().min(1),
|
||||
rationale: text,
|
||||
});
|
||||
const relationshipSchema = z.object({
|
||||
type: z.enum(["depends-on", "related-to", "contradicts"]),
|
||||
@@ -25,12 +25,12 @@ const relationshipSchema = z.object({
|
||||
const resolutionSchema = z.discriminatedUnion("disposition", [
|
||||
z.object({
|
||||
disposition: z.literal("verified"),
|
||||
rationale: boundedText,
|
||||
rationale: text,
|
||||
evidence_ids: z.array(evidenceIdSchema).min(1),
|
||||
}),
|
||||
z.object({
|
||||
disposition: z.enum(["withdrawn", "out-of-scope"]),
|
||||
rationale: boundedText,
|
||||
rationale: text,
|
||||
evidence_ids: z.array(evidenceIdSchema),
|
||||
}),
|
||||
]);
|
||||
@@ -48,7 +48,7 @@ const residualUnknownObjectSchema = z.object({
|
||||
.string()
|
||||
.regex(/^[a-f0-9]{64}$/u)
|
||||
.nullable(),
|
||||
question: boundedText,
|
||||
question: text,
|
||||
status: z.enum([
|
||||
"open",
|
||||
"investigating",
|
||||
@@ -57,7 +57,7 @@ const residualUnknownObjectSchema = z.object({
|
||||
"resolved",
|
||||
]),
|
||||
severity: z.enum(["low", "medium", "high", "critical"]),
|
||||
domain: z.string().trim().min(1).max(100),
|
||||
domain: text,
|
||||
supporting_evidence_ids: z.array(evidenceIdSchema),
|
||||
contradicting_evidence_ids: z.array(evidenceIdSchema),
|
||||
required_authority: z
|
||||
|
||||
@@ -6,7 +6,10 @@ import {
|
||||
} from "./javascriptApplicationGraph.js";
|
||||
import { createHistoricalSourceGraph } from "./referenceSourceGraph.js";
|
||||
import { compareSourceToBundle } from "./sourceToBundleComparison.js";
|
||||
import { sourceToBundleComparisonResultSchema } from "./sourceToBundleComparisonSchemas.js";
|
||||
import {
|
||||
SOURCE_TO_BUNDLE_SIGNAL_WEIGHTS,
|
||||
sourceToBundleComparisonResultSchema,
|
||||
} from "./sourceToBundleComparisonSchemas.js";
|
||||
import { artifactEvidence } from "./javascriptApplicationGraph.fixture.js";
|
||||
|
||||
const HASH = {
|
||||
@@ -148,6 +151,49 @@ describe("historical source to bundle comparison", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("source to bundle complete metadata", () => {
|
||||
it("accepts long source metadata and all reported limitations", () => {
|
||||
const result = compareSourceToBundle({
|
||||
reference: historicalGraph("complete"),
|
||||
application: {
|
||||
evidenceId: EVIDENCE_ID,
|
||||
rootArtifactSha256: HASH.artifact,
|
||||
graph: applicationGraph("complete"),
|
||||
},
|
||||
});
|
||||
const item = result.items[0];
|
||||
if (item === undefined) throw new Error("Expected a comparison item");
|
||||
|
||||
const parsed = sourceToBundleComparisonResultSchema.parse({
|
||||
...result,
|
||||
items: [
|
||||
{
|
||||
...item,
|
||||
source_path: "p".repeat(4_097),
|
||||
source_language: "l".repeat(101),
|
||||
limitations: Array.from(
|
||||
{ length: 101 },
|
||||
(_, index) => `gap-${index}`,
|
||||
),
|
||||
candidates: item.candidates.map((candidate) => ({
|
||||
...candidate,
|
||||
signals: Array.from({ length: 7 }, (_, index) => ({
|
||||
kind: SOURCE_TO_BUNDLE_SIGNAL_WEIGHTS[index % 6]?.[0],
|
||||
weight: SOURCE_TO_BUNDLE_SIGNAL_WEIGHTS[index % 6]?.[1],
|
||||
source_value: "v".repeat(4_097),
|
||||
current_values: ["v".repeat(4_097)],
|
||||
})),
|
||||
})),
|
||||
},
|
||||
],
|
||||
limitations: Array.from({ length: 1_001 }, (_, index) => `gap-${index}`),
|
||||
});
|
||||
|
||||
expect(parsed.items[0]?.limitations).toHaveLength(101);
|
||||
expect(parsed.limitations).toHaveLength(1_001);
|
||||
});
|
||||
});
|
||||
|
||||
const historicalGraph = (
|
||||
inventoryState: "complete" | "partial",
|
||||
paths = [
|
||||
|
||||
@@ -7,7 +7,7 @@ import { historicalSourceGraphSchema } from "./referenceSourceGraph.js";
|
||||
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
||||
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const nodeIdSchema = z.string().regex(/^jag_node_[a-f0-9]{64}$/u);
|
||||
const boundedTextSchema = z.string().min(1).max(4_096);
|
||||
const textSchema = z.string().min(1);
|
||||
|
||||
export const SOURCE_TO_BUNDLE_SIGNAL_WEIGHTS = [
|
||||
["exact-source-digest", 100],
|
||||
@@ -36,8 +36,8 @@ export const compareSourceToBundleInputSchema = z.strictObject({
|
||||
const sourceToBundleSignalSchema = z.strictObject({
|
||||
kind: sourceToBundleSignalKindSchema,
|
||||
weight: z.number().int().min(1).max(100),
|
||||
source_value: boundedTextSchema,
|
||||
current_values: z.array(boundedTextSchema).min(1),
|
||||
source_value: textSchema,
|
||||
current_values: z.array(textSchema).min(1),
|
||||
});
|
||||
|
||||
const sourceToBundleCandidateSchema = z.strictObject({
|
||||
@@ -45,14 +45,14 @@ const sourceToBundleCandidateSchema = z.strictObject({
|
||||
current_node_kind: z.enum(JAVASCRIPT_APPLICATION_NODE_KINDS),
|
||||
score: z.number().int().min(1).max(300),
|
||||
confidence: z.enum(["exact", "high", "medium", "low"]),
|
||||
signals: z.array(sourceToBundleSignalSchema).min(1).max(6),
|
||||
signals: z.array(sourceToBundleSignalSchema).min(1),
|
||||
});
|
||||
|
||||
const sourceToBundleItemSchema = z.strictObject({
|
||||
mapping_id: z.string().regex(/^stbc_item_[a-f0-9]{64}$/u),
|
||||
source_path: boundedTextSchema,
|
||||
source_path: textSchema,
|
||||
source_sha256: digestSchema.nullable(),
|
||||
source_language: z.string().min(1).max(100).nullable(),
|
||||
source_language: textSchema.nullable(),
|
||||
status: z.enum([
|
||||
"unchanged",
|
||||
"modified",
|
||||
@@ -65,7 +65,7 @@ const sourceToBundleItemSchema = z.strictObject({
|
||||
confidence: z.enum(["exact", "high", "medium", "unknown"]),
|
||||
current_node_ids: z.array(nodeIdSchema),
|
||||
candidates: z.array(sourceToBundleCandidateSchema),
|
||||
limitations: z.array(boundedTextSchema).max(100),
|
||||
limitations: z.array(textSchema),
|
||||
});
|
||||
|
||||
/** Deterministic, evidence-bearing historical-source to shipped-bundle comparison. */
|
||||
@@ -115,7 +115,7 @@ export const sourceToBundleComparisonResultSchema = z.strictObject({
|
||||
candidate_evaluations: z.number().int().min(0),
|
||||
}),
|
||||
evidence_links: z.array(evidenceIdSchema).min(1).max(1),
|
||||
limitations: z.array(boundedTextSchema).max(1_000),
|
||||
limitations: z.array(textSchema),
|
||||
});
|
||||
|
||||
export type SourceToBundleComparisonResult = z.infer<
|
||||
|
||||
@@ -47,7 +47,7 @@ const observedPatternSchema = z.enum([
|
||||
const artifactSelectorSchema = z
|
||||
.object({
|
||||
kind: z.literal("artifact"),
|
||||
logical_path: z.string().min(1).max(4_096),
|
||||
logical_path: z.string().min(1),
|
||||
})
|
||||
.strict();
|
||||
const functionSelectorSchema = z
|
||||
@@ -75,7 +75,7 @@ const mappingSchema = z
|
||||
side_alignment: z.enum(["left_to_left", "left_to_right"]),
|
||||
hypothesis: z
|
||||
.object({
|
||||
statement: z.string().trim().min(1).max(500),
|
||||
statement: z.string().trim().min(1),
|
||||
expected_pattern: expectedPatternSchema,
|
||||
})
|
||||
.strict(),
|
||||
@@ -110,7 +110,7 @@ const correlationItemSchema = z.object({
|
||||
}),
|
||||
side_alignment: z.enum(["left_to_left", "left_to_right"]),
|
||||
hypothesis: z.object({
|
||||
statement: z.string().min(1).max(500),
|
||||
statement: z.string().min(1),
|
||||
expected_pattern: expectedPatternSchema,
|
||||
}),
|
||||
observed_pattern: observedPatternSchema,
|
||||
|
||||
@@ -98,7 +98,7 @@ it("correlates every supplied mapping and accepts complete comparison lists", ()
|
||||
...mapping,
|
||||
hypothesis: {
|
||||
...mapping.hypothesis,
|
||||
statement: `Hypothesis ${i}`,
|
||||
statement: `Hypothesis ${i} ${"x".repeat(600)}`,
|
||||
},
|
||||
}));
|
||||
const input = {
|
||||
@@ -116,6 +116,10 @@ it("correlates every supplied mapping and accepts complete comparison lists", ()
|
||||
expect(
|
||||
staticRuntimeCorrelationInputSchema.parse(input).mappings,
|
||||
).toHaveLength(501);
|
||||
expect(
|
||||
staticRuntimeCorrelationInputSchema.parse(input).mappings[0]?.hypothesis
|
||||
.statement.length,
|
||||
).toBeGreaterThan(500);
|
||||
const fullInput = {
|
||||
...input,
|
||||
static_comparisons: [FUNCTION_COMPARISON_EVIDENCE],
|
||||
|
||||
@@ -82,7 +82,7 @@ const sourceMapSchema = z.union([
|
||||
const webTextArtifactSummarySchema = z.object({
|
||||
sha256: z.string().regex(/^[a-f0-9]{64}$/u),
|
||||
bytes: z.number().int().min(0),
|
||||
media_type: z.string().min(1).max(256),
|
||||
media_type: z.string().min(1),
|
||||
charset: z.literal("utf-8"),
|
||||
text_available: z.literal(true),
|
||||
});
|
||||
|
||||
@@ -164,6 +164,30 @@ describe("web bundle analyzer", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("web bundle artifact metadata", () => {
|
||||
it("preserves long provider media types in artifact summaries", () => {
|
||||
const result = analyzeCapturedWebBundle(inspection("export {};"));
|
||||
const mediaType = `application/${"x".repeat(300)}`;
|
||||
const artifact = result.capture.source_artifacts[0] ?? {
|
||||
sha256: "0".repeat(64),
|
||||
bytes: 0,
|
||||
media_type: "application/javascript",
|
||||
charset: "utf-8" as const,
|
||||
text_available: true as const,
|
||||
};
|
||||
|
||||
expect(
|
||||
webBundleAnalysisSchema.parse({
|
||||
...result,
|
||||
capture: {
|
||||
...result.capture,
|
||||
source_artifacts: [{ ...artifact, media_type: mediaType }],
|
||||
},
|
||||
}).capture.source_artifacts[0]?.media_type,
|
||||
).toBe(mediaType);
|
||||
});
|
||||
});
|
||||
|
||||
const inspection = (source: string) =>
|
||||
webPageInspectionSchema.parse({
|
||||
browser: {
|
||||
|
||||
Reference in New Issue
Block a user