fix(json): preserve runtime limits across JSON file readers (#1350)

* fix(cli): preserve runtime JSON string-limit diagnostics

* test(json): check actionable oversized Evidence recovery

* fix(json): decode large UTF-8 inputs by character length

* test(json): reject truncated UTF-8 after large input decode
This commit is contained in:
Ysopwnable
2026-10-09 19:39:35 +00:00
committed by GitHub
parent 750fb65650
commit 9c4a68bc19
8 changed files with 232 additions and 81 deletions
@@ -8,6 +8,7 @@ import {
EvidenceIntegrityError,
} from "../../domain/evidenceErrors.js";
import { err, ok, type Result } from "../../domain/result.js";
import type { AnalysisResourceConstraintError } from "../../domain/analysisErrorCore.js";
import { readJsonFile, writeTextFile } from "../JsonFiles.js";
type SnapshotFailure = EvidenceFileError | EvidenceIntegrityError;
@@ -15,7 +16,9 @@ type SnapshotFailure = EvidenceFileError | EvidenceIntegrityError;
/** Read and validate an analysis snapshot from the caller's path. */
export const readAnalysisSnapshot = async (
path: string,
): Promise<Result<AnalysisSnapshot, SnapshotFailure>> => {
): Promise<
Result<AnalysisSnapshot, SnapshotFailure | AnalysisResourceConstraintError>
> => {
const loaded = await readJsonFile(path);
if (!loaded.ok) return loaded;
try {