mirror of
https://github.com/n8n-io/n8n.git
synced 2026-12-04 00:30:34 +00:00
ci: Verify the publisher and apply a 24-hour gate to base image candidates (#44527)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
98294a5bfe
commit
bc6ca59aa5
7 files changed
+383
-23
No files matched your search
@@ -187,7 +187,7 @@ These only run if specific files changed:
|
||||
| `packages/quality/efficiency/scale/benchmark/**` | `build-benchmark-image.yml` | master |
|
||||
| `packages/@n8n/instance-ai/src/**`, `packages/@n8n/instance-ai/skills/**`, `packages/@n8n/instance-ai/knowledge-base/**`, `packages/@n8n/instance-ai/evaluations/**`, `packages/cli/src/modules/instance-ai/**`, `packages/core/src/execution-engine/eval-mock-helpers.ts`, `packages/@n8n/agents/src/**` | `ci-instance-ai-evals.yml` | on PR `opened` / `reopened` / `ready_for_review` |
|
||||
| `docker/get-n8n.sh`, `docker/get-n8n-compose.yml`, `docker/test-get-n8n.sh` | `test-get-n8n.yml` | any |
|
||||
| `.github/workflows/sec-base-image-refresh.yml`, `.github/scripts/docker/base-image-candidates.mjs` | `sec-base-image-refresh.yml` on PRs only; it also runs daily and on dispatch. Skips fork PRs, which get no registry secrets | any |
|
||||
| `.github/workflows/sec-base-image-refresh.yml`, `.github/scripts/docker/base-image-candidates.mjs`, `.github/scripts/docker/base-image-publisher.mjs`, `security/keys/dhi.pub` | `sec-base-image-refresh.yml` on PRs only; it also runs daily and on dispatch. Skips fork PRs, which get no registry secrets | any |
|
||||
|
||||
### Pushes to an open PR
|
||||
|
||||
@@ -922,7 +922,8 @@ Scripts in `.github/scripts/`:
|
||||
| `docker/should-smoke-build.mjs`| Narrow the `pnpm-workspace.yaml` smoke trigger to native dependency pins | `docker-build-smoke.yml`|
|
||||
| `docker/base-debian-smoke-check.mjs`| Verify the Debian base image contract (tools, no package manager, fonts, global npm modules) on amd64 and arm64 | `build-base-image.yml`|
|
||||
| `docker/bake-inputs-changed.mjs`| Decide whether an image must build: compare its resolved bake inputs and Dockerfile between two commits | `build-base-image.yml`, `build-node-pc-image.yml`|
|
||||
| `docker/base-image-candidates.mjs`| Find the newest digest of each upstream base image pin and keep it when a Trivy scan shows that it removes fixable OS findings | `sec-base-image-refresh.yml`|
|
||||
| `docker/base-image-candidates.mjs`| Find the newest digest of each upstream base image pin and keep it when a Trivy scan shows that it removes fixable OS findings. A candidate is ready when its publisher is verified and it is at least 24 hours old. A manual run skips the age check | `sec-base-image-refresh.yml`|
|
||||
| `docker/base-image-publisher.mjs`| Verify the publisher of a base image digest (cosign for DHI and distroless, SLSA provenance for Docker Official Images) and read its publication time | `sec-base-image-refresh.yml`|
|
||||
| `attest-image-sbom.mjs` | Generate, validate, and optionally attest image SBOMs | `docker-build-push.yml`, `test-sbom-nightly.yml` |
|
||||
|
||||
### Node CLI Scripts
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
* Each upstream source is a pin in docker/docker-bake.hcl. The script resolves
|
||||
* the newest digest of the pinned tag, then scans the pinned and the newest
|
||||
* digest with Trivy on each platform. The newest digest is a candidate when it
|
||||
* removes at least one finding. The publisher check and the 24-hour gate come
|
||||
* after this step.
|
||||
* removes at least one finding. A candidate is ready when its publisher is
|
||||
* verified and it is at least 24 hours old (see applyGate).
|
||||
*
|
||||
* Usage: node base-image-candidates.mjs [--out <file>]
|
||||
* Needs docker buildx, trivy, and a login to each private registry (dhi.io).
|
||||
* Writes the result as JSON to --out and to $GITHUB_STEP_SUMMARY, and
|
||||
* candidates=<count> to $GITHUB_OUTPUT.
|
||||
* Usage: node base-image-candidates.mjs [--out <file>] [--skip-gate]
|
||||
* Needs docker buildx, trivy, cosign, and a login to each private registry
|
||||
* (dhi.io). Writes the result as JSON to --out and to $GITHUB_STEP_SUMMARY,
|
||||
* and ready=<count> to $GITHUB_OUTPUT.
|
||||
*/
|
||||
|
||||
import { execFileSync } from 'node:child_process';
|
||||
@@ -22,6 +22,8 @@ import path from 'node:path';
|
||||
import { parseArgs } from 'node:util';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
import { verifyPublisher } from './base-image-publisher.mjs';
|
||||
|
||||
const BAKE_FILE = 'docker/docker-bake.hcl';
|
||||
|
||||
/**
|
||||
@@ -100,6 +102,26 @@ export function evaluateSource(pin, newestDigest, scans) {
|
||||
return { ...result, status: removes ? 'candidate' : 'no-fix', platforms };
|
||||
}
|
||||
|
||||
export const GATE_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
/**
|
||||
* Applies the publisher check, the 24-hour gate and the package-set rule to a
|
||||
* candidate. A digest is ready when its publisher is verified and it is at
|
||||
* least 24 hours old. A manual run skips the gate. A digest that adds a
|
||||
* package, or that skipped the gate, is ready without auto-merge, so that a
|
||||
* person reviews it.
|
||||
*/
|
||||
export function applyGate(candidate, publisher, { now, skipGate }) {
|
||||
const checked = { ...candidate, publisher };
|
||||
if (!publisher.verified) return { ...checked, status: 'unverified' };
|
||||
const gated = !publisher.publishedAt || now - Date.parse(publisher.publishedAt) < GATE_MS;
|
||||
if (gated && !skipGate) {
|
||||
return { ...checked, status: publisher.publishedAt ? 'in-24h-gate' : 'no-publish-time' };
|
||||
}
|
||||
const addsPackage = candidate.platforms.some((platform) => platform.addedPackages.length > 0);
|
||||
return { ...checked, status: 'ready', autoMerge: !addsPackage && !gated, gateSkipped: gated };
|
||||
}
|
||||
|
||||
function resolveNewestDigest(pin) {
|
||||
const out = execFileSync(
|
||||
'docker',
|
||||
@@ -160,25 +182,33 @@ export function renderSummary(results) {
|
||||
const lines = [
|
||||
'## Base image candidates',
|
||||
'',
|
||||
'| Source | Status | Platform | Removed | Added | New packages |',
|
||||
'| --- | --- | --- | --- | --- | --- |',
|
||||
'| Source | Status | Published | Auto-merge | Platform | Removed | Added | New packages |',
|
||||
'| --- | --- | --- | --- | --- | --- | --- | --- |',
|
||||
];
|
||||
const errors = [];
|
||||
for (const result of results) {
|
||||
const published = result.publisher?.publishedAt ?? '-';
|
||||
const autoMerge = result.autoMerge === undefined ? '-' : result.autoMerge ? 'yes' : 'no';
|
||||
const head = `| \`${result.source}\` | ${result.status} | ${published} | ${autoMerge}`;
|
||||
if (result.publisher?.error) errors.push(`- \`${result.source}\`: ${result.publisher.error}`);
|
||||
if (result.platforms.length === 0) {
|
||||
lines.push(`| \`${result.source}\` | ${result.status} | - | - | - | - |`);
|
||||
lines.push(`${head} | - | - | - | - |`);
|
||||
continue;
|
||||
}
|
||||
for (const platform of result.platforms) {
|
||||
lines.push(
|
||||
`| \`${result.source}\` | ${result.status} | ${platform.platform} | ${count(platform.removed)} | ${count(platform.added)} | ${platform.addedPackages.join(', ') || '-'} |`,
|
||||
`${head} | ${platform.platform} | ${count(platform.removed)} | ${count(platform.added)} | ${platform.addedPackages.join(', ') || '-'} |`,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (errors.length > 0) lines.push('', '### Publisher errors', '', ...errors);
|
||||
return `${lines.join('\n')}\n`;
|
||||
}
|
||||
|
||||
function main() {
|
||||
const { values } = parseArgs({ options: { out: { type: 'string' } } });
|
||||
async function main() {
|
||||
const { values } = parseArgs({
|
||||
options: { out: { type: 'string' }, 'skip-gate': { type: 'boolean', default: false } },
|
||||
});
|
||||
const hcl = readFileSync(BAKE_FILE, 'utf8');
|
||||
const workDir = mkdtempSync(path.join(tmpdir(), 'base-image-candidates-'));
|
||||
const results = [];
|
||||
@@ -196,7 +226,11 @@ function main() {
|
||||
pinned: scan(pinnedRef, platform, workDir),
|
||||
newest: scan(newestRef, platform, workDir),
|
||||
}));
|
||||
const result = evaluateSource(pin, newestDigest, scans);
|
||||
let result = evaluateSource(pin, newestDigest, scans);
|
||||
if (result.status === 'candidate') {
|
||||
const publisher = await verifyPublisher(pin, newestDigest, PLATFORMS);
|
||||
result = applyGate(result, publisher, { now: Date.now(), skipGate: values['skip-gate'] });
|
||||
}
|
||||
console.log(`${name}: ${result.status} (${result.newest})`);
|
||||
results.push(result);
|
||||
}
|
||||
@@ -208,9 +242,9 @@ function main() {
|
||||
if (process.env.GITHUB_STEP_SUMMARY)
|
||||
appendFileSync(process.env.GITHUB_STEP_SUMMARY, renderSummary(results));
|
||||
if (process.env.GITHUB_OUTPUT) {
|
||||
const candidates = results.filter((result) => result.status === 'candidate').length;
|
||||
appendFileSync(process.env.GITHUB_OUTPUT, `candidates=${candidates}\n`);
|
||||
const ready = results.filter((result) => result.status === 'ready').length;
|
||||
appendFileSync(process.env.GITHUB_OUTPUT, `ready=${ready}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
if (import.meta.url === pathToFileURL(process.argv[1]).href) main();
|
||||
if (import.meta.url === pathToFileURL(process.argv[1]).href) await main();
|
||||
@@ -2,7 +2,9 @@ import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import {
|
||||
GATE_MS,
|
||||
SOURCES,
|
||||
applyGate,
|
||||
compareScans,
|
||||
evaluateSource,
|
||||
readPin,
|
||||
@@ -136,6 +138,64 @@ describe('evaluateSource', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('applyGate', () => {
|
||||
const now = Date.parse('2026-11-19T12:00:00Z');
|
||||
const candidate = (addedPackages = []) => ({
|
||||
source: 'DHI_REF',
|
||||
status: 'candidate',
|
||||
platforms: [{ platform: 'linux/amd64', removed: [], added: [], addedPackages }],
|
||||
});
|
||||
const publisher = (publishedAt, verified = true) => ({ publisher: 'dhi', verified, publishedAt });
|
||||
const hoursAgo = (hours) => new Date(now - hours * 60 * 60 * 1000).toISOString();
|
||||
|
||||
it('keeps a digest with a failed publisher check out', () => {
|
||||
const result = applyGate(candidate(), publisher(hoursAgo(48), false), { now, skipGate: true });
|
||||
assert.equal(result.status, 'unverified');
|
||||
});
|
||||
|
||||
it('keeps a digest younger than 24 hours in the gate', () => {
|
||||
const result = applyGate(candidate(), publisher(hoursAgo(23)), { now, skipGate: false });
|
||||
assert.equal(result.status, 'in-24h-gate');
|
||||
});
|
||||
|
||||
it('releases a digest at exactly 24 hours', () => {
|
||||
const publishedAt = new Date(now - GATE_MS).toISOString();
|
||||
const result = applyGate(candidate(), publisher(publishedAt), { now, skipGate: false });
|
||||
assert.equal(result.status, 'ready');
|
||||
assert.equal(result.autoMerge, true);
|
||||
});
|
||||
|
||||
it('keeps a digest without a publication time out', () => {
|
||||
const result = applyGate(candidate(), publisher(null), { now, skipGate: false });
|
||||
assert.equal(result.status, 'no-publish-time');
|
||||
});
|
||||
|
||||
it('skips the gate on a manual run, without auto-merge', () => {
|
||||
const young = applyGate(candidate(), publisher(hoursAgo(1)), { now, skipGate: true });
|
||||
const unknown = applyGate(candidate(), publisher(null), { now, skipGate: true });
|
||||
for (const result of [young, unknown]) {
|
||||
assert.equal(result.status, 'ready');
|
||||
assert.equal(result.autoMerge, false);
|
||||
assert.equal(result.gateSkipped, true);
|
||||
}
|
||||
});
|
||||
|
||||
it('keeps auto-merge on a manual run for a digest older than 24 hours', () => {
|
||||
const result = applyGate(candidate(), publisher(hoursAgo(48)), { now, skipGate: true });
|
||||
assert.equal(result.autoMerge, true);
|
||||
assert.equal(result.gateSkipped, false);
|
||||
});
|
||||
|
||||
it('turns auto-merge off for a digest that adds a package', () => {
|
||||
const result = applyGate(candidate(['curl']), publisher(hoursAgo(48)), {
|
||||
now,
|
||||
skipGate: false,
|
||||
});
|
||||
assert.equal(result.status, 'ready');
|
||||
assert.equal(result.autoMerge, false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('renderSummary', () => {
|
||||
it('renders one row for each platform', () => {
|
||||
const result = evaluateSource(pin, digest('c'), [
|
||||
@@ -150,15 +210,29 @@ describe('renderSummary', () => {
|
||||
newest: summarizeReport(report([])),
|
||||
},
|
||||
]);
|
||||
const summary = renderSummary([result, evaluateSource(pin, digest('a'), [])]);
|
||||
const ready = applyGate(
|
||||
result,
|
||||
{ publisher: 'dhi', verified: true, publishedAt: '2026-11-17T00:00:00.000Z' },
|
||||
{ now: Date.parse('2026-11-19T00:00:00Z'), skipGate: false },
|
||||
);
|
||||
const summary = renderSummary([ready, evaluateSource(pin, digest('a'), [])]);
|
||||
assert.match(
|
||||
summary,
|
||||
/\| `DHI_REF` \| candidate \| linux\/amd64 \| 1 C \/ 0 H \/ 0 M \| 0 C \/ 0 H \/ 0 M \| curl \|/,
|
||||
/\| `DHI_REF` \| ready \| 2026-11-17T00:00:00.000Z \| no \| linux\/amd64 \| 1 C \/ 0 H \/ 0 M \| 0 C \/ 0 H \/ 0 M \| curl \|/,
|
||||
);
|
||||
assert.match(
|
||||
summary,
|
||||
/\| `DHI_REF` \| candidate \| linux\/arm64 \| 0 C \/ 1 H \/ 0 M \| 0 C \/ 0 H \/ 0 M \| - \|/,
|
||||
/\| `DHI_REF` \| ready \| 2026-11-17T00:00:00.000Z \| no \| linux\/arm64 \| 0 C \/ 1 H \/ 0 M \| 0 C \/ 0 H \/ 0 M \| - \|/,
|
||||
);
|
||||
assert.match(summary, /\| `DHI_REF` \| current \| - \| - \| - \| - \|/);
|
||||
assert.match(summary, /\| `DHI_REF` \| current \| - \| - \| - \| - \| - \| - \|/);
|
||||
});
|
||||
|
||||
it('lists the publisher errors', () => {
|
||||
const unverified = applyGate(
|
||||
evaluateSource(pin, digest('c'), []),
|
||||
{ publisher: 'dhi', verified: false, publishedAt: null, error: 'no signatures found' },
|
||||
{ now: 0, skipGate: false },
|
||||
);
|
||||
assert.match(renderSummary([unverified]), /- `DHI_REF`: no signatures found/);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* Checks who published a base image digest, and when.
|
||||
*
|
||||
* DHI and distroless sign their images with cosign. The Rekor entry of the
|
||||
* signature gives the publication time. Rekor signs that time, so the registry
|
||||
* cannot change it. A digest signed before its push would pass the 24-hour
|
||||
* gate early. We accept this: the signature follows the push by seconds.
|
||||
* Docker Official Images have no signature. For them, the SLSA provenance
|
||||
* must name the docker-library builder and source, and Docker Hub gives the
|
||||
* push time of the tag.
|
||||
*/
|
||||
|
||||
import { execFileSync } from 'node:child_process';
|
||||
|
||||
/** The DHI signing key, from https://registry.scout.docker.com/keyring/dhi/latest.pub. */
|
||||
const DHI_KEY = 'security/keys/dhi.pub';
|
||||
|
||||
const DISTROLESS_IDENTITY = [
|
||||
'--certificate-identity',
|
||||
'keyless@distroless.iam.gserviceaccount.com',
|
||||
'--certificate-oidc-issuer',
|
||||
'https://accounts.google.com',
|
||||
];
|
||||
|
||||
const DOCKER_LIBRARY = 'https://github.com/docker-library';
|
||||
|
||||
export function publisherOf(repository) {
|
||||
if (repository.startsWith('dhi.io/')) return 'dhi';
|
||||
if (repository.startsWith('gcr.io/distroless/')) return 'distroless';
|
||||
if (!repository.includes('/')) return 'docker-official';
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The earliest Rekor time of the verified signatures of `digest`, from `cosign verify --output json`. */
|
||||
export function signatureTime(verified, digest) {
|
||||
const times = verified
|
||||
.filter((entry) => entry.critical?.image?.['docker-manifest-digest'] === digest)
|
||||
.map((entry) => entry.optional?.Bundle?.Payload?.integratedTime)
|
||||
.filter(Number.isInteger);
|
||||
return times.length > 0 ? new Date(Math.min(...times) * 1000).toISOString() : null;
|
||||
}
|
||||
|
||||
/** Returns why the SLSA provenance of a Docker Official Image is wrong, or null when it is correct. */
|
||||
export function checkProvenance(provenance, repository, platforms) {
|
||||
const source = `${DOCKER_LIBRARY}/${repository}.git#`;
|
||||
for (const platform of platforms) {
|
||||
const slsa = provenance?.[platform]?.SLSA;
|
||||
const builder = slsa?.builder?.id ?? slsa?.runDetails?.builder?.id;
|
||||
const uri =
|
||||
slsa?.invocation?.configSource?.uri ??
|
||||
slsa?.buildDefinition?.externalParameters?.configSource?.uri;
|
||||
if (builder !== DOCKER_LIBRARY) return `${platform}: the builder is ${builder ?? 'missing'}`;
|
||||
if (!uri?.startsWith(source)) return `${platform}: the source is ${uri ?? 'missing'}`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The push time of a Docker Hub tag, when the tag still points at `digest`. */
|
||||
export function hubPushTime(tag, digest) {
|
||||
if (tag?.digest !== digest || !tag.tag_last_pushed) return null;
|
||||
return new Date(tag.tag_last_pushed).toISOString();
|
||||
}
|
||||
|
||||
function cosignVerify(args, ref) {
|
||||
const out = execFileSync('cosign', ['verify', ...args, '--output', 'json', ref], {
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
return JSON.parse(out);
|
||||
}
|
||||
|
||||
async function verifyDockerOfficial(pin, digest, platforms) {
|
||||
const out = execFileSync(
|
||||
'docker',
|
||||
[
|
||||
'buildx',
|
||||
'imagetools',
|
||||
'inspect',
|
||||
`${pin.repository}@${digest}`,
|
||||
'--format',
|
||||
'{{json .Provenance}}',
|
||||
],
|
||||
{ encoding: 'utf8' },
|
||||
);
|
||||
const error = checkProvenance(JSON.parse(out), pin.repository, platforms);
|
||||
if (error) return { verified: false, publishedAt: null, error };
|
||||
|
||||
// The provenance passed, so a Docker Hub failure only leaves the time unknown.
|
||||
const url = `https://hub.docker.com/v2/repositories/library/${pin.repository}/tags/${pin.tag}`;
|
||||
try {
|
||||
const response = await fetch(url, { signal: AbortSignal.timeout(30_000) });
|
||||
if (!response.ok) throw new Error(`${url} returned ${response.status}`);
|
||||
return { verified: true, publishedAt: hubPushTime(await response.json(), digest) };
|
||||
} catch (error) {
|
||||
return { verified: true, publishedAt: null, error: error.message };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies the publisher of `<repository>@<digest>` and reads its publication
|
||||
* time. A failed check returns verified: false with the reason.
|
||||
*/
|
||||
export async function verifyPublisher(pin, digest, platforms) {
|
||||
const publisher = publisherOf(pin.repository);
|
||||
const ref = `${pin.repository}@${digest}`;
|
||||
try {
|
||||
switch (publisher) {
|
||||
case 'dhi': {
|
||||
// DHI attaches the signature as an OCI referrer.
|
||||
const verified = cosignVerify(['--experimental-oci11', '--key', DHI_KEY], ref);
|
||||
return { publisher, verified: true, publishedAt: signatureTime(verified, digest) };
|
||||
}
|
||||
case 'distroless': {
|
||||
const verified = cosignVerify(DISTROLESS_IDENTITY, ref);
|
||||
return { publisher, verified: true, publishedAt: signatureTime(verified, digest) };
|
||||
}
|
||||
case 'docker-official':
|
||||
return { publisher, ...(await verifyDockerOfficial(pin, digest, platforms)) };
|
||||
default:
|
||||
return { publisher, verified: false, publishedAt: null, error: 'unknown publisher' };
|
||||
}
|
||||
} catch (error) {
|
||||
const detail = String(error.stderr ?? '').trim() || error.message;
|
||||
return { publisher, verified: false, publishedAt: null, error: detail.split('\n').at(-1) };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
checkProvenance,
|
||||
hubPushTime,
|
||||
publisherOf,
|
||||
signatureTime,
|
||||
} from './base-image-publisher.mjs';
|
||||
|
||||
const digest = (char) => `sha256:${char.repeat(64)}`;
|
||||
|
||||
describe('publisherOf', () => {
|
||||
it('maps each source repository to its publisher', () => {
|
||||
assert.equal(publisherOf('dhi.io/node'), 'dhi');
|
||||
assert.equal(publisherOf('gcr.io/distroless/cc-debian13'), 'distroless');
|
||||
assert.equal(publisherOf('python'), 'docker-official');
|
||||
});
|
||||
|
||||
it('does not trust an unknown repository', () => {
|
||||
assert.equal(publisherOf('docker.io/someone/python'), null);
|
||||
assert.equal(publisherOf('gcr.io/other/cc-debian13'), null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('signatureTime', () => {
|
||||
const signature = (manifestDigest, integratedTime) => ({
|
||||
critical: { image: { 'docker-manifest-digest': manifestDigest } },
|
||||
optional: { Bundle: { Payload: { integratedTime } } },
|
||||
});
|
||||
|
||||
it('returns the earliest Rekor time of the digest', () => {
|
||||
const verified = [signature(digest('a'), 1794519463), signature(digest('a'), 1794446025)];
|
||||
assert.equal(signatureTime(verified, digest('a')), '2026-11-12T01:13:45.000Z');
|
||||
});
|
||||
|
||||
it('ignores a signature of another digest', () => {
|
||||
assert.equal(signatureTime([signature(digest('b'), 1794446025)], digest('a')), null);
|
||||
});
|
||||
|
||||
it('returns null without a Rekor entry', () => {
|
||||
const verified = [{ critical: { image: { 'docker-manifest-digest': digest('a') } } }];
|
||||
assert.equal(signatureTime(verified, digest('a')), null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkProvenance', () => {
|
||||
const slsa = (builder, uri) => ({
|
||||
SLSA: { builder: { id: builder }, invocation: { configSource: { uri } } },
|
||||
});
|
||||
const source = 'https://github.com/docker-library/python.git#152874b1:3.13/alpine3.24';
|
||||
const platforms = ['linux/amd64', 'linux/arm64'];
|
||||
|
||||
it('accepts the docker-library builder and source on each platform', () => {
|
||||
const provenance = {
|
||||
'linux/amd64': slsa('https://github.com/docker-library', source),
|
||||
'linux/arm64': slsa('https://github.com/docker-library', source),
|
||||
};
|
||||
assert.equal(checkProvenance(provenance, 'python', platforms), null);
|
||||
});
|
||||
|
||||
it('rejects another builder', () => {
|
||||
const provenance = {
|
||||
'linux/amd64': slsa('https://github.com/someone', source),
|
||||
'linux/arm64': slsa('https://github.com/docker-library', source),
|
||||
};
|
||||
assert.match(checkProvenance(provenance, 'python', platforms), /linux\/amd64: the builder/);
|
||||
});
|
||||
|
||||
it('rejects the source of another image', () => {
|
||||
const other = 'https://github.com/docker-library/pythonx.git#1:3.13/alpine3.24';
|
||||
const provenance = {
|
||||
'linux/amd64': slsa('https://github.com/docker-library', other),
|
||||
'linux/arm64': slsa('https://github.com/docker-library', other),
|
||||
};
|
||||
assert.match(checkProvenance(provenance, 'python', platforms), /the source is/);
|
||||
});
|
||||
|
||||
it('rejects a missing platform', () => {
|
||||
const provenance = { 'linux/amd64': slsa('https://github.com/docker-library', source) };
|
||||
assert.match(
|
||||
checkProvenance(provenance, 'python', platforms),
|
||||
/linux\/arm64: the builder is missing/,
|
||||
);
|
||||
});
|
||||
|
||||
it('reads the SLSA v1 fields', () => {
|
||||
const v1 = {
|
||||
SLSA: {
|
||||
runDetails: { builder: { id: 'https://github.com/docker-library' } },
|
||||
buildDefinition: { externalParameters: { configSource: { uri: source } } },
|
||||
},
|
||||
};
|
||||
const provenance = { 'linux/amd64': v1, 'linux/arm64': v1 };
|
||||
assert.equal(checkProvenance(provenance, 'python', platforms), null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('hubPushTime', () => {
|
||||
it('returns the push time when the tag points at the digest', () => {
|
||||
const tag = { digest: digest('a'), tag_last_pushed: '2026-11-12T03:55:00.123456Z' };
|
||||
assert.equal(hubPushTime(tag, digest('a')), '2026-11-12T03:55:00.123Z');
|
||||
});
|
||||
|
||||
it('returns null when the tag moved to another digest', () => {
|
||||
const tag = { digest: digest('b'), tag_last_pushed: '2026-11-12T03:55:00Z' };
|
||||
assert.equal(hubPushTime(tag, digest('a')), null);
|
||||
});
|
||||
});
|
||||
@@ -12,6 +12,8 @@ on:
|
||||
paths:
|
||||
- '.github/workflows/sec-base-image-refresh.yml'
|
||||
- '.github/scripts/docker/base-image-candidates.mjs'
|
||||
- '.github/scripts/docker/base-image-publisher.mjs'
|
||||
- 'security/keys/dhi.pub'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@@ -53,8 +55,19 @@ jobs:
|
||||
version: v0.76.2
|
||||
cache: true
|
||||
|
||||
- name: Install cosign
|
||||
uses: sigstore/cosign-installer@756fe2d284c7292c4e9b62c8a28f1e5629c59532 # v4.1.3
|
||||
with:
|
||||
cosign-release: v3.1.4
|
||||
|
||||
# A manual run skips the 24-hour gate. A digest that it lets through gets no auto-merge.
|
||||
- name: Find candidate digests
|
||||
run: node .github/scripts/docker/base-image-candidates.mjs --out base-image-candidates.json
|
||||
env:
|
||||
EVENT: ${{ github.event_name }}
|
||||
run: |
|
||||
args=(--out base-image-candidates.json)
|
||||
if [ "$EVENT" = workflow_dispatch ]; then args+=(--skip-gate); fi
|
||||
node .github/scripts/docker/base-image-candidates.mjs "${args[@]}"
|
||||
|
||||
- name: Upload candidates
|
||||
if: always()
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEKdROmntRJFBrOJOQF5ww6gDBJqGm
|
||||
Fxa4333s1KsL9ISjtmRzGNih9lNRsqfRVjgFgJIdL6EQ9dohdanvn7r2cg==
|
||||
-----END PUBLIC KEY-----
|
||||
Reference in new issue
Block a user