mirror of
https://github.com/morluto/rea.git
synced 2026-12-02 11:33:10 +00:00
3f4e24bced143e6bb261d4269f18dd39e23c128f
163
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2c78ff1f75 |
fix(cli): reject non-integer output filter indices (#15491)
Co-authored-by: hhang <169027046+xu91102@users.noreply.github.com> |
||
|
|
82613c0ace |
fix(session): never overwrite the open target with a snapshot or bundle (#15449)
* fix(session): never overwrite the open target with a snapshot or bundle * test(session): cover a hard-linked target and own the test directory cleanup |
||
|
|
dfc987577e |
fix(cli): honor index and open-ended output selectors (#15417)
* fix(cli): honor index and open-ended output selectors * test(cli): count tokens for the selected array-shaped output |
||
|
|
b26c2ddd57 | fix(mcp): admit declared hosts on a loopback HTTP bind (#15439) | ||
|
|
1a85e2f4f5 | docs(clients): state client tool-count limits and how to narrow REA's catalog (#15446) | ||
|
|
089dfa3a8b |
fix(setup): derive client deadlines from one record per client (#15371)
* fix(setup): derive client deadlines from one record per client Each supported client definition now declares the MCP deadlines it applies to REA's server: key, unit, built-in default, maximum, coverage and whether progress resets it. Setup raises a shorter or missing deadline to REA's recommendation within the client's maximum and keeps a longer one; doctor reports the same shortfall from the same record. Cline, Zed, Antigravity, Hermes, Goose and Gemini CLI gain deadlines; the codex/kimi/grok/dsh name branches, the Goose timeout literal and the per-client startup constants are removed. Refs #15337 * fix(setup): keep a raised Goose timeout over a short inherited one and expect Antigravity's deadline |
||
|
|
3394771745 |
docs(cline): explain heap exhaustion and how to raise each heap (#15394)
* docs(cline): explain heap exhaustion and how to raise each heap A JavaScript heap out-of-memory error under Cline over Remote-SSH usually comes from VS Code's extension host, which keeps every tool result for the task, not from REA. Name which process it is, how to raise each heap, and the regex worker side effect of raising REA's. Refs #15330 * docs(cline): add NODE_OPTIONS to the existing launch env, inside nested transport |
||
|
|
1f233d091e |
docs(install): review a pinned release script before the curl installer (#14451)
Co-authored-by: Vincent Koc <vincentkoc@ieee.org> |
||
|
|
3772cab2e5 | docs(godot): include PCK format 1 in supported formats (#15270) | ||
|
|
86d15047a9 | docs(cli): list endpoint comparison among evidence-bundle commands (#15274) | ||
|
|
2afad5b789 |
fix(setup): honor OpenCode system, managed and policy configuration (#15081)
Discover the OpenCode system and managed layers and honor their effective MCP policy when planning, publishing, diagnosing, or removing registrations. Preserve the writable layer's dialect and verify effective registration and policy after publication. Fixes #15036. Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> |
||
|
|
061239a5de |
fix(setup): follow the registration Copilot, Codex, and Kiro load (#15230)
Follow the effective Copilot, Codex, and Kiro MCP registration. Use the same resolved Kiro agent file for the approval plan and the write. Fixes #15032. Fixes #15034. Fixes #15035. Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> |
||
|
|
a4d89b9eb1 | docs(setup): correct removed npx cache repair guidance (#15254) | ||
|
|
9e32fae01d |
docs: keep onboarding text understandable for everyone (#15253)
* docs: keep onboarding and recovery text plain for everyone AGENTS.md now asks for jargon-free onboarding, setup, update and recovery text, and the installation guide describes the npx cache repair. * docs(agents): ask for understandable onboarding text |
||
|
|
9a4e2df67f |
revert(setup): restore npx rea-agents setup (#15245)
Revert "fix(setup): do not persist versioned launcher paths (#15123)"
This reverts commit
|
||
|
|
1a63844638 |
docs(install): another REA installation's launcher is owned, not foreign (#15239)
installation.md said a registration pointing at a different installation path is foreign, so setup blocks until the entry is renamed or removed. Setup treats a launcher of another installed rea-agents package as owned with a stale state and migrates it to the selected installation. Scope the foreign sentence to launchers that do not prove REA ownership. Co-authored-by: Vincent Koc <vincentkoc@ieee.org> |
||
|
|
490461938b |
fix(update): drain output after progress destination closes (#4894)
* fix(update): bound package-manager output collection * fix(update): drain output after progress destination closes * test(update): use shared progress test deadlines |
||
|
|
b0a910b8f4 |
fix(update): report Frida native module readiness (#7216)
fix(update): report Frida readiness after verified updates |
||
|
|
d840860bd7 |
feat(mcp): advertise each tool's family in tools/list _meta (#7154)
* feat(mcp): advertise each tool's family in tools/list _meta Clients that index a large catalog lazily had to guess each REA tool's group from its name. Every tools/list entry now carries the contract's adapter family under the vendor-prefixed _meta key "io.github.morluto/rea", attached once at the contract-to-registration boundary. The recorded catalog replays it unchanged on the deferred path. No tool is hidden or renamed and input schemas are unchanged. Closes #6870 * refactor(mcp): advertise the selectable family id in tools/list _meta Since #7228 the contract-owned family inventory gives every tool one selectable id, the vocabulary REA_MCP_TOOL_FAMILIES accepts. Advertise that id instead of the adapter kind so clients can map an advertised tool back to the scope that enables it. * fix(mcp): omit family metadata for contracts outside the inventory Renamed test fixtures have no published family; advertise nothing for them instead of throwing. Drop the docs claim that a family move changes the catalog digest, since the digest hashes the adapter kind. * docs(mcp): scope family _meta promise to domain tools; pin catalog env in test --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org> |
||
|
|
92c61a7c61 |
fix(setup): do not persist versioned launcher paths (#15123)
* fix(setup): do not persist versioned launcher paths A command saved from nvm, Volta, Homebrew Cellar, mise, or a package cache stops launching after an upgrade or prune, and doctor then treats that registration as foreign. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(setup): recognize default nvm installation layouts The usual POSIX install is ~/.nvm/versions/node, and nvm-windows stores each release in nvm\v<version>. Both were still saved, and the launcher guide still told setup to keep a cache path. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(setup): keep durable Windows and mise launcher paths Default Windows Volta and pnpm dlx stores were still persisted, and mise's stable latest alias was dropped before the Aube launcher could use it. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(setup): keep a mise shim when Node itself is versioned A versioned running runtime was rejected before a durable Node alias could be selected, and fnm's installed tree was still saved. Doctor now tells version-manager and package-cache paths apart from a session directory. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(setup): reject versioned aube store targets and align install routes Reject version-tagged node_modules/.mise store targets beneath mise latest aliases (while keeping verified outer Aube shims), reject asdf/nodenv/nvs/nix/snap versioned paths, fix the nvm-sensitive Windows runtime assertion in setupLauncherAlias tests, and align installation docs, install.sh, and getting-started guidance with durable-path registration. * fix(setup): recognize custom manager env roots and align onboarding docs Pass environment through versionedLauncherPath and transientLauncherRemediation so custom version-manager env roots are classified accurately while preserving fnm_multishells as a session path; fix Windows PowerShell rea.cmd and Linux PATH persistence in get-started; align remaining setup quick starts and affected setup acceptance/boundary tests. * fix(setup): reject session paths and configured package caches Windows fnm session directories and custom npm or Bun cache roots were still eligible for client registration. Quick starts now require a durable Node install, and the website setup copy no longer uses a PowerShell-invalid command chain. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(setup): resolve configured launcher roots * docs(setup): align persistent launcher prerequisites * docs(setup): persist paths in Bash login profiles * fix(setup): name the missing saved launcher path * fix(setup): reject Bunx execution-cache launchers * docs(setup): add writable npm prefix prerequisite * style(website): format prefix prerequisites * chore(website): format setup introduction --------- Co-authored-by: Ambuj Agrawal <aseachambuj@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Vincent Koc <vincentkoc@ieee.org> |
||
|
|
eb5cd34258 |
fix(devicetree): read later FDT versions backwards compatible with v17 (#14136)
* fix(devicetree): read later FDT versions backwards compatible with v17 The header reader admitted only versions 16 and 17 and consulted last_comp_version only to reject a value above the version. DTSpec 5.1 requires a client to accept any version backwards compatible with version 17, and libfdt reads such a blob with the version 17 header. Admit a later version whose last_comp_version is 17 or lower and read it with the version 17 layout, reporting the declared version. A later version that needs a newer reader and any version below 16 stay unsupported, and v16 and v17 outcomes are unchanged. FIT recognition shares the reader, so it now claims a FIT in such a version as well. * test(devicetree): cover a later FDT version backwards compatible with v17 Parse the shared fixture with version 18 and last_comp_version 16: the header is read with the version 17 layout and the tree decodes as it does for v17. Raising last_comp_version to 18 keeps the blob unsupported. FIT recognition, which shares the header reader, covers the same version. On the previous reader the version 18 parse and the version 18 FIT recognition fail, because version 18 was refused before last_comp_version was read. * docs(devicetree): describe later FDT versions backwards compatible with v17 * test(devicetree): keep the unsupported-version cases on an incompatible header The CLI and MCP error cases used version 18 as an arbitrary unsupported version, but their fixture declares last_comp_version 16, which is now read as a version 17 blob. Declare last_comp_version 18 there so both cases still reach unsupported_target through the public paths. The shared fixture takes the declared compatibility version for this, and the parser case uses it instead of patching the header word. * test(devicetree): cover compatible versions through CLI and MCP --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org> |
||
|
|
5e51d46a31 |
docs(setup): explain one-off CLI use without MCP registration (#14973)
* docs(setup): explain one-off CLI use without MCP registration * docs(setup): put package-runner trust requirement beside CLI example |
||
|
|
fc6867c514 |
chore(main): release rea-agents 7.0.0 (#15143)
* chore(main): release rea-agents 6.11.0 * chore(release): finalize REA 7.0.0 notes and metadata * chore(release): format the 7.0.0 contribution inventory * docs(release): highlight firmware and embedded CPU support --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
2ce4471c9f |
fix(setup): honor KIRO_HOME for the Kiro user configuration (#15056)
* fix(setup): honor KIRO_HOME for the Kiro user configuration * fix(setup): fall back when KIRO_HOME is any filesystem root The ancestor check compared the selected root against home with path.relative, which returns an absolute path across drives, so a KIRO_HOME of D:\ or a UNC share root was accepted while Kiro itself falls back to ~/.kiro. Check the selected path against its own root separately, and document the override in the client configuration guide. * test(setup): clear KIRO_HOME from lifecycle test environments The client-location scrubber omitted KIRO_HOME, so lifecycle tests calling supportedClients/detectClients and systemUninstallHost with the default process.env could resolve a runner-exported KIRO_HOME outside their temporary home and touch the real Kiro registration. * fix(setup): resolve Kiro home aliases before selecting a profile * refactor(setup): use the captured host platform for Kiro path checks --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
8306fba960 |
fix(ghidra): list compatible installed JDKs in doctor remediation (#15099)
* fix(ghidra): list compatible installed JDKs in doctor remediation * refactor(ghidra): derive doctor JDK candidates from installation admission Candidate discovery now consumes the installation's parsed Java requirement, its Java-side admission (bounds, 64-bit JDK, and the os.name/os.arch native directory), its bounded probe environment, and its PATH and Homebrew enumeration instead of re-deriving them. - Expose javaRequirement on the installation inspection; doctor read a field that did not exist, so discovery never ran. - Search only when configuration passed and the Java probe failed. - Enumerate macOS JavaVirtualMachines roots instead of running java_home, removing the unowned listing subprocess. - Add PATH launchers on every platform, including Windows java.exe. - Filter Homebrew formulae before selection and drop the fixed entry and probe caps; realpath deduplication bounds probes by distinct JDKs. - Propagate cancellation from aborted searches and failed probes. - Report candidates as structured compatible_jdks details. * refactor(ghidra): share installation discovery seams with JDK candidates * refactor(ghidra): name discovered JDKs as the Java remediation When doctor finds compatible JDKs, the remediation names them instead of appending them to the generic selection advice. Document the search and details.compatible_jdks. * refactor(ghidra): split installation inspection into owned modules GhidraInstallation.ts gathers installation facts; the judgments and helpers move to their owners: - GhidraInstallationChecks: configuration, version, headless, native decompiler, and Java checks and their remediation. - GhidraJavaSelection: JVM selection, probing, and Homebrew fallback, extracted from installationCoordinates, plus the Java helpers that JDK discovery shares. - GhidraNativePlatform: native directory tables, decompiler header assessment, and JVM os.name/os.arch mapping. - GhidraInstallationPathDiscovery: Ghidra launcher discovery on PATH. - GhidraExecutableHeaderProbe now lives with its producer. Java selection resolves the PATH launcher on every platform, so the installation records the absolute command it probed. JDK discovery then recognises it and does not launch the same Linux JVM twice. --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
7e71400a7c |
fix(setup): read Devin project MCP configuration (#15101)
* fix(setup): read Devin project MCP configuration Devin loads .devin/mcp_config.json and .devin/mcp_config.local.json from the working directory up to the nearest .git or .jj, above the user file. A local file outranks every shared file, and a nested directory outranks its ancestors. REA only read the user file, so doctor judged it while Devin ran a project entry, and project uninstall skipped Devin. Return Devin's project candidates in that order, evaluate them with whole-definition replacement, and include Devin in project uninstall. Setup still writes only the user file. Fixes #15041 * fix(setup): apply Devin precedence by directory --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
3474d40489 |
fix(setup): use native Copilot configuration for VS Code (#15098)
* fix(setup): use native Copilot configuration for VS Code * fix(setup): preserve the legacy VS Code updater contract * docs: clarify Copilot doctor and uninstall commands * test(setup): check the configured client in BOM round trips * test(ci): publish Pascal compiler readiness atomically --------- Co-authored-by: Abotboot <173614984+Abotboot@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
993c693bc1 |
fix(setup): read Amp workspace MCP settings (#15102)
* fix(setup): read Amp workspace MCP settings Amp reads the nearest .amp/settings.json or .amp/settings.jsonc from the working directory up to the repository root (only the working directory outside a Git repository), and a workspace amp.mcpServers entry takes precedence over the user entry with the same name. REA only read ~/.config/amp/settings.json, so doctor and setup judged a registration Amp does not run and project uninstall left the workspace row in place. The effective registration reader now admits Amp's workspace layer and selects one whole server definition per name. Both workspace files in the same directory are refused, as for the user settings, because Amp does not document which one wins. Project uninstall includes Amp. Fixes #15037 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(setup): share Amp settings names and the existence check Reuse one existence check for OpenCode's user path and Amp's workspace walk, name the Amp settings files once, and name the formats whose effective registration includes project layers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(setup): describe Amp workspace settings selection Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(setup): honor Amp workspace selection and approval scope * fix(setup): retain Amp launcher repair alongside approval guidance --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
cbdcea12a3 |
fix(setup): write Windsurf Cascade settings to its native config (#15132)
* fix(setup): write Windsurf Cascade settings to its native config * fix(doctor): surface older Windsurf registrations --------- Co-authored-by: Jatin Pandey <279688498+JayDev-27@users.noreply.github.com> |
||
|
|
8e62e1c7ae |
fix(setup): honor Mastra Code project registrations in doctor (#15122)
* fix(setup): honor Mastra Code project registrations in doctor * fix(doctor): share Mastra Code project scope with provider diagnostics * fix(doctor): cancel Mastra Code registration discovery * fix(doctor): retain structured Mastra Code cancellation --------- Co-authored-by: Jatin Pandey <279688498+JayDev-27@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
43f7680c1f |
fix(setup): support Antigravity workspace .agents/mcp_config.json (#15125)
* fix(setup): support Antigravity workspace .agents/mcp_config.json * fix(setup): verify Antigravity project writes and repository lookup * fix(setup): confine project registration to the selected workspace * fix(mcp): enforce write scope for every project registration * test(setup): use existing project root in Kilo layer conflict test --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
a3be3f429a |
fix(setup): honor Mastra Code's MCP disable flag (#15126)
* fix(setup): report Mastra Code's MASTRACODE_DISABLE_MCP switch Mastra Code reads MASTRACODE_DISABLE_MCP at startup and stops loading every MCP source. REA's client table has no such fact, so doctor kept reporting ~/.mastracode/mcp.json as aligned while Mastra started no server, and setup rewrote a registration the running client ignores. readClientPolicyBlock now answers for mastracode through a small module of its own. The value is truthy only for 1/true/yes/on, case-insensitively and after trimming, matching Mastra Code's isTruthyEnv. Doctor, setup's inspect/configure and mcp add pass the launcher environment they already resolve, so a supplied environment decides the outcome instead of the host process.env. The documented load order also lists the project .mcp.json, which this change does not read yet; #15038 stays open for that half. Tests: mastracodePolicySources (13, new) covers the value table; mastracodeDisabledRegistration (2, new) covers status, setup refusal and an unchanged file; geminiPolicySources (4) and setupPolicySnapshot (7) still pass. check:fast is green across 3328 files. The CLI boundary suite mcpAddClientPolicy needs a compiled dist/cli-runtime and was not run. Refs #15038 (cherry picked from commit 4e5ea523f4a4c3040c7d172758558fb6a0241966) * fix(setup): enforce the Mastra flag for project MCP registration * style(test): format Mastra MCP regression * test(doctor): prove the Mastra disable policy gates a valid launcher --------- Co-authored-by: 2SinceJuly <202121119+2SinceJuly@users.noreply.github.com> |
||
|
|
4170a4ce40 |
fix(setup): honor Claude Code local managed MCP policy (#15127)
* fix(setup): honor Claude Code local managed MCP policy * test(setup): cover Claude project registration under managed MCP * fix(doctor): report Claude name denies before missing config |
||
|
|
6537e35fa7 |
fix(setup): honor Qwen Code MCP settings precedence (#15131)
* fix(setup): honor Qwen Code MCP settings precedence * fix(setup): preserve Qwen settings identity and readiness |
||
|
|
3928b3981a |
fix(setup): preserve native Codex registration settings (#15119)
* fix(setup): preserve native Codex registration settings * test(setup): verify nested Grok settings by their parsed values * test(setup): preserve fractional Codex seconds alongside milliseconds |
||
|
|
88dfef4e33 |
docs(setup): describe refreshing another installation's registration
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> |
||
|
|
a23a30c41d |
docs(cli): name the code for every argument parse failure
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> |
||
|
|
88373e3fba |
feat(apple): inspect Image4 (IMG4, IM4P, IM4M) firmware containers offline (#14907)
* feat(apple): inspect Image4 (IMG4, IM4P, IM4M) firmware containers offline Image4 files are recognized from a DER SEQUENCE whose first element is the IA5String IMG4, IM4P, or IM4M, independent of the filename, and are inventoried as apple-img4. The stored payload octet string is exposed as payload, the embedded IM4M sequence as manifest.der, and the IM4R sequence as restore-info.der. Keybags contribute a count and key types, with initialization vectors and keys left out of metadata; an encrypted payload is refused on open; signatures and certificates are reported by size; LZFSE and complzss payloads stay compressed; IM4R property names are listed and their values stay redacted. Four fixed allowances refuse excessive DER depth, element count, property count, and string length, and inventory coverage is unknown whenever a limitation is recorded. * fix(apple): read Image4 fields by universal tag and position Compare universal tag numbers instead of identifier octets, so constructed OCTET STRING and string values are recognized and reported. Read IM4P fields by position so an unsupported payload keeps its slot and a constructed keybag still marks the payload encrypted. Walk every constructed value once, caching the children of header-walked values so each element is charged once, and check large values a consumer does not decode. Report unknown restore members, extra property and object fields and a mistyped certificate chain. Decode UTF8String as UTF-8, accept DER sign padding on unsigned 32-bit integers, and recognize the magic with the shared BER header decoder. * fix(apple): read IM4P and IMG4 slots by position and keep unknown counts null Follow img4tool and img4lib: after the payload, an optional keybag OCTET STRING, then an optional compression SEQUENCE, then PAYP in [0]; IMG4 holds IM4P, [0] IM4M and [1] IM4R in that order. A value outside its slot is reported as unknown and never takes another field's role, and an EXPLICIT wrapper holds exactly one value. An absent or undecodable description is null rather than empty, and an undecoded keybag reports a null count and types instead of zero; a decoded keybag counts every entry. * fix(apple): keep Image4 compression unknown when it cannot be read An encrypted payload without a compression field, or a declared algorithm other than LZFSE with no recognizable magic, now reports compression "unknown" instead of "none". Make ia5Text the single owner of the retained-text allowance so a string too large to tree-parse is refused rather than reported absent, keep the canonical BOOLEAN check in the structural pass only, check the keybag's inner SEQUENCE through the shared decoder instead of its first octet, note a manifest version other than 0, and name the spec constants after their sources. Add a hand-encoded IM4P golden that does not use the fixture builders. * fix(apple): keep stopped Image4 slots and bound retained bytes A value whose end cannot be found keeps its identifier, so a stopped keybag still marks the payload encrypted and a stopped payload keeps its slot; the values after it become a limitation. The IMG4 payload slot is consumed whatever it holds, so an unsupported value does not hide the manifest and restore slots. A property body that is not a SET or SEQUENCE is reported instead of read as empty, and an entry whose name cannot be read is one unknown entry whose value is never walked for more names, so restore values stay redacted. Load a value only when it may be decoded and fits an 8 MiB retained budget; larger primitives and values past the budget are walked by header. * fix(apple): keep restore properties opaque and small fields readable A PRIVATE-tagged restore value is one property: only its name is reported, and its value is never searched for names, even when the name is unreadable or is IM4R. Only the IM4R property SET is walked as a container. Small primitives are always loaded, so names and scalars stay readable after the retained budget is used. A declared uncompressed size that is negative or not an exact integer is reported as a limitation. * fix(apple): reserve tree budget only for parsed values and keep PRIVATE manifest entries opaque Reserve retained bytes only for a value that will be tree-parsed, so a ranged wrapper around a large payload no longer uses budget a later small indefinite value needs. A PRIVATE manifest entry must name itself; when its name cannot be read it is reported and its value is never interpreted as manifest facts. * fix(apple): report MANB, MANP and IM4R entries with no body A MANB, MANP or IM4R entry that holds only its name is a missing body, not a confirmed-empty one, so it is reported as a limitation while sibling facts are kept. * fix(apple): require a SEQUENCE for named manifest entries A context-, application- or other-tagged manifest value that begins with a name is unsupported structure, reported as an unknown tag rather than read as a manifest entry. * fix(apple): assign IMG4 values to slots by position and context tag One slot assigner owns the IMG4 layout: a context-tagged value fills the slot with its tag number, skipping earlier optional slots, and any other value occupies the next slot even when it cannot fill it. An unsupported manifest value therefore no longer hides a following [1] IM4R. --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com> |
||
|
|
ba1ddffd7e |
feat(artifacts): inspect Sega Mega Drive and Genesis ROM headers offline (#14895)
* feat(artifacts): inspect Sega Mega Drive and Genesis ROM headers offline These ROMs are inventoried as containers. A plain image matches when the four bytes at offset 0x100 are SEGA; an SMD dump matches the copier mark 0xAA 0xBB and a block count whose de-interleaved bytes carry SEGA, then the odd and even halves are merged into the linear image. The root record stores the 68000 vectors, header strings, declared and computed word checksum, ROM and RAM ranges, devices, external RAM, and region, with members vectors.bin, header.bin, and program.bin (SMD members carry an image offset and a null file range). A checksum or range disagreement leaves coverage unknown, 32X and Sega CD remain labels only, and a file past 8 MiB or 512 SMD blocks is refused under the named fixed ceilings before its body is buffered; the shared region reader maps that refusal onto the typed allowance, and the guide, CLI, supported-targets table, CI scopes, and ceiling registry include the format. * Address review feedback * Address review feedback * Address review feedback * fix(artifacts): read Mega Drive work RAM on the 24-bit bus and keep ambiguous regions A header that declares work RAM as 0xE0FF0000-0xE0FFFFFF, the SGDK default, was reported outside the work-RAM window because the check compared full 32-bit values. The 68000 drives 24 address lines, so the window check now compares bus addresses; metadata keeps the declared values. A region field of a lone A, B or E is both a classic region letter and a one-digit mask, and references disagree on which it is. It was reported as letters with no limitation. It is now region_style ambiguous, keeps both readings in region_characters and region_mask, and records a limitation. * refactor(artifacts): name Mega Drive header fields once and share the SMD half layout Header field offsets and lengths were literals repeated at each read, and device support was sliced twice from separate literals. One TEXT_FIELDS table, the named numeric offsets and the EXTERNAL_RAM block now hold the layout, citing SGDK's rom_head.c and Genesis Plus GX's getrominfo and sram_init. SMD recognition and de-interleaving each encoded which block half holds the odd bytes. Both now use SMD_ODD_HALF and SMD_EVEN_HALF, and the decoder takes the block count from the de-interleaved image instead of recomputing it from the file size. The SMD round-trip test only checked the fixture against its own inverse. It now also pins the fixture's file bytes to the Genesis Plus GX deinterleave_block layout. * fix(artifacts): model the Mega Drive 68000 bus once and decide SMD dumps before ESP images Header addresses were compared in three places with two rules: the RAM check masked to 24 bits while the reset-PC check compared raw 32-bit values, and neither knew the work-RAM mirror. One owner now holds the MC68000 24-bit bus (the top byte is not driven) and the Mega Drive work RAM, 64 KiB mirrored through 0xE00000-0xFFFFFF (Genesis Plus GX gen_init maps pages 0xE0-0xFF to it). The reset PC is checked against the ROM range on that bus, so 0xFF000200 fetches from 0x200, and a RAM range is work RAM when it covers at most 64 KiB inside the mirror, such as 0xE00000-0xE0FFFF. Metadata keeps the declared values. An SMD dump of 233 or 489 blocks has 0xE9, the ESP image magic, in its copier header's block-count byte, so the ESP image recognizer claimed it. The shared recognizer table now decides the SMD layout, whose signature also needs the AA BB mark, interleaved SEGA bytes and an exact size, before the ESP recognizers, and the plain layout keeps its place after the leading-magic formats. * fix(docs): restore separate Mega Drive and N64 entries after the main merge * fix(mega-drive): read ROM range and checksum window on the 24-bit bus The reset PC check already masked the top address byte, but ROM ordering, extent, the nonzero-start note and the checksum window still used the raw declared endpoints. A 0x400-byte image declaring 0xFF000000-0xFF0002FF summed through 0x3FF instead of 0x2FF, and a full 0xFF000000-0xFF0003FF alias was marked incomplete. Derive bus addresses once in the parser and keep the declared values in metadata. * fix(artifacts): order every Mega Drive header range on the 24-bit bus The ROM range was ordered on the 68000 bus, but the RAM range and the external RAM range still compared raw 32-bit endpoints. A header whose endpoints alias through different top bytes, such as RAM 0xE0FF0000-0x00FFFFFF, was reported as reversed even though the bus range is the 0xFF0000-0xFFFFFF work RAM. The bus owner now has one ordering rule, busOrdered, and the ROM, RAM and external RAM checks all use it. Declared values stay in metadata. A range whose end wraps past the 24-bit bus, such as 0xFF0000-0x1000000, is now reported as reversed, which is what the bus sees. * fix(artifacts): keep truncated region failures typed and publish Mega Drive bus addresses A region decoder could only report malformed, limit or unsupported, and the shared DecodedRegionArtifactReader mapped every kind but malformed to a fixed-limit refusal. A recognized Mega Drive header cut short was therefore reported as malformed, and an unsupported region failure would have surfaced as a limit. RegionDecodeFailure now has truncated, with the measured extent, and the reader maps each kind to its own typed failure: malformed, truncated, unsupported or limit. The header checks already interpret ROM, RAM and reset addresses on the 68000's 24-bit bus, but metadata exposed only the stored longwords, so the raw m68k hand-off told callers to load at the stored ROM start. A header that stores 0xFF000000 then loads at the wrong address. ROM and RAM ranges now carry bus_start and bus_end, the reset vector carries reset_pc_bus, and the guide and skill hand off with rom.bus_start. --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
61fb6cf68a |
feat(native): list Mach-O function starts and data-in-code entries offline (#14897)
* feat(native): list Mach-O function starts and data-in-code entries offline
The diff adds a static reader for LC_FUNCTION_STARTS and LC_DATA_IN_CODE
on one thin Mach-O or one selected slice of a universal file. Starts are
absolute VM addresses from ULEB128 deltas off the __TEXT vmaddr, and
each data-in-code entry reports offset, length, kind, and the function
start that owns its address, with one offset and limit applied to each
selected table and counts covering every entry.
inspect_macho_function_starts and inspect-macho-function-starts expose
that report, require architecture only for a universal file, and refuse
a combined table above max_entries with no partial result. The shared
load-command walk now yields each command once and stores the Mach-O
segment name and vmaddr on load regions, and the guides and limit docs
record coverage, paging, and the read and entry budgets.
* build: add advertised schema summary for inspect_macho_function_starts
* Address review feedback
* fix(native): bound function-start decoding and page before building rows
- Check each start against an interval index of executable segments, built
once, instead of scanning every segment per start.
- Walk LC_FUNCTION_STARTS once. Count and check every start and
data-in-code entry, but build result objects only for the requested page,
and resolve owners for that page during the same walk.
- Keep every declared Mach-O segment in the shared reader (macho_segments),
so a __TEXT with no file bytes still anchors the deltas, as
llvm-objdump does. LoadRegion no longer carries macho_segment.
- On 32-bit ARM, clear the Thumb tag (bit 0) from published starts and
report it as `thumb`, keeping the tagged value for the next delta, as
ld64 encodes and LLDB decodes. Wrap 32-bit images at 2^32.
- Intersect Evidence file ranges with the selected universal slice.
* refactor(native): normalize function-start format facts once
- One table, MACHO_DICE_KIND_NAMES, names data-in-code kinds for the
reader, the schema and the report check, which each had their own copy.
- Each linkedit command's dataoff/datasize is normalized once against the
slice (end, 32-bit fit, in-slice bytes) instead of the overflow check and
the in-slice length being recomputed in three helpers.
- Name CPU_TYPE_ARM, VM_PROT_EXECUTE and UINT32_MAX after their headers.
- Report coverage.text_not_at_header when __TEXT does not map file offset
0: llvm-objdump anchors the deltas on the __TEXT vmaddr and dyld on the
mach_header address, and they disagree there.
- Pin the fixture's expected starts to literal addresses.
* build: refresh the inspect_macho_function_starts schema summary after merging main
* fix(cli): keep lipo's flag name out of --architecture help text
The architecture help for four commands said "as lipo -thin does", which
the CLI option-alias check reads as a registered short flag `-thin`.
Describe the lipo behavior without spelling its flag.
* Revert "fix(cli): keep lipo's flag name out of --architecture help text"
This reverts commit
|
||
|
|
b3f70898e4 |
feat(firmware): inspect and extract Android DTBO partition images (#14398)
* feat(firmware): inspect and extract Android DTBO partition images * fix(firmware): replace fixed DTBO limits with artifact_limits * fix(artifacts): keep saved effective_limits compatible without android_dtbo * fix(firmware): accept shared DTBO payloads and keep unknown facts unknown mkdtimg writes a repeated input file once and points every entry for it at the same payload (libufdt mkdtimg_core.c search_fdt_info), so an exactly shared range is valid; only partial overlaps are refused. A compressed entry's inner FDT magic was not examined, so fdt_magic_valid is now null rather than false. Bytes inside total_size that the header, entry table and payloads do not claim are reported with their range and make coverage unknown. dt_table_header and dt_table_entry field offsets are named after dt_table.h. * fix(firmware): charge every DTBO row against artifact_limits.expanded_bytes Shared payloads are valid, but each row is hashed and can be extracted separately, so 4096 rows naming one 16 MiB payload multiplied inventory and extraction work to 64 GiB. Admit the declared bytes of every row against the shared aggregate expansion allowance before reading any payload, as PCK aliases do. * test(firmware): throw the parser's typed error in DTBO success cases Success cases asserted ok and returned, so a parse failure showed only a boolean mismatch. They now throw the typed ParseFailureError, as the testing guide requires. * test(firmware): drop a duplicated result guard --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
bbd1540d10 |
feat(yara): scan an admitted artifact with caller-supplied YARA rules (#14688)
* feat(yara): scan an admitted artifact with caller-supplied YARA rules Add inspect_yara_matches (CLI inspect-yara-matches), which runs the installed yara command (REA_YARA_COMMAND or yara on PATH) with caller-supplied rule files against one local file. The result lists matching rules with tags, typed metadata and string match offsets, bound to the SHA-256 of the scanned file and of each rule file. yara is launched with an argument list under owned process supervision. Its stdout is parsed as it streams, and the scanned file is re-verified after the scan. command_timeout_ms, max_output_bytes and max_matches are per-call arguments and runtime analysis settings with REA_YARA_* launch seeds; max_file_bytes is per call. String matches beyond max_matches are counted and coverage is partial. A rule compile error is an input error naming the rule file, and a missing yara command is reported as capability_unavailable without affecting other tools. REA bundles no rules and downloads nothing. * Address review feedback * fix(yara): keep the scanned file's observation when a rule file fails * fix(yara): require qualified Windows paths and resolve relative POSIX commands * fix(yara): stage owned snapshot, preserve CLI array bounds, and report file-size required_value * fix(yara): preserve relative includes, retain completed matches, order snapshot cleanup, and declare writesFilesystem * chore(yara): update advertised schema summary for inspect_yara_matches * fix(yara): handle regex arguments in include rewriter and retain completed matches across process cleanup * fix(yara): preserve raw include bytes and staged file identity across close * fix(yara): preserve completed rule identities and malformed-output primaries * fix(yara): bound rewritten rule staging and preserve cleanup cancellation * fix(yara): record completed rule identity before flushing rewritten includes * Address review feedback * Address review feedback * fix(skills): restore the macOS flat installer guidance this branch dropped The authored native-and-artifacts reference had lost main's macOS .pkg paragraph, so the generated Cursor plugin copy no longer matched it and the skill freshness check failed in docs, source tests and packaging. * fix(yara): classify compile errors by kind and keep unrecognized diagnostics yara 4.x prints compiler diagnostics in two forms, with and without a rule (cli/yara.c print_compiler_error). The include failure in the stub used a form yara never prints, so a real missing include was untested. Parse both forms once into severity, source, line, rule and message, classify the message by libyara's text (include, syntax, undefined, duplicate, unreadable file, other), and give one repair per kind present. Stderr lines that match no documented form are kept verbatim instead of only counted. * fix(yara): decode every meta escape yara prints and anchor diagnostic file names Meta strings: yara 4.x print_escaped_data also escapes an apostrophe and writes \a \b \v \f, so a meta value such as "author's" failed the whole scan as an unknown escape. Decode exactly the escapes yara writes, named after that function, and refuse octal forms it never writes. Diagnostics: a file name or message can contain "(N): ". Match the rule files yara was given exactly and end any other file name at the first location rather than the last. Name yara's EXIT_FAILURE. * fix(yara): keep an ambiguous diagnostic location unknown and scope duplicate advice A file name and a message can both contain "(N): ". Split an unnamed file only where one complete diagnostic remains; several splits leave the source and line null with the whole text kept, instead of shortening the file name or dropping the line to unrecognized stderr. Duplicate advice now covers string, tag and metadata identifiers within their rule, not only rule names. --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
17b53ee004 |
feat(artifacts): inventory Nintendo 64 ROM images and normalize byte order offline (#14911)
* feat(artifacts): inventory Nintendo 64 ROM images and normalize byte order offline An n64-rom image is recognized from the first word in z64 (80 37 12 40), v64 (37 80 40 12), or n64 (40 12 37 80) order plus a 4-byte-aligned boot address in KSEG0 or KSEG1. The reader normalizes the cartridge header and serves header.bin, ipl3.bin, and program.z64 in big-endian order, swapping v64 and n64 bytes and recording that swap as decoded. It names the IPL3/CIC variant from the CRC32 of bytes 0x40..0x1000 and, for a known variant, recomputes the CRC pair over the 1 MiB window; a mismatch, unknown CIC, short window, or non-zero reserved header bytes leave coverage unknown, and a file above 64 MiB is refused before any swap. Comparison ignores n64-rom and n64-rom-entry metadata so dump order is not treated as a content change, and decoded members share the idle-abort helper the Switch executable reader now calls. * fix(n64): admit members before reading and follow each byte order's swap unit Charge artifact_limits.expanded_bytes from the file size and byte order before the checksum window is read and swapped. The member layout now has one owner, n64RomRegions, which the parser and the allowance both use. The length rule follows the order's swap unit, as in mupen64plus-core: a z64 image of any length needs no swap, a v64 image needs an even length and an n64 image a multiple of 4. The guide now says that a printable destination byte outside the known table keeps its code with a null destination_name. * refactor(n64): name header fields from the spec and share the boot-address check Header offsets, the first-word magics, the CIC 6105 table offset and the KSEG bounds are now named constants with their reference sources, and recognition and parsing share one boot-address decision. A closed-form test checks the cartridge checksum on an all-zero window for every CIC, derived from the checksum routine rather than from n64CartridgeCrc. * fix(n64): keep the present bytes of a final partial word in the checksum window The checksum routine now reads one defined window, n64ChecksumWindow: the image through 0x101000 with only the bytes past a shorter file taken as zero. A z64 or v64 image that ends inside a word keeps that word's bytes instead of losing the whole word. The limitation now says how many bytes were assumed. --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
dc12e5768b |
fix(ghidra): let sessions share a checkpointed target (#14856)
* fix(ghidra): report a held checkpoint lease as retryable contention * fix(ghidra): let sessions share a checkpointed target Sessions restore a checkpoint into private projects without a lease. The socket lease is held only while one session publishes, and publication is a compare-and-set on the source that session started from, so a later save is refused instead of overwriting another session's edits. Addresses #14834. Stacked on #14844. * feat(ghidra): bound the checkpoint save wait with a launch control REA_GHIDRA_CHECKPOINT_SAVE_WAIT_MS replaces the fixed 30 s wait for another session's checkpoint publication. Default 30000 ms, floor 50 ms (one lease poll), maximum 600000 ms. The value is parsed when REA starts and fixed for a session when its checkpoint owner is constructed. It is a restart-only launch control in the numeric limit registry, not a runtime analysis setting, so the MCP tool catalog is unchanged. The busy refusal names the control, the applied value, its source and the range, and binds them as an environment limit. An invalid value is reported by doctor and registration validation and refuses only a checkpointed Ghidra session. * fix(ghidra): keep checkpoint save waits and refusals accurate - Poll again when a lease probe races the owner's release or another waiter's stale-socket recovery instead of failing the save with configuration_invalid. - Release the publication lease even when a staging or superseded file removal fails, so a retained cleanup does not block other saves. - Report an initial analysis overtaken by another session's edits as a superseded restore (reopen) rather than as refused edits. - Carry the save-wait details.limit onto a busy close_binary, through AnalysisClientCreation, and document the close-time shape. * fix(ghidra): report discarded checkpoint edits and end a forced close's save wait A session whose checkpoint save was refused because another session published first releases its edits on the next close_binary. That close now reports it: the result carries checkpoint {status: "discarded", reason: "superseded", directory}, alongside the snapshot receipt when snapshot_path was given. Only the close that releases the Program reports it, so a failed cleanup keeps the refusal and its retry reports instead. AnalysisClient.close returns an optional EngineCloseReport that the composite client, BinarySession close and closeWithSnapshot carry to the close_binary contract; an ordinary close keeps result null. A graceful close's final save did not observe a forced stop while it waited for another session's publication lease, so a cancelled request escalating the close could block for the whole save wait (up to ten minutes). The escalation now aborts that wait. The abort covers only the lease wait, the save's cancellation cutoff; once the lease is held the bounded publication completes, so a committed save is never reported as failed. The busy refusal's recovery and the installation guide now state that REA_GHIDRA_CHECKPOINT_SAVE_WAIT_MS cannot make an MCP client wait longer: that client's request deadline is separate and unknown to REA. The refusal keeps its environment details.limit. * fix(ghidra): tell a contention retry to reopen once the owner saved edits A session that waited for a checkpoint lease keeps the generation it selected, so after the owner saves Program edits and closes, repeating the call cannot succeed. Report that outcome as a typed superseded failure with reopen recovery instead of a checkpoint-directory configuration error, and say so in the busy recovery. * fix(ghidra): report both failures when checkpoint file removal and lease release fail retryCleanup rethrew a lease release failure before the saved removal failure became part of the error, so callers saw only the lease. A release failure alongside a removal failure is now reported with it: one ProviderCleanupError names both reasons, keeps the pending files and the retained lease as cleanup resources, and carries both causes. A lone release failure keeps its own error. * fix(ghidra): keep close facts and launch causes through composed failures Completed close facts were dropped wherever a later failure was composed. A released engine's discard report and a saved snapshot receipt are now carried by one owner, retainCloseOutcome, which every close composition calls on its outermost error with the outcomes it composed: the composite client when a sibling fails after a child released its edits, the session when file, candidate or bundle cleanup fails after the provider closed, the process-capture close wrapper, and the Ghidra client when cleanup fails after its JVM stopped. The report rides the failure as partial_observation.checkpoint and is not repeated by the retry. This replaces retainSavedAnalysisSnapshot and the close wrapper's snapshot extractor. Only close_binary reports edits released unsaved, so open_binary of another target, opening app resources, reset_investigation and external mutations now refuse with capability_unavailable while a client reports them through the new AnalysisClient.unsavedCloseReport, instead of releasing them silently. A launch failure was replaced by a superseded-restore error whenever another session had saved meanwhile. The launcher now records whether the failure happened while restoring the checkpoint, and only that failure is explained as superseded; any other keeps its cause, output and diagnostics. The busy recovery now says that a repeated call can report a superseded checkpoint when the other session's save changed it. * fix(ghidra): deliver the discard report through GhidraProvider and keep refusals typed GhidraProvider wraps its client in DeferredAnalysisClient, whose AnalysisClientCreation released the client through a cleanup lease and returned ok(null), so the real close_binary path dropped the discard report. The lease entry now keeps the releasing close's report and hands it to one release outcome; a failed release, a failed inspection cleanup and a retained creation failure carry it through retainCloseOutcome. The GhidraProvider client does the same when native AOT cleanup also fails. A boundary test drives close_binary through GhidraProvider. A forced close could still publish when its stop arrived while the lease was being acquired. Acquiring the lease is now the cancellation cutoff: publish checks the lease signal right after it and stops, and cleanup releases the lease. A refused save whose cleanup also failed was wrapped into a generic adapter error, so the client missed the refusal and kept the staged file for another impossible save. The checkpoint now keeps its typed refusal primary and unwrapped, carrying the cleanup failure on it; the client records the discard and reports the cleanup failure in diagnostics. * fix(ghidra): report released edits only for refused saves and keep startup cleanup failures A superseded initial analysis (stage restore) set the same refused-save flag as a refused edit, so its stopped JVM became a released-unsaved report: the session claimed discarded edits it never had, and open_binary refused the reopen its own error asked for. The refusal now states whether it refused edits (GhidraCheckpointSupersededError.refusesEdits, true only for a save), and the client records a discard only from that fact. Any refusal still discards its staged file. The cleanup failure a checkpoint refusal carries was read at close but not by the startup session failure factory. Ghidra lifecycle errors that carry a cleanup failure are now recognized by one guard, isGhidraCleanupCarrier, used by bindGhidraSessionFailure and the close error alike; the close diagnostic is renamed carried_cleanup_failure since it covers every carrier. |
||
|
|
3a8a717b02 |
feat(ghidra): set function signatures and define the types they use (#14859)
* feat(ghidra): set function signatures and define the types they use annotate_native_function accepts an optional C prototype, applied with USER_DEFINED source in the same transaction as the name and comments, verified by readback and rolled back with them on refusal. define_native_data_types stores caller-authored struct, union, enum and typedef definitions atomically under /rea_caller_defined and refuses existing names. inspect_native_data_type reports those types with source caller-defined, and annotation readback reports the applied prototype and its source. Refs #14831 * feat(ghidra): bound caller C text with launch controls and refuse unapplied constructs The lengths of a signature and of type declarations and the nesting depth of parentheses are launch-only REA_ controls with measured defaults, floors and maxima, written into the bridge's session descriptor. A refusal names the control, its effective value, source and range. The bridge tokenizes caller C before Ghidra's parser sees it and refuses what that parser accepts without applying: attributes, storage-class specifiers, variable declarations, directives other than #pragma pack, literals, function bodies, default arguments, unnamed enums and repeated member names. A type name that names different types is refused. When a function has no calling convention and the prototype names none, the compiler specification's default convention, which Ghidra already uses to assign the locked storage, is recorded, and annotation readback reports the convention. Refs #14831 * fix(ghidra): apply the signature bound to the caller's text The bridge appended the semicolon its parser needs before checking the length, so a prototype of exactly the admitted length was refused. The readback prototype is documented as reusable only when its function and type names are C identifiers. Refs #14831 * chore(mcp): refresh advertised schema summaries for Ghidra type edits Refs #14831 * fix(ghidra): bound caller C text per call and report dropped qualifiers Ghidra's C parser cannot be cancelled, so REA bounds the text it parses. The three launch-only environment controls left an agent that hit them with a restart as its only recovery. The two length bounds are now per-call parameters, signature_max_utf16 on annotate_native_function and declarations_max_utf16 on define_native_data_types, with the same defaults and measured maxima. A refusal reports details.limit with control_kind "parameter" and required_value, the text's length, so the generated recovery names the value to pass or asks for shorter text. The text fields no longer carry a schema maximum, so every over-length refusal is typed. Parenthesis nesting is a fixed ceiling of 8 levels, registered as a representation bound, because each level doubles parse time. The session descriptor no longer carries C parser limits, and the config module, environment entries and restart-only registry rows are removed. const and volatile are still applied without effect, because Ghidra's types have no representation for them. Both edits now return dropped_qualifiers with each qualifier's line and column, and for a signature its parameter index, null for the return type, instead of dropping them silently. * fix(ghidra): read caller C through one tokenizer and bound nesting per call The C admission scan tracked lines only at LF and read directives as raw lines matched by a regular expression, so a CR-only line break shifted dropped-qualifier positions and a trailing comment on #pragma pack was refused. One tokenizer now owns caller C positions, comments and literals: CR, LF and CRLF each end a line as in Ghidra's parser, and directives are admitted from its tokens, so comments read as whitespace there too. A block comment that would carry a directive onto another line is refused. Parenthesis nesting was a fixed ceiling justified by parse time, a resource limit. It is now the per-call parenthesis_max_depth (default 8, range 1..12) on both type-edit tools. The bridge measures the deepest nesting over the whole text and sends it, with a text's length, as the wire failure's required_value, so details.limit reports the bridge's own measurement instead of the adapter re-reading the request. The tokenizer also decides whether a prototype is terminated, so the parser sees the caller's text unchanged: no leading whitespace is stripped, and a trailing line comment no longer swallows the appended terminator. * fix(ghidra): parse caller C inside the edit's rollback and refuse parser diagnostics Ghidra's C parser writes the type database even with storeDataType false: a definition whose name matches an existing empty composite fills that type in place, in the parser's own nested transaction. Both type edits parsed before opening their transaction, so a refused definition, such as one conflicting with a DWARF placeholder, left that placeholder filled. Parsing, validation and storage now share the edit's one transaction, and parseCallerC refuses to run outside one. The parser also records diagnostics it cannot apply, such as a repeated enumerator it drops, and still reports success. Both edits now refuse any diagnostic with Ghidra's message, before anything is stored. The real-Ghidra verifier gains a phase with an ELF object whose DWARF declares an opaque struct, proving a refused definition leaves that empty composite unchanged, and refuses a repeated enumerator. * fix(ghidra): admit caller C from one audited table of tokens Ghidra drops Review kept finding one more construct Ghidra's C parser consumes without applying, because admission listed spellings piecemeal. The tokenizer now owns one table, audited against every token and production of Ghidra 12.2's C.jj and checked on Ghidra 12.2, in that grammar's own spellings: - Refused, because meaning is lost: __ptr32 and __ptr64 (stored as a native-width pointer), __near and __far, every attribute, declspec, __readableTo, alignas, packed and asm spelling, [[...]] attributes, storage and inline specifiers including __forceinline, __pragma and _Pragma, _Static_assert, Objective-C @ blocks (Ghidra skips their whole text), and backslashes. - Reported in dropped_qualifiers as pure qualifiers: every const and volatile spelling, restrict, __unaligned and __w64. #pragma pack is admitted only in the operand forms Ghidra applies as written with a decimal value; (0x1), (010), (show) and (pop, n) were ignored or read differently, and "# pragma" is a line marker Ghidra skips. An enum tag that neither the text nor the database defines made Ghidra invent an empty enum without a diagnostic; declarations now refuse it as they do an invented struct or union. Identifiers admit $, as C.jj's do, and the tokenizer reads numbers and [[ as single tokens. * fix(ghidra): bound caller type depth, admit only constant expressions Ghidra evaluates, refuse unmatched pack pops Recursion: the tokenizer's [[ lookahead re-entered next() for each "[", and the dependency walk recursed per pointer, array and member level. Both are iterative now. Ghidra 12.2's own data-type code recurses too: 1024 pointer or array levels resolve, 2048 exhaust the stack inside addDataType while its database lock is held, leaving the Program unable to save. Every parsed type's chain through pointers, arrays, typedefs and members, including existing database types, is now measured iteratively and refused beyond a fixed 256-level ceiling before Ghidra walks it. An unexpected StackOverflowError ends the session with a reason instead of being caught by the parser call, since Ghidra's lock may then be held. Constant expressions: Ghidra leaves names, casts, sizeof, floating and binary literals unevaluated and substitutes a default, so "MASK = FIRST << 4" was stored as 2, and it truncates values outside int. Enum values, array sizes and bit-field widths are admitted only as integer literals with arithmetic, shift, comparison, bitwise and logical operators, checked iteratively with C's rules to stay in int, including implicit enumerator values; anything else is refused at its position. Pragma pack: Ghidra ignores a bare (push), a pop with nothing pushed keeps the current packing, and a plain pop pops past labelled entries. The tokenizer tracks admitted pushes and admits a pop only when Ghidra's result matches C's. * fix(ghidra): admit constant expressions only as one literal, skip absent pointer targets, state the type-depth recovery truthfully Constant expressions: emulating C against Ghidra's own evaluator is an open-ended class of mismatches (comparisons, unsigned arithmetic such as ~0U >> 1 giving -1, names, casts, truncation). The evaluator is removed. Enum values, array sizes and bit-field widths are admitted only as one decimal or hex integer literal within int, optionally negated, without suffixes; anything else is refused at the first token that leaves that form, and the refusal says to write the computed value. Implicit enumerator values are still checked against int. Dependency walk: Ghidra's generic pointer has a null pointed-to type, and pushing it onto the ArrayDeque threw. Both the dependency and depth walks now take children from one cTypeChildren and skip an absent child. Type depth: the depth is measured over the whole chain before comparing it with the limit, so the refusal reports the depth it used, and it names the type from the parser's table rather than walking the type for a name. The recovery no longer suggests splitting into named types, which cannot help because depth counts through typedefs and existing types; it says only fewer nested levels do. * refactor(ghidra): refuse parentheses in definitions and keep parenthesis_max_depth on signatures only Under the literal-only rule for constant expressions, every parenthesis in a define_native_data_types text already ended in a refusal (function declarators, attributes, casts, sizeof, or a Ghidra diagnostic for a grouped declarator), so parenthesis_max_depth changed only which refusal a caller saw. A definition now refuses its first parenthesis at its position, and the parameter is removed from that tool's schema; it stays on annotate_native_function, whose prototype has a parameter list. * fix(ghidra): refuse distinct types that share one parser name Ghidra keeps struct tags, enum tags and typedefs in separate maps. Combining those maps dropped a typedef such as typedef int item when struct item was also defined, and the call still succeeded. Overlapping names are stored only when the definitions are equivalent, which keeps typedef struct s { ... } s as one struct. Any other overlap is refused with conflicting_type_definitions before the transaction stores anything. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): roll back a composite the parser fills in place Ghidra's parser replaces an empty composite during parsing and returns that same object. A later same-path check would store the fill as unchanged. Record those empty composites before parsing and refuse if parsing fills one, so the open transaction restores them. A different layout of a non-empty caller type still conflicts and leaves the stored type in place. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): close line comments at EOF and refuse overflowing pack values Ghidra's // skip token requires a line break, so a comment at the end of declarations or of an already-terminated signature was rejected. A newline is appended whenever the text ends in a line comment, before any semicolon added for an unterminated prototype. Integer.parseInt drops a pack operand outside a Java int and leaves the previous packing, so #pragma pack(2147483648) stored a natural layout. Decimal pack operands are admitted only when that parse succeeds. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(ghidra): assert the empty-composite refusal by code and readback Defining a struct over the DWARF placeholder fills that empty composite during parsing, so the refusal is data_type_conflict before the old name-conflict message. The verifier checks that code and that the placeholder still has no fields. Co-authored-by: morluto <morluto@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com> |
||
|
|
059df00e70 |
fix(ghidra): report a held checkpoint lease as retryable contention (#14844)
* fix(ghidra): report a held checkpoint lease as retryable contention * fix(ghidra): tell a contention retry to reopen once the owner saved edits A session that waited for a checkpoint lease keeps the generation it selected, so after the owner saves Program edits and closes, repeating the call cannot succeed. Report that outcome as a typed superseded failure with reopen recovery instead of a checkpoint-directory configuration error, and say so in the busy recovery. |
||
|
|
a6b1b3e92c |
docs(mcp): clarify when discovery requires a catalog refresh (#14837)
* fix(mcp): direct cold tool calls to exact-name discovery * fix(mcp): share conditional catalog refresh guidance --------- Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com> |
||
|
|
dbbe334ec1 |
feat(artifacts): inventory macOS flat installer packages offline (#11377)
* feat(artifacts): inventory macOS flat installer packages offline * fix(artifacts): keep refused pkg members unavailable during inspection A XAR member whose decode failed or whose decoded size contradicted the TOC stayed a readable entry, so shared inspection reopened it, hit the same mismatch at stream flush and aborted the whole scan. Record those members and have open() report them as unavailable content, so the scan keeps the partial facts and the named refusal. * fix(artifacts): report out-of-range installKBytes as unknown The Distribution parser accepted any safe integer for a pkg-ref's installKBytes, but the report field is uint32. A value such as 4294967296 parsed fine and then failed schema validation, which rejected the whole inventory report. Bound the attribute to uint32 at parse time so an out-of-range value reads as unknown. * fix(artifacts): charge decoded pkg archive bytes against the shared budget The shared expansion budget charged each Scripts or Payload member by its stored XAR size, so several small gzip members could each decode toward the per-archive allowance while barely moving the total. Decode now stops at what remains of the shared budget, the decoded size is charged, and an archive that would exceed it is listed as not expanded. gunzipBounded also recognizes Node's ERR_BUFFER_TOO_LARGE, which is what maxOutputLength raises, so an oversize gzip member is reported as a limit rather than as invalid gzip data. * fix(artifacts): keep expanded pkg Scripts/Payload archives in inventory Expanding a gzip-cpio Scripts or Payload member deleted the stored XAR entry, so its heap offset, sizes and TOC checksums dropped out of inventory and extraction. Keep the stored occurrence at a sibling logical path (for example Payload.cpio.gz) with sourcePath still naming the XAR member, so it sits alongside the expanded children. * fix(artifacts): count pkg check scripts in UTF-8 bytes scriptLength returned the JavaScript string length, so non-ASCII installation-check and volume-check scripts reported the wrong byte count. Measure the selected text with Buffer.byteLength. * fix(artifacts): keep pkg FIFO and device members non-materializable A cpio member that is not a directory, symlink or regular file (FIFO, character or block device, socket) was inventoried as an empty regular file. Emit it as a metadata declaration with a limitation naming its type, keep its mode in format metadata, and refuse open() on it. * fix(artifacts): bound pkg member archived range before reading it Refuse a zlib-encoded XAR member whose archived heap range exceeds the compress bound of its decode allowance, and never read the range of an unsupported encoding, so a package-controlled archived length cannot reach a buffer allocation unbounded. * fix(artifacts): refuse installer XML with an unexpected root element Distribution must have an <installer-gui-script> root and PackageInfo a <pkg-info> root. Any other root is now a named malformed-input refusal instead of a product or component identity with null fields. * fix(artifacts): keep duplicate XAR TOC paths as distinct pkg entries Key XAR file entries by their TOC occurrence instead of their path, so a later record at the same path no longer overwrites the earlier one. Expanded Scripts/Payload member keys now derive from their archive key for the same reason. * fix(artifacts): cap streamed XAR inflate output before forwarding it maxOutputLength does not bound a zlib stream, so count emitted bytes in createBoundedXarInflate and fail before forwarding past the allowance. The member stream also fails as soon as decoded bytes pass the TOC extracted size instead of waiting for EOF. * fix(artifacts): read XAR TOC execute bits across owner, group and other The XAR TOC <mode> was tested only on its last octal digit, so a mode such as 0750 reported a non-executable entry. Parse the octal text and test (mode & 0o111) like the cpio path. * fix(artifacts): keep XAR TOC directories and link-only symlinks as pkg entries TOC records without a heap body were dropped from the inventory, so directories, symlinks declared only by <link>, and empty files vanished. They now become their own occurrences: directories stay non-openable, symlinks open as their declared target text, empty files open as zero bytes, and other record types are kept as non-materializable metadata. Installer document lookup only considers heap-backed records. The shared lifecycle cases open the first entry, so they now use the component package fixture, whose first TOC record is a heap-backed file. * fix(artifacts): record Scripts and Payload presence from the XAR TOC A listed Scripts or Payload archive is now present before expansion is attempted. When the shared budget skips it or the XAR read is refused, its compression is reported as "unread" instead of "absent". * fix(artifacts): keep pkg coverage unknown when content was refused Coverage was complete whenever no archive hit the shared expansion budget, even when a heap range, encoding, decode, cpio or pbzx refusal left content unread. Any refusal other than the header-version notice now keeps coverage unknown. * fix(artifacts): only treat the cpio archive limit as a shared budget stop A zero or oversize cpio namesize raises the name limit, whose maximum is 4096 bytes. When exactly 4096 bytes of shared budget remained, that limit was mistaken for the budget stop and the refusal was dropped. Match the limit name as well as its maximum. * fix(artifacts): keep cpio members read before a damaged tail A Scripts or Payload archive whose cpio stream ends or breaks after complete members used to discard all of them and report an empty inventory with false script flags. parseCpioOdcPrefix now returns the members read before the failure along with the failure itself, and the pkg reader keeps those members as entries while recording the refusal, so coverage stays unknown. A failure before any complete member is still a plain refusal. * fix(artifacts): keep an out-of-range XAR TOC mode unknown Parse <mode> once in the TOC reader. Octal text that does not fit a uint32 becomes null, so one bad entry no longer fails the inventory schema check for the whole package. * fix(artifacts): cancel paused memory-backed pkg members A retained member streamed into a paused consumer kept its output open after abort, because the in-memory source has no signal and the shared stream owner defers cancellation until production finishes. The member output now retires on abort while its final validation has not started. * Address review feedback * fix(artifacts): share one expansion allowance across XAR members * fix(artifacts): count XAR TOC nodes before building the DOM A small TOC could hold millions of ignored elements under the byte limits, and each became a DOM node before the file count ran. Parse the TOC through parseXmlDocumentWithinNodeLimit with a 256-per-file node allowance and report a capacity limit past it. * fix(artifacts): cancel a paused XAR decoder after its source retires A highly compressed zlib member can finish reading its archived range while the decoder is still paused on a slow consumer. The file source's abort listener is gone by then and ownArtifactStream deferred abort until production finished, so cancellation waited for the consumer to resume. Once the source closes, an abort now destroys a decoder that has not ended. The output's final validation only starts after the decoder ends, so it keeps failure precedence. * fix(artifacts): reset XAR reader state when preparation retries When one caller cancelled preparation and another retried it on the same reader, #prepare built fresh metadata but kept #entries and #refusedContent from the cancelled attempt. The retry then skipped members already refused without recording their refusals, so coverage could report complete while open() still refused the member. #prepare now clears both maps before it reads the package. * fix(artifacts): align macOS pkg reader with format failure API and zlib output limits * fix(artifacts): bound XAR TOC expanded paths, preserve valid TOC records, and populate symlink linkTarget * fix(pkg): enforce package-wide cpio caps, strict UTF-8 names, root Distribution, and stored size checks * fix(macos-pkg): bound package-wide installer metadata bytes and records * fix(macos-pkg): tie installer metadata budgets to artifact_limits.expanded_bytes Wire macOS flat package Distribution/PackageInfo byte, record, and XML-node allowances into artifact_limits.expanded_bytes via macosPkgMetadataBudget: - Preserve the 4 MiB total, 1 MiB per-document, 4,096-record, and 65,536-node defaults when artifact_limits.expanded_bytes is omitted so aliased-heap metadata bombs remain bounded. - Charge every Distribution and PackageInfo read (including aliased stored heap ranges) against the shared expanded_bytes budget alongside zlib XAR members and Scripts/Payload expansion. - Raise the byte allowances and scale record (1 per 1,024 bytes, min 4,096) and XML-node (16 per record) allowances when artifact_limits.expanded_bytes is set, and report effective limits with artifact_limits.expanded_bytes recovery on metadata limit refusals. - Also add qualcomm-mbn to PE_OVERLAY_LEADING_FORMATS to resolve the typecheck conflict introduced by merging origin/main. * fix(macos-pkg): strip repeated ./ prefixes and tie cpio limits to expanded_bytes - Normalize cpio member paths with withoutCurrentDirectoryPrefix (handling repeated leading ./ segments and archive-root entries such as ./. and ././) both when counting retained path bytes and when forming logical paths, preserving the recorded name in sourcePath. - Derive Scripts/Payload cpio archive-byte, member-count, and expanded path-byte allowances from artifact_limits.expanded_bytes via macosPkgCpioBudget (keeping 64 MiB / 4,096 members / 4 MiB defaults when omitted, removing hardcoded cpio clamps, and reporting effective limits with artifact_limits.expanded_bytes recovery). - Update docs/macos-pkg.md and docs/reference/limits-and-recovery.md and add regression tests. --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
0f5ab1e042 |
feat(artifacts): inspect Debian package control metadata and contents (#10689)
* feat(artifacts): inspect Debian package control metadata and contents * fix(deb): throw ParseFailureError and record the new tool's schema counts DebPackageFormatFailure now extends ParseFailureError, as the architecture guard requires of parser failure classes; its kind, partial and message are unchanged. The advertised-dialect baseline takes the counts the inspect_deb_package input schema adds ($schema in both profiles, and allOf, default, examples, the \/ escape, the unanchored path pattern and untyped nodes in the full profile). * docs(deb): say dpkg runs maintainer scripts, not dpkg-deb dpkg-deb only reads the archive; installing with dpkg is what runs the maintainer scripts. Correct the spec so the safety rationale names the right tool. * refactor(deb): project format failures through parseFailureAnalysisError The provider now maps DebPackageFormatFailure with the shared parseFailureAnalysisError instead of its own instanceof ladder, passing the partial ar/control/data observation as diagnostics. The helper takes that optional diagnostics argument. DebPackageCapacityFailure extends ParseFailureError<"limit"> with the resource and maximum as its limit, and the provider keeps its limit recovery. * test(deb): resolve inspect_deb_package from its contract family The CLI acceptance and MCP boundary tests now take the contract from DEB_PACKAGE_TOOL_CONTRACTS instead of the full catalog, as the testing guide asks of focused contract tests. * fix(deb): require debian-binary and a control file for complete coverage Coverage was complete with a missing or empty debian-binary, or a control.tar that held no control file. It now needs a known format version and the control file as well as the control and data members, and each gap adds a limitation. * fix(deb): count hardlinks in the md5sums path cross-check dpkg lists every name of a hardlinked file in md5sums, while tar stores the later names as hardlink entries. The cross-check inventory now takes hardlink paths as well as regular files, so those names are no longer counted missing. * fix(deb): decode xz only when its index declares a size within the limit The sync @napi-rs/lzma decoder takes no output bound, so a member whose index could not be read was decoded with no limit and checked only after allocation. decodeXz now refuses such a member, as truncated when the footer is missing and malformed otherwise, before calling the decoder. * fix(deb): leave the md5sums cross-check unknown when an input is unread md5sums that is not UTF-8 counted as zero listed paths, and a package with no data.tar counted as an empty inventory. The cross-check is now computed only when both were read; otherwise it stays null and a limitation says which input was missing. * fix(deb): refuse Version and Installed-Size values the output schema rejects A Version with an empty upstream part or Debian revision (1:, 1:-1, 1.0-) and an Installed-Size past the safe integer range reached DebControl and failed the output schema, so the service lost the report. The parser now records a malformed field issue and leaves the value null. * build(deb): declare src/deb as a provider module layer Main now requires every top-level src unit in UNIT_LAYERS. src/deb is a provider like src/sqlite, and its two type imports of application ports are recorded in the upward-import baseline the same way. The xz spy binding now accepts the string or bytes input XzApi.compressSync takes. * fix(deb): keep tar names and link targets as stored Read ustar name, prefix and linkname fields, and GNU long names, as NUL-terminated UTF-8 without trimming or rewriting backslashes, and keep spaces in md5sums paths. A name that is not UTF-8 is shown with U+FFFD replacements and counted in a limitation, since it may not match md5sums. * fix(deb): read control files from the control.tar root only Look up control, conffiles, md5sums and maintainer scripts by their normalized root path, so a nested subdir/control or subdir/postinst no longer stands in for the root file. * fix(deb): read PAX records by byte length PAX record lengths count bytes, so walk the extended header bytes and decode each record on its own. A UTF-8 path no longer swallows part of the next record. A path or linkpath record that is not UTF-8 is counted in the same not-UTF-8 limitation as ustar names. * fix(deb): keep unreadable relationship alternatives as issues Accept hyphenated architecture qualifiers such as kfreebsd-amd64, and have parseDebianRelationshipField return the alternatives it cannot read. parseControl records each as a malformed issue on its field, so the package reports partial coverage instead of dropping a dependency. * fix(deb): deliver the whole partial report on a refusal A Debian package refusal now carries the bounded partial report as diagnostics.partial, so control facts, relationships, maintainer-script facts, ar member offsets and file rows read before the failure reach CLI and MCP callers, not just member names and a count. * fix(deb): decode only the maintainer script interpreter line interpreterLine now finds the first newline in the script bytes and decodes only the #! line, so non-UTF-8 bytes later in the script, or a cut through a multi-byte character at byte 256, no longer hide a valid interpreter. * fix(deb): bound unreadable relationship diagnostics per field parseDebianRelationshipField now counts unreadable alternatives and keeps only the first, and parseControl records one issue per field with that count and the first term cut to 120 characters, so a field of many `|` separators no longer grows the report with its input. * test(deb): check parser guidance through its owning formatters Export undecodableTarNamesLimitation and unreadableRelationshipsDetail from the parser and assert delivered limitations and issue details through them, so wording edits change one place. * fix(deb): bound PAX header work before each tar entry Keep only the path and linkpath PAX keys the reader uses, set in place rather than copying an accumulated object per header, and refuse more than eight GNU long name/link or PAX headers before one entry as malformed, so a run of short PAX headers cannot stall the server. * fix(deb): apply PAX owner records to the following entry PAX uid, gid, uname and gname now override the fixed ustar fields, which can hold shortened or fallback values. A uid or gid that is not a safe decimal integer falls back to the fixed field. * fix(deb): keep GNU ar string tables as counted members A // string-table member is now kept in the ar inventory and counted against max_ar_members like any other member. As an unknown role it is listed in extra_member_names, so coverage reports partial. * fix(deb): honor PAX size records and escaped md5sums names - A PAX size record overrides the next entry's ustar size field. Reading and skipping by the header field reported an empty file and then parsed its data as a header, refusing a valid archive. - GNU md5sum writes a leading backslash and escapes names that contain a backslash, newline or carriage return. Those lines were dropped, so the cross-check counted listed files as missing; they are now read, and lines that are not digest lines are counted in a limitation. * fix(deb): bound relationship alternatives and read PAX headers faithfully - Count relationship alternatives across the control file before building any, refusing more than a fixed 65,536; a field of '|' separators within the control budget could build millions of report objects. - Refuse a PAX extended header whose record length is unreadable or runs past the member, instead of using the fields read so far. - Keep global (g) PAX values for every later entry and per-file (x) values for the next entry only; global values were cleared after the first file. * refactor(deb): drop an unused import * chore(mcp): drop the dialect baseline main retired in #10693 * fix(analysis-view): call completeWithinViewCoverage with main's single count Main dropped its redundant second argument; both arguments were the same count here. * test(mcp): record this PR's advertised-schema summary Add the advertised-schema summary for inspect_deb_package, generated with npm run verify:advertised-schemas -- --update-summary. * fix(deb): bound repeated global PAX text and accept xz stream padding A global PAX path, linkpath, uname or gname is copied into every later row, so each reuse is now charged to the member byte budget (max_data_bytes or max_control_bytes) and refused before the row is added. An empty global PAX value now deletes the earlier global override, so later entries read their header owner again. xzUncompressedSize and the footer check skip trailing zero Stream Padding in 4-byte groups before locating the footer, so valid padded xz members are no longer reported as truncated. * fix(deb): trim trailing tar path slashes with a backward scan The unanchored /\/+$/u retried from every slash, so a PAX path or md5sums name made of a long slash run and a final non-slash took quadratic time. logicalTarPath now trims trailing slashes with a linear charCodeAt scan from the end. * fix(deb): parse global PAX owner ids once per global record Global uid and gid values were run through paxId for every later entry, and the repeated-text budget skips numeric keys, so a long global owner value was rescanned once per row. Parse them when the global record is read and reuse the numbers. * refactor(deb): report coverage with the shared coverage status schema * refactor(deb): classify provider failures through classifyProviderFailure * fix(deb): bound resolved ar member names before copying them GNU ar /N references can repeat one string-table entry without charging its text to any budget, and every resolved name is copied into the report and its Evidence. Refuse a BSD or GNU long name above 4096 bytes before it is read or sliced, so repeated references cannot expand a small table into large report text. * test(deb): register the debPackage capability conformance case debPackage is declared in CAPABILITY_DECLARATIONS but had no entry in PROVIDER_CAPABILITY_CONFORMANCE, so the conformance suite failed for it. Name the existing Debian package CLI acceptance test as its case. * fix(deb): flag repeated control and data members as extra Only the first debian-binary, control.tar*, and data.tar* member is read. A later member with the same role was neither decoded nor listed, so a package with an empty first data.tar and a populated second one reported complete coverage. Repeated members now land in extra_member_names with a limitation, which keeps coverage partial. * refactor(deb): use the shared excerpt and error message owners The architecture guards from main count a hand-written ellipsis cut in the relationship issue detail and two inline error-to-message copies. Use ellipsisExcerpt and errorMessage instead. * refactor(deb): move DebPackagePort to src/ports/deb The provider imported its port from the application layer, which needed an upward allowance in the module-layer baseline. Put the port beside the other provider ports and drop the allowance. * fix(deb): record only caller-selected budgets in Evidence Omitted inspect_deb_package budgets no longer appear in Evidence parameters as if the caller set them; only supplied fields are kept. * fix(deb): report fixed reader allowances as limits The ar member name, tar extension header, and relationship alternatives allowances stop inspection without showing the input is invalid. Report them as `limit` parse failures (DebPackageAllowanceFailure) with the partial report attached, and project them as resource_constraint with a fixed-allowance recovery instead of invalid_request. * fix(deb): refuse GNU ar long name references outside the string table A `/<offset>` reference past the end of the `//` string table, or one that lands on an empty entry, resolved to an empty member name. The report then failed debPackageSchema and callers got AnalysisOutputError with no file identity or partial facts. Check the offset and the resolved name, and refuse as a malformed DebPackageFormatFailure that carries the partial report. * fix(deb): align ar members by stored size and require padding Advance past each ar member using the stored header size, so a BSD #1/N extended name with odd length keeps the next header aligned. Refuse an odd-sized member whose padding byte is missing at end of file instead of reporting complete coverage for a truncated container. * fix(deb): trim NUL-terminated header fields in linear time Trim fixed-width ar and tar header fields at the first NUL with indexOf instead of a NUL-to-end regex, which retried from every NUL when a continuation line followed a NUL run. Control-field decimal parsing no longer applies header NUL trimming. * fix(deb): skip the tar path prefix on GNU headers GNU tar headers use the 345-499 region for atime, ctime and sparse data, not a POSIX path prefix. Only join the prefix when the header carries the POSIX "ustar\0" magic. * docs(readme): drop duplicated target tables in five translations The fa, ko, th, zh-TW and zh guides carried the target table twice. Restore each to upstream and add the single Debian packages row. * fix(deb): report oversized Zstandard windows as a fixed allowance A valid control or data zstd member can request a decoder window above the fixed 128 MiB ceiling. Node raises ZSTD_error_frameParameter_windowTooLarge, which the parser reported as malformed. Map it to a DebPackageAllowanceFailure naming the new zstd_window_bytes allowance, matching ZipArtifactReader. * fix(package): bundle XZ decoder binaries for every plugin host The plugin archive is produced on Linux x64, where npm ci drops other platforms' optional packages. The packaging step only restored the PTY binaries, so Codex plugin installs on macOS and Windows had no @napi-rs/lzma binding and valid XZ packages failed as unsupported. Derive the platform packages from the locked runtime tree instead: every optional dependency of a runtime package that targets darwin/linux/win32 on x64/arm64 is restored at its locked path with a verified integrity, and the packed archive is checked for each one. * fix(deb): keep only applied PAX keys while reading records parsePax stored every record's key before PAX_KEYS filtered them, so one extended header of many short records with distinct keys grew an object property per record before any entry limit ran. Records whose key is not one this reader applies are now read and dropped, and parsePax is covered directly in DebPackageParser.test.ts. * Address review feedback * Trim deb822 lines with linear scans The trailing-whitespace alternative of the shared trim expression retried from every position of a long interior whitespace run, so a package Description could take quadratic time. Scan from each end instead and cover a long tab and space run in a test. * fix(deb): read only the first control paragraph parseControl used the first paragraph of the control file, but deb822Paragraphs built a map for every paragraph first. A control file of many small paragraphs could allocate millions of maps within the decompressed-size budget. deb822Paragraphs now takes a paragraph limit and yields string lines lazily, and parseControl stops after the first paragraph. * fix(deb): report unreadable tar modes as null A tar header whose mode field is not octal was reported as mode 0000, which invents a permission the archive never stated. Report the mode as null and add a malformed issue for the member, so coverage is partial. * fix(deb): refuse GNU sparse tar entries GNU PAX sparse headers (GNU.sparse.*) rename the following entry to a synthetic GNUSparseFile path and store only mapped segments, so reading it as a regular file reported the wrong name and size and could miss md5sums cross-checks. Old GNU sparse (S) entries can also carry extension blocks their size field does not count. Refuse both as an unsupported format instead of reporting wrong file facts. * refactor: use shared artifact inspection for Debian packages * fix(deb): report per-call budget refusals as parameter limits * Address review feedback * Address review feedback * fix(deb): bound xz decoding, inherit global PAX size, and redact Homepage URLs * fix(deb): bound xz index preflight memory and preserve typed cancellation with partial facts * fix(deb): bound nested relationship lists, align tar stored-body rule, and scope async parse * fix(deb): walk actual XZ block boundaries, scan control lines without arrays, and guard XZ close gate * refactor(deb): avoid throwaway filter arrays in DebPackageParser --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local> |
||
|
|
14b4d1f7ad |
feat(firmware): inventory and extract UBI image volumes offline (#13333)
* feat(firmware): inventory and extract UBI image volumes offline * docs: name ubi-volume among compared format metadata kinds The artifact comparison contract lists every format metadata kind that compare_artifacts compares. ubi-volume now carries a declaration, so the contract names it beside the other members. * fix(firmware): keep UBI LEB ranges private to the reader entries() yielded copyArtifactEntry(entry), which spreads the private volume field by reference, so a caller could rewrite volume.ranges and change the bytes the next open() read. Yield only the public entry fields, and test that a returned entry carries no volume mapping. * fix(firmware): keep LEB source ranges in ubi-volume metadata Saved Evidence now records the lnum, PEB, image offset and length of each chosen LEB, so a reassembled volume can be traced to its image bytes. The image summary keeps counts. * fix(firmware): reject smaller UBI eraseblock sizes whose LEB padding is invalid A dynamic LEB with data_size 0 and data_pad equal to a smaller candidate LEB passed the size check, so a valid aligned image was refused as ambiguous. Require data_pad below the candidate LEB, as classifyUbiPeb and the volume table alignment rule already do. * fix(ubi): refuse a UBI# file shorter than its erase-counter header recognizeUbiImage recognized any 4 to 63 byte file starting with UBI# without a CRC or version to check, so open_binary accepted it as an archive and inventory labelled it a container. It now takes the file size and refuses a file that cannot hold the 64-byte header. A short prefix read from a longer file still defers to the reader. * fix(ubi): refuse a volume whose only surviving LEB copy failed its CRC When both competing PEBs for a LEB are wear-leveling copies and both fail their data CRC, the older failed copy still won and open() served bytes that had already failed verification. Mark that LEB unverified and refuse the volume with extract refusal unverified_copy, keeping its inventory. * fix(ubi): refuse an image whose EC headers disagree instead of skipping them Eraseblock discovery and both spacing checks skipped a valid erase-counter header whose image_seq or layout differed from PEB 0, treating it as absent. Alternating sequences or a conflicting second header then measured a multiple of the real eraseblock size and read the image, so a volume became an extractable empty or header-polluted volume. Any valid header now begins an eraseblock, and classifyUbiPeb and checkUbiPebs refuse the disagreement. * fix(ubi): rule out a smaller eraseblock size whose volume table is invalid The ambiguity check declared a smaller eraseblock size equally valid from erased header positions and LEB fit alone. With 128 KiB eraseblocks, data_offset 4096 and a volume of alignment 6144, data_pad is 4096, but a 64 KiB LEB would need data_pad 0, so that size cannot describe the image and a valid image was refused. The check now also requires a volume table copy to stay valid under the smaller geometry, and runs after the table copies are read. * fix(ubi): compare the volume ID in a UBI volume declaration The compared ubi-volume declaration left out the volume ID. A volume renumbered from ID 0 to ID 1 keeps its path and reconstructed bytes, so artifact comparison reported it unchanged even though consumers that address volumes by number now see a different volume. The declaration now includes the ID, and PEB placement stays out of it. * fix(ubi): refuse a volume with no mapped LEB when PEBs are corrupt When a volume's only data PEB had a bad EC or VID header CRC, classification dropped its mapping and reassembly read the absence of surviving headers as an empty volume: a static volume got used_ebs 0, a dynamic one zero LEBs, and both were served as extractable empty files. A corrupt PEB may have held that data, so a volume with no mapped LEB in an image with corrupt PEBs is now inventoried but refused as lost_lebs, with used_ebs null and a named limitation. An image without corrupt PEBs still reads an unmapped volume as empty. * fix(ubi): accept EC headers in static LEB data no smaller eraseblock holds A static volume holding a nested UBI image with the same EC layout puts valid EC headers on a smaller grid inside its payload. With 128 KiB eraseblocks, data_offset 4096 and full 126976-byte static LEBs, the spacing check and the smaller-grid scan refused such a header as a geometry conflict, though ubiSmallerPebSizeHoldsLebs already rules out every smaller size those LEBs would have to fit. Both scans now run their verdict after the PEBs and volume table copies are read, and set aside a header at a position only ruled-out sizes would begin at. A spacing conflict still takes precedence over later failures, and a header where a smaller size stays possible, as under dynamic LEBs, is still refused. * Address review feedback * Address review feedback * Address review feedback * Address review feedback * fix(ubi-image): carry parser limit facts through reader refusals parseFailure now passes the named parser limit and a typed parser fixedAllowance when it wraps a UBI limit refusal, so the 16 MiB eraseblock size ceiling and the 262,144-eraseblock count ceiling reach CLI and MCP with reported_limits and the fixed-ceiling recovery. * fix(ubi-image): ignore nested EC headers no eraseblock could begin at The second-header scan now skips headers inside the data the first PEB's own VID header declares, so a static LEB holding a nested UBI image no longer measures the eraseblock at the nested header. The spacing check now counts only headers at positions an eligible smaller eraseblock (dividing the measured size, larger than data_offset) would begin at, and after the LEBs are read only the sizes they still admit. A dynamic LEB holding a nested image of small eraseblocks parses the same in PEB 2 as in PEB 5. * fix(ubi-image): read only the first VID header within the eraseblock ceiling The eraseblock search read every byte from offset 0 through the first PEB's declared vid_hdr_offset to find its VID header. A CRC-valid EC header could declare an offset of 1 GiB and make the reader allocate a buffer that size before the eraseblock ceiling refused the image. ubiFirstVidHeaderOffset now admits the VID header only when it lies inside the file and the fixed eraseblock ceiling, and the reader reads just those 64 bytes. A header past the ceiling is never read, so the search reaches its bounded eraseblock-size refusal as before. * fix(ubi-image): skip EC headers whose offset cannot be the eraseblock size A dynamic VID header declares data_size 0, so a first PEB holding a nested UBI image only rules out the nested header at data_offset. The next nested header, 6144 bytes into a 128 KiB eraseblock, was taken as the eraseblock size and the valid 524288-byte image was refused as not a multiple of it. The second-header search now skips headers at offsets that do not divide the file size, since no eraseblock size could put them there. The first header at any offset is still kept for the refusal when no size fits. * fix(ubi-image): reject truncated dumps with misleading PEB headers * Address review feedback * Address review feedback * Address review feedback * Keep undersized UBI candidates provisional on valid VID extents A CRC-valid VID header whose data_pad and data_size do not fit a candidate LEB now records the eraseblock size it needs. A dividing candidate smaller than that stays retryable, with its image kept as the fallback, so a later candidate that holds every LEB in full is accepted. * Address review feedback * Address review feedback * Exercise the UBI PEB count ceiling in memory * fix: reject unrelated UBI header conflicts * fix: verify static UBI payloads before retrying geometry * fix: bound UBI static payload CRC work across PEB size candidates * fix: repair UBI integration after merging main * Address review feedback * fix: let cancellation retire paused UBI volume streams * test: synchronize paused UBI volume cancellation * fix: preserve UBI read failures during cancellation * perf(ubi): count PEB states and extractable volumes in one pass Replace the per-state .filter(...).length scans in assembleUbiImage and summarizeUbiImage with single loops, per docs/development/tool-design.md. * Address review feedback * fix(firmware): close UBI geometry ambiguity and corrupt-PEB tail gaps * fix(firmware): verify erased UBI PEB bodies and validate layout VID headers * fix(firmware): defer and cache UBI erased-body scans and deduplicate stream check helper * fix(firmware): eliminate quadratic UBI erased-range scans and cache dynamic copy CRCs * test(firmware): assert UBI erased-range coalescing, walk steps, and elapsed time * perf(ubi): cache EC header scan across block-size retries * fix(ubi): bound EC header scan cache and stream past cap --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |