mirror of
https://github.com/garrytan/gstack.git
synced 2026-10-31 14:06:50 +01:00
* fix(deps): clear the OSV suppressions that expire on 2026-11-30 Delete the hono, @anthropic-ai/sdk (#2754) and sprintf-js ignores, which the lockfiles no longer match. Override image-size to 2.0.4 (#2753) and chokidar to 4.0.3 in lib/diagram-render (drops braces), and delete those ignores. Re-date katex to 2027-01-31: its fix is outside mermaid 11's range (mermaid-js/mermaid#8388). html-to-docx 1.8.0 bundles its own image-size 1.x, which the override cannot reach and whose ICNS parser loops forever. make-pdf --to docx now hands it only PNG, JPEG, GIF, WebP or SVG bytes. A golden docx test proves the Word output is unchanged. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * build(deps-dev): @types/bun 1.4.3, prettier 3.9.10; hold the Anthropic SDKs to patches Replaces dependabot #3228 without its agent-sdk 0.3 and sdk 0.133 bumps, which break typecheck:test and overlay-sdk-cancel-eof. Their 0.x breaking releases are semver-minor to dependabot, so the ignore covers minor and major. @types/bun 1.4.3 retires 18 test type diagnostics; the baseline locks that in. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(ci): exempt dependabot dependency-manifest PRs from Version Gate rule 1 Dependabot never edits VERSION, so hard rule 1 failed every package.json PR it opened. The workflow now passes the PR author and changed-file list; the gate skips rule 1 only for dependabot[bot] when every file is a package.json, bun.lock(b) or .github/dependabot.yml. A failed file lookup keeps the rule. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(make-pdf): guard every html-to-docx sizing path, keep non-ICNS formats Review found three spellings that got past the regex guard and still hung --to docx: a data-src decoy, a percent-encoded separator, and an unquoted encoded colon. html-to-docx sizes images on three paths, and buildImage URI-decodes the whole src first. The guard now mirrors all three, drops ICNS (the only input its bundled image-size routes to the looping parser) instead of allowlisting formats, so BMP and TIFF embed as before, and re-parses the result with html-to-docx's own html-to-vdom to fail closed on anything the regex misreads. The golden test tolerates CRLF checkouts on Windows. Version Gate treats a failed file lookup as an empty list, so a partial paginated result cannot decide the exemption. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * chore(release): stamp v1.91.121.0 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * chore(release): restamp v1.91.122.0 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
126 lines
6.2 KiB
TypeScript
126 lines
6.2 KiB
TypeScript
/**
|
|
* Workflow action pins (supply chain, free).
|
|
*
|
|
* A tag (`@v7`) or branch ref is mutable: whoever controls the action's
|
|
* repository can repoint it, and the next CI run executes the new code with
|
|
* this repository's token and secrets. Every remote `uses:` in a workflow or
|
|
* composite action must name a full 40-character commit SHA (Dependabot's
|
|
* `github-actions` ecosystem keeps those current, with the tag in a trailing
|
|
* comment), and every `docker://` image must name a sha256 digest. Local
|
|
* actions (`./...`) are part of this checkout and need no pin.
|
|
*/
|
|
import { describe, expect, test } from 'bun:test';
|
|
import * as fs from 'node:fs';
|
|
import * as path from 'node:path';
|
|
|
|
const ROOT = path.resolve(__dirname, '..');
|
|
const GITHUB_DIR = path.join(ROOT, '.github');
|
|
|
|
/** Why a `uses:` reference is not immutable, or null when it is. */
|
|
export function pinProblem(uses: string): string | null {
|
|
if (uses.startsWith('./')) return null;
|
|
if (uses.startsWith('docker://')) {
|
|
return /@sha256:[0-9a-f]{64}$/.test(uses) ? null : 'docker image is not pinned to a sha256 digest';
|
|
}
|
|
const at = uses.lastIndexOf('@');
|
|
if (at <= 0) return 'remote action has no ref';
|
|
if (!/^[\w.-]+\/[\w.-]+(?:\/[\w./-]+)?$/.test(uses.slice(0, at))) return 'unrecognized action reference';
|
|
return /^[0-9a-f]{40}$/.test(uses.slice(at + 1)) ? null : 'ref is not a full 40-character commit SHA';
|
|
}
|
|
|
|
/** Every `uses:` in a workflow (job steps and reusable-workflow jobs) or composite action. */
|
|
export function usesReferences(document: any): string[] {
|
|
const refs: string[] = [];
|
|
const steps = (list: any) => {
|
|
for (const step of Array.isArray(list) ? list : []) if (typeof step?.uses === 'string') refs.push(step.uses);
|
|
};
|
|
for (const job of Object.values<any>(document?.jobs ?? {})) {
|
|
if (typeof job?.uses === 'string') refs.push(job.uses);
|
|
steps(job?.steps);
|
|
}
|
|
steps(document?.runs?.steps);
|
|
return refs;
|
|
}
|
|
|
|
function automationFiles(): string[] {
|
|
const files: string[] = [];
|
|
const workflows = path.join(GITHUB_DIR, 'workflows');
|
|
for (const name of fs.readdirSync(workflows).sort()) {
|
|
if (/\.ya?ml$/.test(name)) files.push(path.join(workflows, name));
|
|
}
|
|
const actions = path.join(GITHUB_DIR, 'actions');
|
|
for (const name of fs.existsSync(actions) ? fs.readdirSync(actions).sort() : []) {
|
|
for (const file of ['action.yml', 'action.yaml']) {
|
|
if (fs.existsSync(path.join(actions, name, file))) files.push(path.join(actions, name, file));
|
|
}
|
|
}
|
|
return files;
|
|
}
|
|
|
|
describe('workflow action pins', () => {
|
|
test('the classifier accepts immutable references and rejects mutable ones', () => {
|
|
for (const ok of [
|
|
'./.github/actions/restore-deps',
|
|
'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1',
|
|
'github/codeql-action/upload-sarif@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2',
|
|
'google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@f4cfcc01edc9c8b756a9b873b7a623ca674da51e',
|
|
`docker://alpine@sha256:${'a'.repeat(64)}`,
|
|
]) expect(pinProblem(ok), ok).toBeNull();
|
|
for (const bad of [
|
|
'actions/checkout@v7',
|
|
'actions/checkout@main',
|
|
'actions/checkout@3d3c42e',
|
|
'actions/checkout',
|
|
'google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.3.8',
|
|
'docker://alpine:3.20',
|
|
'docker://alpine',
|
|
]) expect(pinProblem(bad), bad).not.toBeNull();
|
|
});
|
|
|
|
test('every remote action, reusable workflow and docker image is pinned immutably', () => {
|
|
const files = automationFiles();
|
|
const problems: string[] = [];
|
|
let scanned = 0;
|
|
for (const file of files) {
|
|
const source = fs.readFileSync(file, 'utf-8');
|
|
const refs = usesReferences(Bun.YAML.parse(source));
|
|
// A parse that misses `uses:` lines would pass vacuously; count them.
|
|
const lines = source.split('\n').filter((line) => /^\s*(?:-\s+)?uses:\s*\S/.test(line)).length;
|
|
expect(refs.length, `${path.relative(ROOT, file)}: parsed ${refs.length} of ${lines} uses: lines`).toBe(lines);
|
|
scanned += refs.length;
|
|
for (const ref of refs) {
|
|
const problem = pinProblem(ref);
|
|
if (problem) problems.push(`${path.relative(ROOT, file)}: ${ref} (${problem})`);
|
|
}
|
|
}
|
|
expect(files.length).toBeGreaterThan(10);
|
|
expect(scanned).toBeGreaterThan(100);
|
|
expect(problems, 'pin each action to a full commit SHA with the tag in a trailing comment').toEqual([]);
|
|
});
|
|
|
|
test('Dependabot keeps the pinned actions current', () => {
|
|
const config = Bun.YAML.parse(fs.readFileSync(path.join(GITHUB_DIR, 'dependabot.yml'), 'utf-8')) as any;
|
|
expect((config.updates ?? []).map((update: any) => update['package-ecosystem'])).toContain('github-actions');
|
|
});
|
|
|
|
test('Dependabot holds Playwright minor and major bumps behind the windowsHide patch; patch updates still flow', () => {
|
|
const config = Bun.YAML.parse(fs.readFileSync(path.join(__dirname, '..', '.github', 'dependabot.yml'), 'utf-8')) as any;
|
|
const bun = (config.updates ?? []).find((update: any) => update['package-ecosystem'] === 'bun');
|
|
const ignored = Object.fromEntries((bun?.ignore ?? []).map((rule: any) => [rule['dependency-name'], rule]));
|
|
const pkg = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf-8'));
|
|
expect(Object.keys(pkg.patchedDependencies ?? {}).some(key => key.startsWith('playwright-core@'))).toBe(true);
|
|
for (const name of ['playwright', 'playwright-core']) {
|
|
expect(ignored[name]).toEqual({ 'dependency-name': name, 'update-types': ['version-update:semver-minor', 'version-update:semver-major'] });
|
|
}
|
|
});
|
|
|
|
test('Dependabot holds the Anthropic SDKs to patch updates; their 0.x breaking releases arrive as semver-minor', () => {
|
|
const config = Bun.YAML.parse(fs.readFileSync(path.join(GITHUB_DIR, 'dependabot.yml'), 'utf-8')) as any;
|
|
const bun = (config.updates ?? []).find((update: any) => update['package-ecosystem'] === 'bun');
|
|
const ignored = Object.fromEntries((bun?.ignore ?? []).map((rule: any) => [rule['dependency-name'], rule]));
|
|
for (const name of ['@anthropic-ai/claude-agent-sdk', '@anthropic-ai/sdk']) {
|
|
expect(ignored[name]).toEqual({ 'dependency-name': name, 'update-types': ['version-update:semver-minor', 'version-update:semver-major'] });
|
|
}
|
|
});
|
|
});
|