Skip to content

test(native): bound section lookups by table reads instead of elapsed time - #11648

Merged
morluto merged 1 commit into
mainfrom
test/elapsed-time-counters
Nov 16, 2026
Merged

morluto merged 1 commit into
mainfrom
test/elapsed-time-counters

Conversation

@morluto

@morluto morluto commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Summary

Refs #10513 (native parser family). Four wall-clock bounds in three native parser test files are replaced by deterministic work counts or deleted where an existing assertion already detects the regression. Each change is checked against a mutant that reintroduces the regression.

Problem and expected behavior

The bounds (expect(performance.now() - started).toBeLessThan(1_000 | 5_000 | 10_000)) can fail on a loaded CI shard without a regression, and two of them did not detect the regression they were written for.

Change and scope

  • PeLoadConfigParser.test.ts (1 bound): the test wraps readPeImage's sections and mappings in a counting proxy and asserts at most 4 x 65535 element reads for 4096 callbacks over 65,535 sections (measured 131,071). The proxy throws past the budget, so a regression fails at once instead of running for seconds.
  • NativeInitializersParsers.test.ts (2 bounds):
    • near-maximal section table: the same counting proxy on readElfDirectoryFromBuffer sections, budget 12 x 65535 (measured 393,222, about one walk per consumer).
    • huge DT_INIT_ARRAYSZ: the existing createFileMappingIndex spy now counts offset lookups; the test asserts fewer than MAX_NATIVE_INITIALIZER_ENTRIES + 1024 (measured 66,194). The old bound and the examined_entries assertion both missed a 4x slot budget, because unbacked slots are not counted as examined.
  • KernelModuleParser.test.ts (1 bound): deleted. With the section-name cache removed, the module exceeds the 16 MiB section-name budget and the test already fails.

No production code changes. Not included: the other #10513 families (lifecycle and cancellation bounds, JavaScript/web, Go strings, Solidity, managed artifacts, source maps); WabtOutput, ElfNoteParser and javascriptRouteScan guard regex backtracking (#10783).

Contribution scope: within existing boundaries.

Contract and boundary impact

  • Semantic owner and earliest changed stage: tests only.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

Mutants (each applied alone to the production file, then restored):

  • PE: a per-lookup walk over sections inside the section-name lookup fails the PE test (budget exceeded).
  • ELF initializers: a per-lookup walk over sections in nameAt fails the near-maximal test.
  • ELF initializers: clamping the slot loop at 4x the budget fails the DT_INIT_ARRAYSZ test; before this change it passed.
  • Kernel modules: disabling the decodedNames cache in nativeSectionDirectory.ts fails the shared-name test without its bound.
  • Remaining proof gaps: the counting proxies observe element reads of the parsed tables, not other per-lookup work; a regression that rescans a different structure is not covered.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- src/native/elf/KernelModuleParser.test.ts src/native/initializers/NativeInitializersParsers.test.ts src/native/pe/PeLoadConfigParser.test.ts: 207 passed (1.6 s).
  • The four mutants above, each with npm run test:focused on the affected file: each fails the intended test only.
  • npm run check:fast: passed. npx oxfmt on the changed files.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (tests only).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

… time

PE TLS callback and ELF initializer section lookups now assert section-table reads through a counting proxy on the parsed image, and the huge DT_INIT_ARRAYSZ case asserts mapping lookups. The kernel-module shared-name bound is deleted: removing the section-name cache already fails that test on the 16 MiB name budget.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-16T01:46:29.265084Z
We couldn’t complete this review. Comment @codex review to try again.
040d659 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; the replacement assertions retain the intended regression checks.

Summary

This test-only PR replaces four elapsed-time checks with counted work or existing assertions.

  • PE callback tests count section-table reads instead of elapsed time.
  • ELF initializer tests count mapping lookups for oversized arrays.
  • ELF initializer tests bound section-table reads for full slot scans.
  • Kernel module tests rely on existing results instead of a time limit.

No actionable issues were found. Source review only; tests and mutation checks were not rerun. Supersession could not be checked because GitHub authentication was unavailable.

Acknowledged coverage limit: morluto explicitly notes that the proxies do not detect repeated walks over other structures.

Reviews (1) · Last reviewed commit: "test(native): bound section lookups by t..." · Reviewed by Greptile

@morluto
morluto merged commit 8318d28 into main Nov 16, 2026
7 checks passed
@morluto
morluto deleted the test/elapsed-time-counters branch November 16, 2026 01:58
@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant