fix(entropy): name offset when the byte window starts past EOF (#6495)

Fixes #6482

Co-authored-by: Abelo9996 <Abelo9996@users.noreply.github.com>
This commit is contained in:
Abel YagubyanandAbelo9996 authored and GitHub committed 2026-10-23 23:42:07 +09:00
1 parent 8f91e60558
commit e8dad898da
3 files changed
+23 -2

No files matched your search

+1 -1
View File
@@ -116,5 +116,5 @@ Then rerun this installer.",implemented,verified by shell branch inspection
90,install.sh:version mismatch,Installed rea reports a different version,installed version ACTUAL does not match EXPECTED.,Low risk; gives exact integrity mismatch,Keep current copy,unchanged,verified by exact installer test
90.5,@modelcontextprotocol/server:tool input validation,Caller sends arguments that violate a declared tool schema,"Canonical invalid_request with the SDK diagnostic plus recovery.kind=inspect_input_contract and a bounded instruction to read the advertised schema or call tools/list",Keeps field/type correction while telling the agent how to recover; diagnostics over 4 KiB stay on the existing retained-error path,Normalize ordinary validation failures and retain oversized diagnostics,verified by real in-memory and stdio MCP client/server calls with wrong argument types
90.6,incur:unknown CLI command,Caller enters an unknown REA command,"'COMMAND' is not a command for 'rea'. Suggested command: rea --help",Low risk; identifies input and exact discovery action,Keep framework-generated copy,unchanged,verified by real packaged dispatcher invocation
91,src/application/binaryDiagnostics/ByteEntropyService.ts,Invalid file or window,"Expected a regular file.; Selected file could not be found.; Selected byte window extends beyond the end of the file.; File size exceeds exact numeric offset representation.",Invalid selection cannot produce complete entropy Evidence,Choose a readable regular file and a window within its byte size,implemented,entropy service and MCP boundary tests
91,src/application/binaryDiagnostics/ByteEntropyService.ts,Invalid file or window,"Expected a regular file.; Selected file could not be found.; Selected byte window starts beyond the end of the file.; Selected byte window extends beyond the end of the file.; File size exceeds exact numeric offset representation.",Invalid selection cannot produce complete entropy Evidence,Choose a readable regular file and a window within its byte size,implemented,entropy service and MCP boundary tests
92,src/domain/analysisView/byteEntropyView.ts,Non-summary entropy view,Byte entropy Evidence supports the summary view; retrieve parent Evidence for the complete block series.,Unsupported view selection,Use the summary view or retrieve complete parent Evidence,implemented,typed input rejection
1 harm_rank location trigger current_copy user_risk proposed_replacement implementation_status verification_result
116
117
118
119
120
@@ -69,6 +69,22 @@ it("rejects missing files, non-files and windows beyond EOF, but accepts empty w
).toContainEqual(expect.stringContaining("reports a size of 0"));
});
it.each([
[{ offset: 2048 }, "offset"],
[{ offset: 2048, length: 0 }, "offset"],
[{ offset: 512, length: 1024 }, "length"],
])("names the selector that puts %o past EOF", async (window, field) => {
const root = await createTestTempDirectory("rea-entropy-window-");
const path = join(root, "bytes");
await writeFile(path, Buffer.alloc(1024));
const result = await new ByteEntropyService().inspect({ path, ...window });
if (result.ok) throw new Error("Expected an out-of-file window to fail");
expect(projectAnalysisError(result.error)).toMatchObject({
code: "invalid_request",
details: { issues: [{ path: [field], reason: "invalid_value" }] },
});
});
it.skipIf(process.platform !== "linux")(
"marks a generated /proc file that reports size 0 as not shown empty",
async () => {
@@ -202,8 +202,13 @@ export class ByteEntropyService {
"path",
"File size exceeds exact numeric offset representation.",
);
if (input.offset > size)
throw invalid(
"offset",
"Selected byte window starts beyond the end of the file.",
);
const length = input.length ?? size - input.offset;
if (input.offset > size || length > size - input.offset)
if (length > size - input.offset)
throw invalid(
"length",
"Selected byte window extends beyond the end of the file.",