Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
143 lines
5.6 KiB
TypeScript
143 lines
5.6 KiB
TypeScript
// Security Sensitive Guard Workflow tests cover sensitive file guard workflow behavior.
|
|
import { readFileSync } from "node:fs";
|
|
import { describe, expect, it } from "vitest";
|
|
import { parse } from "yaml";
|
|
|
|
const WORKFLOW = ".github/workflows/security-sensitive-guard.yml";
|
|
const CODEOWNERS = ".github/CODEOWNERS";
|
|
|
|
type WorkflowStep = {
|
|
env?: Record<string, string>;
|
|
name?: string;
|
|
run?: string;
|
|
uses?: string;
|
|
with?: Record<string, string>;
|
|
};
|
|
|
|
type WorkflowJob = {
|
|
if?: string;
|
|
needs?: string | string[];
|
|
permissions?: Record<string, string>;
|
|
steps?: WorkflowStep[];
|
|
};
|
|
|
|
type Workflow = {
|
|
jobs?: Record<string, WorkflowJob>;
|
|
name?: string;
|
|
permissions?: Record<string, string>;
|
|
};
|
|
|
|
function readWorkflow(): Workflow {
|
|
return parse(readFileSync(WORKFLOW, "utf8")) as Workflow;
|
|
}
|
|
|
|
describe("security-sensitive guard workflow", () => {
|
|
it("uses the security-sensitive guard check name", () => {
|
|
const parsed = readWorkflow();
|
|
|
|
expect(parsed.name).toBe("Security Sensitive Guard");
|
|
expect(parsed.jobs).toHaveProperty("security-sensitive-guard-detect");
|
|
expect(parsed.jobs).toHaveProperty("security-sensitive-guard");
|
|
});
|
|
|
|
it("uses a metadata-only pull_request_target workflow with bounded write permissions", () => {
|
|
const workflow = readFileSync(WORKFLOW, "utf8");
|
|
const parsed = readWorkflow();
|
|
|
|
expect(workflow).toContain("pull_request_target:");
|
|
expect(workflow).toContain("checks trusted base script only; never checks out PR head");
|
|
expect(parsed.permissions).toEqual({
|
|
contents: "read",
|
|
"pull-requests": "write",
|
|
issues: "write",
|
|
});
|
|
expect(parsed.jobs?.["security-sensitive-guard-detect"]?.permissions).toBeUndefined();
|
|
expect(parsed.jobs?.["security-sensitive-guard"]?.permissions).toBeUndefined();
|
|
});
|
|
|
|
it("checks out only trusted base scripts and does not execute PR-controlled code", () => {
|
|
const workflow = readFileSync(WORKFLOW, "utf8");
|
|
const forbiddenSnippets = [
|
|
"github.event.pull_request.head",
|
|
"pullRequest.head",
|
|
"pnpm install",
|
|
"npm install",
|
|
"pnpm dlx",
|
|
"actions: write",
|
|
"id-token: write",
|
|
];
|
|
|
|
for (const snippet of forbiddenSnippets) {
|
|
expect(workflow).not.toContain(snippet);
|
|
}
|
|
|
|
const jobs = readWorkflow().jobs ?? {};
|
|
for (const jobName of ["security-sensitive-guard-detect", "security-sensitive-guard"]) {
|
|
const steps = jobs[jobName]?.steps ?? [];
|
|
const checkout = steps.find((step) => step.uses?.startsWith("actions/checkout@"));
|
|
|
|
expect(checkout?.uses).toBe("actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd");
|
|
expect(checkout?.with?.ref).toBe("${{ github.workflow_sha }}");
|
|
expect(checkout?.with?.ref).not.toBe("${{ github.event.pull_request.base.sha }}");
|
|
expect(checkout?.with?.["persist-credentials"]).toBe(false);
|
|
expect(steps.at(-1)?.run).toBe("node scripts/github/security-sensitive-guard.mjs");
|
|
}
|
|
|
|
expect(workflow).not.toContain("OPENCLAW_SECURITY_SENSITIVE_GUARD_ROLLOUT_SHA");
|
|
expect(workflow).not.toContain("Check security-sensitive guard rollout eligibility");
|
|
expect(workflow).not.toContain("steps.rollout.outputs.ready");
|
|
expect(workflow).not.toContain("/compare/");
|
|
});
|
|
|
|
it("keeps detection separate from the final required check", () => {
|
|
const jobs = readWorkflow().jobs ?? {};
|
|
const detectJob = jobs["security-sensitive-guard-detect"];
|
|
const finalJob = jobs["security-sensitive-guard"];
|
|
const detectSteps = detectJob?.steps ?? [];
|
|
const finalSteps = finalJob?.steps ?? [];
|
|
|
|
expect(finalJob?.needs).toEqual(["security-sensitive-guard-detect"]);
|
|
expect(finalJob?.if).toContain("always()");
|
|
expect(detectSteps.at(-1)?.env?.OPENCLAW_SECURITY_SENSITIVE_GUARD_MODE).toBe("detect");
|
|
expect(finalSteps.at(-1)?.env?.OPENCLAW_SECURITY_SENSITIVE_GUARD_MODE).toBe("enforce");
|
|
expect(finalSteps.at(-1)?.env?.OPENCLAW_SECURITY_TEAM_SLUG).toBe("openclaw-secops");
|
|
expect(finalSteps.at(-1)?.env?.OPENCLAW_SECURITY_APPROVERS).toBe(
|
|
"vincentkoc,steipete,joshavant",
|
|
);
|
|
});
|
|
|
|
it("uses a dedicated checked-in script and detects the intended file surfaces", () => {
|
|
const workflow = readFileSync(WORKFLOW, "utf8");
|
|
const script = readFileSync("scripts/github/security-sensitive-guard.mjs", "utf8");
|
|
const sharedScript = readFileSync("scripts/github/guard-shared.mjs", "utf8");
|
|
const guardSources = `${script}\n${sharedScript}`;
|
|
|
|
expect(workflow).toContain("scripts/github/security-sensitive-guard.mjs");
|
|
expect(script).toContain('"security-sensitive-changed"');
|
|
expect(script).toContain('path: ".gitignore"');
|
|
expect(script).toContain(".env");
|
|
expect(script).toContain("/allow-security-sensitive-change");
|
|
expect(script).toContain("openclaw-secops");
|
|
expect(guardSources).toContain("/memberships/");
|
|
expect(script).toContain("A later push requires a fresh approval.");
|
|
expect(script).toContain("process.exitCode = 1");
|
|
});
|
|
|
|
it("requires secops review for future workflow or guard changes", () => {
|
|
const codeowners = readFileSync(CODEOWNERS, "utf8");
|
|
expect(codeowners).toContain(
|
|
"/.github/workflows/security-sensitive-guard.yml @openclaw/openclaw-secops",
|
|
);
|
|
expect(codeowners).toContain(
|
|
"/test/scripts/security-sensitive-guard-workflow.test.ts @openclaw/openclaw-secops",
|
|
);
|
|
expect(codeowners).toContain(
|
|
"/test/scripts/security-sensitive-guard-script.test.ts @openclaw/openclaw-secops",
|
|
);
|
|
expect(codeowners).toContain(
|
|
"/scripts/github/security-sensitive-guard.mjs @openclaw/openclaw-secops",
|
|
);
|
|
expect(codeowners).toContain("/.gitignore @openclaw/openclaw-secops");
|
|
});
|
|
});
|