mirror of
https://github.com/openai/codex-security.git
synced 2026-11-21 02:12:29 +08:00
Remove the separate nineteen-name registry. Compare action.yml with the keys requested by the parser for default, external-provider, and opt-in Deep Scan inputs. Use the declared names to check README examples and isolate test environments. Verified with npm run validate (223 tests, unchanged distribution), six synthetic mutations including unconditional and conditional parser typos, and six keyless CLI preflights against 0.6.0 and 0.8.3. Action input syntax and defaults are unchanged; no migration is required.
47 lines
2.7 KiB
TypeScript
47 lines
2.7 KiB
TypeScript
import { readFile } from 'node:fs/promises';
|
|
import assert from 'node:assert/strict';
|
|
import { parse } from 'yaml';
|
|
import { parseInputs } from '../src/inputs.ts';
|
|
import { OUTPUT_NAMES } from '../src/main.ts';
|
|
const metadata = parse(await readFile(new URL('../../action.yml', import.meta.url), 'utf8'));
|
|
assert.deepEqual(Object.keys(metadata.outputs).sort(), [...OUTPUT_NAMES].sort(), 'action.yml outputs must match implementation');
|
|
assert.equal(metadata.runs.using, 'node24');
|
|
assert.equal(metadata.runs.main, 'github-action/dist/index.cjs');
|
|
assert.equal(metadata.runs.post, 'github-action/dist/post.cjs');
|
|
assert.equal(metadata.runs['post-if'], 'always()');
|
|
const inputNames = new Set<string>();
|
|
const parseWithMetadata = (overrides: Record<string, string> = {}) => parseInputs(name => {
|
|
inputNames.add(name);
|
|
return overrides[name] ?? String(metadata.inputs[name]?.default ?? '').replace('${{ github.workspace }}', '/checkout');
|
|
}, '/checkout');
|
|
const defaults = parseWithMetadata();
|
|
assert.equal(defaults.failOnSeverity, 'none');
|
|
assert.equal(defaults.scope, 'repository');
|
|
assert.equal(defaults.uploadArtifacts, false);
|
|
assert.equal(defaults.verbose, true);
|
|
assert.equal(defaults.provider, 'openai');
|
|
assert.equal(defaults.model, 'gpt-5.6-sol');
|
|
for (const provider of ['amazon-bedrock', 'openrouter', 'fireworks']) {
|
|
const inputs = parseWithMetadata({provider});
|
|
assert.equal(inputs.model, '', 'Non-OpenAI providers must not inherit an OpenAI model default');
|
|
}
|
|
assert.equal(parseWithMetadata({mode:'deep', 'cyber-access-program':'standard'}).cyberAccessProgram, 'standard');
|
|
assert.deepEqual([...inputNames].sort(), Object.keys(metadata.inputs).sort(), 'action.yml inputs must match the parser');
|
|
for (const group of [metadata.inputs, metadata.outputs]) for (const value of Object.values(group) as {description: string}[]) assert.ok(value.description);
|
|
const examples = await readFile(new URL('../README.md', import.meta.url), 'utf8');
|
|
let workflowCount = 0;
|
|
for (const match of examples.matchAll(/```yaml\n([\s\S]*?)\n```/g)) {
|
|
const example = parse(match[1]);
|
|
if (!example?.jobs) continue;
|
|
workflowCount++;
|
|
for (const job of Object.values(example.jobs) as {steps: {uses?: string; with?: Record<string,unknown>}[]}[]) {
|
|
for (const step of job.steps) {
|
|
if (step.uses?.startsWith('openai/codex-security@')) {
|
|
for (const key of Object.keys(step.with ?? {})) assert.ok(Object.hasOwn(metadata.inputs, key), `Workflow example uses unknown input ${key}`);
|
|
} else if (step.uses) assert.match(step.uses, /@[a-f0-9]{40}$/, 'Example dependency must use a full commit SHA');
|
|
}
|
|
}
|
|
}
|
|
assert.equal(workflowCount, 3, 'README must include complete PR, repository, and Bedrock workflows');
|
|
console.log('Action metadata and implementation contract agree.');
|