Files
reverse-engineering-anything/src/server/sessionAvailabilityPolicy.ts
T
Rishikesh Gowda K K 891371e738 fix(objdump): reflect observed launch failure in discovery availability (#9051)
* fix(objdump): reflect observed launch failure in discovery availability

Distinguish a statically registered standalone command from an executable
whose launch has failed in the active server session. Discovery leaves
unprobed commands optimistically available, reports an observed launch
failure as provider_unavailable with the command remediation, keeps the
tool callable for retries, and clears the failure after a subsequent
successful launch.

Fixes #8826.

* test(reverse): verify overlapping command launch dispatch ordering

* test(reverse): unblock gated test workers before awaiting service closure

* test(reverse): bound lifecycle acknowledgement and join launched workers

* fix(reverse): distinguish host capacity exhaustion from command launch failures

* fix(reverse): preserve host capacity across Linux process ownership preparation

* fix(reverse): exclude process ownership admission failures from command launch state

* fix(reverse): preserve Darwin process ownership preparation error across command launch

* fix(reverse): disambiguate cleanup declaration in provider observation

* fix(reverse): preserve command deadline timeout during Darwin ownership preparation

* fix(reverse): isolate Darwin baseline ps errors and provide platform-aware admission guidance

* fix(reverse): rely on typed baseline admission failures and use owning repair formatter in tests

* test(reverse): use owning formatters for process ownership remediation assertions

* fix(reverse): restrict Linux ownership prerequisite remediation to missing ps and preserve system error codes

* fix(reverse): retain typed process ownership prerequisite with preserved error codes

* fix(reverse): remove unvalidated error label fallbacks and keep admission tags out of system_code

* fix(reverse): keep Windows native runner failures out of command-launch state

* fix(process): preserve current_process_unreported refusal in Linux provider readiness

* fix(process): distinguish no-code ps failure from missing ps and cover rizin launch failure

* fix(windows): classify process_spawn host-control rejections as RuntimeControlUnavailableError
2026-11-09 17:39:34 +08:00

88 lines
3.4 KiB
TypeScript

import {
HOST_RESTRICTED_FEATURES,
type AvailabilityPolicy,
type HostRestrictedFeature,
} from "../application/CapabilityInventory.js";
import { platform } from "node:process";
import type { CapabilityAvailabilityFacts } from "../application/CapabilityAvailability.js";
/** Either the caller or the observed host can mark an integration unsupported. */
const combineHostUnsupported = (
configured: AvailabilityPolicy["hostUnsupported"],
observed: NonNullable<AvailabilityPolicy["hostUnsupported"]>,
): Partial<Record<HostRestrictedFeature, boolean>> => {
const combined: Partial<Record<HostRestrictedFeature, boolean>> = {};
for (const feature of HOST_RESTRICTED_FEATURES)
if (configured?.[feature] === true || observed[feature] === true)
combined[feature] = true;
return combined;
};
/** Select configured availability reporting or the target-free defaults. */
export const sessionAvailabilityPolicy = (
configured: (() => AvailabilityPolicy) | undefined,
defaults: CapabilityAvailabilityFacts,
): (() => AvailabilityPolicy) => {
const policy =
configured ??
(() => ({
packetCaptureEnabled:
defaults.optionalFeatures?.packetCaptureEnabled ?? false,
signalRecordingEnabled:
defaults.optionalFeatures?.signalRecordingEnabled ?? false,
wasmArtifactEnabled:
defaults.optionalFeatures?.wasmArtifactEnabled ?? false,
evmInterfaceEnabled:
defaults.optionalFeatures?.evmInterfaceEnabled ?? false,
processCaptureEnabled: platform !== "win32",
recordedCrashEnabled:
defaults.optionalFeatures?.recordedCrashEnabled ?? false,
binaryLayoutEnabled:
defaults.optionalFeatures?.binaryLayoutEnabled ?? false,
firmwareInspectionEnabled:
defaults.optionalFeatures?.firmwareInspectionEnabled ?? false,
firmwareExtractionEnabled:
defaults.optionalFeatures?.firmwareExtractionEnabled ?? false,
javascriptRecoveryEnabled:
defaults.optionalFeatures?.javascriptRecoveryEnabled ?? false,
webModuleResolutionEnabled:
defaults.optionalFeatures?.webModuleResolutionEnabled ?? false,
browserObservationEnabled:
defaults.optionalFeatures?.browserObservationEnabled ?? false,
browserScenarioEnabled:
defaults.optionalFeatures?.browserScenarioEnabled ?? false,
electronObservationEnabled:
defaults.optionalFeatures?.electronObservationEnabled ?? false,
electronAutomationEnabled:
defaults.optionalFeatures?.electronAutomationEnabled ?? false,
v8InspectorObservationEnabled:
defaults.optionalFeatures?.v8InspectorObservationEnabled ?? false,
}));
// Observed host support also bounds a configured policy: no policy lets the
// default providers pass their execution host checks.
return () => {
const value: AvailabilityPolicy = policy();
return {
...value,
...(defaults.optionalProviderLoadFailures === undefined
? {}
: {
optionalProviderLoadFailures: defaults.optionalProviderLoadFailures,
}),
...(defaults.commandProviderFailures === undefined
? {}
: {
commandProviderFailures: defaults.commandProviderFailures,
}),
...(defaults.hostUnsupported === undefined
? {}
: {
hostUnsupported: combineHostUnsupported(
value.hostUnsupported,
defaults.hostUnsupported,
),
}),
};
};
};