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
174 lines
5.3 KiB
JavaScript
174 lines
5.3 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Audits patched dependency pins for exact versions and drift.
|
|
import { execFileSync } from "node:child_process";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import YAML from "yaml";
|
|
|
|
const PACKAGE_DEPENDENCY_SECTIONS = ["dependencies", "devDependencies", "optionalDependencies"];
|
|
const WORKSPACE_DEPENDENCY_SECTIONS = ["overrides"];
|
|
const EXACT_SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;
|
|
const EXACT_NPM_ALIAS_PATTERN =
|
|
/^npm:(?:@[^/\s]+\/)?[^@\s]+@\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;
|
|
const PINNED_GIT_PATTERN = /(?:#|\/commit\/)[0-9a-f]{40}$/iu;
|
|
const PINNED_GITHUB_TARBALL_PATTERN =
|
|
/^https:\/\/codeload\.github\.com\/[^/\s]+\/[^/\s]+\/tar\.gz\/[0-9a-f]{40}$/iu;
|
|
|
|
function listTrackedPackageJsonFiles(cwd) {
|
|
return execFileSync("git", ["ls-files", "-z", "--", "*package.json"], {
|
|
cwd,
|
|
encoding: "utf8",
|
|
})
|
|
.split("\0")
|
|
.filter(Boolean)
|
|
.toSorted((left, right) => left.localeCompare(right));
|
|
}
|
|
|
|
function readJson(filePath) {
|
|
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
}
|
|
|
|
function readTrackedJson(cwd, relativePath) {
|
|
const filePath = path.join(cwd, relativePath);
|
|
if (fs.existsSync(filePath)) {
|
|
return readJson(filePath);
|
|
}
|
|
return JSON.parse(
|
|
execFileSync("git", ["show", `:${relativePath}`], {
|
|
cwd,
|
|
encoding: "utf8",
|
|
}),
|
|
);
|
|
}
|
|
|
|
function isAllowedPinnedSpec(spec) {
|
|
if (typeof spec !== "string") {
|
|
return false;
|
|
}
|
|
if (EXACT_SEMVER_PATTERN.test(spec) || EXACT_NPM_ALIAS_PATTERN.test(spec)) {
|
|
return true;
|
|
}
|
|
if (spec === "workspace:*" || spec.startsWith("file:") || spec.startsWith("link:")) {
|
|
return true;
|
|
}
|
|
if (/^(?:git\+|github:|gitlab:|bitbucket:)/u.test(spec)) {
|
|
return PINNED_GIT_PATTERN.test(spec);
|
|
}
|
|
if (PINNED_GITHUB_TARBALL_PATTERN.test(spec)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function collectPackageJsonViolations(cwd) {
|
|
const violations = [];
|
|
for (const relativePath of listTrackedPackageJsonFiles(cwd)) {
|
|
const packageJson = readTrackedJson(cwd, relativePath);
|
|
for (const section of PACKAGE_DEPENDENCY_SECTIONS) {
|
|
for (const [name, spec] of Object.entries(packageJson[section] ?? {})) {
|
|
if (!isAllowedPinnedSpec(spec)) {
|
|
violations.push({ file: relativePath, section, name, spec });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return violations;
|
|
}
|
|
|
|
function collectDependencyMapViolations(file, section, dependencyMap, violations) {
|
|
for (const [name, spec] of Object.entries(dependencyMap ?? {})) {
|
|
if (!isAllowedPinnedSpec(spec)) {
|
|
violations.push({ file, section, name, spec });
|
|
}
|
|
}
|
|
}
|
|
|
|
function collectWorkspaceViolations(cwd) {
|
|
const file = "pnpm-workspace.yaml";
|
|
const workspacePath = path.join(cwd, file);
|
|
if (!fs.existsSync(workspacePath)) {
|
|
return [];
|
|
}
|
|
const workspace = YAML.parse(fs.readFileSync(workspacePath, "utf8"));
|
|
const violations = [];
|
|
for (const section of WORKSPACE_DEPENDENCY_SECTIONS) {
|
|
collectDependencyMapViolations(file, section, workspace?.[section], violations);
|
|
}
|
|
for (const [packageName, extension] of Object.entries(workspace?.packageExtensions ?? {})) {
|
|
collectDependencyMapViolations(
|
|
file,
|
|
`packageExtensions.${packageName}.dependencies`,
|
|
extension?.dependencies,
|
|
violations,
|
|
);
|
|
}
|
|
return violations;
|
|
}
|
|
|
|
/**
|
|
* Collects dependency pin violations for the current workspace.
|
|
*/
|
|
export function collectDependencyPinViolations(cwd = process.cwd()) {
|
|
return [...collectPackageJsonViolations(cwd), ...collectWorkspaceViolations(cwd)];
|
|
}
|
|
|
|
/**
|
|
* Builds the full dependency pin audit payload.
|
|
*/
|
|
export function collectDependencyPinAudit(cwd = process.cwd()) {
|
|
const packageJsonFiles = listTrackedPackageJsonFiles(cwd);
|
|
let packageSpecCount = 0;
|
|
for (const relativePath of packageJsonFiles) {
|
|
const packageJson = readTrackedJson(cwd, relativePath);
|
|
for (const section of PACKAGE_DEPENDENCY_SECTIONS) {
|
|
packageSpecCount += Object.keys(packageJson[section] ?? {}).length;
|
|
}
|
|
}
|
|
const workspaceViolations = collectWorkspaceViolations(cwd);
|
|
const violations = [...collectPackageJsonViolations(cwd), ...workspaceViolations];
|
|
return {
|
|
packageManifestCount: packageJsonFiles.length,
|
|
packageSpecCount,
|
|
violations,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Runs the dependency pin check.
|
|
*/
|
|
export async function main() {
|
|
const audit = collectDependencyPinAudit();
|
|
const { violations } = audit;
|
|
if (violations.length === 0) {
|
|
process.stdout.write(
|
|
`PASS direct dependency pin guard: checked ${audit.packageSpecCount} directly declared ` +
|
|
`dependency specs across ${audit.packageManifestCount} tracked package manifests; ` +
|
|
"0 violations.\n",
|
|
);
|
|
return;
|
|
}
|
|
|
|
console.error(
|
|
`FAIL direct dependency pin guard: ${violations.length} unpinned directly declared ` +
|
|
"dependency specs found. Direct dependency specs must be pinned exactly outside peer " +
|
|
"dependency contracts:",
|
|
);
|
|
for (const violation of violations) {
|
|
console.error(
|
|
`- ${violation.file}:${violation.section}:${violation.name} -> ${JSON.stringify(violation.spec)}`,
|
|
);
|
|
}
|
|
process.exitCode = 1;
|
|
}
|
|
|
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
main().catch(
|
|
/** @param {unknown} error */ (error) => {
|
|
console.error(error);
|
|
process.exit(1);
|
|
},
|
|
);
|
|
}
|