2026-10-07 16:03:37 +08:00
|
|
|
import type { ProviderIdentity } from "../AnalysisProvider.js";
|
2026-07-24 13:16:35 +00:00
|
|
|
import {
|
|
|
|
|
createEvidence,
|
|
|
|
|
type Evidence,
|
|
|
|
|
type EvidenceObservation,
|
2026-10-07 16:03:37 +08:00
|
|
|
} from "../../domain/evidence.js";
|
2026-07-24 13:16:35 +00:00
|
|
|
import type {
|
|
|
|
|
JavaScriptRuntimeObservation,
|
|
|
|
|
JavaScriptRuntimeTargetList,
|
|
|
|
|
ListJavaScriptRuntimeTargetsInput,
|
|
|
|
|
ObserveJavaScriptRuntimeInput,
|
2026-10-07 17:16:58 +08:00
|
|
|
} from "../../domain/javascript/javascriptRuntimeObservation.js";
|
2026-07-24 13:16:35 +00:00
|
|
|
|
|
|
|
|
type RuntimeObservationOperation =
|
|
|
|
|
| "list_javascript_runtime_targets"
|
|
|
|
|
| "observe_javascript_runtime";
|
|
|
|
|
|
2026-09-29 07:08:46 +08:00
|
|
|
/** Create deterministic Evidence for one passive Inspector operation. */
|
2026-07-24 13:16:35 +00:00
|
|
|
export const createJavaScriptRuntimeObservationEvidence = (
|
|
|
|
|
operation: RuntimeObservationOperation,
|
|
|
|
|
input: ListJavaScriptRuntimeTargetsInput | ObserveJavaScriptRuntimeInput,
|
|
|
|
|
result: JavaScriptRuntimeTargetList | JavaScriptRuntimeObservation,
|
|
|
|
|
provider: ProviderIdentity,
|
|
|
|
|
): Evidence =>
|
|
|
|
|
createEvidence(undefined, provider, {
|
|
|
|
|
predicateType:
|
|
|
|
|
operation === "list_javascript_runtime_targets"
|
2026-09-29 13:57:24 +08:00
|
|
|
? "rea.javascript-runtime-target-list"
|
|
|
|
|
: "rea.javascript-runtime-observation",
|
2026-07-24 13:16:35 +00:00
|
|
|
operation,
|
|
|
|
|
parameters: parameters(input),
|
2026-10-16 06:46:25 +08:00
|
|
|
result,
|
2026-07-24 13:16:35 +00:00
|
|
|
rawResult: null,
|
|
|
|
|
confidence: "observed",
|
|
|
|
|
authority: "external-service",
|
|
|
|
|
environment: {
|
|
|
|
|
id: `${result.runtime.product}@${result.runtime.protocol_version}`,
|
2026-10-06 00:50:38 +08:00
|
|
|
platform: "unknown",
|
|
|
|
|
architecture: "unknown",
|
2026-07-24 13:16:35 +00:00
|
|
|
isolation: "none",
|
|
|
|
|
},
|
2026-10-06 00:50:38 +08:00
|
|
|
limitations: [
|
|
|
|
|
...result.limitations,
|
|
|
|
|
"Runtime host platform and architecture were not observed.",
|
|
|
|
|
],
|
2026-07-24 13:16:35 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const parameters = (
|
|
|
|
|
input: ListJavaScriptRuntimeTargetsInput | ObserveJavaScriptRuntimeInput,
|
|
|
|
|
): EvidenceObservation["parameters"] => ({
|
|
|
|
|
inspector_endpoint: input.inspector_endpoint,
|
|
|
|
|
...("target_id" in input
|
|
|
|
|
? {
|
|
|
|
|
target_id: input.target_id,
|
2026-09-29 08:20:18 +08:00
|
|
|
...(input.runtime_kind === undefined
|
|
|
|
|
? {}
|
|
|
|
|
: { runtime_kind: input.runtime_kind }),
|
2026-07-24 13:16:35 +00:00
|
|
|
observation_ms: input.observation_ms,
|
|
|
|
|
}
|
2026-09-29 07:08:46 +08:00
|
|
|
: {}),
|
2026-07-24 13:16:35 +00:00
|
|
|
});
|