Remove the /cso test files, CI workflows and docs ahead of removing /cso (GST-3920) (#4837)

Deletes the tests, test fixtures, CI workflows, scripts and docs that
exist only for /cso. Nothing changes for anyone using gstack.

Why: this is the first half of removing /cso. The whole removal is too
big to review in one pull request, so #4833 removes the skill and its
helper code next.

Nothing to do: #4833 lands right after this one.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-25 21:09:24 +00:00
1 parent 1145e80a47
commit fd7e8c7b36
113 files changed
+47 -19061

No files matched your search

-102
View File
@@ -1,102 +0,0 @@
/** Private evaluator inputs. Never copy this module or its JSON output into producer snapshots. */
import { createHash } from 'node:crypto';
import { CORPUS_VERSION, type EvalFamily } from '../fixtures/cso-eval/materialize';
export interface OracleRequest { method: 'GET' | 'POST'; path: string; body?: string; headers?: Record<string, string> }
export interface OracleResponse { status: number; body: string; headers?: Record<string, string> }
export interface PrivateOracle {
version: string;
controls: Array<{ request: OracleRequest; response: (value: OracleResponse) => boolean }>;
attack: OracleRequest;
vulnerable: (value: OracleResponse) => boolean;
fixed: (value: OracleResponse) => boolean;
/** More than the exposed training assertion: alternative attack payloads. */
heldOut: Array<{ request: OracleRequest; fixed: (value: OracleResponse) => boolean }>;
}
const get = (params: Record<string, string>): OracleRequest => ({ method: 'GET', path: `/action?${new URLSearchParams(params)}` });
const post = (value: object): OracleRequest => ({ method: 'POST', path: '/action', body: JSON.stringify(value), headers: { 'content-type': 'application/json' } });
const contains = (status: number, expected: string) => (response: OracleResponse) => response.status === status && response.body.includes(expected);
const rejects = (status: number) => (response: OracleResponse) => response.status === status;
const jsonValue = (value: OracleResponse): any => { try { return JSON.parse(value.body); } catch { return null; } };
export function oracleFor(family: EvalFamily): PrivateOracle {
const input: Record<EvalFamily, Omit<PrivateOracle, 'version'>> = {
'sql-injection': {
controls: [{ request: get({ name: 'alice' }), response: contains(200, 'HELLO_ALICE') }],
attack: get({ name: "nobody' OR 1=1 --" }), vulnerable: contains(200, 'SECRET_ADMIN_NOTE'),
fixed: value => value.status === 200 && Array.isArray(jsonValue(value)) && jsonValue(value).length === 0,
heldOut: [{ request: get({ name: "' UNION SELECT 'ORACLE_SQL_MARKER' --" }), fixed: value => value.status === 200 && !value.body.includes('ORACLE_SQL_MARKER') }],
},
'command-injection': {
controls: [{ request: get({ name: 'Ada' }), response: value => value.status === 200 && jsonValue(value)?.output === 'Ada' }],
attack: get({ name: '"; printf CSO_COMMAND_EXECUTED; #' }), vulnerable: value => value.status === 200 && jsonValue(value)?.output === 'CSO_COMMAND_EXECUTED', fixed: rejects(400),
heldOut: [{ request: get({ name: '$(printf ORACLE_COMMAND_MARKER)' }), fixed: rejects(400) }],
},
'path-traversal': {
controls: [{ request: get({ file: 'hello.txt' }), response: contains(200, 'PUBLIC_HELLO') }],
attack: get({ file: '../private.txt' }), vulnerable: contains(200, 'PRIVATE_DOCUMENT_SECRET'), fixed: rejects(403),
heldOut: [{ request: get({ file: 'subdir/../../private.txt' }), fixed: rejects(403) }],
},
ssrf: {
controls: [{ request: get({ url: 'http://127.0.0.1:8001/public' }), response: contains(200, 'PUBLIC_STATUS') }],
attack: get({ url: 'http://127.0.0.1:8001/private' }), vulnerable: contains(200, 'INTERNAL_SERVICE_SECRET'), fixed: rejects(403),
heldOut: [{ request: get({ url: 'http://localhost:8001/private' }), fixed: rejects(403) }],
},
'object-authorization': {
controls: [{ request: get({ id: 'invoice-1' }), response: value => value.status === 200 && jsonValue(value)?.total === 12 }],
attack: get({ id: 'invoice-2' }), vulnerable: value => value.status === 200 && jsonValue(value)?.total === 9800, fixed: rejects(403),
heldOut: [{ request: get({ id: 'invoice-2', owner: 'member-1' }), fixed: rejects(403) }],
},
'tenant-isolation': {
controls: [{ request: get({ tenant: 'tenant-a' }), response: contains(200, 'OWN_TENANT_DOCUMENT') }],
attack: get({ tenant: 'tenant-b' }), vulnerable: contains(200, 'OTHER_TENANT_SECRET'),
fixed: value => value.status === 200 && value.body.includes('OWN_TENANT_DOCUMENT') && !value.body.includes('OTHER_TENANT_SECRET'),
heldOut: [{ request: get({ tenant: 'tenant-b', actor_tenant: 'tenant-b' }), fixed: value => value.status === 200 && !value.body.includes('OTHER_TENANT_SECRET') }],
},
'html-injection': {
controls: [{ request: get({ name: 'Alice' }), response: contains(200, '<main>Welcome Alice</main>') }],
attack: get({ name: '<img src=x onerror="window.CSO_XSS=1">' }), vulnerable: contains(200, '<img src=x onerror='),
fixed: value => value.status === 200 && !value.body.includes('<img') && value.body.includes('&lt;img'),
heldOut: [{ request: get({ name: '</main><svg onload="window.ORACLE_XSS=1">' }), fixed: value => value.status === 200 && !value.body.includes('<svg') && value.body.includes('&lt;svg') }],
},
'open-redirect': {
controls: [{ request: get({ next: '/account' }), response: value => value.status === 302 && jsonValue(value)?.next === '/account' && value.headers?.location === '/account' }],
attack: get({ next: 'https://attacker.invalid/collect' }), vulnerable: value => value.status === 302 && value.headers?.location === 'https://attacker.invalid/collect', fixed: rejects(400),
heldOut: [{ request: get({ next: '//attacker.invalid/collect' }), fixed: rejects(400) }, { request: get({ next: '/\\attacker.invalid/collect' }), fixed: rejects(400) }],
},
'mass-assignment': {
controls: [{ request: post({ display_name: 'Ada' }), response: value => value.status === 200 && jsonValue(value)?.display_name === 'Ada' }],
attack: post({ role: 'admin' }), vulnerable: value => value.status === 200 && jsonValue(value)?.role === 'admin', fixed: value => value.status === 200 && jsonValue(value)?.role === 'member',
heldOut: [{ request: post({ id: 'member-2', role: 'owner', display_name: 'Grace' }), fixed: value => value.status === 200 && jsonValue(value)?.id === 'member-1' && jsonValue(value)?.role === 'member' && jsonValue(value)?.display_name === 'Grace' }],
},
'resource-exhaustion': {
controls: [{ request: get({ count: '5' }), response: value => value.status === 200 && jsonValue(value)?.count === 5 }],
// Bounded proof of missing admission, not an attempt to exhaust the runner.
attack: get({ count: '250' }), vulnerable: value => value.status === 200 && jsonValue(value)?.count === 250, fixed: rejects(400),
heldOut: [{ request: get({ count: '101' }), fixed: rejects(400) }, { request: get({ count: '0' }), fixed: rejects(400) }],
},
};
return { version: CORPUS_VERSION, ...input[family] };
}
export interface Observation { request: OracleRequest; response: OracleResponse }
export interface PrivateEvidence {
original: { booted: boolean; controls: Observation[]; attack: Observation };
patched: { booted: boolean; controls: Observation[]; attack: Observation; heldOut: Observation[]; existingTestsPassed: boolean };
immutableVerifier: boolean;
independentRootCauseReview: boolean;
featurePreserved: boolean;
boundaryMocks: boolean;
}
const sameRequest = (left: OracleRequest, right: OracleRequest) => JSON.stringify(left) === JSON.stringify(right);
/** Only trusted runner observations may enter this function; producer claims are not observations. */
export function judgeRepair(family: EvalFamily, evidence: PrivateEvidence): { reproduced: boolean; correctRepair: boolean; evidenceHash: string } {
const oracle = oracleFor(family);
const controls = (observations: Observation[]) => oracle.controls.every(control => observations.some(observation => sameRequest(control.request, observation.request) && control.response(observation.response)));
const original = evidence.original, patched = evidence.patched;
const reproduced = original.booted && controls(original.controls) && sameRequest(original.attack.request, oracle.attack) && oracle.vulnerable(original.attack.response);
const correctRepair = reproduced && patched.booted && controls(patched.controls) && sameRequest(patched.attack.request, oracle.attack) && oracle.fixed(patched.attack.response)
&& oracle.heldOut.every(assertion => patched.heldOut.some(observation => sameRequest(assertion.request, observation.request) && assertion.fixed(observation.response)))
&& patched.existingTestsPassed && evidence.immutableVerifier && evidence.independentRootCauseReview && evidence.featurePreserved && !evidence.boundaryMocks;
return { reproduced, correctRepair, evidenceHash: createHash('sha256').update(JSON.stringify({ version: oracle.version, family, evidence })).digest('hex') };
}
-34
View File
@@ -1,34 +0,0 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
export function createPrecisionLossCandidate(
target: string,
contents: string,
readFileId: (file: string) => bigint = file => fs.lstatSync(file, { bigint: true }).ino,
): bigint {
if (fs.existsSync(target)) throw new Error('Precision fixture target already exists');
const directory = path.dirname(target);
if (fs.lstatSync(directory).isSymbolicLink()) throw new Error('Precision fixture directory must not be linked');
const pool = fs.mkdtempSync(path.join(directory, 'ntfs-id-'));
let aboveSafe = 0;
try {
for (let batch = 0; batch < 512; batch++) {
const files: string[] = [];
for (let slot = 0; slot < 2; slot++) {
const file = path.join(pool, `candidate-${slot}`);
fs.writeFileSync(file, contents, { flag: 'wx' });
files.push(file);
const inode = readFileId(file);
if (inode > BigInt(Number.MAX_SAFE_INTEGER)) aboveSafe++;
if (inode > BigInt(Number.MAX_SAFE_INTEGER) && String(Number(inode)) !== String(inode)) {
fs.linkSync(file, target);
return inode;
}
}
for (const file of files) fs.unlinkSync(file);
}
throw new Error(`No precision-losing NTFS file ID within 1024 file creations (${aboveSafe} above-safe observations)`);
} finally {
fs.rmSync(pool, { recursive: true, force: true });
}
}
-51
View File
@@ -1,51 +0,0 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { dispatchCsoCommand, type CsoCliDependencies } from '../../lib/cso/cli';
import { validateRuntimeCatalog, type QualifiedRuntime, type RuntimeCatalog, type RuntimePlatform } from '../../lib/cso/runtime-catalog';
import { completeRuntimeCatalogFixture, installStagedRuntime } from './cso-runtime-catalog';
export interface QualifiedCsoCli {
readonly catalog: RuntimeCatalog;
readonly runtime: QualifiedRuntime;
command<T = unknown>(args: string[]): Promise<T>;
}
/** Bind a staged Node image to the real command dispatcher without adding a production override. */
export function qualifiedNodeCli(options: {
image: string;
versions: Record<string, string>;
watchdogPath: string;
platform: RuntimePlatform;
}): QualifiedCsoCli {
if (!path.isAbsolute(options.watchdogPath) || !fs.statSync(options.watchdogPath).isFile()) {
throw new Error('Node lifecycle qualification requires an absolute compiled watchdog path');
}
for (const key of ['node', 'npm', 'cso-preparation']) {
if (!/^\d+\.\d+\.\d+$/.test(options.versions[key] ?? '')) {
throw new Error(`Node lifecycle qualification requires exact ${key} version metadata`);
}
}
if (options.versions['cso-preparation'] !== '1.0.0') {
throw new Error('Node lifecycle qualification requires cso-preparation 1.0.0');
}
const catalog = completeRuntimeCatalogFixture('node-lifecycle-fixture');
const fixture = catalog.runtimes.find(item => item.stack === 'node' && item.platform === options.platform);
if (!fixture) throw new Error('Node lifecycle catalog fixture is incomplete');
const runtime = installStagedRuntime(catalog, { ...fixture, image: options.image, versions: options.versions });
validateRuntimeCatalog(catalog);
const dependencies: CsoCliDependencies = Object.freeze({
runtimeCatalog: catalog,
watchdogPath: () => options.watchdogPath,
});
return Object.freeze({
catalog,
runtime,
async command<T = unknown>(args: string[]): Promise<T> {
const [command, ...commandArgs] = args;
if (!command) throw new Error('CSO qualification command is required');
return await dispatchCsoCommand(command, commandArgs, dependencies) as T;
},
});
}
-4
View File
@@ -75,10 +75,6 @@ export const FREE_FIXTURES: Readonly<Record<string, readonly string[]>> = {
'test/fixtures/coverage-audit-two-file-grep.json': ['test/coverage-audit-evidence.test.ts'],
'test/fixtures/coverage-audit-wc-anchor.json': ['test/coverage-audit-evidence.test.ts'],
'test/fixtures/credential-rejection-39696775546.json': ['test/credential-rejection.test.ts'],
'test/fixtures/cso-e2e/**': ['test/cso-e2e-report-contract.test.ts'],
'test/fixtures/cso-eval/**': ['scripts/cso-eval.ts', 'test/cso-eval.test.ts', 'test/cso-stack-cold-integration.test.ts', 'test/helpers/cso-eval-oracles.ts'],
'test/fixtures/cso-http-smoke.c': ['test/cso-docker-integration.test.ts'],
'test/fixtures/cso-sarif/**': ['test/cso-scanner-cli.test.ts', 'test/cso-scanners.test.ts'],
'test/fixtures/design-completion-envelope-90f.json': ['test/plan-count-completion.test.ts'],
'test/fixtures/design-consultation-section-design-md.md': ['test/carve-section-sharding.test.ts'],
'test/fixtures/design-count-native-8525.json': ['test/plan-count-completion.test.ts'],