refactor(evidence): reuse observed file reports for binary metadata (#15161)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-11-30 06:05:57 +00:00
1 parent 66ed78735a
commit 546f94f766
8 files changed
+103 -186

No files matched your search

@@ -1,8 +1,9 @@
import { insideArtifact } from "./artifactRange.js";
import { artifactRangeLocation, insideArtifact } from "./artifactRange.js";
import type { ExecutionOptions } from "../../ports/AnalysisProvider.js";
import type { KernelModulePort } from "../../ports/binaryDiagnostics/KernelModulePort.js";
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
import { createEvidence, type Evidence } from "../../domain/evidence.js";
import type { Evidence } from "../../domain/evidence.js";
import { observedFileEvidence } from "../observedFileEvidence.js";
import { elfObjectTypeName } from "../../domain/native/elfNotes.js";
import {
inspectKernelModuleInputSchema,
@@ -51,29 +52,15 @@ export class KernelModuleService {
buildEvidence: (value, identity, parameters) => {
const architecture =
value.machine === null ? undefined : elfArchitecture(value.machine);
const locations = [
{ kind: "artifact-path" as const, path: value.artifact.path },
...rangesOf(value).map((range) => ({
kind: "file-offset-range" as const,
start: range.offset,
end: range.offset + range.bytes,
})),
];
return createEvidence(
{
path: value.artifact.path,
format: value.applicability === "unsupported" ? "file" : "elf",
sha256: value.artifact.sha256,
...(architecture === undefined ? {} : { architecture }),
},
return observedFileEvidence(
value,
identity,
OPERATION,
parameters,
rangesOf(value).map(artifactRangeLocation),
{
operation: OPERATION,
parameters,
result: value,
confidence: "observed",
limitations: value.limitations,
locations,
format: value.applicability === "unsupported" ? "file" : "elf",
...(architecture === undefined ? {} : { architecture }),
},
);
},