merge: PR #36을 합친 검사 브랜치에 넣는다
This commit is contained in:
@@ -82,7 +82,7 @@ jobs:
|
||||
name: "merge / tests"
|
||||
if: ${{ gitea.event_name != 'workflow_dispatch' || (inputs.stage != 'documentation' && inputs.stage != 'main') }}
|
||||
# FE-GATE-013 runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# FE-GATE-013 runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs
|
||||
# FE-GATE-013 runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
@@ -303,6 +303,8 @@ jobs:
|
||||
vulnerability_provider:
|
||||
name: external-vulnerability-provider
|
||||
needs: immutable_build
|
||||
# provider sandbox runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# provider sandbox runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
outputs:
|
||||
@@ -349,6 +351,8 @@ jobs:
|
||||
provenance_provider:
|
||||
name: external-provenance-provider
|
||||
needs: immutable_build
|
||||
# provider sandbox runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# provider sandbox runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
outputs:
|
||||
|
||||
@@ -1813,7 +1813,7 @@
|
||||
"retentionClassId": "release-coherence",
|
||||
"hostRequirements": [
|
||||
"Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers",
|
||||
"unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs"
|
||||
"unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs"
|
||||
],
|
||||
"hostEnvironment": "system-container"
|
||||
},
|
||||
@@ -2513,6 +2513,10 @@
|
||||
"provider-evidence/vulnerability-report.json"
|
||||
]
|
||||
}
|
||||
],
|
||||
"hostRequirements": [
|
||||
"Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers",
|
||||
"unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2600,6 +2604,10 @@
|
||||
"provider-evidence/provenance-attestation.json"
|
||||
]
|
||||
}
|
||||
],
|
||||
"hostRequirements": [
|
||||
"Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers",
|
||||
"unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -183,7 +183,11 @@ sandbox는 `bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net`으로
|
||||
이 옵션마다 비특권 user namespace가 필요하다. 이 조건은 provider job과 merge
|
||||
게이트 FE-GATE-013(`test:system`의 provider 테스트) 둘 다에 걸린다.
|
||||
`config/ci/gates.json`의 FE-GATE-013 `hostRequirements`에 같은 조건이 있고,
|
||||
생성 workflow는 그것을 merge job의 `runs-on` 옆 주석으로 보여 준다.
|
||||
생성 workflow는 그것을 merge job의 `runs-on` 옆 주석으로 보여 준다. release의
|
||||
provider job 둘도 같은 조건을 job의 `hostRequirements`로 갖고(계약이 FE-GATE-013과
|
||||
같은지 본다), 생성 workflow가 그 job의 `runs-on` 옆에 같은 주석을 쓴다.
|
||||
`scripts/run-and-validate-provider.ts`는 provider를 띄우기 전에 아래 검사와 같은
|
||||
namespace 점검을 돌아, 이 조건이 없는 runner에서 이름과 host 설정을 대며 멈춘다.
|
||||
|
||||
- Ubuntu 23.10부터는 `kernel.apparmor_restrict_unprivileged_userns=1`이
|
||||
기본이다(24.04도 같다). `/usr/bin/bwrap`에 `userns`를 허용하는 AppArmor
|
||||
|
||||
@@ -88,14 +88,24 @@ export async function findSystemTestPrerequisiteFailures(
|
||||
}
|
||||
|
||||
if (executable.get(BWRAP)) {
|
||||
const probe = host.spawn(BWRAP, NAMESPACE_PROBE_ARGUMENTS, PROBE_TIMEOUT_MS);
|
||||
if (probe.error || probe.status !== 0) {
|
||||
failures.push(await namespaceFailure(host, probe));
|
||||
}
|
||||
const failure = await findProviderSandboxNamespaceFailure(host);
|
||||
if (failure !== undefined) failures.push(failure);
|
||||
}
|
||||
return failures;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1101/13-03. Whether this host lets the provider sandbox create its
|
||||
* namespaces, and if not, why and what to do. The release provider jobs run
|
||||
* it before the provider (scripts/run-and-validate-provider.ts).
|
||||
*/
|
||||
export async function findProviderSandboxNamespaceFailure(
|
||||
host: SystemTestHost = nodeSystemTestHost,
|
||||
): Promise<string | undefined> {
|
||||
const probe = host.spawn(BWRAP, NAMESPACE_PROBE_ARGUMENTS, PROBE_TIMEOUT_MS);
|
||||
return probe.error || probe.status !== 0 ? namespaceFailure(host, probe) : undefined;
|
||||
}
|
||||
|
||||
async function namespaceFailure(
|
||||
host: SystemTestHost,
|
||||
probe: ReturnType<SystemTestHost["spawn"]>,
|
||||
|
||||
@@ -432,6 +432,9 @@ const jobSchema = z
|
||||
browserGateIds: z.array(id).max(64),
|
||||
environment: z.array(environmentBindingSchema).max(32),
|
||||
steps: z.array(jobStepSchema).min(1).max(64),
|
||||
// 1101/13-03. What the runner of a job without a gate needs (the provider
|
||||
// jobs' sandbox). Rendered beside its runner label like a gate's.
|
||||
hostRequirements: z.array(nonEmpty.max(512)).min(1).max(8).optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
@@ -862,6 +865,20 @@ function validateContractSemantics(
|
||||
// paired backend's nightly lanes.
|
||||
main_gate: ["FE-GATE-029", "FE-GATE-030"],
|
||||
};
|
||||
// 1101/13-03. The provider jobs run FE-GATE-013's sandbox (systemd-run
|
||||
// scope, bwrap with the same namespace options), so they need its host.
|
||||
const sandboxRequirements = JSON.stringify(
|
||||
contract.gates.find(({ id: gateId }) => gateId === "FE-GATE-013")?.hostRequirements ?? [],
|
||||
);
|
||||
for (const job of contract.jobs) {
|
||||
if (job.kind === "provider") {
|
||||
if (JSON.stringify(job.hostRequirements ?? []) !== sandboxRequirements) {
|
||||
issue(`provider job host requirements must equal FE-GATE-013's: ${job.id}`);
|
||||
}
|
||||
} else if (job.hostRequirements !== undefined) {
|
||||
issue(`only a provider job declares host requirements of its own: ${job.id}`);
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(contract.jobs.map(({ id }) => id)) !== JSON.stringify(Object.keys(expectedJobOwnership))) {
|
||||
issue("job registry must contain the exact thirteen canonical jobs in semantic order");
|
||||
}
|
||||
|
||||
@@ -267,11 +267,17 @@ function renderHostRequirements(
|
||||
job: CiWorkflowJob,
|
||||
index: ReturnType<typeof indexCiGateContract>,
|
||||
): string[] {
|
||||
return job.gateIds.flatMap((gateId) =>
|
||||
(index.gates.get(gateId)?.hostRequirements ?? []).map(
|
||||
(requirement) => ` # ${gateId} runner requirement: ${requirement}`,
|
||||
return [
|
||||
...job.gateIds.flatMap((gateId) =>
|
||||
(index.gates.get(gateId)?.hostRequirements ?? []).map(
|
||||
(requirement) => ` # ${gateId} runner requirement: ${requirement}`,
|
||||
),
|
||||
),
|
||||
);
|
||||
// 1101/13-03. A provider job runs the provider sandbox and has no gate.
|
||||
...(job.hostRequirements ?? []).map(
|
||||
(requirement) => ` # provider sandbox runner requirement: ${requirement}`,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
type ProviderGuardianLease,
|
||||
} from "./lib/provider-guardian-client.ts";
|
||||
import { createProviderOutputLimiter } from "./lib/provider-output-limiter.ts";
|
||||
import { findProviderSandboxNamespaceFailure } from "./check-system-test-prerequisites.ts";
|
||||
import { PROVIDER_SANDBOX_NAMESPACE_ARGUMENTS } from "./lib/provider-sandbox-namespaces.ts";
|
||||
import {
|
||||
providerProcessTraceEnvironment,
|
||||
@@ -125,6 +126,13 @@ await access("/usr/bin/systemd-run", constants.X_OK).catch(() => {
|
||||
await access("/usr/bin/systemctl", constants.X_OK).catch(() => {
|
||||
throw new Error("provider cgroup unavailable: /usr/bin/systemctl is required");
|
||||
});
|
||||
// 1101/13-03. A runner that refuses the sandbox's unprivileged user and
|
||||
// network namespaces fails here, by name and with its host settings, instead
|
||||
// of later with bwrap's raw error.
|
||||
const namespaceFailure = await findProviderSandboxNamespaceFailure();
|
||||
if (namespaceFailure !== undefined) {
|
||||
throw new Error(`provider sandbox unavailable: ${namespaceFailure}`);
|
||||
}
|
||||
await assertProviderCgroupManagerAvailable();
|
||||
const trust = await readProviderTrust(workspaceRoot, publicKeyPath, keyId);
|
||||
if (!trust) throw new TypeError("provider supervisor trust key is invalid");
|
||||
|
||||
@@ -85,7 +85,7 @@ jobs:
|
||||
name: "merge / tests"
|
||||
if: \${{ gitea.event_name != 'workflow_dispatch' || (inputs.stage != 'documentation' && inputs.stage != 'main') }}
|
||||
# FE-GATE-013 runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# FE-GATE-013 runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs
|
||||
# FE-GATE-013 runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
@@ -306,6 +306,8 @@ jobs:
|
||||
vulnerability_provider:
|
||||
name: external-vulnerability-provider
|
||||
needs: immutable_build
|
||||
# provider sandbox runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# provider sandbox runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
outputs:
|
||||
@@ -352,6 +354,8 @@ jobs:
|
||||
provenance_provider:
|
||||
name: external-provenance-provider
|
||||
needs: immutable_build
|
||||
# provider sandbox runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# provider sandbox runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
outputs:
|
||||
|
||||
@@ -1743,7 +1743,44 @@ describe("CI workflow generation", () => {
|
||||
expect(header.split("\n").filter((line) => line.startsWith(" # "))).toEqual(
|
||||
requirements.map((requirement) => ` # FE-GATE-013 runner requirement: ${requirement}`),
|
||||
);
|
||||
expect(workflow.match(/ runner requirement: /gu)).toHaveLength(requirements.length);
|
||||
// FE-GATE-013 in merge_test, and the two release provider jobs.
|
||||
expect(workflow.match(/ runner requirement: /gu)).toHaveLength(requirements.length * 3);
|
||||
});
|
||||
|
||||
// 1101/13-03. The release provider jobs run the same sandbox (systemd-run
|
||||
// scope, bwrap with the same namespace options) on whatever runner picks
|
||||
// them up, and nothing beside their runner label said what it needs.
|
||||
it("states the provider sandbox's runner requirements beside each provider job's runner label", async () => {
|
||||
const contract = await loadCiGateContract(process.cwd());
|
||||
const index = indexCiGateContract(contract);
|
||||
const requirements = index.gates.get("FE-GATE-013")?.hostRequirements ?? [];
|
||||
expect(requirements.length).toBeGreaterThan(0);
|
||||
const providerJobs = contract.jobs.filter(({ kind }) => kind === "provider");
|
||||
expect(providerJobs.map(({ id }) => id)).toEqual(["vulnerability_provider", "provenance_provider"]);
|
||||
for (const job of providerJobs) expect(job.hostRequirements).toEqual(requirements);
|
||||
|
||||
const workflow = renderCiWorkflow(contract);
|
||||
for (const [job, next] of [
|
||||
["vulnerability_provider", "provenance_provider"],
|
||||
["provenance_provider", "promotion"],
|
||||
] as const) {
|
||||
const block = workflow.slice(workflow.indexOf(` ${job}:\n`), workflow.indexOf(` ${next}:\n`));
|
||||
const header = block.slice(0, block.indexOf(" runs-on: ubuntu-latest\n"));
|
||||
expect(header.split("\n").filter((line) => line.startsWith(" # ")), job).toEqual(
|
||||
requirements.map((requirement) => ` # provider sandbox runner requirement: ${requirement}`),
|
||||
);
|
||||
}
|
||||
|
||||
// A provider job's requirements are the sandbox's: they cannot drift from FE-GATE-013's.
|
||||
const drifted = {
|
||||
...contract,
|
||||
jobs: contract.jobs.map((job) =>
|
||||
job.id === "provenance_provider" ? { ...job, hostRequirements: ["a different runner"] } : job,
|
||||
),
|
||||
};
|
||||
expect(() => parseCiGateContract(drifted)).toThrow(
|
||||
/provider job host requirements must equal FE-GATE-013's: provenance_provider/u,
|
||||
);
|
||||
});
|
||||
|
||||
// The job container has neither systemd nor bubblewrap, so FE-GATE-013 runs
|
||||
|
||||
@@ -3,6 +3,7 @@ import { readFile } from "node:fs/promises";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
findProviderSandboxNamespaceFailure,
|
||||
findSystemTestPrerequisiteFailures,
|
||||
formatSystemTestPrerequisiteReport,
|
||||
NAMESPACE_PROBE_ARGUMENTS,
|
||||
@@ -123,3 +124,35 @@ describe("system test prerequisites (1105/12-01)", () => {
|
||||
expect(calls.map(({ command }) => command)).toEqual(["/usr/bin/systemctl"]);
|
||||
});
|
||||
});
|
||||
|
||||
// 1101/13-03. The release provider jobs run the same sandbox on whatever
|
||||
// runner picks them up. The supervisor checked only that the executables
|
||||
// exist, so a host that refuses the namespaces failed later with bwrap's raw
|
||||
// error and without the host settings.
|
||||
describe("provider sandbox namespace check (1101/13-03)", () => {
|
||||
it("passes on a host that creates the namespaces and probes only with bwrap", async () => {
|
||||
const { host, calls } = fakeHost({ status: 0, stderr: "" });
|
||||
|
||||
expect(await findProviderSandboxNamespaceFailure(host)).toBeUndefined();
|
||||
expect(calls).toEqual([{ command: "/usr/bin/bwrap", args: NAMESPACE_PROBE_ARGUMENTS }]);
|
||||
});
|
||||
|
||||
it("names the restriction, bwrap's stderr and the host settings on a host that refuses them", async () => {
|
||||
const { host } = fakeHost(
|
||||
{ status: 1, stderr: `${RTM_NEWADDR}\n` },
|
||||
{ "/proc/sys/kernel/apparmor_restrict_unprivileged_userns": "1\n" },
|
||||
);
|
||||
|
||||
const failure = (await findProviderSandboxNamespaceFailure(host)) ?? "";
|
||||
expect(failure).toMatch(/^this host does not allow unprivileged user and network namespaces/u);
|
||||
expect(failure).toContain(`bwrap stderr: ${RTM_NEWADDR}`);
|
||||
expect(failure).toContain("kernel.apparmor_restrict_unprivileged_userns = 1");
|
||||
});
|
||||
|
||||
it("runs before the provider supervisor launches anything", async () => {
|
||||
const provider = await readFile("scripts/run-and-validate-provider.ts", "utf8");
|
||||
const check = provider.indexOf("await findProviderSandboxNamespaceFailure()");
|
||||
expect(check).toBeGreaterThan(0);
|
||||
expect(check).toBeLessThan(provider.indexOf("superviseProviderEvidence({"));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user