-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathmuse-glimmer-vllm-image-provenance.test.ts
More file actions
62 lines (55 loc) · 2.58 KB
/
Copy pathmuse-glimmer-vllm-image-provenance.test.ts
File metadata and controls
62 lines (55 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { readFileSync } from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import YAML from "yaml";
import { VLLM_MODELS } from "../src/lib/inference/vllm-models.js";
import { detectVllmProfile, resolveVllmRuntimeProfile } from "../src/lib/inference/vllm.js";
import {
MUSE_GLIMMER_VLLM_IMAGE_REFERENCE,
verifyMuseGlimmerVllmImageProvenance,
} from "./support/muse-glimmer-vllm-image-provenance-test-support.js";
const ROOT = path.join(import.meta.dirname, "..");
const RECORD_PATH = path.join(
ROOT,
"internal",
"security-reviews",
"muse-glimmer-vllm-image-provenance-v1.json",
);
const RECIPE_PATH = path.join(
ROOT,
"managed-inference",
"recipes",
"vllm.muse-glimmer-30b-nvfp4-w4a4.spark-single.v1.yaml",
);
type JsonRecord = Record<string, unknown>;
const provenance = JSON.parse(readFileSync(RECORD_PATH, "utf8")) as unknown;
const recipe = YAML.parse(readFileSync(RECIPE_PATH, "utf8")) as {
spec: { runtime: { architecture: string; image: string; imageDownloadSizeBytes: number } };
};
describe("Muse Glimmer vLLM image provenance", () => {
// source-shape-contract: security -- Mutating each trust field proves the reviewed provenance record fails closed before a substituted external runtime can be published.
it.each([
["publisher drift", ["publisher", "namespace"], "attacker"],
["manifest drift", ["image", "manifestDigest"], `sha256:${"0".repeat(64)}`],
["platform drift", ["image", "platform", "architecture"], "amd64"],
["source drift", ["build", "sourceRevision"], "0".repeat(40)],
["label drift", ["reportedLabels", "org.opencontainers.image.revision"], "0".repeat(40)],
["support ancestry drift", ["upstreamSupport", "relationship"], "unverified"],
["runtime dependency drift", ["runtimeDependencies", "huggingfaceHubVersion"], "1.27.0"],
["revision serialization drift", ["revisionSerialization", "resolvedRevisionAfterPickle"], "main"],
] as const)("rejects %s", (_name, pathParts, replacement) => {
const changed = structuredClone(provenance) as JsonRecord;
let target = changed;
pathParts.slice(0, -1).forEach((part) => {
target = target[part] as JsonRecord;
});
const leaf = pathParts.at(-1)!;
expect(Object.hasOwn(target, leaf)).toBe(true);
const original = target[leaf];
target[leaf] = replacement;
expect(target[leaf]).not.toEqual(original);
expect(() => verifyMuseGlimmerVllmImageProvenance(changed)).toThrow();
});
});