Files
codex-security/github-action/scripts/check-metadata.ts
T
0cdb22a6db feat(action): add Codex Security GitHub Action (#1015)
* feat(action): integrate GitHub Action alongside the CLI

* fix(action): update pinned CLI to 0.1.29

* fix(action): omit estimated cost from scan summaries

* docs(action): simplify setup and usage guide

* docs(action): schedule weekly scans in quick start

* docs(action): minimize quick-start scan configuration

* docs(action): configure Luna PR scans and verify annotations

* Update README.md

* fix(action): update pinned CLI to 0.1.30

* fix(action): normalize paths and preserve results on summary failure

* refactor(action): remove fixed-value public inputs

* refactor(action): use job check with explicit scan outcomes

* refactor(action): use runtime manifest as single CLI version source

* fix(action): explain incomplete scan coverage in summaries

* docs: add GitHub Actions quick start to main README

* Update README.md

* fix(action): defer policy and knowledge-base handling to CLI

* refactor(action): consume validated CLI results

* fix(action): preserve scan outcomes when SARIF is unavailable

* fix(action): allow configured Dependabot scans

* test(action): add hosted dry-run smoke job

* fix(action): ignore unrelated input environment variables

* refactor(action): simplify runtime setup

* refactor(action): simplify inputs for repository and PR scans

* chore(action): update Codex Security CLI to 0.1.31

* feat(action): restore deep scan mode and time budget

* fix(action): warn on valid partial scans

* fix(action): refresh audited dependencies and preserve diagnostics

* fix(action): escape legacy runner commands in diagnostics

* fix(action): preserve result and SARIF reporting semantics

* fix(action): keep report text and selected paths literal

* fix(action): accept existing literal scope filenames

* fix(action): check large diffs without capturing path lists

* test(action): wait for child readiness before timeout

* refactor(action): delegate scanner behavior to the CLI

* fix(action): preserve runner tools and bind scan reports to the requested commit

* fix(action): preserve runner tool selection and process cleanup

* fix(action): clean up descendants before draining process output

* fix(action): preserve Python loading and inspect worktree configuration

* fix(action): preserve runner tracking through MCP launchers

* test(plugin): preserve interpreter loader settings in worker fixtures

* test(action): create the CLI integration runtime temp directory

---------

Co-authored-by: dans-oai <321942207+dans-oai@users.noreply.github.com>
Co-authored-by: mldangelo-oai <269034524+mldangelo-oai@users.noreply.github.com>
Co-authored-by: Michael D'Angelo <mdangelo@openai.com>
2026-10-05 23:50:02 -04:00

35 lines
2.2 KiB
TypeScript

import { readFile } from 'node:fs/promises';
import assert from 'node:assert/strict';
import { parse } from 'yaml';
import { INPUT_NAMES, parseInputs } from '../src/inputs.js';
import { OUTPUT_NAMES } from '../src/main.js';
const metadata = parse(await readFile(new URL('../../action.yml', import.meta.url), 'utf8'));
assert.deepEqual(Object.keys(metadata.inputs).sort(), [...INPUT_NAMES].sort(), 'action.yml inputs must match the parser');
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 defaults = parseInputs(name => String(metadata.inputs[name]?.default ?? '').replace('${{ github.workspace }}', '/checkout'), '/checkout');
assert.equal(defaults.failOnSeverity, 'none');
assert.equal(defaults.scope, 'repository');
assert.equal(defaults.uploadArtifacts, false);
assert.equal(defaults.verbose, true);
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(INPUT_NAMES.includes(key as typeof INPUT_NAMES[number]), `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, 2, 'README must include complete PR and repository workflows');
console.log('Action metadata and implementation contract agree.');