mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
Project retained Go and Rust dependency metadata as deterministic, bounded CycloneDX documents with parent provenance and explicit unknowns. Share current Evidence identity admission and canonical document-ceiling recovery. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning) Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import {
|
|
metadataReportSubjectFormat,
|
|
type MachoTargetSelection,
|
|
} from "../apple/machoTargetSelection.js";
|
|
import { binaryMetadataArchitecture } from "../binaryMetadataArchitecture.js";
|
|
import { evidenceFileTarget } from "../evidence.js";
|
|
import type { AnalysisError } from "../analysisErrorBase.js";
|
|
import { err, ok, type Result } from "../result.js";
|
|
import { analysisViewInputError } from "./analysisViewErrors.js";
|
|
import type { AnalysisViewParent } from "./analysisViewParent.js";
|
|
|
|
/**
|
|
* One owner for the metadata-report subject check. The parent subject must
|
|
* name the report artifact's digest, container format and CPU family.
|
|
*/
|
|
export const requireMetadataReportSubject = (
|
|
parent: AnalysisViewParent,
|
|
report: {
|
|
readonly format: "elf" | "pe" | "macho";
|
|
readonly architecture: string;
|
|
readonly artifact: { readonly sha256: string };
|
|
readonly selected_slice?: MachoTargetSelection;
|
|
},
|
|
message: string,
|
|
): Result<void, AnalysisError> => {
|
|
const subject = evidenceFileTarget(parent);
|
|
if (
|
|
subject == null ||
|
|
subject.sha256 !== report.artifact.sha256 ||
|
|
subject.format !== metadataReportSubjectFormat(report) ||
|
|
subject.architecture !==
|
|
(binaryMetadataArchitecture(report.architecture) ?? null)
|
|
)
|
|
return err(
|
|
analysisViewInputError([
|
|
{
|
|
path: ["source", "subject"],
|
|
reason: "invalid_value",
|
|
message,
|
|
},
|
|
]),
|
|
);
|
|
return ok(undefined);
|
|
};
|