mirror of
https://github.com/openai/codex-security.git
synced 2026-11-21 02:12:29 +08:00
* 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>
61 lines
4.2 KiB
JavaScript
61 lines
4.2 KiB
JavaScript
// Runs the SHIPPED action in a temporary checkout with dry-run and no secrets.
|
|
import { mkdir, mkdtemp, writeFile, readFile, rm, lstat } from 'node:fs/promises';
|
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
import { tmpdir } from 'node:os';
|
|
import { join, resolve } from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { parse } from 'yaml';
|
|
const repositoryRoot = resolve(import.meta.dirname, '../..');
|
|
const metadata = parse(await readFile(join(repositoryRoot, 'action.yml'), 'utf8'));
|
|
const root = await mkdtemp(join(tmpdir(), 'codex-action-linux-smoke-'));
|
|
const baseEnv = {PATH: process.env.PATH, HOME: root, GIT_CONFIG_NOSYSTEM:'1', GIT_CONFIG_GLOBAL:'/dev/null'};
|
|
try {
|
|
const git = (...args) => execFileSync('/usr/bin/git', ['-c','user.name=Smoke','-c','user.email=smoke@example.invalid',...args], {cwd:root,env:baseEnv,encoding:'utf8',stdio:['ignore','pipe','pipe']}).trim();
|
|
git('init','-b','main'); git('remote','add','origin','https://github.com/example/smoke.git');
|
|
await writeFile(join(root,'app.js'), 'export const add = (a, b) => a + b;\n');
|
|
git('add','app.js'); git('commit','-m','fixture');
|
|
const sha=git('rev-parse','HEAD');
|
|
// GitHub command files sit outside the checkout, as in an actual job.
|
|
const commandRoot = await mkdtemp(join(tmpdir(),'codex-action-commands-'));
|
|
try {
|
|
for (const name of ['output','state','summary']) await writeFile(join(commandRoot,name),'');
|
|
await writeFile(join(commandRoot,'event.json'),'{}');
|
|
const action = resolve(repositoryRoot, metadata.runs.main);
|
|
const run = spawnSync(process.execPath,[action], {cwd:root, encoding:'utf8', timeout:600_000,maxBuffer:8*1024*1024,env:{...baseEnv,
|
|
GITHUB_ACTIONS:'true',GITHUB_EVENT_NAME:'workflow_dispatch',GITHUB_EVENT_PATH:join(commandRoot,'event.json'),
|
|
GITHUB_REPOSITORY:'example/smoke',GITHUB_SHA:sha,GITHUB_REF:'refs/heads/main',GITHUB_ACTOR:'smoke',GITHUB_SERVER_URL:'https://github.com',
|
|
GITHUB_WORKSPACE:root,RUNNER_TEMP:commandRoot,RUNNER_TRACKING_ID:'synthetic-smoke-job',GITHUB_OUTPUT:join(commandRoot,'output'),GITHUB_STATE:join(commandRoot,'state'),GITHUB_STEP_SUMMARY:join(commandRoot,'summary'),
|
|
'INPUT_DRY-RUN':'true',INPUT_VERBOSE:'true',
|
|
}});
|
|
if (run.status !== 0) {
|
|
console.error(run.stdout); console.error(run.stderr);
|
|
throw run.error ?? new Error(`Packaged action exited ${run.status}`);
|
|
}
|
|
const output=await readFile(join(commandRoot,'output'),'utf8');
|
|
assert.match(output,/scan-status<<[^\n]+\nskipped\n/);
|
|
assert.match(output,/skip-reason<<[^\n]+\ndry-run\n/);
|
|
assert.doesNotMatch(output,/sarif-upload-ready<<[^\n]+\ntrue\n/);
|
|
const state = await readFile(join(commandRoot, 'state'), 'utf8');
|
|
const runtimeRoot = /^runtime-root<<([^\n]+)\n([^\n]+)\n\1$/m.exec(state)?.[2];
|
|
const runtimeTempRoot = /^runtime-temp-root<<([^\n]+)\n([^\n]+)\n\1$/m.exec(state)?.[2];
|
|
assert.ok(runtimeRoot && runtimeTempRoot, 'Main entrypoint must save cleanup state');
|
|
const runPost = async () => {
|
|
const post = spawnSync(process.execPath, [resolve(repositoryRoot, metadata.runs.post)], {
|
|
cwd: root, encoding: 'utf8', timeout: 10_000,
|
|
env: {...baseEnv, 'STATE_runtime-root': runtimeRoot, 'STATE_runtime-temp-root': runtimeTempRoot},
|
|
});
|
|
assert.equal(post.status, 0, `Post entrypoint failed: ${post.stderr}`);
|
|
await assert.rejects(lstat(runtimeRoot), {code: 'ENOENT'});
|
|
};
|
|
// Main already cleaned up; post must tolerate the absent runtime.
|
|
await assert.rejects(lstat(runtimeRoot), {code: 'ENOENT'});
|
|
await runPost();
|
|
// Simulate a runtime left behind when main could not finish cleanup.
|
|
await mkdir(join(runtimeRoot, 'home'), {recursive: true, mode: 0o700});
|
|
await writeFile(join(runtimeRoot, '.codex-security-action-owned'), 'codex-security-action-v1\n', {mode: 0o600});
|
|
await writeFile(join(runtimeRoot, 'home', 'auth.json'), '{"token":"synthetic-smoke-token"}\n', {mode: 0o600});
|
|
await runPost();
|
|
console.log('Packaged Linux action installed the locked CLI, passed dry-run, and verified post cleanup for absent and leftover runtimes without credentials or model calls.');
|
|
} finally { await rm(commandRoot,{recursive:true,force:true}); }
|
|
} finally { await rm(root,{recursive:true,force:true}); }
|