Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

chore(security): require immutable workflow dependencies

Sima Bagheric9579f123566
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b35b125d..a00120a8 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -12,8 +12,8 @@ jobs:
matrix:
node-version: [18, 20, 22, 24]
steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-node@v4
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
@@ -28,13 +28,13 @@ jobs:
webm-artifact:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-node@v4
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
- name: Provision a known Chrome runtime
id: setup-chrome
- uses: browser-actions/setup-chrome@v2
+ uses: browser-actions/setup-chrome@48ad923757ca74d66703209fe939badbdf80f2f4 # v2.2.0
with:
chrome-version: stable
install-dependencies: true
@@ -73,8 +73,8 @@ jobs:
zip-freshness:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-node@v4
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
- name: Rebuild archify.zip and compare exact bytes
@@ -93,8 +93,8 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-node@v4
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
- name: Extract packaged skill
diff --git a/.github/workflows/dsh.yml b/.github/workflows/dsh.yml
index cfd34fe8..ffe75f85 100644
--- a/.github/workflows/dsh.yml
+++ b/.github/workflows/dsh.yml
@@ -30,10 +30,10 @@ jobs:
name: DSH package contract
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
fetch-depth: 0
- - uses: actions/setup-node@v4
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
- name: Static adapter contracts
@@ -45,13 +45,13 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
fetch-depth: 0
- - uses: actions/setup-node@v4
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
- - uses: pnpm/action-setup@v4
+ - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
with:
version: 10
- name: Real tarball install, discovery, package-smoke, uninstall
@@ -70,13 +70,13 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 40
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
fetch-depth: 0
- - uses: actions/setup-node@v4
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
- - uses: pnpm/action-setup@v4
+ - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
with:
version: 10
- name: Real DSH distribution acceptance
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 0590f2d7..52737164 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -11,8 +11,8 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-node@v4
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
cache: npm
@@ -25,7 +25,7 @@ jobs:
working-directory: archify
- name: Provision a known Chrome runtime
id: setup-chrome
- uses: browser-actions/setup-chrome@v2
+ uses: browser-actions/setup-chrome@48ad923757ca74d66703209fe939badbdf80f2f4 # v2.2.0
with:
chrome-version: stable
install-dependencies: true
@@ -68,7 +68,7 @@ jobs:
- name: Committed zip must match the build (same gate as CI)
run: cmp -s /tmp/archify-built.zip archify.zip
- name: Create GitHub Release with the zip attached
- uses: softprops/action-gh-release@v2
+ uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
with:
files: archify.zip
generate_release_notes: true
diff --git a/.github/workflows/star-history.yml b/.github/workflows/star-history.yml
index b8122271..84d0ea67 100644
--- a/.github/workflows/star-history.yml
+++ b/.github/workflows/star-history.yml
@@ -16,7 +16,7 @@ jobs:
update:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: narayann7/star-history-action@a68d8f9d67ca20d55b682a264e69152dcf326e9c # v1.0.5
with:
output-dir: assets
diff --git a/archify/test/workflow-action-pinning.test.mjs b/archify/test/workflow-action-pinning.test.mjs
new file mode 100644
index 00000000..405d5f63
--- /dev/null
+++ b/archify/test/workflow-action-pinning.test.mjs
@@ -0,0 +1,100 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import fs from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
+const remoteRefPattern = /^[0-9a-fA-F]{40}$/;
+
+function yamlFilesUnder(relativeRoot) {
+ const root = path.join(repoRoot, relativeRoot);
+ if (!fs.existsSync(root)) return [];
+ const files = [];
+ function visit(directory) {
+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
+ const absolute = path.join(directory, entry.name);
+ if (entry.isDirectory()) {
+ visit(absolute);
+ continue;
+ }
+ if (entry.isFile() && /\.(?:yml|yaml)$/i.test(entry.name)) files.push(absolute);
+ }
+ }
+ visit(root);
+ return files.sort();
+}
+
+function leadingSpaces(line) {
+ return line.match(/^ */)?.[0].length ?? 0;
+}
+
+function usesReferences(source) {
+ const references = [];
+ const lines = source.split(/\r?\n/);
+ let blockScalarIndent = null;
+ for (let index = 0; index < lines.length; index += 1) {
+ const line = lines[index];
+ if (blockScalarIndent !== null) {
+ if (line.trim() === '') continue;
+ if (leadingSpaces(line) > blockScalarIndent) continue;
+ blockScalarIndent = null;
+ }
+ if (/^\s*#/.test(line)) continue;
+ const matches = line.matchAll(
+ /(?:^\s*(?:-\s*)?|[,{]\s*)(?:"uses"|'uses'|uses)\s*:\s*(?:"([^"]+)"|'([^']+)'|([^#,\s}]+))/g,
+ );
+ for (const match of matches) {
+ references.push({ line: index + 1, value: match[1] ?? match[2] ?? match[3] });
+ }
+ if (
+ /^\s*(?:-\s*)?(?:"[^"]+"|'[^']+'|[A-Za-z0-9_-]+)\s*:\s*[>|][0-9+-]*\s*(?:#.*)?$/.test(line)
+ ) {
+ blockScalarIndent = leadingSpaces(line);
+ }
+ }
+ return references;
+}
+
+function mutableRemoteReferences() {
+ const files = [...yamlFilesUnder('.github/workflows'), ...yamlFilesUnder('.github/actions')];
+ const failures = [];
+ for (const absolute of files) {
+ const relative = path.relative(repoRoot, absolute).split(path.sep).join('/');
+ const source = fs.readFileSync(absolute, 'utf8');
+ for (const reference of usesReferences(source)) {
+ const value = reference.value;
+ if (value.startsWith('./')) continue;
+ if (value.startsWith('docker://')) continue;
+ const separator = value.lastIndexOf('@');
+ const ref = separator === -1 ? '' : value.slice(separator + 1);
+ if (!remoteRefPattern.test(ref)) {
+ failures.push(`${relative}:${reference.line}: ${value}`);
+ }
+ }
+ }
+ return failures;
+}
+
+test('remote GitHub Actions and reusable workflows use immutable commit SHAs', () => {
+ const failures = mutableRemoteReferences();
+ assert.deepEqual(failures, [], [
+ 'Remote GitHub Actions and reusable workflows must use full 40-character commit SHAs.',
+ ...failures,
+ ].join('\n'));
+});
+
+test('workflow action pinning scanner ignores local and Docker Actions', () => {
+ const source = [
+ 'steps:',
+ ' - uses: ./local-action',
+ ' - uses: docker://alpine:3.20',
+ ' - uses: actions/checkout@0123456789abcdef0123456789abcdef01234567',
+ ' - run: |',
+ ' echo "uses: actions/checkout@v4"',
+ ].join('\n');
+ assert.deepEqual(
+ usesReferences(source).map(({ value }) => value),
+ ['./local-action', 'docker://alpine:3.20', 'actions/checkout@0123456789abcdef0123456789abcdef01234567'],
+ );
+});