mirror of
https://github.com/openai/codex-security.git
synced 2026-11-25 18:11:46 +08:00
* fix(sdk): restore GPT-6 Sol cost estimates and budgets * feat(action)!: prepare hosted runners and require complete CI reviews * fix(action): handle containers and retargeted pull requests * Align the main Action quick start with sandbox and coverage behavior * test(packaging): await tar extraction in package fixtures * fix(action): preserve required scans across metadata edits * fix(action): verify sandbox startup before hosted setup * fix(action): only provision Ubuntu after sandbox startup failures * fix(action): preserve setup diagnostics and check native configuration * fix(action): preserve runner setup and PR check semantics * fix(action): verify live PR targets on the triggering host * docs(action): clarify check migration and SARIF permissions --------- Co-authored-by: mldangelo-oai <269034524+mldangelo-oai@users.noreply.github.com>
34 lines
1.6 KiB
TypeScript
34 lines
1.6 KiB
TypeScript
import { DefaultArtifactClient } from '@actions/artifact';
|
|
import { mkdtemp, chmod, writeFile, rm } from 'node:fs/promises';
|
|
import { join } from 'node:path';
|
|
import { readReportFile, type ScanResults } from './results.js';
|
|
import type { Inputs } from './inputs.js';
|
|
|
|
export async function collectReports(result: ScanResults): Promise<Map<string, Buffer>> {
|
|
const reports = new Map<string, Buffer>();
|
|
for (const [name, path] of [
|
|
['scan-manifest.json', result.paths.manifestPath], ['findings.json', result.paths.jsonPath],
|
|
['coverage.json', result.paths.coveragePath], ['exports/results.sarif', result.paths.sarifPath],
|
|
]) {
|
|
if (!path) continue;
|
|
const data = await readReportFile(result.paths.resultsDirectory, name);
|
|
reports.set(name, data);
|
|
}
|
|
return reports;
|
|
}
|
|
export async function uploadReports(reports: Map<string, Buffer>, inputs: Inputs, tempRoot: string): Promise<number | undefined> {
|
|
if (!reports.size) throw new Error('Artifact upload requested, but no validated reports are available.');
|
|
const staging = await mkdtemp(join(tempRoot, 'codex-security-upload-'));
|
|
try {
|
|
await chmod(staging, 0o700);
|
|
const files: string[] = [];
|
|
for (const [name, bytes] of reports) {
|
|
const dest = join(staging, name === 'exports/results.sarif' ? 'results.sarif' : name);
|
|
await writeFile(dest, bytes, {mode: 0o600, flag: 'wx'});
|
|
files.push(dest);
|
|
}
|
|
const artifact = await new DefaultArtifactClient().uploadArtifact(inputs.artifactName, files, staging, {retentionDays: inputs.retentionDays, compressionLevel: 0});
|
|
return artifact.id;
|
|
} finally { await rm(staging, {recursive: true, force: true}); }
|
|
}
|