Merge remote-tracking branch 'origin/main' into feat/signature-posture
# Conflicts: # docs/product-catalog.json # docs/verification/managed-conformance-manifest.json # skills/reverse-engineer-anything/SKILL.md # src/generatedMcpToolCatalog.ts
This commit is contained in:
@@ -239,7 +239,7 @@ jobs:
|
|||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
package-e2e:
|
package-e2e:
|
||||||
name: Package/install integration (${{ matrix.os }})
|
name: Native package baseline (${{ matrix.platform }} ${{ matrix.architecture }})
|
||||||
needs: [changes, windows-native-build]
|
needs: [changes, windows-native-build]
|
||||||
if: github.event_name == 'push' || needs.changes.outputs.package == 'true'
|
if: github.event_name == 'push' || needs.changes.outputs.package == 'true'
|
||||||
strategy:
|
strategy:
|
||||||
@@ -253,7 +253,7 @@ jobs:
|
|||||||
- os: ubuntu-24.04-arm
|
- os: ubuntu-24.04-arm
|
||||||
platform: linux
|
platform: linux
|
||||||
architecture: arm64
|
architecture: arm64
|
||||||
- os: macos-14
|
- os: macos-15
|
||||||
platform: darwin
|
platform: darwin
|
||||||
architecture: arm64
|
architecture: arm64
|
||||||
- os: macos-15-intel
|
- os: macos-15-intel
|
||||||
@@ -286,12 +286,15 @@ jobs:
|
|||||||
path: native/windows/build/
|
path: native/windows/build/
|
||||||
- run: npm run verify:windows-native:artifact
|
- run: npm run verify:windows-native:artifact
|
||||||
- run: npm run verify:package
|
- run: npm run verify:package
|
||||||
|
- name: Verify real Node Inspector discovery and observation
|
||||||
|
if: matrix.platform == 'darwin'
|
||||||
|
run: npm run verify:inspector
|
||||||
|
|
||||||
apple-artifacts:
|
apple-artifacts:
|
||||||
name: Real Apple artifact CLI/MCP E2E
|
name: Real Apple artifact CLI/MCP E2E
|
||||||
needs: changes
|
needs: changes
|
||||||
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
|
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
|
||||||
runs-on: macos-14
|
runs-on: macos-15
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -355,12 +358,6 @@ jobs:
|
|||||||
- os: ubuntu-24.04-arm
|
- os: ubuntu-24.04-arm
|
||||||
platform: linux
|
platform: linux
|
||||||
architecture: arm64
|
architecture: arm64
|
||||||
- os: macos-14
|
|
||||||
platform: darwin
|
|
||||||
architecture: arm64
|
|
||||||
- os: macos-15-intel
|
|
||||||
platform: darwin
|
|
||||||
architecture: x64
|
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
platform: win32
|
platform: win32
|
||||||
architecture: x64
|
architecture: x64
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
|
|
||||||
<a href="https://trendshift.io/repositories/82054?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-82054" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/82054" alt="morluto%2Frea | Trendshift" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/82054?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-82054" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/82054" alt="morluto%2Frea | Trendshift" width="250" height="55"/></a>
|
||||||
|
|
||||||
[Documentation](https://morluto.github.io/rea/) · [Quick start](#quick-start) · [Current status](#current-status) · [Investigation model](#the-investigation-model) · [Tool catalog](#tool-catalog-for-investigation) · [Roadmap](#roadmap) · [How it works](#how-it-works)
|
**[Website](https://morluto.github.io/rea/) · [Guides](https://morluto.github.io/rea/guides/) · [DX-Ball showcase](https://morluto.github.io/rea/showcase/dx-ball/)**
|
||||||
|
|
||||||
|
[Quick start](#quick-start) · [Current status](#current-status) · [Investigation model](#the-investigation-model) · [Tool catalog](#tool-catalog-for-investigation) · [Roadmap](#roadmap) · [How it works](#how-it-works)
|
||||||
|
|
||||||
<code>npx rea-agents setup</code>
|
<code>npx rea-agents setup</code>
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
<a href="https://trendshift.io/repositories/82054?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-82054" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/82054" alt="morluto%2Frea | Trendshift" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/82054?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-82054" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/82054" alt="morluto%2Frea | Trendshift" width="250" height="55"/></a>
|
||||||
|
|
||||||
|
**[الموقع (بالإنجليزية)](https://morluto.github.io/rea/) · [أدلة الاستخدام](https://morluto.github.io/rea/guides/) · [دراسة حالة DX-Ball](https://morluto.github.io/rea/showcase/dx-ball/)**
|
||||||
|
|
||||||
[البدء السريع](#البدء-السريع) · [حالة الدعم](#حالة-الدعم) · [من الملف التنفيذي إلى السلوك](#من-الملف-التنفيذي-إلى-السلوك) · [منصة أدوات التحقيق](#منصة-أدوات-التحقيق) · [خطة العمل](#خطة-العمل) · [كيف يعمل؟](#كيف-يعمل)
|
[البدء السريع](#البدء-السريع) · [حالة الدعم](#حالة-الدعم) · [من الملف التنفيذي إلى السلوك](#من-الملف-التنفيذي-إلى-السلوك) · [منصة أدوات التحقيق](#منصة-أدوات-التحقيق) · [خطة العمل](#خطة-العمل) · [كيف يعمل؟](#كيف-يعمل)
|
||||||
|
|
||||||
<table aria-label="REA community">
|
<table aria-label="REA community">
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
<a href="https://trendshift.io/repositories/82054?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-82054" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/82054" alt="morluto%2Frea | Trendshift" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/82054?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-82054" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/82054" alt="morluto%2Frea | Trendshift" width="250" height="55"/></a>
|
||||||
|
|
||||||
|
**[ウェブサイト(英語)](https://morluto.github.io/rea/) · [ガイド](https://morluto.github.io/rea/guides/) · [DX-Ball の事例](https://morluto.github.io/rea/showcase/dx-ball/)**
|
||||||
|
|
||||||
[クイックスタート](#クイックスタート) · [現在の対応状況](#現在の対応状況) · [バイナリから動作へ](#バイナリから動作へ) · [調査ツールカタログ](#調査ツールカタログ) · [ロードマップ](#ロードマップ) · [仕組み](#仕組み)
|
[クイックスタート](#クイックスタート) · [現在の対応状況](#現在の対応状況) · [バイナリから動作へ](#バイナリから動作へ) · [調査ツールカタログ](#調査ツールカタログ) · [ロードマップ](#ロードマップ) · [仕組み](#仕組み)
|
||||||
|
|
||||||
<table aria-label="REA community">
|
<table aria-label="REA community">
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
<a href="https://trendshift.io/repositories/82054?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-82054" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/82054" alt="morluto%2Frea | Trendshift" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/82054?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-82054" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/82054" alt="morluto%2Frea | Trendshift" width="250" height="55"/></a>
|
||||||
|
|
||||||
|
**[웹사이트(영문)](https://morluto.github.io/rea/) · [가이드](https://morluto.github.io/rea/guides/) · [DX-Ball 사례](https://morluto.github.io/rea/showcase/dx-ball/)**
|
||||||
|
|
||||||
[빠른 시작](#빠른-시작) · [현재 지원 범위](#현재-지원-범위) · [바이너리에서 동작까지](#바이너리에서-동작까지) · [조사 도구 카탈로그](#조사-도구-카탈로그) · [로드맵](#로드맵) · [작동 방식](#작동-방식)
|
[빠른 시작](#빠른-시작) · [현재 지원 범위](#현재-지원-범위) · [바이너리에서 동작까지](#바이너리에서-동작까지) · [조사 도구 카탈로그](#조사-도구-카탈로그) · [로드맵](#로드맵) · [작동 방식](#작동-방식)
|
||||||
|
|
||||||
<table aria-label="REA community">
|
<table aria-label="REA community">
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
<a href="https://trendshift.io/repositories/82054?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-82054" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/82054" alt="morluto%2Frea | Trendshift" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/82054?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-82054" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/82054" alt="morluto%2Frea | Trendshift" width="250" height="55"/></a>
|
||||||
|
|
||||||
|
**[网站(英文)](https://morluto.github.io/rea/) · [使用指南](https://morluto.github.io/rea/guides/) · [DX-Ball 案例](https://morluto.github.io/rea/showcase/dx-ball/)**
|
||||||
|
|
||||||
[快速开始](#快速开始) · [当前状态](#当前状态) · [从二进制到行为](#从二进制到行为) · [调查工具目录](#调查工具目录) · [路线图](#路线图) · [工作原理](#工作原理)
|
[快速开始](#快速开始) · [当前状态](#当前状态) · [从二进制到行为](#从二进制到行为) · [调查工具目录](#调查工具目录) · [路线图](#路线图) · [工作原理](#工作原理)
|
||||||
|
|
||||||
<table aria-label="REA community">
|
<table aria-label="REA community">
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
struct ChildBatch<Element> {
|
||||||
|
let values: [Element]
|
||||||
|
let complete: Bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func captureChildValues<Element>(requestedCount: Int, copy: () -> [Element]?) -> ChildBatch<Element> {
|
||||||
|
guard requestedCount > 0 else { return ChildBatch(values: [], complete: true) }
|
||||||
|
let returned = copy() ?? []
|
||||||
|
let values = Array(returned.prefix(requestedCount))
|
||||||
|
return ChildBatch(values: values, complete: values.count == requestedCount)
|
||||||
|
}
|
||||||
@@ -26,11 +26,12 @@ func childCount(_ element: AXUIElement) -> Int {
|
|||||||
var count = 0
|
var count = 0
|
||||||
return AXUIElementGetAttributeValueCount(element, kAXChildrenAttribute as CFString, &count) == .success ? count : 0
|
return AXUIElementGetAttributeValueCount(element, kAXChildrenAttribute as CFString, &count) == .success ? count : 0
|
||||||
}
|
}
|
||||||
func children(_ element: AXUIElement, limit: Int) -> [AXUIElement] {
|
func children(_ element: AXUIElement, count: Int) -> ChildBatch<AXUIElement> {
|
||||||
var value: CFArray?
|
captureChildValues(requestedCount: count) {
|
||||||
let count = min(limit, childCount(element))
|
var value: CFArray?
|
||||||
if count == 0 { return [] }
|
guard AXUIElementCopyAttributeValues(element, kAXChildrenAttribute as CFString, 0, count, &value) == .success else { return nil }
|
||||||
return AXUIElementCopyAttributeValues(element, kAXChildrenAttribute as CFString, 0, count, &value) == .success ? value as? [AXUIElement] ?? [] : []
|
return value as? [AXUIElement]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
func text(_ element: AXUIElement, _ key: String) -> Any { (attribute(element, key) as? String) ?? NSNull() as Any }
|
func text(_ element: AXUIElement, _ key: String) -> Any { (attribute(element, key) as? String) ?? NSNull() as Any }
|
||||||
func windowBounds(_ element: AXUIElement) -> CGRect? {
|
func windowBounds(_ element: AXUIElement) -> CGRect? {
|
||||||
@@ -115,9 +116,12 @@ func observe(_ request: Request) async throws -> [String: Any] {
|
|||||||
if path.count >= 32 { if totalChildren > 0 { truncated = true }; continue }
|
if path.count >= 32 { if totalChildren > 0 { truncated = true }; continue }
|
||||||
let available = max(0, request.max_nodes - nodes.count - pending.count)
|
let available = max(0, request.max_nodes - nodes.count - pending.count)
|
||||||
let count = min(available, totalChildren)
|
let count = min(available, totalChildren)
|
||||||
let items = children(element, limit: count)
|
let batch = children(element, count: count)
|
||||||
|
if !batch.complete { truncated = true }
|
||||||
if totalChildren > count { truncated = true }
|
if totalChildren > count { truncated = true }
|
||||||
for index in (0..<count).reversed() { pending.append((items[index], path + [index])) }
|
for (index, item) in batch.values.enumerated().reversed() {
|
||||||
|
pending.append((item, path + [index]))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var screenshot: Any = NSNull()
|
var screenshot: Any = NSNull()
|
||||||
|
|||||||
@@ -295,6 +295,30 @@ lifecycles. Runtime ports retain their distinct Inspector, passive Electron and
|
|||||||
active Electron effects; shipped Electron hooks remain at their existing
|
active Electron effects; shipped Electron hooks remain at their existing
|
||||||
provider boundary.
|
provider boundary.
|
||||||
|
|
||||||
|
## Managed capability ownership
|
||||||
|
|
||||||
|
`src/domain/managed/` owns managed artifact and member semantics, reconstruction
|
||||||
|
import, native-boundary verification and application graph projection.
|
||||||
|
`src/application/managed/` owns their shared Evidence workflows, and
|
||||||
|
`src/contracts/managed/` owns their named contracts and examples. Producer
|
||||||
|
metadata/IL parsing stays in `src/dotnet/`; target resolution, Evidence, ordering
|
||||||
|
and investigation records retain their shared owners. Path-based member
|
||||||
|
comparison preserves its actual target/byte-digest admission and existing parser
|
||||||
|
helper.
|
||||||
|
|
||||||
|
`scripts/verify/managed/` groups the portable conformance entrypoint and its
|
||||||
|
support, manifest, oracle and completion-report helpers. Its PE byte fixture
|
||||||
|
builder and declaration live in `scripts/fixtures/managed/`, shared with the
|
||||||
|
installed-package lane and existing managed conformance tests. `verify:managed`
|
||||||
|
keeps its command name and optional caller-cwd manifest resolution. Compiled
|
||||||
|
catalog and generator imports follow the owners; document-check cache inputs
|
||||||
|
include the relocated runtime verifier and fixture files.
|
||||||
|
|
||||||
|
Portable byte fixtures, optional operator-local manifests, actual ILSpy oracles
|
||||||
|
and real Ghidra NativeAOT checks retain their distinct proof levels and
|
||||||
|
prerequisites. The existing NativeAOT fixture/engine lane keeps its owner. This
|
||||||
|
move preserves implementations, Evidence identities and generated commitments.
|
||||||
|
|
||||||
## Binary application ownership
|
## Binary application ownership
|
||||||
|
|
||||||
`src/application/binary/` owns the active session, deep-provider registry and
|
`src/application/binary/` owns the active session, deep-provider registry and
|
||||||
|
|||||||
@@ -669,9 +669,9 @@
|
|||||||
"mcp_prompts": 6
|
"mcp_prompts": 6
|
||||||
},
|
},
|
||||||
"digests": {
|
"digests": {
|
||||||
"tools_sha256": "c7373daff6f47d20cd5a172d0ef8371e748ae19b181371bfdd7a0a63e0958ddd",
|
"tools_sha256": "be1e9960aa3f883718336cdef7ea8e3230afb92bc1066410a90f7768c3e76a65",
|
||||||
"prompts_sha256": "ef2de8814390b340623c32001610aa2709d90bed51537b6e562ab3abf144ab4d",
|
"prompts_sha256": "ef2de8814390b340623c32001610aa2709d90bed51537b6e562ab3abf144ab4d",
|
||||||
"combined_sha256": "c78943b1c2690688aafee61608a87a0a1e7385a496533bc9f72cbdee72e09a37",
|
"combined_sha256": "7b69d46ec74998e90d856f650b8f24affa362fbc6c48e49f0b8ddbb836125d8a",
|
||||||
"providers_sha256": "a7d885531ee25d42c51385444faec544d34cd7eba6250a7dc75c4faedd4454a3"
|
"providers_sha256": "a7d885531ee25d42c51385444faec544d34cd7eba6250a7dc75c4faedd4454a3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-2
@@ -61,6 +61,16 @@ needed, exercise the actual target through browser, Electron, or process
|
|||||||
capture. Real model trials are manual; Vitest covers deterministic evaluator
|
capture. Real model trials are manual; Vitest covers deterministic evaluator
|
||||||
logic.
|
logic.
|
||||||
|
|
||||||
|
`verify:managed` runs the portable PE byte-fixture conformance entrypoint under
|
||||||
|
`scripts/verify/managed/`, with its byte builder under
|
||||||
|
`scripts/fixtures/managed/`. It checks static classification, members,
|
||||||
|
reconstruction, native-boundary relationships and application graphs without
|
||||||
|
executing fixture PE files. Operator-local manifests and actual ILSpy oracles
|
||||||
|
remain optional, separately reported checks; the real Ghidra NativeAOT lane has
|
||||||
|
its own toolchain prerequisites. See [the managed guide](managed-code-analysis.md)
|
||||||
|
for those configurations. Generated completion-ledger checks use the same owning
|
||||||
|
entrypoint and include its verifier/fixture files in their cache inputs.
|
||||||
|
|
||||||
## End-to-end, integration and golden evidence
|
## End-to-end, integration and golden evidence
|
||||||
|
|
||||||
Full E2E tests invoke the production command dispatcher and real providers,
|
Full E2E tests invoke the production command dispatcher and real providers,
|
||||||
@@ -334,8 +344,8 @@ CI exercises the pinned Node.js runtime on native hosted runners:
|
|||||||
| --------------------- | ------------------ | ---------------------------------------------------------------------------------------- |
|
| --------------------- | ------------------ | ---------------------------------------------------------------------------------------- |
|
||||||
| Linux x64 | `ubuntu-latest` | Installed package and real Node Inspector CLI/MCP |
|
| Linux x64 | `ubuntu-latest` | Installed package and real Node Inspector CLI/MCP |
|
||||||
| Linux arm64 (aarch64) | `ubuntu-24.04-arm` | Installed package and real Node Inspector CLI/MCP |
|
| Linux arm64 (aarch64) | `ubuntu-24.04-arm` | Installed package and real Node Inspector CLI/MCP |
|
||||||
| macOS arm64 | `macos-14` | Installed package and real Node Inspector CLI/MCP |
|
| macOS 15 arm64 | `macos-15` | Installed package and real Node Inspector CLI/MCP |
|
||||||
| macOS x64 | `macos-15-intel` | Installed package and real Node Inspector CLI/MCP |
|
| macOS 15 x64 | `macos-15-intel` | Installed package and real Node Inspector CLI/MCP |
|
||||||
| Windows x64 | `windows-latest` | Curated capabilities, native controls, installed package and real Node Inspector CLI/MCP |
|
| Windows x64 | `windows-latest` | Curated capabilities, native controls, installed package and real Node Inspector CLI/MCP |
|
||||||
|
|
||||||
Package and Inspector matrices assert the actual Node platform/architecture
|
Package and Inspector matrices assert the actual Node platform/architecture
|
||||||
@@ -345,6 +355,11 @@ limits. Package checks cover installation, CLI/MCP discovery, target-free
|
|||||||
analysis, configuration backups/recovery, Evidence and owned lifecycle; Inspector
|
analysis, configuration backups/recovery, Evidence and owned lifecycle; Inspector
|
||||||
checks execute source-owned loopback targets and special filename cases.
|
checks execute source-owned loopback targets and special filename cases.
|
||||||
|
|
||||||
|
macOS uses one OS version with one native baseline job per architecture. Each job
|
||||||
|
runs package and Inspector checks after a single dependency installation. The
|
||||||
|
separate Inspector matrix covers Linux and Windows; Apple artifact checks retain
|
||||||
|
their own macOS 15 arm64 job for Xcode-dependent workflows.
|
||||||
|
|
||||||
These native baseline checks complement the Linux source-test shards and the
|
These native baseline checks complement the Linux source-test shards and the
|
||||||
separate Apple-artifact and real-provider lanes. Actual Hopper, Ghidra, IDA,
|
separate Apple-artifact and real-provider lanes. Actual Hopper, Ghidra, IDA,
|
||||||
browser and managed-tool claims require their corresponding verification lanes.
|
browser and managed-tool claims require their corresponding verification lanes.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"manifest_id": "ecm_f6604e02c812e3c564e5dc64c531321fbe4d3f788e90830b3584e330b1f8fdd7",
|
"manifest_id": "ecm_b9deaf8c476e6ab8b2ca20046190ea1538c863d9a25763ed0b637fe2bd316467",
|
||||||
"verifier": {
|
"verifier": {
|
||||||
"id": "rea-managed-conformance",
|
"id": "rea-managed-conformance",
|
||||||
"version": "1"
|
"version": "1"
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"skill_digests": [
|
"skill_digests": [
|
||||||
{
|
{
|
||||||
"skill_id": "reverse-engineer-anything",
|
"skill_id": "reverse-engineer-anything",
|
||||||
"sha256": "cb96a48bb7c9c0f06e03d9caacd129fd6995091d339b63e269de11d363a2a3a3"
|
"sha256": "cad8005182fc760894e956db9865a746b725a7e0a11e2c223fccc9e8c1797368"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"claims": [
|
"claims": [
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"vitepress": {
|
"vitepress": {
|
||||||
"entry": ["docs/.vitepress/config.ts"]
|
"entry": ["docs/.vitepress/config.ts"]
|
||||||
},
|
},
|
||||||
|
"ignoreBinaries": ["mkfifo"],
|
||||||
"ignoreDependencies": ["electron", "esbuild", "webpack"],
|
"ignoreDependencies": ["electron", "esbuild", "webpack"],
|
||||||
"ignoreExportsUsedInFile": true,
|
"ignoreExportsUsedInFile": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|||||||
+2
-1
@@ -42,6 +42,7 @@
|
|||||||
"dist",
|
"dist",
|
||||||
"install.sh",
|
"install.sh",
|
||||||
"bridge/hopper_bridge.py",
|
"bridge/hopper_bridge.py",
|
||||||
|
"bridge/native/NativeUIChildren.swift",
|
||||||
"bridge/native/ReaNativeUI.swift",
|
"bridge/native/ReaNativeUI.swift",
|
||||||
"bridge/ghidra/ReaGhidraBridge.java",
|
"bridge/ghidra/ReaGhidraBridge.java",
|
||||||
"bridge/ghidra/ReaGhidraExtensions.java",
|
"bridge/ghidra/ReaGhidraExtensions.java",
|
||||||
@@ -142,7 +143,7 @@
|
|||||||
"verify:javascript-runtime": "npm run build:cached && node scripts/verify/javascript/runtime-observation.mjs",
|
"verify:javascript-runtime": "npm run build:cached && node scripts/verify/javascript/runtime-observation.mjs",
|
||||||
"verify:javascript:digests": "npm run build:cached && node scripts/verify/javascript/digests.mjs",
|
"verify:javascript:digests": "npm run build:cached && node scripts/verify/javascript/digests.mjs",
|
||||||
"verify:application-workflows": "npm run build:cached && node scripts/verify/javascript/application-workflows.mjs",
|
"verify:application-workflows": "npm run build:cached && node scripts/verify/javascript/application-workflows.mjs",
|
||||||
"verify:managed": "npm run build:cached && node scripts/verify-managed-conformance.mjs",
|
"verify:managed": "npm run build:cached && node scripts/verify/managed/conformance.mjs",
|
||||||
"verify:firmware": "npm run build:cached && node scripts/verify/firmware/analysis.mjs",
|
"verify:firmware": "npm run build:cached && node scripts/verify/firmware/analysis.mjs",
|
||||||
"fixtures:firmware": "node scripts/fixtures/firmware/generate.mjs",
|
"fixtures:firmware": "node scripts/fixtures/firmware/generate.mjs",
|
||||||
"verify:android": "npm run build:cached && node scripts/verify/android/analysis.mjs",
|
"verify:android": "npm run build:cached && node scripts/verify/android/analysis.mjs",
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ delete verifierEnvironment.REA_ILSPY_CMD_PATH;
|
|||||||
|
|
||||||
const { stdout } = await exec(
|
const { stdout } = await exec(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[join(root, "scripts/verify-managed-conformance.mjs")],
|
[join(root, "scripts/verify/managed/conformance.mjs")],
|
||||||
{
|
{
|
||||||
cwd: root,
|
cwd: root,
|
||||||
env: verifierEnvironment,
|
env: verifierEnvironment,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Ajv2020 } from "ajv/dist/2020.js";
|
|||||||
import { McpServer } from "@modelcontextprotocol/server";
|
import { McpServer } from "@modelcontextprotocol/server";
|
||||||
|
|
||||||
import { TOOL_CONTRACTS } from "../dist/contracts/toolContracts.js";
|
import { TOOL_CONTRACTS } from "../dist/contracts/toolContracts.js";
|
||||||
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "../dist/contracts/managedWorkflowToolContracts.js";
|
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "../dist/contracts/managed/managedWorkflowToolContracts.js";
|
||||||
import { auxiliaryAnalysisProviderDeclarations } from "../dist/composition/auxiliaryAnalysisProviders.js";
|
import { auxiliaryAnalysisProviderDeclarations } from "../dist/composition/auxiliaryAnalysisProviders.js";
|
||||||
import { toolRegistrationOptions } from "../dist/server/toolRegistrationOptions.js";
|
import { toolRegistrationOptions } from "../dist/server/toolRegistrationOptions.js";
|
||||||
import { ensureGeneratedFile } from "./lib/generated-file.mjs";
|
import { ensureGeneratedFile } from "./lib/generated-file.mjs";
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ import time
|
|||||||
# Keep this digest aligned with LinuxHopper.ts and rerun real-Hopper verification
|
# Keep this digest aligned with LinuxHopper.ts and rerun real-Hopper verification
|
||||||
# before accepting another vendor build.
|
# before accepting another vendor build.
|
||||||
SUPPORTED_HOPPER_SHA256 = {
|
SUPPORTED_HOPPER_SHA256 = {
|
||||||
"0294ced141cc373468ee22d8343e7dac41980cb05a937994ca81c9f09afe7ded"
|
"0294ced141cc373468ee22d8343e7dac41980cb05a937994ca81c9f09afe7ded",
|
||||||
|
"1339f9e58377442b0c6fcb0dfc3cec20d593cc557408521fad9a00dbc6b8da13",
|
||||||
}
|
}
|
||||||
EXPECTED_SCREEN = (1280, 1024)
|
EXPECTED_SCREEN = (1280, 1024)
|
||||||
EXPECTED_DIALOG = (189, 370, 901, 284)
|
EXPECTED_DIALOG = (189, 370, 901, 284)
|
||||||
|
|||||||
@@ -42,12 +42,13 @@ const SOURCE_PATHS = {
|
|||||||
sessionContracts: "dist/contracts/sessionToolContracts.js",
|
sessionContracts: "dist/contracts/sessionToolContracts.js",
|
||||||
nativeContracts: "dist/contracts/nativeToolContracts.js",
|
nativeContracts: "dist/contracts/nativeToolContracts.js",
|
||||||
artifactContracts: "dist/contracts/artifactToolContracts.js",
|
artifactContracts: "dist/contracts/artifactToolContracts.js",
|
||||||
managedContracts: "dist/contracts/managedToolContracts.js",
|
managedContracts: "dist/contracts/managed/managedToolContracts.js",
|
||||||
firmwareContracts: "dist/contracts/firmware/firmwareToolContracts.js",
|
firmwareContracts: "dist/contracts/firmware/firmwareToolContracts.js",
|
||||||
firmwareProvider: "dist/firmware/FirmwareRelease.js",
|
firmwareProvider: "dist/firmware/FirmwareRelease.js",
|
||||||
androidContracts: "dist/contracts/android/androidToolContracts.js",
|
androidContracts: "dist/contracts/android/androidToolContracts.js",
|
||||||
androidProvider: "dist/android/JadxRelease.js",
|
androidProvider: "dist/android/JadxRelease.js",
|
||||||
managedWorkflowContracts: "dist/contracts/managedWorkflowToolContracts.js",
|
managedWorkflowContracts:
|
||||||
|
"dist/contracts/managed/managedWorkflowToolContracts.js",
|
||||||
browserContracts: "dist/contracts/browserToolContracts.js",
|
browserContracts: "dist/contracts/browserToolContracts.js",
|
||||||
browserScenarioContracts: "dist/contracts/browserScenarioToolContracts.js",
|
browserScenarioContracts: "dist/contracts/browserScenarioToolContracts.js",
|
||||||
electronContracts: "dist/contracts/javascript/electronToolContracts.js",
|
electronContracts: "dist/contracts/javascript/electronToolContracts.js",
|
||||||
@@ -88,9 +89,9 @@ const SOURCE_PATHS = {
|
|||||||
"dist/domain/javascript/javascriptRuntimeObservation.js",
|
"dist/domain/javascript/javascriptRuntimeObservation.js",
|
||||||
webBundleAnalysis: "dist/domain/webBundleAnalysis.js",
|
webBundleAnalysis: "dist/domain/webBundleAnalysis.js",
|
||||||
webCaptureDiff: "dist/domain/webCaptureDiff.js",
|
webCaptureDiff: "dist/domain/webCaptureDiff.js",
|
||||||
managedArtifact: "dist/domain/managedArtifact.js",
|
managedArtifact: "dist/domain/managed/managedArtifact.js",
|
||||||
managedComparison: "dist/domain/managedMemberComparison.js",
|
managedComparison: "dist/domain/managed/managedMemberComparison.js",
|
||||||
managedNativeVerification: "dist/domain/managedNativeVerification.js",
|
managedNativeVerification: "dist/domain/managed/managedNativeVerification.js",
|
||||||
webMcpDiscovery: "dist/domain/webMcpDiscovery.js",
|
webMcpDiscovery: "dist/domain/webMcpDiscovery.js",
|
||||||
webScreenshot: "dist/domain/webScreenshot.js",
|
webScreenshot: "dist/domain/webScreenshot.js",
|
||||||
javascriptApplicationGraph:
|
javascriptApplicationGraph:
|
||||||
|
|||||||
@@ -15,6 +15,23 @@ const root = await mkdtemp(join(tmpdir(), "rea-ui-fixture-"));
|
|||||||
let child;
|
let child;
|
||||||
let fixturePid;
|
let fixturePid;
|
||||||
try {
|
try {
|
||||||
|
const childRetrievalTest = join(root, "child-retrieval-test");
|
||||||
|
await promisify(execFile)("/usr/bin/xcrun", [
|
||||||
|
"swiftc",
|
||||||
|
fileURLToPath(
|
||||||
|
new URL("../bridge/native/NativeUIChildren.swift", import.meta.url),
|
||||||
|
),
|
||||||
|
fileURLToPath(
|
||||||
|
new URL(
|
||||||
|
"../tests/conformance/native/native-ui-children/main.swift",
|
||||||
|
import.meta.url,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
"-o",
|
||||||
|
childRetrievalTest,
|
||||||
|
]);
|
||||||
|
await promisify(execFile)(childRetrievalTest, []);
|
||||||
|
|
||||||
const contents = join(root, "Fixture.app", "Contents");
|
const contents = join(root, "Fixture.app", "Contents");
|
||||||
await mkdir(join(contents, "MacOS"), { recursive: true });
|
await mkdir(join(contents, "MacOS"), { recursive: true });
|
||||||
await writeFile(
|
await writeFile(
|
||||||
@@ -82,7 +99,6 @@ try {
|
|||||||
"capture_native_ui_scenario",
|
"capture_native_ui_scenario",
|
||||||
{
|
{
|
||||||
...scope,
|
...scope,
|
||||||
restore: "leave-as-is",
|
|
||||||
screenshot: false,
|
screenshot: false,
|
||||||
steps: [
|
steps: [
|
||||||
{ kind: "click", path: button.path },
|
{ kind: "click", path: button.path },
|
||||||
@@ -111,8 +127,6 @@ try {
|
|||||||
String(scope.pid),
|
String(scope.pid),
|
||||||
"--window-id",
|
"--window-id",
|
||||||
String(scope.window_id),
|
String(scope.window_id),
|
||||||
"--restore",
|
|
||||||
"leave-as-is",
|
|
||||||
"--steps",
|
"--steps",
|
||||||
JSON.stringify([
|
JSON.stringify([
|
||||||
{ kind: "click", path: button.path },
|
{ kind: "click", path: button.path },
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { writeFile } from "node:fs/promises";
|
|||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import { createEvidence } from "../dist/domain/evidence.js";
|
import { createEvidence } from "../dist/domain/evidence.js";
|
||||||
import { buildManagedPeFixture } from "./lib/managed-pe-fixture.mjs";
|
import { buildManagedPeFixture } from "./fixtures/managed/pe.mjs";
|
||||||
import { functionDossier, json, run } from "./lib/verify-package-core.mjs";
|
import { functionDossier, json, run } from "./lib/verify-package-core.mjs";
|
||||||
|
|
||||||
const buildManagedFixtures = async (workspace) => {
|
const buildManagedFixtures = async (workspace) => {
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { createEvidence } from "../../dist/domain/evidence.js";
|
import { createEvidence } from "../../../dist/domain/evidence.js";
|
||||||
|
|
||||||
const COMPLETION_PROVIDER = {
|
const COMPLETION_PROVIDER = {
|
||||||
id: "rea-managed-conformance",
|
id: "rea-managed-conformance",
|
||||||
@@ -3,21 +3,21 @@ import { tmpdir } from "node:os";
|
|||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
|
|
||||||
import { inspectManagedArtifactBytes } from "../dist/dotnet/ManagedArtifactInspector.js";
|
import { inspectManagedArtifactBytes } from "../../../dist/dotnet/ManagedArtifactInspector.js";
|
||||||
import { inspectManagedMembersBytes } from "../dist/dotnet/ManagedMemberInspector.js";
|
import { inspectManagedMembersBytes } from "../../../dist/dotnet/ManagedMemberInspector.js";
|
||||||
import { inspectManagedNativeBoundariesBytes } from "../dist/dotnet/ManagedNativeBoundaryInspector.js";
|
import { inspectManagedNativeBoundariesBytes } from "../../../dist/dotnet/ManagedNativeBoundaryInspector.js";
|
||||||
import { compareManagedMemberPaths } from "../dist/application/ManagedMemberComparisonService.js";
|
import { compareManagedMemberPaths } from "../../../dist/application/managed/ManagedMemberComparisonService.js";
|
||||||
import { verifyManagedNativeBoundariesEvidence } from "../dist/application/ManagedNativeVerificationService.js";
|
import { verifyManagedNativeBoundariesEvidence } from "../../../dist/application/managed/ManagedNativeVerificationService.js";
|
||||||
import { importManagedReconstructionEvidence } from "../dist/application/ManagedReconstructionService.js";
|
import { importManagedReconstructionEvidence } from "../../../dist/application/managed/ManagedReconstructionService.js";
|
||||||
import { projectManagedApplicationGraphEvidence } from "../dist/application/ManagedApplicationGraphService.js";
|
import { projectManagedApplicationGraphEvidence } from "../../../dist/application/managed/ManagedApplicationGraphService.js";
|
||||||
import { traceApplicationFeatureEvidence } from "../dist/application/javascript/JavaScriptApplicationWorkflowService.js";
|
import { traceApplicationFeatureEvidence } from "../../../dist/application/javascript/JavaScriptApplicationWorkflowService.js";
|
||||||
import { MANAGED_STATIC_PROVIDER } from "../dist/application/InvestigationProviders.js";
|
import { MANAGED_STATIC_PROVIDER } from "../../../dist/application/InvestigationProviders.js";
|
||||||
import { createEvidence } from "../dist/domain/evidence.js";
|
import { createEvidence } from "../../../dist/domain/evidence.js";
|
||||||
import {
|
import {
|
||||||
alternateMvid,
|
alternateMvid,
|
||||||
buildNativePeFixture,
|
buildNativePeFixture,
|
||||||
} from "./lib/managed-pe-fixture.mjs";
|
} from "../../fixtures/managed/pe.mjs";
|
||||||
import { createManagedConformanceSupport } from "./lib/managed-conformance-support.mjs";
|
import { createManagedConformanceSupport } from "./support.mjs";
|
||||||
import {
|
import {
|
||||||
comparisonLimits,
|
comparisonLimits,
|
||||||
defaultIlBody,
|
defaultIlBody,
|
||||||
@@ -25,9 +25,12 @@ import {
|
|||||||
inspectionLimits,
|
inspectionLimits,
|
||||||
memberLimits,
|
memberLimits,
|
||||||
nativeBoundaryLimits,
|
nativeBoundaryLimits,
|
||||||
} from "./lib/managed-conformance-config.mjs";
|
} from "./config.mjs";
|
||||||
import { createManagedCompletionReport } from "./lib/managed-completion-report.mjs";
|
import { createManagedCompletionReport } from "./completion-report.mjs";
|
||||||
import { completeVerifierRun, createVerifierRun } from "./lib/verifier-run.mjs";
|
import {
|
||||||
|
completeVerifierRun,
|
||||||
|
createVerifierRun,
|
||||||
|
} from "../../lib/verifier-run.mjs";
|
||||||
|
|
||||||
const verifierRun = createVerifierRun();
|
const verifierRun = createVerifierRun();
|
||||||
const workspace = await mkdtemp(join(tmpdir(), "rea-managed-conformance-"));
|
const workspace = await mkdtemp(join(tmpdir(), "rea-managed-conformance-"));
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
import { basename, dirname, isAbsolute, resolve } from "node:path";
|
import { basename, dirname, isAbsolute, resolve } from "node:path";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
|
|
||||||
import { parseBinaryTarget } from "../../dist/application/BinaryTargetResolver.js";
|
import { parseBinaryTarget } from "../../../dist/application/BinaryTargetResolver.js";
|
||||||
import { inspectManagedArtifactBytes } from "../../dist/dotnet/ManagedArtifactInspector.js";
|
import { inspectManagedArtifactBytes } from "../../../dist/dotnet/ManagedArtifactInspector.js";
|
||||||
import { inspectManagedMembersBytes } from "../../dist/dotnet/ManagedMemberInspector.js";
|
import { inspectManagedMembersBytes } from "../../../dist/dotnet/ManagedMemberInspector.js";
|
||||||
import { projectManagedApplicationGraphEvidence } from "../../dist/application/ManagedApplicationGraphService.js";
|
import { projectManagedApplicationGraphEvidence } from "../../../dist/application/managed/ManagedApplicationGraphService.js";
|
||||||
import { traceApplicationFeatureEvidence } from "../../dist/application/javascript/JavaScriptApplicationWorkflowService.js";
|
import { traceApplicationFeatureEvidence } from "../../../dist/application/javascript/JavaScriptApplicationWorkflowService.js";
|
||||||
import { createEvidence } from "../../dist/domain/evidence.js";
|
import { createEvidence } from "../../../dist/domain/evidence.js";
|
||||||
import { MANAGED_STATIC_PROVIDER } from "../../dist/application/InvestigationProviders.js";
|
import { MANAGED_STATIC_PROVIDER } from "../../../dist/application/InvestigationProviders.js";
|
||||||
import {
|
import {
|
||||||
ensure,
|
ensure,
|
||||||
methodTokenRow,
|
methodTokenRow,
|
||||||
parseManagedAppManifest,
|
parseManagedAppManifest,
|
||||||
} from "./managed-conformance-manifest-parser.mjs";
|
} from "./manifest-parser.mjs";
|
||||||
|
|
||||||
export const createManagedManifestVerifier = (context) => ({
|
export const createManagedManifestVerifier = (context) => ({
|
||||||
verifyManagedAppManifest: (rawManifest, manifestPath) =>
|
verifyManagedAppManifest: (rawManifest, manifestPath) =>
|
||||||
@@ -5,12 +5,12 @@ import { basename, isAbsolute, join, resolve } from "node:path";
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { promisify } from "node:util";
|
import { promisify } from "node:util";
|
||||||
|
|
||||||
import { inspectManagedArtifactBytes } from "../../dist/dotnet/ManagedArtifactInspector.js";
|
import { inspectManagedArtifactBytes } from "../../../dist/dotnet/ManagedArtifactInspector.js";
|
||||||
import { inspectManagedMembersBytes } from "../../dist/dotnet/ManagedMemberInspector.js";
|
import { inspectManagedMembersBytes } from "../../../dist/dotnet/ManagedMemberInspector.js";
|
||||||
import { importManagedReconstructionEvidence } from "../../dist/application/ManagedReconstructionService.js";
|
import { importManagedReconstructionEvidence } from "../../../dist/application/managed/ManagedReconstructionService.js";
|
||||||
import { createEvidence } from "../../dist/domain/evidence.js";
|
import { createEvidence } from "../../../dist/domain/evidence.js";
|
||||||
import { MANAGED_STATIC_PROVIDER } from "../../dist/application/InvestigationProviders.js";
|
import { MANAGED_STATIC_PROVIDER } from "../../../dist/application/InvestigationProviders.js";
|
||||||
import { createManagedManifestVerifier } from "./managed-conformance-manifest.mjs";
|
import { createManagedManifestVerifier } from "./manifest.mjs";
|
||||||
|
|
||||||
const execFileAsync = promisify(execFile);
|
const execFileAsync = promisify(execFile);
|
||||||
|
|
||||||
@@ -2,9 +2,9 @@ import { createHash } from "node:crypto";
|
|||||||
import { writeFile } from "node:fs/promises";
|
import { writeFile } from "node:fs/promises";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import { parseBinaryTarget } from "../../dist/application/BinaryTargetResolver.js";
|
import { parseBinaryTarget } from "../../../dist/application/BinaryTargetResolver.js";
|
||||||
import { buildManagedPeFixture } from "./managed-pe-fixture.mjs";
|
import { buildManagedPeFixture } from "../../fixtures/managed/pe.mjs";
|
||||||
import { createManagedConformanceOracleSupport } from "./managed-conformance-oracles.mjs";
|
import { createManagedConformanceOracleSupport } from "./oracles.mjs";
|
||||||
|
|
||||||
export const createManagedConformanceSupport = (context) => {
|
export const createManagedConformanceSupport = (context) => {
|
||||||
const fixtureBytes = async (name, bytes) => {
|
const fixtureBytes = async (name, bytes) => {
|
||||||
@@ -4,7 +4,7 @@ description: Reverse engineer native, managed, Electron/JavaScript, packaged, fi
|
|||||||
metadata:
|
metadata:
|
||||||
version: "28"
|
version: "28"
|
||||||
tool_count: 131
|
tool_count: 131
|
||||||
catalog_digest: "c78943b1c2690688aafee61608a87a0a1e7385a496533bc9f72cbdee72e09a37"
|
catalog_digest: "7b69d46ec74998e90d856f650b8f24affa362fbc6c48e49f0b8ddbb836125d8a"
|
||||||
---
|
---
|
||||||
|
|
||||||
# REA
|
# REA
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ export class JadxMcpTransport implements Transport {
|
|||||||
readonly runId = randomUUID();
|
readonly runId = randomUUID();
|
||||||
#spawned: SpawnedOwnedProviderProcess | undefined;
|
#spawned: SpawnedOwnedProviderProcess | undefined;
|
||||||
#supervisor: ProviderProcessSupervisor | undefined;
|
#supervisor: ProviderProcessSupervisor | undefined;
|
||||||
#buffer = Buffer.alloc(0);
|
#frameBuffer = Buffer.alloc(0);
|
||||||
|
#frameLength = 0;
|
||||||
#bytes = 0;
|
#bytes = 0;
|
||||||
#started = false;
|
#started = false;
|
||||||
#closed = false;
|
#closed = false;
|
||||||
@@ -61,12 +62,16 @@ export class JadxMcpTransport implements Transport {
|
|||||||
stdin: "pipe",
|
stdin: "pipe",
|
||||||
});
|
});
|
||||||
this.#spawned = spawned;
|
this.#spawned = spawned;
|
||||||
this.#supervisor = new ProviderProcessSupervisor({
|
this.#supervisor = new ProviderProcessSupervisor(
|
||||||
...spawned,
|
{
|
||||||
ownsProcessLifetime: true,
|
...spawned,
|
||||||
cleanup:
|
ownsProcessLifetime: true,
|
||||||
spawned.cleanup ?? (() => cleanupOwnedProcessGroup(spawned.ownership)),
|
cleanup:
|
||||||
});
|
spawned.cleanup ??
|
||||||
|
(() => cleanupOwnedProcessGroup(spawned.ownership)),
|
||||||
|
},
|
||||||
|
{ captureStdout: false },
|
||||||
|
);
|
||||||
if (
|
if (
|
||||||
spawned.process.stdin === undefined ||
|
spawned.process.stdin === undefined ||
|
||||||
spawned.process.stdin === null ||
|
spawned.process.stdin === null ||
|
||||||
@@ -117,6 +122,8 @@ export class JadxMcpTransport implements Transport {
|
|||||||
|
|
||||||
async #stop(): Promise<void> {
|
async #stop(): Promise<void> {
|
||||||
this.#closed = true;
|
this.#closed = true;
|
||||||
|
this.#frameBuffer = Buffer.alloc(0);
|
||||||
|
this.#frameLength = 0;
|
||||||
// A cancellation may race acquisition. Join it before inspecting ownership.
|
// A cancellation may race acquisition. Join it before inspecting ownership.
|
||||||
await this.#starting?.catch(() => undefined);
|
await this.#starting?.catch(() => undefined);
|
||||||
const process = this.#spawned?.process;
|
const process = this.#spawned?.process;
|
||||||
@@ -161,22 +168,42 @@ export class JadxMcpTransport implements Transport {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.#buffer = Buffer.concat([this.#buffer, bytes]);
|
|
||||||
try {
|
try {
|
||||||
let newline: number;
|
let offset = 0;
|
||||||
while ((newline = this.#buffer.indexOf(10)) !== -1) {
|
while (offset < bytes.length) {
|
||||||
if (newline > MAX_FRAME_BYTES)
|
const newline = bytes.indexOf(10, offset);
|
||||||
|
const end = newline === -1 ? bytes.length : newline;
|
||||||
|
const fragment = bytes.subarray(offset, end);
|
||||||
|
const frameBytes = this.#frameLength + fragment.length;
|
||||||
|
if (frameBytes > MAX_FRAME_BYTES)
|
||||||
throw new Error(`JADX MCP frame exceeds ${MAX_FRAME_BYTES} bytes`);
|
throw new Error(`JADX MCP frame exceeds ${MAX_FRAME_BYTES} bytes`);
|
||||||
const line = this.#buffer.subarray(0, newline).toString("utf8");
|
this.#appendFrame(fragment, frameBytes);
|
||||||
this.#buffer = this.#buffer.subarray(newline + 1);
|
if (newline === -1) return;
|
||||||
|
const line = this.#frameBuffer
|
||||||
|
.subarray(0, this.#frameLength)
|
||||||
|
.toString("utf8");
|
||||||
|
this.#frameBuffer = Buffer.alloc(0);
|
||||||
|
this.#frameLength = 0;
|
||||||
this.onmessage?.(deserializeMessage(line));
|
this.onmessage?.(deserializeMessage(line));
|
||||||
|
offset = newline + 1;
|
||||||
}
|
}
|
||||||
if (this.#buffer.length > MAX_FRAME_BYTES)
|
|
||||||
throw new Error(`JADX MCP frame exceeds ${MAX_FRAME_BYTES} bytes`);
|
|
||||||
} catch (cause) {
|
} catch (cause) {
|
||||||
this.#fail(cause instanceof Error ? cause : new Error(String(cause)));
|
this.#fail(cause instanceof Error ? cause : new Error(String(cause)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#appendFrame(fragment: Buffer, frameBytes: number): void {
|
||||||
|
if (frameBytes > this.#frameBuffer.length) {
|
||||||
|
const capacity = Math.min(
|
||||||
|
MAX_FRAME_BYTES,
|
||||||
|
Math.max(frameBytes, this.#frameBuffer.length * 2, 1),
|
||||||
|
);
|
||||||
|
const grown = Buffer.allocUnsafe(capacity);
|
||||||
|
this.#frameBuffer.copy(grown, 0, 0, this.#frameLength);
|
||||||
|
this.#frameBuffer = grown;
|
||||||
|
}
|
||||||
|
fragment.copy(this.#frameBuffer, this.#frameLength);
|
||||||
|
this.#frameLength = frameBytes;
|
||||||
|
}
|
||||||
#fail(error: Error): void {
|
#fail(error: Error): void {
|
||||||
this.#failure ??= error.message;
|
this.#failure ??= error.message;
|
||||||
this.onerror?.(error);
|
this.onerror?.(error);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { OfficialToolName } from "../contracts/officialToolContracts.js";
|
|||||||
import type { EnhancedToolName } from "../contracts/enhancedInputs.js";
|
import type { EnhancedToolName } from "../contracts/enhancedInputs.js";
|
||||||
import type { NativeToolName } from "../contracts/nativeToolContracts.js";
|
import type { NativeToolName } from "../contracts/nativeToolContracts.js";
|
||||||
import type { ArtifactAnalysisOperation } from "../contracts/artifactToolContracts.js";
|
import type { ArtifactAnalysisOperation } from "../contracts/artifactToolContracts.js";
|
||||||
import type { ManagedToolName } from "../contracts/managedToolContracts.js";
|
import type { ManagedToolName } from "../contracts/managed/managedToolContracts.js";
|
||||||
import type { AnalysisError } from "../domain/analysisErrorBase.js";
|
import type { AnalysisError } from "../domain/analysisErrorBase.js";
|
||||||
import type { AnalysisProfileCommitment } from "../domain/analysisProfile.js";
|
import type { AnalysisProfileCommitment } from "../domain/analysisProfile.js";
|
||||||
import type { JsonValue } from "../domain/jsonValue.js";
|
import type { JsonValue } from "../domain/jsonValue.js";
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import type { ArtifactAnalysisOperation } from "../contracts/artifactToolContrac
|
|||||||
import {
|
import {
|
||||||
isManagedToolName,
|
isManagedToolName,
|
||||||
type ManagedToolName,
|
type ManagedToolName,
|
||||||
} from "../contracts/managedToolContracts.js";
|
} from "../contracts/managed/managedToolContracts.js";
|
||||||
import { EvidenceIntegrityError } from "../domain/evidenceErrors.js";
|
import { EvidenceIntegrityError } from "../domain/evidenceErrors.js";
|
||||||
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
||||||
import { type AnalysisError } from "../domain/analysisErrorBase.js";
|
import { type AnalysisError } from "../domain/analysisErrorBase.js";
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { describe, expect, it } from "vitest";
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
installLinuxHopper,
|
installLinuxHopper,
|
||||||
|
linuxHopperLauncherDigestSupported,
|
||||||
linuxHopperInstallDisclosure,
|
linuxHopperInstallDisclosure,
|
||||||
linuxPackageManagerCommands,
|
linuxPackageManagerCommands,
|
||||||
linuxSharedLibrariesAvailable,
|
linuxSharedLibrariesAvailable,
|
||||||
@@ -93,6 +94,20 @@ describe("Linux Hopper host classification", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Linux Hopper installation", () => {
|
describe("Linux Hopper installation", () => {
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
"Debian and Arch",
|
||||||
|
"0294ced141cc373468ee22d8343e7dac41980cb05a937994ca81c9f09afe7ded",
|
||||||
|
],
|
||||||
|
["RPM", "1339f9e58377442b0c6fcb0dfc3cec20d593cc557408521fad9a00dbc6b8da13"],
|
||||||
|
])("accepts the pinned %s launcher build", (_, digest) => {
|
||||||
|
expect(linuxHopperLauncherDigestSupported(digest)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("rejects an unverified launcher build", () => {
|
||||||
|
expect(linuxHopperLauncherDigestSupported("0".repeat(64))).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it("discloses the exact download, integrity evidence, and privileged command", () => {
|
it("discloses the exact download, integrity evidence, and privileged command", () => {
|
||||||
expect(linuxHopperInstallDisclosure("deb", false)).toEqual({
|
expect(linuxHopperInstallDisclosure("deb", false)).toEqual({
|
||||||
downloadUrl:
|
downloadUrl:
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ import { execFileOutput } from "../process/ExecFileOutput.js";
|
|||||||
const execFileAsync = promisify(execFile);
|
const execFileAsync = promisify(execFile);
|
||||||
const DOWNLOAD_PREFIX = "https://www.hopperapp.com:443/downloader/public/";
|
const DOWNLOAD_PREFIX = "https://www.hopperapp.com:443/downloader/public/";
|
||||||
const MAX_PACKAGE_BYTES = 100_000_000;
|
const MAX_PACKAGE_BYTES = 100_000_000;
|
||||||
const SUPPORTED_HOPPER_SHA256 =
|
const SUPPORTED_HOPPER_SHA256 = new Set([
|
||||||
"0294ced141cc373468ee22d8343e7dac41980cb05a937994ca81c9f09afe7ded";
|
"0294ced141cc373468ee22d8343e7dac41980cb05a937994ca81c9f09afe7ded",
|
||||||
|
"1339f9e58377442b0c6fcb0dfc3cec20d593cc557408521fad9a00dbc6b8da13",
|
||||||
|
]);
|
||||||
interface LinuxHopperRelease {
|
interface LinuxHopperRelease {
|
||||||
readonly filename: string;
|
readonly filename: string;
|
||||||
readonly file_length: string;
|
readonly file_length: string;
|
||||||
@@ -262,7 +264,7 @@ export const linuxHopperBinarySupported = async (
|
|||||||
try {
|
try {
|
||||||
const hash = createHash("sha256");
|
const hash = createHash("sha256");
|
||||||
for await (const chunk of createReadStream(path)) hash.update(chunk);
|
for await (const chunk of createReadStream(path)) hash.update(chunk);
|
||||||
return hash.digest("hex") === SUPPORTED_HOPPER_SHA256;
|
return linuxHopperLauncherDigestSupported(hash.digest("hex"));
|
||||||
} catch (cause: unknown) {
|
} catch (cause: unknown) {
|
||||||
// best-effort cleanup: optional build probing; unreadable means unsupported.
|
// best-effort cleanup: optional build probing; unreadable means unsupported.
|
||||||
void cause;
|
void cause;
|
||||||
@@ -270,6 +272,10 @@ export const linuxHopperBinarySupported = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Match a launcher extracted from one of the pinned official Linux packages. */
|
||||||
|
export const linuxHopperLauncherDigestSupported = (digest: string): boolean =>
|
||||||
|
SUPPORTED_HOPPER_SHA256.has(digest);
|
||||||
|
|
||||||
/** Interpret ldd output conservatively so a present but broken launcher is unhealthy. */
|
/** Interpret ldd output conservatively so a present but broken launcher is unhealthy. */
|
||||||
export const linuxSharedLibrariesAvailable = (output: string): boolean =>
|
export const linuxSharedLibrariesAvailable = (output: string): boolean =>
|
||||||
!/(?:=>\s+not found|error while loading shared libraries)/iu.test(output);
|
!/(?:=>\s+not found|error while loading shared libraries)/iu.test(output);
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ export class FakeSetupHost implements SetupHost {
|
|||||||
linuxDistribution = (): Promise<LinuxDistribution | undefined> =>
|
linuxDistribution = (): Promise<LinuxDistribution | undefined> =>
|
||||||
Promise.resolve(this.distribution);
|
Promise.resolve(this.distribution);
|
||||||
hopperPath = (): Promise<string | undefined> => Promise.resolve(this.hopper);
|
hopperPath = (): Promise<string | undefined> => Promise.resolve(this.hopper);
|
||||||
|
initialSetupState = async (scope?: DoctorScope) => ({
|
||||||
|
...(this.hopper === undefined ? {} : { hopperPath: this.hopper }),
|
||||||
|
providerEnvironment: await this.providerEnvironment(),
|
||||||
|
doctor: await this.doctor(scope),
|
||||||
|
});
|
||||||
providerEnvironment = (): Promise<SetupProviderEnvironment> =>
|
providerEnvironment = (): Promise<SetupProviderEnvironment> =>
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
...(this.hopper === undefined
|
...(this.hopper === undefined
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { expect, it } from "vitest";
|
||||||
|
|
||||||
|
import { runSetup } from "./Setup.js";
|
||||||
|
import { FakeSetupHost, options } from "./Setup.fixture.js";
|
||||||
|
|
||||||
|
it("uses the shared initial host snapshot for setup planning", async () => {
|
||||||
|
const host = new FakeSetupHost();
|
||||||
|
host.hopperPath = () => {
|
||||||
|
throw new Error("setup snapshot should provide the Hopper path");
|
||||||
|
};
|
||||||
|
host.providerEnvironment = () => {
|
||||||
|
throw new Error("setup snapshot should provide provider settings");
|
||||||
|
};
|
||||||
|
host.initialSetupState = async (scope) => ({
|
||||||
|
hopperPath: "/snapshot/Hopper",
|
||||||
|
providerEnvironment: { HOPPER_LAUNCHER_PATH: "/snapshot/Hopper" },
|
||||||
|
doctor: await host.doctor(scope),
|
||||||
|
});
|
||||||
|
host.clients = [{ name: "codex", configPath: "/codex.json" }];
|
||||||
|
|
||||||
|
const result = await runSetup(
|
||||||
|
{ ...options(false), dryRun: true, clientIds: ["codex"] },
|
||||||
|
host,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.status).toBe("planned");
|
||||||
|
expect(result.plannedActions.map(({ id }) => id)).toContain(
|
||||||
|
"configure_client:codex",
|
||||||
|
);
|
||||||
|
expect(host.doctorCalls).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("refreshes doctor after approved setup changes", async () => {
|
||||||
|
const host = new FakeSetupHost();
|
||||||
|
host.doctorHealthy = false;
|
||||||
|
host.skill = "unchanged";
|
||||||
|
host.clients = [{ name: "codex", configPath: "/codex.json" }];
|
||||||
|
const configureClient = host.configureClient;
|
||||||
|
host.configureClient = (client, providerEnvironment, command) => {
|
||||||
|
host.doctorHealthy = true;
|
||||||
|
return configureClient(client, providerEnvironment, command);
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await runSetup(
|
||||||
|
{ ...options(true), clientIds: ["codex"], installSkill: false },
|
||||||
|
host,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.doctor.healthy).toBe(true);
|
||||||
|
expect(host.doctorCalls).toBe(2);
|
||||||
|
});
|
||||||
@@ -42,8 +42,15 @@ export const runSetup = async (
|
|||||||
);
|
);
|
||||||
const unsupported = await hostRemediation(host, false);
|
const unsupported = await hostRemediation(host, false);
|
||||||
if (unsupported !== undefined) return fail(unsupported);
|
if (unsupported !== undefined) return fail(unsupported);
|
||||||
let hopperPath = await host.hopperPath();
|
const initialState = await host.initialSetupState?.(options.readinessScope);
|
||||||
let providerEnvironment = await initialProviderEnvironment(host, hopperPath);
|
let hopperPath =
|
||||||
|
initialState === undefined
|
||||||
|
? await host.hopperPath()
|
||||||
|
: initialState.hopperPath;
|
||||||
|
let providerEnvironment =
|
||||||
|
initialState === undefined
|
||||||
|
? await initialProviderEnvironment(host, hopperPath)
|
||||||
|
: initialState.providerEnvironment;
|
||||||
const discovery = await discoverSetupState({
|
const discovery = await discoverSetupState({
|
||||||
host,
|
host,
|
||||||
providerEnvironment,
|
providerEnvironment,
|
||||||
@@ -51,6 +58,9 @@ export const runSetup = async (
|
|||||||
proposeHopper:
|
proposeHopper:
|
||||||
options.proposeHopper ?? (confirm !== undefined && !options.structured),
|
options.proposeHopper ?? (confirm !== undefined && !options.structured),
|
||||||
doctorScope: options.readinessScope,
|
doctorScope: options.readinessScope,
|
||||||
|
...(initialState === undefined
|
||||||
|
? {}
|
||||||
|
: { initialDoctor: initialState.doctor }),
|
||||||
});
|
});
|
||||||
clientStates = discovery.clientStates;
|
clientStates = discovery.clientStates;
|
||||||
const clientSelectionAllowed =
|
const clientSelectionAllowed =
|
||||||
|
|||||||
@@ -22,7 +22,12 @@ import {
|
|||||||
} from "./SetupClientConfiguration.js";
|
} from "./SetupClientConfiguration.js";
|
||||||
import { setupInstallFailure } from "./SetupInstallFailure.js";
|
import { setupInstallFailure } from "./SetupInstallFailure.js";
|
||||||
import { providerRegistrationEnvironment } from "./SetupRegistrationEnvironment.js";
|
import { providerRegistrationEnvironment } from "./SetupRegistrationEnvironment.js";
|
||||||
import type { SetupHost, SetupProviderEnvironment } from "./SetupTypes.js";
|
import type {
|
||||||
|
SetupHost,
|
||||||
|
SetupInitialState,
|
||||||
|
SetupProviderEnvironment,
|
||||||
|
} from "./SetupTypes.js";
|
||||||
|
import type { DoctorScope } from "./Doctor.js";
|
||||||
|
|
||||||
/** Resolve the executable and arguments used in a managed MCP registration. */
|
/** Resolve the executable and arguments used in a managed MCP registration. */
|
||||||
export const setupRegistrationCommand = (
|
export const setupRegistrationCommand = (
|
||||||
@@ -91,6 +96,25 @@ export const systemSetupHost = (
|
|||||||
macosVersion: () => doctorHost.macosVersion(),
|
macosVersion: () => doctorHost.macosVersion(),
|
||||||
linuxDistribution: readLinuxDistribution,
|
linuxDistribution: readLinuxDistribution,
|
||||||
hopperPath: async () => (await runDoctor(undefined, doctorHost)).hopperPath,
|
hopperPath: async () => (await runDoctor(undefined, doctorHost)).hopperPath,
|
||||||
|
initialSetupState: async (
|
||||||
|
scope?: DoctorScope,
|
||||||
|
): Promise<SetupInitialState> => {
|
||||||
|
const diagnosis = await runDoctor(undefined, doctorHost, scope);
|
||||||
|
return {
|
||||||
|
...(diagnosis.hopperPath === undefined
|
||||||
|
? {}
|
||||||
|
: { hopperPath: diagnosis.hopperPath }),
|
||||||
|
providerEnvironment: {
|
||||||
|
...providerRegistrationEnvironment(
|
||||||
|
diagnosis.providerInspections ?? [],
|
||||||
|
),
|
||||||
|
...(diagnosis.hopperPath === undefined
|
||||||
|
? {}
|
||||||
|
: { HOPPER_LAUNCHER_PATH: diagnosis.hopperPath }),
|
||||||
|
},
|
||||||
|
doctor: diagnosis,
|
||||||
|
};
|
||||||
|
},
|
||||||
providerEnvironment: async () => {
|
providerEnvironment: async () => {
|
||||||
const diagnosis = await runDoctor(undefined, doctorHost);
|
const diagnosis = await runDoctor(undefined, doctorHost);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import type {
|
|||||||
} from "./SetupTypes.js";
|
} from "./SetupTypes.js";
|
||||||
import type { SetupClient } from "./SupportedClients.js";
|
import type { SetupClient } from "./SupportedClients.js";
|
||||||
import type { DoctorScope } from "./Doctor.js";
|
import type { DoctorScope } from "./Doctor.js";
|
||||||
|
import type { DoctorReport } from "./Doctor.js";
|
||||||
|
|
||||||
/** Read-only setup facts shared by client selection and preflight. */
|
/** Read-only setup facts shared by client selection and preflight. */
|
||||||
export interface SetupDiscovery {
|
export interface SetupDiscovery {
|
||||||
@@ -36,8 +37,10 @@ export const discoverSetupState = async (input: {
|
|||||||
readonly forceHopperInstall: boolean;
|
readonly forceHopperInstall: boolean;
|
||||||
readonly proposeHopper: boolean;
|
readonly proposeHopper: boolean;
|
||||||
readonly doctorScope: DoctorScope | undefined;
|
readonly doctorScope: DoctorScope | undefined;
|
||||||
|
readonly initialDoctor?: DoctorReport;
|
||||||
}): Promise<SetupDiscovery> => {
|
}): Promise<SetupDiscovery> => {
|
||||||
const initialDoctor = await input.host.doctor(input.doctorScope);
|
const initialDoctor =
|
||||||
|
input.initialDoctor ?? (await input.host.doctor(input.doctorScope));
|
||||||
const linuxHopperRepairNeeded = initialDoctor.checks.some(
|
const linuxHopperRepairNeeded = initialDoctor.checks.some(
|
||||||
({ name, ok, detail }) =>
|
({ name, ok, detail }) =>
|
||||||
!ok &&
|
!ok &&
|
||||||
|
|||||||
@@ -9,6 +9,13 @@ import type {
|
|||||||
/** Exact non-secret provider variables propagated into managed registrations. */
|
/** Exact non-secret provider variables propagated into managed registrations. */
|
||||||
export type SetupProviderEnvironment = Readonly<Record<string, string>>;
|
export type SetupProviderEnvironment = Readonly<Record<string, string>>;
|
||||||
|
|
||||||
|
/** Read-only host facts shared by the initial setup plan. */
|
||||||
|
export interface SetupInitialState {
|
||||||
|
readonly hopperPath?: string;
|
||||||
|
readonly providerEnvironment: SetupProviderEnvironment;
|
||||||
|
readonly doctor: DoctorReport;
|
||||||
|
}
|
||||||
|
|
||||||
/** Result of one backup/write/readback transaction. */
|
/** Result of one backup/write/readback transaction. */
|
||||||
export type ClientConfigurationResult =
|
export type ClientConfigurationResult =
|
||||||
| {
|
| {
|
||||||
@@ -38,6 +45,7 @@ export interface SetupHost {
|
|||||||
macosVersion(): Promise<string | undefined>;
|
macosVersion(): Promise<string | undefined>;
|
||||||
linuxDistribution(): Promise<LinuxDistribution | undefined>;
|
linuxDistribution(): Promise<LinuxDistribution | undefined>;
|
||||||
hopperPath(): Promise<string | undefined>;
|
hopperPath(): Promise<string | undefined>;
|
||||||
|
initialSetupState?(scope?: DoctorScope): Promise<SetupInitialState>;
|
||||||
installHopper(replaceExisting: boolean): Promise<SetupHopperInstallResult>;
|
installHopper(replaceExisting: boolean): Promise<SetupHopperInstallResult>;
|
||||||
providerEnvironment?(): Promise<SetupProviderEnvironment>;
|
providerEnvironment?(): Promise<SetupProviderEnvironment>;
|
||||||
detectedClients(): Promise<readonly SetupClient[]>;
|
detectedClients(): Promise<readonly SetupClient[]>;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
import type { JavaScriptApplicationGraph } from "../../domain/javascript/javascriptApplicationGraph.js";
|
import type { JavaScriptApplicationGraph } from "../../domain/javascript/javascriptApplicationGraph.js";
|
||||||
import type { JavaScriptSemanticGraph } from "../../domain/javascript/javascriptSemanticGraph.js";
|
import type { JavaScriptSemanticGraph } from "../../domain/javascript/javascriptSemanticGraph.js";
|
||||||
import { javascriptRuntimeReconciliationResultSchema } from "../../domain/javascript/javascriptRuntimeReconciliationSchemas.js";
|
import { javascriptRuntimeReconciliationResultSchema } from "../../domain/javascript/javascriptRuntimeReconciliationSchemas.js";
|
||||||
import { managedApplicationGraphResultSchema } from "../../domain/managedApplicationGraph.js";
|
import { managedApplicationGraphResultSchema } from "../../domain/managed/managedApplicationGraph.js";
|
||||||
|
|
||||||
/** Supported immutable source for an application-level graph workflow. */
|
/** Supported immutable source for an application-level graph workflow. */
|
||||||
export interface ApplicationGraphEvidenceSource {
|
export interface ApplicationGraphEvidenceSource {
|
||||||
|
|||||||
+7
-7
@@ -3,19 +3,19 @@ import { z } from "zod";
|
|||||||
import {
|
import {
|
||||||
AnalysisInputError,
|
AnalysisInputError,
|
||||||
AnalysisProtocolError,
|
AnalysisProtocolError,
|
||||||
} from "../domain/analysisErrorCore.js";
|
} from "../../domain/analysisErrorCore.js";
|
||||||
import { type AnalysisError } from "../domain/analysisErrorBase.js";
|
import { type AnalysisError } from "../../domain/analysisErrorBase.js";
|
||||||
import { createEvidence, type Evidence } from "../domain/evidence.js";
|
import { createEvidence, type Evidence } from "../../domain/evidence.js";
|
||||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
||||||
import {
|
import {
|
||||||
managedApplicationGraphResultSchema,
|
managedApplicationGraphResultSchema,
|
||||||
projectManagedApplicationGraph,
|
projectManagedApplicationGraph,
|
||||||
projectManagedApplicationGraphInputSchema,
|
projectManagedApplicationGraphInputSchema,
|
||||||
type ManagedApplicationGraphResult,
|
type ManagedApplicationGraphResult,
|
||||||
type ProjectManagedApplicationGraphInput,
|
type ProjectManagedApplicationGraphInput,
|
||||||
} from "../domain/managedApplicationGraph.js";
|
} from "../../domain/managed/managedApplicationGraph.js";
|
||||||
import { err, ok, type Result } from "../domain/result.js";
|
import { err, ok, type Result } from "../../domain/result.js";
|
||||||
import { MANAGED_WORKFLOW_PROVIDER } from "./InvestigationProviders.js";
|
import { MANAGED_WORKFLOW_PROVIDER } from "../InvestigationProviders.js";
|
||||||
|
|
||||||
const OPERATION = "project_managed_application_graph" as const;
|
const OPERATION = "project_managed_application_graph" as const;
|
||||||
|
|
||||||
+10
-10
@@ -8,22 +8,22 @@ import {
|
|||||||
managedMemberComparisonResultSchema,
|
managedMemberComparisonResultSchema,
|
||||||
parseManagedMemberEvidence,
|
parseManagedMemberEvidence,
|
||||||
type CompareManagedMembersInput,
|
type CompareManagedMembersInput,
|
||||||
} from "../domain/managedMemberComparison.js";
|
} from "../../domain/managed/managedMemberComparison.js";
|
||||||
import {
|
import {
|
||||||
AnalysisInputError,
|
AnalysisInputError,
|
||||||
AnalysisProtocolError,
|
AnalysisProtocolError,
|
||||||
} from "../domain/analysisErrorCore.js";
|
} from "../../domain/analysisErrorCore.js";
|
||||||
import { EvidenceIntegrityError } from "../domain/evidenceErrors.js";
|
import { EvidenceIntegrityError } from "../../domain/evidenceErrors.js";
|
||||||
import { type AnalysisError } from "../domain/analysisErrorBase.js";
|
import { type AnalysisError } from "../../domain/analysisErrorBase.js";
|
||||||
import { createEvidence, type Evidence } from "../domain/evidence.js";
|
import { createEvidence, type Evidence } from "../../domain/evidence.js";
|
||||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
||||||
import { parseBinaryTarget } from "./BinaryTargetResolver.js";
|
import { parseBinaryTarget } from "../BinaryTargetResolver.js";
|
||||||
import { err, ok, type Result } from "../domain/result.js";
|
import { err, ok, type Result } from "../../domain/result.js";
|
||||||
import { inspectManagedMembersBytes } from "../dotnet/ManagedMemberInspector.js";
|
import { inspectManagedMembersBytes } from "../../dotnet/ManagedMemberInspector.js";
|
||||||
import {
|
import {
|
||||||
MANAGED_STATIC_PROVIDER,
|
MANAGED_STATIC_PROVIDER,
|
||||||
MANAGED_WORKFLOW_PROVIDER,
|
MANAGED_WORKFLOW_PROVIDER,
|
||||||
} from "./InvestigationProviders.js";
|
} from "../InvestigationProviders.js";
|
||||||
|
|
||||||
/** Compare managed members from input parsed by a trusted adapter. */
|
/** Compare managed members from input parsed by a trusted adapter. */
|
||||||
export const compareManagedMembersEvidenceValidated = (
|
export const compareManagedMembersEvidenceValidated = (
|
||||||
+7
-7
@@ -3,18 +3,18 @@ import { z } from "zod";
|
|||||||
import {
|
import {
|
||||||
AnalysisInputError,
|
AnalysisInputError,
|
||||||
AnalysisProtocolError,
|
AnalysisProtocolError,
|
||||||
} from "../domain/analysisErrorCore.js";
|
} from "../../domain/analysisErrorCore.js";
|
||||||
import { type AnalysisError } from "../domain/analysisErrorBase.js";
|
import { type AnalysisError } from "../../domain/analysisErrorBase.js";
|
||||||
import { createEvidence, type Evidence } from "../domain/evidence.js";
|
import { createEvidence, type Evidence } from "../../domain/evidence.js";
|
||||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
||||||
import {
|
import {
|
||||||
managedNativeVerificationInputSchema,
|
managedNativeVerificationInputSchema,
|
||||||
verifyManagedNativeBoundaries,
|
verifyManagedNativeBoundaries,
|
||||||
type ManagedNativeVerificationInput,
|
type ManagedNativeVerificationInput,
|
||||||
type ManagedNativeVerificationResult,
|
type ManagedNativeVerificationResult,
|
||||||
} from "../domain/managedNativeVerification.js";
|
} from "../../domain/managed/managedNativeVerification.js";
|
||||||
import { err, ok, type Result } from "../domain/result.js";
|
import { err, ok, type Result } from "../../domain/result.js";
|
||||||
import { MANAGED_WORKFLOW_PROVIDER } from "./InvestigationProviders.js";
|
import { MANAGED_WORKFLOW_PROVIDER } from "../InvestigationProviders.js";
|
||||||
|
|
||||||
const OPERATION = "verify_managed_native_boundaries" as const;
|
const OPERATION = "verify_managed_native_boundaries" as const;
|
||||||
|
|
||||||
+4
-4
@@ -2,13 +2,13 @@ import { createHash } from "node:crypto";
|
|||||||
|
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE } from "../contracts/managedWorkflowExamples.js";
|
import { MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE } from "../../contracts/managed/managedWorkflowExamples.js";
|
||||||
import {
|
import {
|
||||||
importManagedReconstruction,
|
importManagedReconstruction,
|
||||||
managedReconstructionImportInputSchema,
|
managedReconstructionImportInputSchema,
|
||||||
} from "../domain/managedReconstruction.js";
|
} from "../../domain/managed/managedReconstruction.js";
|
||||||
import { managedMemberInspectionSchema } from "../domain/managedArtifact.js";
|
import { managedMemberInspectionSchema } from "../../domain/managed/managedArtifact.js";
|
||||||
import { createEvidence } from "../domain/evidence.js";
|
import { createEvidence } from "../../domain/evidence.js";
|
||||||
import { importManagedReconstructionEvidence } from "./ManagedReconstructionService.js";
|
import { importManagedReconstructionEvidence } from "./ManagedReconstructionService.js";
|
||||||
|
|
||||||
const exampleInput = () =>
|
const exampleInput = () =>
|
||||||
+7
-7
@@ -3,18 +3,18 @@ import { z } from "zod";
|
|||||||
import {
|
import {
|
||||||
AnalysisInputError,
|
AnalysisInputError,
|
||||||
AnalysisProtocolError,
|
AnalysisProtocolError,
|
||||||
} from "../domain/analysisErrorCore.js";
|
} from "../../domain/analysisErrorCore.js";
|
||||||
import { type AnalysisError } from "../domain/analysisErrorBase.js";
|
import { type AnalysisError } from "../../domain/analysisErrorBase.js";
|
||||||
import { createEvidence, type Evidence } from "../domain/evidence.js";
|
import { createEvidence, type Evidence } from "../../domain/evidence.js";
|
||||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
||||||
import {
|
import {
|
||||||
importManagedReconstruction,
|
importManagedReconstruction,
|
||||||
managedReconstructionImportInputSchema,
|
managedReconstructionImportInputSchema,
|
||||||
type ManagedReconstructionImportInput,
|
type ManagedReconstructionImportInput,
|
||||||
type ManagedReconstructionImportResult,
|
type ManagedReconstructionImportResult,
|
||||||
} from "../domain/managedReconstruction.js";
|
} from "../../domain/managed/managedReconstruction.js";
|
||||||
import { err, ok, type Result } from "../domain/result.js";
|
import { err, ok, type Result } from "../../domain/result.js";
|
||||||
import { MANAGED_WORKFLOW_PROVIDER } from "./InvestigationProviders.js";
|
import { MANAGED_WORKFLOW_PROVIDER } from "../InvestigationProviders.js";
|
||||||
|
|
||||||
const OPERATION = "import_managed_reconstruction" as const;
|
const OPERATION = "import_managed_reconstruction" as const;
|
||||||
|
|
||||||
@@ -143,14 +143,29 @@ const asarFailure = (
|
|||||||
path: string,
|
path: string,
|
||||||
operation: string,
|
operation: string,
|
||||||
cause: unknown,
|
cause: unknown,
|
||||||
): ArtifactReaderFailure =>
|
): ArtifactReaderFailure => {
|
||||||
cause instanceof ArtifactReaderFailure
|
if (cause instanceof ArtifactReaderFailure) return cause;
|
||||||
? cause
|
if (isFilesystemFailure(cause))
|
||||||
: new ArtifactReaderFailure(
|
return new ArtifactReaderFailure(
|
||||||
"format",
|
"io",
|
||||||
`Malformed or unreadable ASAR during ${operation}: ${path}`,
|
`Could not ${operation} ASAR at ${path}: ${cause.message}`,
|
||||||
{ cause },
|
{ cause },
|
||||||
);
|
);
|
||||||
|
return new ArtifactReaderFailure(
|
||||||
|
"format",
|
||||||
|
`Malformed ASAR during ${operation}: ${path}`,
|
||||||
|
{ cause },
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const isFilesystemFailure = (
|
||||||
|
cause: unknown,
|
||||||
|
): cause is NodeJS.ErrnoException & Error =>
|
||||||
|
cause instanceof Error &&
|
||||||
|
"errno" in cause &&
|
||||||
|
typeof cause.errno === "number" &&
|
||||||
|
"syscall" in cause &&
|
||||||
|
typeof cause.syscall === "string";
|
||||||
|
|
||||||
const isMissingFile = (cause: unknown): boolean =>
|
const isMissingFile = (cause: unknown): boolean =>
|
||||||
typeof cause === "object" &&
|
typeof cause === "object" &&
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export class DirectoryArtifactReader implements ArtifactReader {
|
|||||||
);
|
);
|
||||||
const handle = await open(
|
const handle = await open(
|
||||||
entry.adapterKey,
|
entry.adapterKey,
|
||||||
constants.O_RDONLY | constants.O_NOFOLLOW,
|
constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const observed = await handle.stat();
|
const observed = await handle.stat();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { z } from "incur";
|
import { z } from "incur";
|
||||||
|
|
||||||
import { compareManagedMemberPaths } from "../application/ManagedMemberComparisonService.js";
|
import { compareManagedMemberPaths } from "../application/managed/ManagedMemberComparisonService.js";
|
||||||
import { verifyManagedNativeBoundariesEvidence } from "../application/ManagedNativeVerificationService.js";
|
import { verifyManagedNativeBoundariesEvidence } from "../application/managed/ManagedNativeVerificationService.js";
|
||||||
import { importManagedReconstructionEvidence } from "../application/ManagedReconstructionService.js";
|
import { importManagedReconstructionEvidence } from "../application/managed/ManagedReconstructionService.js";
|
||||||
import { runProviderAnalysis } from "../application/DirectAnalysis.js";
|
import { runProviderAnalysis } from "../application/DirectAnalysis.js";
|
||||||
import { parseCliJsonInput } from "../cliJsonInput.js";
|
import { parseCliJsonInput } from "../cliJsonInput.js";
|
||||||
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "incur";
|
import { z } from "incur";
|
||||||
|
|
||||||
import { projectManagedApplicationGraphEvidence } from "../application/ManagedApplicationGraphService.js";
|
import { projectManagedApplicationGraphEvidence } from "../application/managed/ManagedApplicationGraphService.js";
|
||||||
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
||||||
import { parseCliJsonInput } from "../cliJsonInput.js";
|
import { parseCliJsonInput } from "../cliJsonInput.js";
|
||||||
import { logCliCommand } from "../cliLogging.js";
|
import { logCliCommand } from "../cliLogging.js";
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import { NATIVE_TOOL_CONTRACTS } from "./nativeToolContracts.js";
|
|||||||
import { ARTIFACT_TOOL_CONTRACTS } from "./artifactToolContracts.js";
|
import { ARTIFACT_TOOL_CONTRACTS } from "./artifactToolContracts.js";
|
||||||
import { FIRMWARE_TOOL_CONTRACTS } from "./firmware/firmwareToolContracts.js";
|
import { FIRMWARE_TOOL_CONTRACTS } from "./firmware/firmwareToolContracts.js";
|
||||||
import { ANDROID_TOOL_CONTRACTS } from "./android/androidToolContracts.js";
|
import { ANDROID_TOOL_CONTRACTS } from "./android/androidToolContracts.js";
|
||||||
import { MANAGED_TOOL_CONTRACTS } from "./managedToolContracts.js";
|
import { MANAGED_TOOL_CONTRACTS } from "./managed/managedToolContracts.js";
|
||||||
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "./managedWorkflowToolContracts.js";
|
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "./managed/managedWorkflowToolContracts.js";
|
||||||
import { BROWSER_TOOL_CONTRACTS } from "./browserToolContracts.js";
|
import { BROWSER_TOOL_CONTRACTS } from "./browserToolContracts.js";
|
||||||
import { BROWSER_SCENARIO_TOOL_CONTRACTS } from "./browserScenarioToolContracts.js";
|
import { BROWSER_SCENARIO_TOOL_CONTRACTS } from "./browserScenarioToolContracts.js";
|
||||||
import { ELECTRON_TOOL_CONTRACTS } from "./javascript/electronToolContracts.js";
|
import { ELECTRON_TOOL_CONTRACTS } from "./javascript/electronToolContracts.js";
|
||||||
|
|||||||
+4
-4
@@ -1,9 +1,9 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import type { ToolContract } from "./toolContracts.js";
|
import type { ToolContract } from "../toolContracts.js";
|
||||||
import { managedOutputSchemas } from "./toolOutputSchemas.js";
|
import { managedOutputSchemas } from "../toolOutputSchemas.js";
|
||||||
import { toolContractMetadata } from "./toolEffects.js";
|
import { toolContractMetadata } from "../toolEffects.js";
|
||||||
import { requireOutputSchema } from "./toolOutputSchemaPrimitives.js";
|
import { requireOutputSchema } from "../toolOutputSchemaPrimitives.js";
|
||||||
|
|
||||||
/** Exact caller boundary for execution-free PE/CLI triage and identity. */
|
/** Exact caller boundary for execution-free PE/CLI triage and identity. */
|
||||||
const managedTargetInputSchema = z.object({
|
const managedTargetInputSchema = z.object({
|
||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
import { createEvidence } from "../domain/evidence.js";
|
import { createEvidence } from "../../domain/evidence.js";
|
||||||
import type {
|
import type {
|
||||||
ManagedMemberInspection,
|
ManagedMemberInspection,
|
||||||
ManagedNativeBoundaryInspection,
|
ManagedNativeBoundaryInspection,
|
||||||
} from "../domain/managedArtifact.js";
|
} from "../../domain/managed/managedArtifact.js";
|
||||||
import type { InspectMacho } from "../domain/nativeInspection.js";
|
import type { InspectMacho } from "../../domain/nativeInspection.js";
|
||||||
|
|
||||||
const MANAGED_STATIC_EXAMPLE_PROVIDER = {
|
const MANAGED_STATIC_EXAMPLE_PROVIDER = {
|
||||||
id: "rea-dotnet-static",
|
id: "rea-dotnet-static",
|
||||||
+6
-6
@@ -1,17 +1,17 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { evidenceSchema } from "../domain/evidence.js";
|
import { evidenceSchema } from "../../domain/evidence.js";
|
||||||
|
|
||||||
import { managedReconstructionImportInputSchema } from "../domain/managedReconstruction.js";
|
import { managedReconstructionImportInputSchema } from "../../domain/managed/managedReconstruction.js";
|
||||||
import type { ToolContract } from "./toolContracts.js";
|
import type { ToolContract } from "../toolContracts.js";
|
||||||
import { managedWorkflowOutputSchemas } from "./toolOutputSchemas.js";
|
import { managedWorkflowOutputSchemas } from "../toolOutputSchemas.js";
|
||||||
import {
|
import {
|
||||||
MANAGED_MEMBER_COMPARISON_EXAMPLE,
|
MANAGED_MEMBER_COMPARISON_EXAMPLE,
|
||||||
MANAGED_NATIVE_VERIFICATION_EXAMPLE,
|
MANAGED_NATIVE_VERIFICATION_EXAMPLE,
|
||||||
MANAGED_APPLICATION_GRAPH_EXAMPLE,
|
MANAGED_APPLICATION_GRAPH_EXAMPLE,
|
||||||
MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE,
|
MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE,
|
||||||
} from "./managedWorkflowExamples.js";
|
} from "./managedWorkflowExamples.js";
|
||||||
import { toolContractMetadata } from "./toolEffects.js";
|
import { toolContractMetadata } from "../toolEffects.js";
|
||||||
import { requireOutputSchema } from "./toolOutputSchemaPrimitives.js";
|
import { requireOutputSchema } from "../toolOutputSchemaPrimitives.js";
|
||||||
|
|
||||||
/** Inputs for comparing two managed observations carried inline. */
|
/** Inputs for comparing two managed observations carried inline. */
|
||||||
export const compareManagedMembersReferenceInputSchema = z
|
export const compareManagedMembersReferenceInputSchema = z
|
||||||
@@ -80,7 +80,7 @@ export const SESSION_TOOL_CONTRACTS = [
|
|||||||
),
|
),
|
||||||
session(
|
session(
|
||||||
"capture_process_scenario",
|
"capture_process_scenario",
|
||||||
"Run one caller-selected command under a PTY and return process capture Evidence with residual unknowns. A command name resolves through the inherited PATH; the working directory defaults to the caller's current directory; host environment variables are inherited with scenario overrides. Filesystem snapshots are opt-in through filesystem_observation_paths. The target runs with the current user's permissions; this is not a security sandbox.",
|
"Run one caller-selected command under a PTY and return process capture Evidence with residual unknowns. A command name resolves through the inherited PATH; the working directory defaults to the caller's current directory; host environment variables are inherited with scenario overrides. Environment keys cannot contain '=' or NUL, and REA_PROCESS_RUN_ID is reserved for process ownership. Filesystem snapshots are opt-in through filesystem_observation_paths. The target runs with the current user's permissions; this is not a security sandbox.",
|
||||||
processScenarioSchema,
|
processScenarioSchema,
|
||||||
),
|
),
|
||||||
session(
|
session(
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import { OFFICIAL_TOOL_CONTRACTS } from "./officialToolContracts.js";
|
|||||||
import { SESSION_TOOL_CONTRACTS } from "./sessionToolContracts.js";
|
import { SESSION_TOOL_CONTRACTS } from "./sessionToolContracts.js";
|
||||||
import { TOOL_CONTRACTS } from "./toolContracts.js";
|
import { TOOL_CONTRACTS } from "./toolContracts.js";
|
||||||
import { ARTIFACT_TOOL_CONTRACTS } from "./artifactToolContracts.js";
|
import { ARTIFACT_TOOL_CONTRACTS } from "./artifactToolContracts.js";
|
||||||
import { MANAGED_TOOL_CONTRACTS } from "./managedToolContracts.js";
|
import { MANAGED_TOOL_CONTRACTS } from "./managed/managedToolContracts.js";
|
||||||
import { FIRMWARE_TOOL_CONTRACTS } from "./firmware/firmwareToolContracts.js";
|
import { FIRMWARE_TOOL_CONTRACTS } from "./firmware/firmwareToolContracts.js";
|
||||||
import { ANDROID_TOOL_CONTRACTS } from "./android/androidToolContracts.js";
|
import { ANDROID_TOOL_CONTRACTS } from "./android/androidToolContracts.js";
|
||||||
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "./managedWorkflowToolContracts.js";
|
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "./managed/managedWorkflowToolContracts.js";
|
||||||
import { NATIVE_TOOL_CONTRACTS } from "./nativeToolContracts.js";
|
import { NATIVE_TOOL_CONTRACTS } from "./nativeToolContracts.js";
|
||||||
import { BROWSER_PROVIDER_TOOL_CONTRACTS } from "./browserProviderToolContracts.js";
|
import { BROWSER_PROVIDER_TOOL_CONTRACTS } from "./browserProviderToolContracts.js";
|
||||||
import { ELECTRON_TOOL_CONTRACTS } from "./javascript/electronToolContracts.js";
|
import { ELECTRON_TOOL_CONTRACTS } from "./javascript/electronToolContracts.js";
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { NATIVE_TOOL_CONTRACTS } from "./nativeToolContracts.js";
|
import { NATIVE_TOOL_CONTRACTS } from "./nativeToolContracts.js";
|
||||||
import { ARTIFACT_TOOL_CONTRACTS } from "./artifactToolContracts.js";
|
import { ARTIFACT_TOOL_CONTRACTS } from "./artifactToolContracts.js";
|
||||||
import { MANAGED_TOOL_CONTRACTS } from "./managedToolContracts.js";
|
import { MANAGED_TOOL_CONTRACTS } from "./managed/managedToolContracts.js";
|
||||||
import { FIRMWARE_TOOL_CONTRACTS } from "./firmware/firmwareToolContracts.js";
|
import { FIRMWARE_TOOL_CONTRACTS } from "./firmware/firmwareToolContracts.js";
|
||||||
import { ANDROID_TOOL_CONTRACTS } from "./android/androidToolContracts.js";
|
import { ANDROID_TOOL_CONTRACTS } from "./android/androidToolContracts.js";
|
||||||
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "./managedWorkflowToolContracts.js";
|
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "./managed/managedWorkflowToolContracts.js";
|
||||||
import { BROWSER_PROVIDER_TOOL_CONTRACTS } from "./browserProviderToolContracts.js";
|
import { BROWSER_PROVIDER_TOOL_CONTRACTS } from "./browserProviderToolContracts.js";
|
||||||
import { ELECTRON_TOOL_CONTRACTS } from "./javascript/electronToolContracts.js";
|
import { ELECTRON_TOOL_CONTRACTS } from "./javascript/electronToolContracts.js";
|
||||||
import { JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS } from "./javascript/javascriptRuntimeObservationToolContracts.js";
|
import { JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS } from "./javascript/javascriptRuntimeObservationToolContracts.js";
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ import {
|
|||||||
managedArtifactInspectionSchema,
|
managedArtifactInspectionSchema,
|
||||||
managedMemberInspectionSchema,
|
managedMemberInspectionSchema,
|
||||||
managedNativeBoundaryInspectionSchema,
|
managedNativeBoundaryInspectionSchema,
|
||||||
} from "../domain/managedArtifact.js";
|
} from "../domain/managed/managedArtifact.js";
|
||||||
import { managedMemberComparisonResultSchema } from "../domain/managedMemberComparison.js";
|
import { managedMemberComparisonResultSchema } from "../domain/managed/managedMemberComparison.js";
|
||||||
import { managedNativeVerificationResultSchema } from "../domain/managedNativeVerification.js";
|
import { managedNativeVerificationResultSchema } from "../domain/managed/managedNativeVerification.js";
|
||||||
import { managedReconstructionImportResultSchema } from "../domain/managedReconstruction.js";
|
import { managedReconstructionImportResultSchema } from "../domain/managed/managedReconstruction.js";
|
||||||
import { managedApplicationGraphResultSchema } from "../domain/managedApplicationGraph.js";
|
import { managedApplicationGraphResultSchema } from "../domain/managed/managedApplicationGraph.js";
|
||||||
import { artifactComparisonResultSchema } from "../domain/artifactComparison.js";
|
import { artifactComparisonResultSchema } from "../domain/artifactComparison.js";
|
||||||
import { functionComparisonResultSchema } from "../domain/functionComparison.js";
|
import { functionComparisonResultSchema } from "../domain/functionComparison.js";
|
||||||
import { bundleComparisonResultSchema } from "../domain/bundleComparison.js";
|
import { bundleComparisonResultSchema } from "../domain/bundleComparison.js";
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import {
|
|||||||
MANAGED_APPLICATION_GRAPH_EXAMPLE,
|
MANAGED_APPLICATION_GRAPH_EXAMPLE,
|
||||||
MANAGED_MEMBER_COMPARISON_EXAMPLE,
|
MANAGED_MEMBER_COMPARISON_EXAMPLE,
|
||||||
MANAGED_NATIVE_VERIFICATION_EXAMPLE,
|
MANAGED_NATIVE_VERIFICATION_EXAMPLE,
|
||||||
} from "./managedWorkflowExamples.js";
|
} from "./managed/managedWorkflowExamples.js";
|
||||||
import {
|
import {
|
||||||
compareManagedMembersReferenceInputSchema,
|
compareManagedMembersReferenceInputSchema,
|
||||||
managedApplicationGraphReferenceInputSchema,
|
managedApplicationGraphReferenceInputSchema,
|
||||||
managedNativeVerificationReferenceInputSchema,
|
managedNativeVerificationReferenceInputSchema,
|
||||||
} from "./managedWorkflowToolContracts.js";
|
} from "./managed/managedWorkflowToolContracts.js";
|
||||||
|
|
||||||
describe("workflow input contracts", () => {
|
describe("workflow input contracts", () => {
|
||||||
it("rejects application Evidence ID references and duplicate inline records", () => {
|
it("rejects application Evidence ID references and duplicate inline records", () => {
|
||||||
|
|||||||
@@ -119,14 +119,30 @@ const addExport = (output: Set<string>, name: string): void => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const memberPath = (node: t.Node | null | undefined): string => {
|
const memberPath = (node: t.Node | null | undefined): string => {
|
||||||
if (node === undefined || node === null) return "";
|
const properties: string[] = [];
|
||||||
if (t.isIdentifier(node) || t.isPrivateName(node))
|
let current = node;
|
||||||
return t.isIdentifier(node) ? node.name : "";
|
while (
|
||||||
if (t.isThisExpression(node)) return "this";
|
current !== undefined &&
|
||||||
if (t.isMemberExpression(node) || t.isOptionalMemberExpression(node)) {
|
current !== null &&
|
||||||
const object = t.isNode(node.object) ? memberPath(node.object) : "";
|
(t.isMemberExpression(current) || t.isOptionalMemberExpression(current))
|
||||||
const property = propertyName(node.property);
|
) {
|
||||||
return object === "" ? property : `${object}.${property}`;
|
properties.push(propertyName(current.property));
|
||||||
|
current = t.isNode(current.object) ? current.object : undefined;
|
||||||
}
|
}
|
||||||
return "";
|
|
||||||
|
const root =
|
||||||
|
current !== undefined && t.isIdentifier(current)
|
||||||
|
? current.name
|
||||||
|
: current !== undefined && t.isThisExpression(current)
|
||||||
|
? "this"
|
||||||
|
: "";
|
||||||
|
if (properties.length === 0) return root;
|
||||||
|
|
||||||
|
properties.reverse();
|
||||||
|
const path = root === "" ? [] : [root];
|
||||||
|
for (const property of properties) {
|
||||||
|
if (path.length === 0 && property === "") continue;
|
||||||
|
path.push(property);
|
||||||
|
}
|
||||||
|
return path.join(".");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -192,6 +192,51 @@ describe("JavaScript semantic analysis: calls 2", () => {
|
|||||||
).not.toBe(left.functionFingerprints[0]?.components.literalSetSha256);
|
).not.toBe(left.functionFingerprints[0]?.components.literalSetSha256);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps fingerprint relations ordered and effects scoped to their owner", () => {
|
||||||
|
const ordered = analyzeJavaScriptSemantics(`
|
||||||
|
function first() {}
|
||||||
|
function second(one, two) {}
|
||||||
|
function ordered() { first(); second(1, 2); }
|
||||||
|
function timerOwner() { setTimeout(work, 10); }
|
||||||
|
function networkOwner() { fetch('/data'); }
|
||||||
|
function noEffects() { return 1; }
|
||||||
|
`);
|
||||||
|
const reversed = analyzeJavaScriptSemantics(`
|
||||||
|
function first() {}
|
||||||
|
function second(one, two) {}
|
||||||
|
function ordered() { second(1, 2); first(); }
|
||||||
|
function timerOwner() { setTimeout(work, 10); }
|
||||||
|
function networkOwner() { fetch('/data'); }
|
||||||
|
function noEffects() { return 1; }
|
||||||
|
`);
|
||||||
|
const fingerprint = (ir: typeof ordered, name: string) =>
|
||||||
|
ir.functionFingerprints.find((value) =>
|
||||||
|
ir.callables.some(
|
||||||
|
(callable) =>
|
||||||
|
callable.callableId === value.callableId && callable.name === name,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
fingerprint(ordered, "ordered")?.components.relationShapeSha256,
|
||||||
|
).not.toBe(
|
||||||
|
fingerprint(reversed, "ordered")?.components.relationShapeSha256,
|
||||||
|
);
|
||||||
|
expect(fingerprint(ordered, "timerOwner")?.components.effects).toContain(
|
||||||
|
"timer",
|
||||||
|
);
|
||||||
|
expect(fingerprint(ordered, "networkOwner")?.components.effects).toContain(
|
||||||
|
"network",
|
||||||
|
);
|
||||||
|
expect(fingerprint(ordered, "noEffects")?.components.effects).toEqual([]);
|
||||||
|
expect(
|
||||||
|
fingerprint(ordered, "timerOwner")?.components.effects,
|
||||||
|
).not.toContain("network");
|
||||||
|
expect(
|
||||||
|
fingerprint(ordered, "networkOwner")?.components.effects,
|
||||||
|
).not.toContain("timer");
|
||||||
|
});
|
||||||
|
|
||||||
it("retains ambiguous local callees and explicit dynamic frontiers", () => {
|
it("retains ambiguous local callees and explicit dynamic frontiers", () => {
|
||||||
const ir = analyzeJavaScriptSemantics(`
|
const ir = analyzeJavaScriptSemantics(`
|
||||||
function left(value) { return value; }
|
function left(value) { return value; }
|
||||||
|
|||||||
@@ -149,6 +149,31 @@ describe("JavaScript semantic analysis: dataflow 1", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("JavaScript semantic call result flows", () => {
|
||||||
|
it("links only directly assigned scalar call results", () => {
|
||||||
|
const ir = analyzeJavaScriptSemantics(`
|
||||||
|
function run() {
|
||||||
|
const direct = produce();
|
||||||
|
const { field } = unpack();
|
||||||
|
const nested = outer(inner());
|
||||||
|
return direct;
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
const bindingNames = new Map(
|
||||||
|
ir.bindings.map(({ bindingId, name }) => [bindingId, name]),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
ir.callResultFlows.map(({ bindingId }) => bindingNames.get(bindingId)),
|
||||||
|
).toEqual(["direct", "nested"]);
|
||||||
|
expect(ir.callSites).toHaveLength(4);
|
||||||
|
expect(ir.callResultFlows.map(({ callSiteId }) => callSiteId)).toEqual([
|
||||||
|
ir.callSites[0]?.callSiteId,
|
||||||
|
ir.callSites[2]?.callSiteId,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("JavaScript semantic analysis: read-modify-write", () => {
|
describe("JavaScript semantic analysis: read-modify-write", () => {
|
||||||
it.each(["+= 1", "++", "--", "||= 1", "&&= 1", "??= 1"])(
|
it.each(["+= 1", "++", "--", "||= 1", "&&= 1", "??= 1"])(
|
||||||
"retains the property read in a read-modify-write operation: %s",
|
"retains the property read in a read-modify-write operation: %s",
|
||||||
|
|||||||
@@ -183,9 +183,7 @@ const collectCallResultFlow = (
|
|||||||
context.ancestors,
|
context.ancestors,
|
||||||
context.state,
|
context.state,
|
||||||
).filter(({ projectionPath }) => projectionPath.length === 0)) {
|
).filter(({ projectionPath }) => projectionPath.length === 0)) {
|
||||||
const binding = [...context.state.bindingsById.values()].find(
|
const binding = context.state.bindingsById.get(assigned.bindingId);
|
||||||
({ bindingId }) => bindingId === assigned.bindingId,
|
|
||||||
);
|
|
||||||
if (binding === undefined) continue;
|
if (binding === undefined) continue;
|
||||||
const identifierRange = range(assigned.identifier);
|
const identifierRange = range(assigned.identifier);
|
||||||
const definition = binding.definitions.find(
|
const definition = binding.definitions.find(
|
||||||
|
|||||||
@@ -50,30 +50,36 @@ export const collectJavaScriptSemanticFingerprints = (
|
|||||||
resourceOperations,
|
resourceOperations,
|
||||||
parserPartial,
|
parserPartial,
|
||||||
} = input;
|
} = input;
|
||||||
|
const callSitesByCaller = groupByOwner(
|
||||||
|
calls.callSites,
|
||||||
|
({ callerCallableId }) => callerCallableId,
|
||||||
|
);
|
||||||
|
const captureCountByCallable = countByOwner(
|
||||||
|
calls.closureCaptures,
|
||||||
|
({ callableId }) => callableId,
|
||||||
|
);
|
||||||
|
const promiseEffectsByOwner = groupByOwner(promises, ownerId);
|
||||||
|
const eventEffectsByOwner = groupByOwner(events, ownerId);
|
||||||
|
const timerEffectsByOwner = groupByOwner(timers, ownerId);
|
||||||
|
const childProcessEffectsByOwner = groupByOwner(
|
||||||
|
[...childProcessSpawns, ...childProcessInteractions],
|
||||||
|
ownerId,
|
||||||
|
);
|
||||||
|
const networkEffectsByOwner = groupByOwner(requestOperations, ownerId);
|
||||||
|
const resourceEffectsByOwner = groupByOwner(resourceOperations, ownerId);
|
||||||
return callables.flatMap((callable) => {
|
return callables.flatMap((callable) => {
|
||||||
if (callable.kind === "class") return [];
|
if (callable.kind === "class") return [];
|
||||||
const node = state.callableNodesById.get(callable.callableId);
|
const node = state.callableNodesById.get(callable.callableId);
|
||||||
if (node === undefined) return [];
|
if (node === undefined) return [];
|
||||||
const syntax = fingerprintSyntax(node, callable.callableId);
|
const syntax = fingerprintSyntax(node, callable.callableId);
|
||||||
const promiseEffects = promises.filter(
|
const promiseEffects = promiseEffectsByOwner.get(callable.callableId) ?? [];
|
||||||
({ ownerCallableId }) => ownerCallableId === callable.callableId,
|
const eventEffects = eventEffectsByOwner.get(callable.callableId) ?? [];
|
||||||
);
|
const timerEffects = timerEffectsByOwner.get(callable.callableId) ?? [];
|
||||||
const eventEffects = events.filter(
|
const childProcessEffects =
|
||||||
({ ownerCallableId }) => ownerCallableId === callable.callableId,
|
childProcessEffectsByOwner.get(callable.callableId) ?? [];
|
||||||
);
|
const networkEffects = networkEffectsByOwner.get(callable.callableId) ?? [];
|
||||||
const timerEffects = timers.filter(
|
const resourceEffects =
|
||||||
({ ownerCallableId }) => ownerCallableId === callable.callableId,
|
resourceEffectsByOwner.get(callable.callableId) ?? [];
|
||||||
);
|
|
||||||
const childProcessEffects = [
|
|
||||||
...childProcessSpawns,
|
|
||||||
...childProcessInteractions,
|
|
||||||
].filter(({ ownerCallableId }) => ownerCallableId === callable.callableId);
|
|
||||||
const networkEffects = requestOperations.filter(
|
|
||||||
({ ownerCallableId }) => ownerCallableId === callable.callableId,
|
|
||||||
);
|
|
||||||
const resourceEffects = resourceOperations.filter(
|
|
||||||
({ ownerCallableId }) => ownerCallableId === callable.callableId,
|
|
||||||
);
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
callableId: callable.callableId,
|
callableId: callable.callableId,
|
||||||
@@ -86,7 +92,12 @@ export const collectJavaScriptSemanticFingerprints = (
|
|||||||
normalizedAstSha256: digest(syntax.normalizedTokens),
|
normalizedAstSha256: digest(syntax.normalizedTokens),
|
||||||
controlFlowSha256: digest(syntax.controlFlowTokens),
|
controlFlowSha256: digest(syntax.controlFlowTokens),
|
||||||
relationShapeSha256: digest(
|
relationShapeSha256: digest(
|
||||||
relationShape(callable, calls, promiseEffects),
|
relationShape(
|
||||||
|
callable,
|
||||||
|
callSitesByCaller.get(callable.callableId) ?? [],
|
||||||
|
captureCountByCallable.get(callable.callableId) ?? 0,
|
||||||
|
promiseEffects,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
literalSetSha256: digest(
|
literalSetSha256: digest(
|
||||||
[...new Set(syntax.literals)].sort(compareCodePoints),
|
[...new Set(syntax.literals)].sort(compareCodePoints),
|
||||||
@@ -114,6 +125,36 @@ export const collectJavaScriptSemanticFingerprints = (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ownerId = <T extends { readonly ownerCallableId: string | null }>(
|
||||||
|
value: T,
|
||||||
|
): string | null => value.ownerCallableId;
|
||||||
|
|
||||||
|
const groupByOwner = <T, K extends string | null>(
|
||||||
|
values: readonly T[],
|
||||||
|
getOwner: (value: T) => K,
|
||||||
|
): Map<K, T[]> => {
|
||||||
|
const grouped = new Map<K, T[]>();
|
||||||
|
for (const value of values) {
|
||||||
|
const owner = getOwner(value);
|
||||||
|
const ownedValues = grouped.get(owner);
|
||||||
|
if (ownedValues === undefined) grouped.set(owner, [value]);
|
||||||
|
else ownedValues.push(value);
|
||||||
|
}
|
||||||
|
return grouped;
|
||||||
|
};
|
||||||
|
|
||||||
|
const countByOwner = <T, K extends string | null>(
|
||||||
|
values: readonly T[],
|
||||||
|
getOwner: (value: T) => K,
|
||||||
|
): Map<K, number> => {
|
||||||
|
const counts = new Map<K, number>();
|
||||||
|
for (const value of values) {
|
||||||
|
const owner = getOwner(value);
|
||||||
|
counts.set(owner, (counts.get(owner) ?? 0) + 1);
|
||||||
|
}
|
||||||
|
return counts;
|
||||||
|
};
|
||||||
|
|
||||||
interface FingerprintSyntax {
|
interface FingerprintSyntax {
|
||||||
readonly normalizedTokens: readonly string[];
|
readonly normalizedTokens: readonly string[];
|
||||||
readonly controlFlowTokens: readonly string[];
|
readonly controlFlowTokens: readonly string[];
|
||||||
@@ -229,21 +270,16 @@ const semanticLiteral = (node: t.Node): string | null => {
|
|||||||
|
|
||||||
const relationShape = (
|
const relationShape = (
|
||||||
callable: JavaScriptSemanticCallable,
|
callable: JavaScriptSemanticCallable,
|
||||||
calls: JavaScriptSemanticCallAnalysis,
|
callSites: JavaScriptSemanticCallAnalysis["callSites"],
|
||||||
|
captureCount: number,
|
||||||
promises: readonly JavaScriptSemanticPromiseOperation[],
|
promises: readonly JavaScriptSemanticPromiseOperation[],
|
||||||
): string[] => [
|
): string[] => [
|
||||||
`returns:${String(callable.returnSites.length)}:${callable.returnCoverage.status}`,
|
`returns:${String(callable.returnSites.length)}:${callable.returnCoverage.status}`,
|
||||||
...calls.callSites
|
...callSites.map(
|
||||||
.filter(({ callerCallableId }) => callerCallableId === callable.callableId)
|
({ kind, resolution, arguments: args, calleeCallableIds }) =>
|
||||||
.map(
|
`call:${kind}:${resolution}:${String(args.length)}:${String(calleeCallableIds.length)}`,
|
||||||
({ kind, resolution, arguments: args, calleeCallableIds }) =>
|
),
|
||||||
`call:${kind}:${resolution}:${String(args.length)}:${String(calleeCallableIds.length)}`,
|
`captures:${String(captureCount)}`,
|
||||||
),
|
|
||||||
`captures:${String(
|
|
||||||
calls.closureCaptures.filter(
|
|
||||||
({ callableId }) => callableId === callable.callableId,
|
|
||||||
).length,
|
|
||||||
)}`,
|
|
||||||
...promises.map(
|
...promises.map(
|
||||||
({ kind, method, ownership, sourceResolution }) =>
|
({ kind, method, ownership, sourceResolution }) =>
|
||||||
`promise:${kind}:${method}:${ownership}:${sourceResolution}`,
|
`promise:${kind}:${method}:${ownership}:${sourceResolution}`,
|
||||||
|
|||||||
@@ -51,3 +51,16 @@ it("preserves source-tree enter/exit order and detached ancestor snapshots", ()
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("skips sparse child slots without disturbing sibling visit order", () => {
|
||||||
|
const parsed = parseJavaScriptSource("const values = [first, , second];");
|
||||||
|
if (parsed === null)
|
||||||
|
throw new TypeError("Expected a parsed JavaScript fixture");
|
||||||
|
const identifiers: string[] = [];
|
||||||
|
traverseJavaScriptAst(parsed.program, {
|
||||||
|
enter: (node) => {
|
||||||
|
if (t.isIdentifier(node)) identifiers.push(node.name);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(identifiers).toEqual(["values", "first", "second"]);
|
||||||
|
});
|
||||||
|
|||||||
@@ -51,11 +51,19 @@ interface TraversalFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const childNodes = (node: t.Node): t.Node[] => {
|
const childNodes = (node: t.Node): t.Node[] => {
|
||||||
const keys: readonly string[] = t.VISITOR_KEYS[node.type] ?? [];
|
const keys = t.VISITOR_KEYS[node.type];
|
||||||
return keys.flatMap((key) => {
|
if (keys === undefined) return [];
|
||||||
|
const children: t.Node[] = [];
|
||||||
|
for (const key of keys) {
|
||||||
const value: unknown = Reflect.get(node, key);
|
const value: unknown = Reflect.get(node, key);
|
||||||
if (t.isNode(value)) return [value];
|
if (t.isNode(value)) {
|
||||||
if (!Array.isArray(value)) return [];
|
children.push(value);
|
||||||
return value.filter((item): item is t.Node => t.isNode(item));
|
continue;
|
||||||
});
|
}
|
||||||
|
if (!Array.isArray(value)) continue;
|
||||||
|
for (const item of value) {
|
||||||
|
if (t.isNode(item)) children.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return children;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import { expect, it } from "vitest";
|
||||||
|
|
||||||
|
import { collectJavaScriptExports } from "./javascriptAstFingerprint.js";
|
||||||
|
import { analyzeJavaScriptStaticSource } from "./javascriptStaticAnalysis.js";
|
||||||
|
import { parseJavaScriptSource } from "./javascriptSourceParser.js";
|
||||||
|
|
||||||
|
const memberChain = ".next".repeat(12_000);
|
||||||
|
|
||||||
|
it("collects a 12,000-member CommonJS export path without recursion", () => {
|
||||||
|
const file = parseJavaScriptSource(`exports${memberChain}.last = 1;`);
|
||||||
|
if (file === null) throw new Error("Expected valid JavaScript");
|
||||||
|
expect(collectJavaScriptExports(file).values).toEqual([
|
||||||
|
`${"next.".repeat(12_000)}last`,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("preserves empty, dynamic, this, and private member path behavior", () => {
|
||||||
|
const file = parseJavaScriptSource(`
|
||||||
|
exports[""].value = 1;
|
||||||
|
exports[""] = 0;
|
||||||
|
exports[key].value = 2;
|
||||||
|
this.exports.ignored = 3;
|
||||||
|
class Example { #private = 0; read() { this.#private = 1; } }
|
||||||
|
`);
|
||||||
|
if (file === null) throw new Error("Expected valid JavaScript");
|
||||||
|
expect(collectJavaScriptExports(file).values).toEqual([
|
||||||
|
"",
|
||||||
|
".value",
|
||||||
|
"key.value",
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps left-first and outer-member-first bundler runtime matches", () => {
|
||||||
|
const source = `
|
||||||
|
(globalThis.webpackChunkLeft || globalThis.webpackChunkRight).push([[1], { 1: function() {} }]);
|
||||||
|
globalThis.webpackChunkOuter.webpackChunkInner.push([[2], { 2: function() {} }]);
|
||||||
|
`;
|
||||||
|
const analysis = analyzeJavaScriptStaticSource(source);
|
||||||
|
expect(
|
||||||
|
analysis.bundler_registrations.find(({ chunk_keys }) =>
|
||||||
|
chunk_keys.includes("1"),
|
||||||
|
)?.runtime,
|
||||||
|
).toBe("webpackChunkLeft");
|
||||||
|
expect(
|
||||||
|
analysis.bundler_registrations.find(({ chunk_keys }) =>
|
||||||
|
chunk_keys.includes("2"),
|
||||||
|
)?.runtime,
|
||||||
|
).toBe("webpackChunkInner");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("analyzes a 12,000-member bundler runtime chain without recursion", () => {
|
||||||
|
const source = `globalThis.webpackChunkApp${memberChain}.push([[1], { 1: function(module) { module.exports.ok = 42; } }]);`;
|
||||||
|
const analysis = analyzeJavaScriptStaticSource(source);
|
||||||
|
expect(analysis.parse_status).toBe("complete");
|
||||||
|
expect(analysis.parse_error_count).toBe(0);
|
||||||
|
expect(analysis.bundler_registrations).toHaveLength(1);
|
||||||
|
expect(analysis.bundler_registrations[0]).toMatchObject({
|
||||||
|
bundler: "webpack",
|
||||||
|
runtime: "webpackChunkApp",
|
||||||
|
chunk_keys: ["1"],
|
||||||
|
modules: [expect.objectContaining({ exports: ["ok"] })],
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -73,19 +73,38 @@ export const chunkRuntime = (call: t.CallExpression): string | undefined => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const findChunkRuntime = (node: t.Node): string | undefined => {
|
const findChunkRuntime = (node: t.Node): string | undefined => {
|
||||||
if (t.isIdentifier(node) && /(?:webpack|rspack)Chunk/iu.test(node.name))
|
const pending: t.Node[] = [node];
|
||||||
return node.name;
|
while (pending.length > 0) {
|
||||||
if (t.isMemberExpression(node) || t.isOptionalMemberExpression(node)) {
|
const current = pending.pop();
|
||||||
const property = semanticStaticPropertyName(node.property, node.computed);
|
if (current === undefined) continue;
|
||||||
if (/(?:webpack|rspack)Chunk/iu.test(property)) return property;
|
if (
|
||||||
return t.isNode(node.object) ? findChunkRuntime(node.object) : undefined;
|
t.isIdentifier(current) &&
|
||||||
|
/(?:webpack|rspack)Chunk/iu.test(current.name)
|
||||||
|
)
|
||||||
|
return current.name;
|
||||||
|
if (
|
||||||
|
t.isMemberExpression(current) ||
|
||||||
|
t.isOptionalMemberExpression(current)
|
||||||
|
) {
|
||||||
|
const property = semanticStaticPropertyName(
|
||||||
|
current.property,
|
||||||
|
current.computed,
|
||||||
|
);
|
||||||
|
if (/(?:webpack|rspack)Chunk/iu.test(property)) return property;
|
||||||
|
if (t.isNode(current.object)) pending.push(current.object);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (t.isAssignmentExpression(current)) {
|
||||||
|
pending.push(current.right, current.left);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (t.isLogicalExpression(current) || t.isBinaryExpression(current)) {
|
||||||
|
pending.push(current.right, current.left);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (t.isParenthesizedExpression(current) || t.isTSAsExpression(current))
|
||||||
|
pending.push(current.expression);
|
||||||
}
|
}
|
||||||
if (t.isAssignmentExpression(node))
|
|
||||||
return findChunkRuntime(node.left) ?? findChunkRuntime(node.right);
|
|
||||||
if (t.isLogicalExpression(node) || t.isBinaryExpression(node))
|
|
||||||
return findChunkRuntime(node.left) ?? findChunkRuntime(node.right);
|
|
||||||
if (t.isParenthesizedExpression(node) || t.isTSAsExpression(node))
|
|
||||||
return findChunkRuntime(node.expression);
|
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -3,13 +3,13 @@ import { createHash } from "node:crypto";
|
|||||||
import canonicalize from "canonicalize";
|
import canonicalize from "canonicalize";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { evidenceSchema, parseEvidence, type Evidence } from "./evidence.js";
|
import { evidenceSchema, parseEvidence, type Evidence } from "../evidence.js";
|
||||||
import {
|
import {
|
||||||
createJavaScriptApplicationGraph,
|
createJavaScriptApplicationGraph,
|
||||||
javascriptApplicationGraphSchema,
|
javascriptApplicationGraphSchema,
|
||||||
type ApplicationEdge,
|
type ApplicationEdge,
|
||||||
type ApplicationNode,
|
type ApplicationNode,
|
||||||
} from "./javascript/javascriptApplicationGraph.js";
|
} from "../javascript/javascriptApplicationGraph.js";
|
||||||
import {
|
import {
|
||||||
managedArtifactInspectionSchema,
|
managedArtifactInspectionSchema,
|
||||||
managedMemberInspectionSchema,
|
managedMemberInspectionSchema,
|
||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
type ManagedMemberInspection,
|
type ManagedMemberInspection,
|
||||||
type ManagedNativeBoundaryInspection,
|
type ManagedNativeBoundaryInspection,
|
||||||
} from "./managedArtifact.js";
|
} from "./managedArtifact.js";
|
||||||
import type { JsonValue } from "./jsonValue.js";
|
import type { JsonValue } from "../jsonValue.js";
|
||||||
import {
|
import {
|
||||||
assessManagedGraphOmissions,
|
assessManagedGraphOmissions,
|
||||||
managedGraphEvidenceCoverage,
|
managedGraphEvidenceCoverage,
|
||||||
@@ -30,8 +30,8 @@ import {
|
|||||||
addBoundaryNodes,
|
addBoundaryNodes,
|
||||||
addMemberNodes,
|
addMemberNodes,
|
||||||
} from "./managedApplicationGraphNodes.js";
|
} from "./managedApplicationGraphNodes.js";
|
||||||
import { digestSchema } from "./../domain/digests.js";
|
import { digestSchema } from "../digests.js";
|
||||||
import { prefixedDigestSchema } from "./../domain/digests.js";
|
import { prefixedDigestSchema } from "../digests.js";
|
||||||
|
|
||||||
const evidenceIdSchema = prefixedDigestSchema("ev");
|
const evidenceIdSchema = prefixedDigestSchema("ev");
|
||||||
const textSchema = z.string().min(1);
|
const textSchema = z.string().min(1);
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import type { ApplicationGraphEvidence } from "./javascript/javascriptApplicationGraph.js";
|
import type { ApplicationGraphEvidence } from "../javascript/javascriptApplicationGraph.js";
|
||||||
import type {
|
import type {
|
||||||
ManagedArtifactInspection,
|
ManagedArtifactInspection,
|
||||||
ManagedMemberInspection,
|
ManagedMemberInspection,
|
||||||
+1
-1
@@ -4,7 +4,7 @@ import {
|
|||||||
createJavaScriptApplicationNode,
|
createJavaScriptApplicationNode,
|
||||||
type ApplicationGraphEvidence,
|
type ApplicationGraphEvidence,
|
||||||
type ApplicationNode,
|
type ApplicationNode,
|
||||||
} from "./javascript/javascriptApplicationGraph.js";
|
} from "../javascript/javascriptApplicationGraph.js";
|
||||||
import { managedSourceCoverage } from "./managedApplicationGraphCoverage.js";
|
import { managedSourceCoverage } from "./managedApplicationGraphCoverage.js";
|
||||||
import {
|
import {
|
||||||
type ManagedMemberInspection,
|
type ManagedMemberInspection,
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { digestSchema } from "./../domain/digests.js";
|
import { digestSchema } from "../digests.js";
|
||||||
|
|
||||||
const tokenSchema = z.string().regex(/^0x[0-9a-f]{8}$/u);
|
const tokenSchema = z.string().regex(/^0x[0-9a-f]{8}$/u);
|
||||||
const offsetSchema = z.number().int().min(0);
|
const offsetSchema = z.number().int().min(0);
|
||||||
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { emptyArraySchema } from "./emptyArraySchema.js";
|
import { emptyArraySchema } from "../emptyArraySchema.js";
|
||||||
import { evidenceSchema } from "./evidence.js";
|
import { evidenceSchema } from "../evidence.js";
|
||||||
import {
|
import {
|
||||||
cliMetadataGuidSchema,
|
cliMetadataGuidSchema,
|
||||||
type ManagedMemberInspection,
|
type ManagedMemberInspection,
|
||||||
@@ -18,8 +18,8 @@ import {
|
|||||||
buildMethodItems,
|
buildMethodItems,
|
||||||
} from "./managedMemberComparisonItems.js";
|
} from "./managedMemberComparisonItems.js";
|
||||||
import { keyMembers, sha256 } from "./managedMemberComparisonMatch.js";
|
import { keyMembers, sha256 } from "./managedMemberComparisonMatch.js";
|
||||||
import { digestSchema } from "./../domain/digests.js";
|
import { digestSchema } from "../digests.js";
|
||||||
import { prefixedDigestSchema } from "./../domain/digests.js";
|
import { prefixedDigestSchema } from "../digests.js";
|
||||||
|
|
||||||
const evidenceIdSchema = prefixedDigestSchema("ev");
|
const evidenceIdSchema = prefixedDigestSchema("ev");
|
||||||
const tokenSchema = z.string().regex(/^0x[0-9a-f]{8}$/u);
|
const tokenSchema = z.string().regex(/^0x[0-9a-f]{8}$/u);
|
||||||
+2
-2
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
|||||||
|
|
||||||
import canonicalize from "canonicalize";
|
import canonicalize from "canonicalize";
|
||||||
|
|
||||||
import { parseEvidence } from "./evidence.js";
|
import { parseEvidence } from "../evidence.js";
|
||||||
import {
|
import {
|
||||||
managedMemberInspectionSchema,
|
managedMemberInspectionSchema,
|
||||||
type ManagedMemberInspection,
|
type ManagedMemberInspection,
|
||||||
@@ -11,7 +11,7 @@ import type {
|
|||||||
ManagedMemberComparisonResult,
|
ManagedMemberComparisonResult,
|
||||||
ManagedMemberComparisonSide,
|
ManagedMemberComparisonSide,
|
||||||
} from "./managedMemberComparison.js";
|
} from "./managedMemberComparison.js";
|
||||||
import type { JsonValue } from "./jsonValue.js";
|
import type { JsonValue } from "../jsonValue.js";
|
||||||
|
|
||||||
export const sha256 = (value: JsonValue): string => {
|
export const sha256 = (value: JsonValue): string => {
|
||||||
const serialized = canonicalize(value);
|
const serialized = canonicalize(value);
|
||||||
+2
-2
@@ -2,12 +2,12 @@ import { createHash } from "node:crypto";
|
|||||||
|
|
||||||
import canonicalize from "canonicalize";
|
import canonicalize from "canonicalize";
|
||||||
|
|
||||||
import { parseEvidence } from "./evidence.js";
|
import { parseEvidence } from "../evidence.js";
|
||||||
import {
|
import {
|
||||||
managedNativeBoundaryInspectionSchema,
|
managedNativeBoundaryInspectionSchema,
|
||||||
type ManagedNativeBoundaryInspection,
|
type ManagedNativeBoundaryInspection,
|
||||||
} from "./managedArtifact.js";
|
} from "./managedArtifact.js";
|
||||||
import type { JsonValue } from "./jsonValue.js";
|
import type { JsonValue } from "../jsonValue.js";
|
||||||
import {
|
import {
|
||||||
managedNativeVerificationResultSchema,
|
managedNativeVerificationResultSchema,
|
||||||
type ManagedNativeVerificationInput,
|
type ManagedNativeVerificationInput,
|
||||||
+4
-4
@@ -3,11 +3,11 @@ import { basename } from "node:path";
|
|||||||
|
|
||||||
import canonicalize from "canonicalize";
|
import canonicalize from "canonicalize";
|
||||||
|
|
||||||
import { parseEvidence } from "./evidence.js";
|
import { parseEvidence } from "../evidence.js";
|
||||||
import { functionDossierSchema } from "./hopperValues.js";
|
import { functionDossierSchema } from "../hopperValues.js";
|
||||||
import { inspectMachoSchema } from "./nativeInspection.js";
|
import { inspectMachoSchema } from "../nativeInspection.js";
|
||||||
import type { ManagedNativeBoundaryInspection } from "./managedArtifact.js";
|
import type { ManagedNativeBoundaryInspection } from "./managedArtifact.js";
|
||||||
import type { JsonValue } from "./jsonValue.js";
|
import type { JsonValue } from "../jsonValue.js";
|
||||||
import {
|
import {
|
||||||
pinvokeVerificationSchema,
|
pinvokeVerificationSchema,
|
||||||
type ManagedNativeVerificationInput,
|
type ManagedNativeVerificationInput,
|
||||||
+4
-4
@@ -1,10 +1,10 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { emptyArraySchema } from "./emptyArraySchema.js";
|
import { emptyArraySchema } from "../emptyArraySchema.js";
|
||||||
import { evidenceSchema } from "./evidence.js";
|
import { evidenceSchema } from "../evidence.js";
|
||||||
import { cliMetadataGuidSchema } from "./managedArtifact.js";
|
import { cliMetadataGuidSchema } from "./managedArtifact.js";
|
||||||
import { digestSchema } from "./../domain/digests.js";
|
import { digestSchema } from "../digests.js";
|
||||||
import { prefixedDigestSchema } from "./../domain/digests.js";
|
import { prefixedDigestSchema } from "../digests.js";
|
||||||
|
|
||||||
const evidenceIdSchema = prefixedDigestSchema("ev");
|
const evidenceIdSchema = prefixedDigestSchema("ev");
|
||||||
const tokenSchema = z.string().regex(/^0x[0-9a-f]{8}$/u);
|
const tokenSchema = z.string().regex(/^0x[0-9a-f]{8}$/u);
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { createEvidence } from "./evidence.js";
|
import { createEvidence } from "../evidence.js";
|
||||||
import { managedReconstructionImportInputSchema } from "./managedReconstruction.js";
|
import { managedReconstructionImportInputSchema } from "./managedReconstruction.js";
|
||||||
|
|
||||||
describe("managed reconstruction import input", () => {
|
describe("managed reconstruction import input", () => {
|
||||||
@@ -3,15 +3,15 @@ import { createHash } from "node:crypto";
|
|||||||
import canonicalize from "canonicalize";
|
import canonicalize from "canonicalize";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { evidenceSchema, parseEvidence } from "./evidence.js";
|
import { evidenceSchema, parseEvidence } from "../evidence.js";
|
||||||
import {
|
import {
|
||||||
cliMetadataGuidSchema,
|
cliMetadataGuidSchema,
|
||||||
managedMemberInspectionSchema,
|
managedMemberInspectionSchema,
|
||||||
type ManagedMemberInspection,
|
type ManagedMemberInspection,
|
||||||
} from "./managedArtifact.js";
|
} from "./managedArtifact.js";
|
||||||
import type { JsonValue } from "./jsonValue.js";
|
import type { JsonValue } from "../jsonValue.js";
|
||||||
import { digestSchema } from "./../domain/digests.js";
|
import { digestSchema } from "../digests.js";
|
||||||
import { prefixedDigestSchema } from "./../domain/digests.js";
|
import { prefixedDigestSchema } from "../digests.js";
|
||||||
|
|
||||||
const evidenceIdSchema = prefixedDigestSchema("ev");
|
const evidenceIdSchema = prefixedDigestSchema("ev");
|
||||||
const tokenSchema = z.string().regex(/^0x[0-9a-f]{8}$/u);
|
const tokenSchema = z.string().regex(/^0x[0-9a-f]{8}$/u);
|
||||||
@@ -28,13 +28,37 @@ describe("direct process scenarios", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("rejects malformed environment names and adapter-reserved identity", () => {
|
it("rejects malformed environment names and adapter-reserved identity", () => {
|
||||||
for (const name of ["", "KEY=VALUE", "KEY\0VALUE", "REA_PROCESS_RUN_ID"])
|
for (const name of ["", "KEY=VALUE", "KEY\0VALUE", "REA_PROCESS_RUN_ID"]) {
|
||||||
expect(
|
const result = processScenarioSchema.safeParse({
|
||||||
processScenarioSchema.safeParse({
|
executable: "node",
|
||||||
executable: "node",
|
environment: { [name]: "value" },
|
||||||
environment: { [name]: "value" },
|
});
|
||||||
}).success,
|
expect(result.success).toBe(false);
|
||||||
).toBe(false);
|
if (name === "" && !result.success) {
|
||||||
|
const invalidKey = result.error.issues[0];
|
||||||
|
expect(invalidKey?.code).toBe("invalid_key");
|
||||||
|
if (invalidKey?.code === "invalid_key") {
|
||||||
|
expect(invalidKey.issues[0]?.message).toBe(
|
||||||
|
"Environment names must not be empty",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name === "REA_PROCESS_RUN_ID" && !result.success) {
|
||||||
|
const invalidKey = result.error.issues[0];
|
||||||
|
expect(invalidKey?.code).toBe("invalid_key");
|
||||||
|
if (invalidKey?.code === "invalid_key") {
|
||||||
|
expect(invalidKey.issues[0]?.message).toBe(
|
||||||
|
"REA_PROCESS_RUN_ID is reserved by the process adapter",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect(
|
||||||
|
processScenarioSchema.safeParse({
|
||||||
|
executable: "node",
|
||||||
|
environment: { "REA_PROCESS_RUN_ID\n": "caller-value" },
|
||||||
|
}).success,
|
||||||
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps bounded capture controls and ordered scheduled interaction", () => {
|
it("keeps bounded capture controls and ordered scheduled interaction", () => {
|
||||||
|
|||||||
@@ -4,10 +4,16 @@ import { z } from "zod";
|
|||||||
|
|
||||||
const positiveBudget = z.number().int().safe().positive();
|
const positiveBudget = z.number().int().safe().positive();
|
||||||
const timedEventBase = { at_ms: z.number().int().safe().nonnegative() };
|
const timedEventBase = { at_ms: z.number().int().safe().nonnegative() };
|
||||||
|
const reservedRunIdEnvironmentName = "REA_PROCESS_RUN_ID";
|
||||||
const environmentName = z
|
const environmentName = z
|
||||||
.string()
|
.string()
|
||||||
.regex(/^[^=\0]+$/u, "Environment names cannot contain '=' or NUL");
|
.min(1, "Environment names must not be empty")
|
||||||
const reservedEnvironment = new Set(["REA_PROCESS_RUN_ID"]);
|
.regex(/^(?!REA_PROCESS_RUN_ID(?![\s\S]))[^=\0]+$/u, {
|
||||||
|
error: (issue) =>
|
||||||
|
issue.input === reservedRunIdEnvironmentName
|
||||||
|
? `${reservedRunIdEnvironmentName} is reserved by the process adapter`
|
||||||
|
: "Environment names cannot contain '=' or NUL",
|
||||||
|
});
|
||||||
export const normalizationSchema = z.object({
|
export const normalizationSchema = z.object({
|
||||||
paths: z.boolean(),
|
paths: z.boolean(),
|
||||||
pids: z.boolean(),
|
pids: z.boolean(),
|
||||||
@@ -170,16 +176,6 @@ export const processScenarioSchema = z
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const explicit = new Set(Object.keys(scenario.environment));
|
|
||||||
for (const name of explicit) {
|
|
||||||
if (reservedEnvironment.has(name)) {
|
|
||||||
context.addIssue({
|
|
||||||
code: "custom",
|
|
||||||
message: `${name} is reserved by the process adapter`,
|
|
||||||
path: ["environment", name],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const event of scenario.events) {
|
for (const event of scenario.events) {
|
||||||
if (event.at_ms > scenario.timeout_ms) {
|
if (event.at_ms > scenario.timeout_ms) {
|
||||||
context.addIssue({
|
context.addIssue({
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
managedArtifactInspectionSchema,
|
managedArtifactInspectionSchema,
|
||||||
type ManagedArtifactInspection,
|
type ManagedArtifactInspection,
|
||||||
type ManagedParseIssue,
|
type ManagedParseIssue,
|
||||||
} from "../domain/managedArtifact.js";
|
} from "../domain/managed/managedArtifact.js";
|
||||||
import {
|
import {
|
||||||
readManagedPeLayout,
|
readManagedPeLayout,
|
||||||
type ManagedCliHeader,
|
type ManagedCliHeader,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
managedMemberInspectionSchema,
|
managedMemberInspectionSchema,
|
||||||
type ManagedMemberInspection,
|
type ManagedMemberInspection,
|
||||||
type ManagedParseIssue,
|
type ManagedParseIssue,
|
||||||
} from "../domain/managedArtifact.js";
|
} from "../domain/managed/managedArtifact.js";
|
||||||
import {
|
import {
|
||||||
readManagedPeLayout,
|
readManagedPeLayout,
|
||||||
type ManagedPeLayout,
|
type ManagedPeLayout,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
managedFailure,
|
managedFailure,
|
||||||
ManagedReaderFailure,
|
ManagedReaderFailure,
|
||||||
} from "./ManagedReaderFailure.js";
|
} from "./ManagedReaderFailure.js";
|
||||||
import type { ManagedMemberInspection } from "../domain/managedArtifact.js";
|
import type { ManagedMemberInspection } from "../domain/managed/managedArtifact.js";
|
||||||
import {
|
import {
|
||||||
type ManagedMetadataLayout,
|
type ManagedMetadataLayout,
|
||||||
type MetadataTableLayout,
|
type MetadataTableLayout,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type {
|
import type {
|
||||||
ManagedArtifactInspection,
|
ManagedArtifactInspection,
|
||||||
ManagedParseIssue,
|
ManagedParseIssue,
|
||||||
} from "../domain/managedArtifact.js";
|
} from "../domain/managed/managedArtifact.js";
|
||||||
import {
|
import {
|
||||||
METADATA_TABLE_NAMES,
|
METADATA_TABLE_NAMES,
|
||||||
type ManagedMetadataLayout,
|
type ManagedMetadataLayout,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type {
|
import type {
|
||||||
ManagedArtifactInspection,
|
ManagedArtifactInspection,
|
||||||
ManagedParseIssue,
|
ManagedParseIssue,
|
||||||
} from "../domain/managedArtifact.js";
|
} from "../domain/managed/managedArtifact.js";
|
||||||
import {
|
import {
|
||||||
metadataRowOffset,
|
metadataRowOffset,
|
||||||
type ManagedMetadataLayout,
|
type ManagedMetadataLayout,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
managedNativeBoundaryInspectionSchema,
|
managedNativeBoundaryInspectionSchema,
|
||||||
type ManagedNativeBoundaryInspection,
|
type ManagedNativeBoundaryInspection,
|
||||||
type ManagedParseIssue,
|
type ManagedParseIssue,
|
||||||
} from "../domain/managedArtifact.js";
|
} from "../domain/managed/managedArtifact.js";
|
||||||
import { type ManagedMetadataLayout } from "./ManagedMetadataLayout.js";
|
import { type ManagedMetadataLayout } from "./ManagedMetadataLayout.js";
|
||||||
import {
|
import {
|
||||||
metadataRowCursor,
|
metadataRowCursor,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
managedNativeBoundaryInspectionSchema,
|
managedNativeBoundaryInspectionSchema,
|
||||||
type ManagedNativeBoundaryInspection,
|
type ManagedNativeBoundaryInspection,
|
||||||
type ManagedParseIssue,
|
type ManagedParseIssue,
|
||||||
} from "../domain/managedArtifact.js";
|
} from "../domain/managed/managedArtifact.js";
|
||||||
import {
|
import {
|
||||||
readManagedMetadataInventory,
|
readManagedMetadataInventory,
|
||||||
type ManagedResourceDirectory,
|
type ManagedResourceDirectory,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { ManagedParseIssue } from "../domain/managedArtifact.js";
|
import type { ManagedParseIssue } from "../domain/managed/managedArtifact.js";
|
||||||
import {
|
import {
|
||||||
managedFailure,
|
managedFailure,
|
||||||
ManagedReaderFailure,
|
ManagedReaderFailure,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { ManagedParseIssue } from "../domain/managedArtifact.js";
|
import type { ManagedParseIssue } from "../domain/managed/managedArtifact.js";
|
||||||
|
|
||||||
/** Bounded format failure retained as caller-visible managed coverage. */
|
/** Bounded format failure retained as caller-visible managed coverage. */
|
||||||
export class ManagedReaderFailure extends Error {
|
export class ManagedReaderFailure extends Error {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
managedMemberInputSchema,
|
managedMemberInputSchema,
|
||||||
managedNativeBoundaryInputSchema,
|
managedNativeBoundaryInputSchema,
|
||||||
type ManagedToolName,
|
type ManagedToolName,
|
||||||
} from "../contracts/managedToolContracts.js";
|
} from "../contracts/managed/managedToolContracts.js";
|
||||||
import type { BinaryTarget } from "../domain/binaryTarget.js";
|
import type { BinaryTarget } from "../domain/binaryTarget.js";
|
||||||
import {
|
import {
|
||||||
AnalysisCancelledError,
|
AnalysisCancelledError,
|
||||||
@@ -35,7 +35,7 @@ import type {
|
|||||||
ManagedArtifactInspection,
|
ManagedArtifactInspection,
|
||||||
ManagedMemberInspection,
|
ManagedMemberInspection,
|
||||||
ManagedNativeBoundaryInspection,
|
ManagedNativeBoundaryInspection,
|
||||||
} from "../domain/managedArtifact.js";
|
} from "../domain/managed/managedArtifact.js";
|
||||||
import { err, ok } from "../domain/result.js";
|
import { err, ok } from "../domain/result.js";
|
||||||
import { inspectManagedArtifactBytes } from "./ManagedArtifactInspector.js";
|
import { inspectManagedArtifactBytes } from "./ManagedArtifactInspector.js";
|
||||||
import { inspectManagedMembersBytes } from "./ManagedMemberInspector.js";
|
import { inspectManagedMembersBytes } from "./ManagedMemberInspector.js";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { MANAGED_STATIC_PROVIDER } from "../application/InvestigationProviders.j
|
|||||||
import {
|
import {
|
||||||
MANAGED_TOOL_CONTRACTS,
|
MANAGED_TOOL_CONTRACTS,
|
||||||
type ManagedToolName,
|
type ManagedToolName,
|
||||||
} from "../contracts/managedToolContracts.js";
|
} from "../contracts/managed/managedToolContracts.js";
|
||||||
|
|
||||||
/** Identity of execution-free managed metadata observations. */
|
/** Identity of execution-free managed metadata observations. */
|
||||||
export const MANAGED_STATIC_PROVIDER_IDENTITY: ProviderIdentity = Object.freeze(
|
export const MANAGED_STATIC_PROVIDER_IDENTITY: ProviderIdentity = Object.freeze(
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -312,6 +312,36 @@ describe("headless IDA lifecycle boundaries", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("headless IDA session ownership and cleanup", () => {
|
describe("headless IDA session ownership and cleanup", () => {
|
||||||
|
it("shares an in-flight close across concurrent cleanup callers", async () => {
|
||||||
|
const { producer, client } = await fixture("headless");
|
||||||
|
expect((await client.execute("health", {})).ok).toBe(true);
|
||||||
|
|
||||||
|
let release: (() => void) | undefined;
|
||||||
|
let notify: (() => void) | undefined;
|
||||||
|
const closeStarted = new Promise<void>((resolve) => {
|
||||||
|
notify = resolve;
|
||||||
|
});
|
||||||
|
producer.beforeCall = async (name) => {
|
||||||
|
if (name !== "idb_close") return;
|
||||||
|
notify?.();
|
||||||
|
await new Promise<void>((resolve) => {
|
||||||
|
release = resolve;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const first = client.closeWithOutcome();
|
||||||
|
await closeStarted;
|
||||||
|
const second = client.closeWithOutcome();
|
||||||
|
release?.();
|
||||||
|
const results = await Promise.all([first, second]);
|
||||||
|
|
||||||
|
expect(results.every((result) => result.ok)).toBe(true);
|
||||||
|
expect(
|
||||||
|
producer.calls.filter(({ name }) => name === "idb_close"),
|
||||||
|
).toHaveLength(1);
|
||||||
|
expect(producer.closes).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
it("retains the workspace after an unconfirmed open, even when inventory is empty, and never retries startup implicitly", async () => {
|
it("retains the workspace after an unconfirmed open, even when inventory is empty, and never retries startup implicitly", async () => {
|
||||||
const { producer, client, root } = await fixture("headless");
|
const { producer, client, root } = await fixture("headless");
|
||||||
producer.beforeCall = async (name) => {
|
producer.beforeCall = async (name) => {
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ export class IdaSessionClient implements AnalysisClient {
|
|||||||
#startup: Promise<void> | undefined;
|
#startup: Promise<void> | undefined;
|
||||||
#closed = false;
|
#closed = false;
|
||||||
#closing = false;
|
#closing = false;
|
||||||
|
#closePromise: Promise<Result<null, AnalysisError>> | undefined;
|
||||||
#workspace: IdaWorkspace | undefined;
|
#workspace: IdaWorkspace | undefined;
|
||||||
#database: string | undefined;
|
#database: string | undefined;
|
||||||
#openAttempted = false;
|
#openAttempted = false;
|
||||||
@@ -385,6 +386,16 @@ export class IdaSessionClient implements AnalysisClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async closeWithOutcome(): Promise<Result<null, AnalysisError>> {
|
async closeWithOutcome(): Promise<Result<null, AnalysisError>> {
|
||||||
|
if (this.#closePromise !== undefined) return this.#closePromise;
|
||||||
|
const closing = this.#closeOnce();
|
||||||
|
const shared = closing.finally(() => {
|
||||||
|
if (this.#closePromise === shared) this.#closePromise = undefined;
|
||||||
|
});
|
||||||
|
this.#closePromise = shared;
|
||||||
|
return shared;
|
||||||
|
}
|
||||||
|
|
||||||
|
async #closeOnce(): Promise<Result<null, AnalysisError>> {
|
||||||
this.#closing = true;
|
this.#closing = true;
|
||||||
await this.#tail;
|
await this.#tail;
|
||||||
if (this.#closed) return ok(null);
|
if (this.#closed) return ok(null);
|
||||||
|
|||||||
@@ -151,6 +151,9 @@ describe("source-map layout admission", () => {
|
|||||||
expect(() => trace({ ...leaf, mappings })).toThrow();
|
expect(() => trace({ ...leaf, mappings })).toThrow();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
it("validates regular-map source indexes after reusing its decoded rows", () => {
|
||||||
|
expect(() => trace({ ...leaf, mappings: "ACAA" })).toThrow(/index/u);
|
||||||
|
});
|
||||||
it("rejects huge indexed offsets before upstream row allocation", () => {
|
it("rejects huge indexed offsets before upstream row allocation", () => {
|
||||||
expect(() =>
|
expect(() =>
|
||||||
trace({
|
trace({
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user