** check. Keeping the old requirement leaves a
+check pending that this workflow no longer produces.
+
+The check name includes the target branch because GitHub can evaluate checks on
+the shared head commit when a test merge commit has no status. The workflow uses
+read-only pull request and Git-ref access on the triggering GitHub host to verify
+the event's head, target branch, and live base SHA before the scan and before
+accepting its result. The pull record's base SHA alone can lag the branch tip.
+Retargeted PRs get a new review. During a run, a changed snapshot fails verification;
+a stale rerun cannot cancel another event's scan.
+The concurrency group also includes the run ID because GitHub compares group
+names without case sensitivity. Separate workflow events can run concurrently.
+Run the workflow from the current PR event after retargeting. If the target has
+advanced since that event, update the PR branch to trigger a fresh review.
+See GitHub's [required-check evaluation](https://docs.github.com/en/pull-requests/how-tos/merge-and-close-pull-requests/troubleshooting-required-status-checks)
+and [rerun semantics](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/re-run-workflows-and-jobs).
+
+When the required check must establish which workflow ran, use an
+[organization ruleset that requires a workflow](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#require-workflows-to-pass-before-merging)
+from a protected ref. Selecting the GitHub Actions app identifies the app, not a
+particular workflow or ref. Code owner approval for `.github/workflows/` and
+`CODEOWNERS`, together with dismissing stale approvals, protects edits in the PR
+being reviewed. It does not stop a workflow on another writable branch from
+creating a check with the same name and app on that PR's head, so it cannot
+substitute for the protected-ref workflow requirement.
+
+
```yaml
+# Required-check policy prerequisites, including merge-time freshness, are in the README.
name: Codex Security PR
on:
pull_request:
- types: [opened, synchronize, reopened, ready_for_review]
+ types: [opened, synchronize, reopened, ready_for_review, edited]
permissions:
contents: read
+ pull-requests: read
concurrency:
- group: codex-security-pr-${{ github.event.pull_request.number }}
+ # Group names are case-insensitive; the run ID also separates case-only retargets.
+ group: codex-security-pr-${{ github.event.pull_request.number }}-${{ github.run_id }}
cancel-in-progress: true
jobs:
security:
- if: github.event.pull_request.head.repo.full_name == github.repository
- name: Codex Security
+ if: >-
+ github.event.pull_request.head.repo.full_name == github.repository &&
+ (github.event.action != 'edited' || github.event.changes.base != null)
+ name: Scan changes
runs-on: ubuntu-24.04
timeout-minutes: 60
+ outputs:
+ scan-status: ${{ steps.security.outputs.scan-status }}
+ skip-reason: ${{ steps.security.outputs.skip-reason }}
steps:
- # Configure Bubblewrap and AppArmor so Codex Security can run safely in its sandbox.
- - name: Set up the Ubuntu sandbox
+ - &verify-current-pr
+ name: Verify the PR still matches this scan
+ env:
+ GH_TOKEN: ${{ github.token }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
+ PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
- sudo apt-get update
- sudo apt-get install --yes bubblewrap apparmor-profiles
- sudo apparmor_parser -r /usr/share/apparmor/extra-profiles/bwrap-userns-restrict
+ current=$(gh api --hostname "${GITHUB_SERVER_URL#https://}" "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER" --jq '[.head.sha, .base.ref, .base.sha] | @tsv')
+ expected=$(printf '%s\t%s\t%s' "$PR_HEAD_SHA" "$PR_BASE_REF" "$PR_BASE_SHA")
+ if [ "$current" != "$expected" ]; then
+ echo 'The PR head or target changed. Run the workflow for the current PR snapshot.' >&2
+ exit 1
+ fi
+ base_ref=$(printf '%s' "$PR_BASE_REF" | jq -sRr @uri)
+ live_base=$(gh api --hostname "${GITHUB_SERVER_URL#https://}" "repos/$GITHUB_REPOSITORY/git/ref/heads/$base_ref" --jq '.object.sha')
+ if [ "$live_base" != "$PR_BASE_SHA" ]; then
+ echo 'The PR head or target changed. Run the workflow for the current PR snapshot.' >&2
+ exit 1
+ fi
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.sha }}
@@ -294,15 +352,56 @@ jobs:
uses: openai/codex-security@REPLACE_WITH_REVIEWED_COMMIT
with:
scope: diff
- model: gpt-5.6-luna
- effort: medium
+ model: gpt-5.6-sol
+ effort: high
+ max-cost: "5"
fail-on-severity: high
env:
OPENAI_API_KEY: ${{ secrets.CODEX_SECURITY_API_KEY }}
+
+ required-review:
+ name: ${{ github.event.action == 'edited' && github.event.changes.base == null && 'metadata / ' || '' }}Codex Security / ${{ github.event.pull_request.base.ref }}
+ needs: security
+ if: always() && (github.event.action != 'edited' || github.event.changes.base != null)
+ runs-on: ubuntu-24.04
+ steps:
+ - *verify-current-pr
+ - name: Require a completed review or an empty diff
+ env:
+ SCAN_JOB_RESULT: ${{ needs.security.result }}
+ SCAN_STATUS: ${{ needs.security.outputs.scan-status }}
+ SKIP_REASON: ${{ needs.security.outputs.skip-reason }}
+ run: |
+ test "$SCAN_JOB_RESULT" = success
+ if [ "$SCAN_STATUS" = completed ]; then
+ exit 0
+ fi
+ test "$SCAN_STATUS" = skipped
+ test "$SKIP_REASON" = empty-diff
```
-This job fails on reported high or critical findings, or on scanner and required
-reporting errors. File and line annotations are enabled by default.
+
+
+The scan job fails on high or critical findings, scanner errors, or required
+reporting errors. After a failure, a later step with `if: failure()` in the same
+job can read any validated reports through the Action outputs. Set
+`upload-artifacts: 'true'` to make those reports downloadable after the job ends.
+File and line annotations are enabled by default.
+
+The repository workflow above reruns when a PR's base branch changes, even when
+the head commit is unchanged. Title and body edits skip the scan and use a
+separate concurrency group and check name, preserving the active scan and its
+required **Codex Security** result.
+
+For `pull_request`, GitHub runs required ruleset workflows on `opened`,
+`synchronize`, and `reopened`. After retargeting a PR covered by that rule, push
+a new commit or close and reopen the PR to scan the new base.
+See [GitHub's supported ruleset triggers](https://docs.github.com/en/enterprise-cloud@latest/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#supported-event-triggers).
+
+For scan-triggering events, the separate **Codex Security** job runs even if the
+scan job is skipped. It passes only after a successful scan job that reports a completed scan or a
+verified empty diff. A dry run, cancellation, or skipped scan job fails this
+required check.
Use PR scanning for trusted contributors with branches in the calling repository.
To scan Dependabot PRs, also configure `CODEX_SECURITY_API_KEY` as a
@@ -310,9 +409,10 @@ To scan Dependabot PRs, also configure `CODEX_SECURITY_API_KEY` as a
The same workflow uses that secret for Dependabot runs and the Actions secret for
other runs. Missing credentials fail with setup guidance.
-Fork PRs are skipped by this example. GitHub treats skipped jobs as successful
-for required checks; skipped does not mean scanned. `pull_request_target` and
-`workflow_run` are not supported.
+The scan job skips fork PRs, so the required check fails for those PRs. Repositories
+accepting fork contributions need an approved review process for them before
+using this check as a merge requirement. `pull_request_target` and `workflow_run`
+are not supported.
The scanner uses applicable `SECURITY.md` guidance from the checked-out revision,
including policy changes in the PR. Review those changes alongside the code.
@@ -326,27 +426,33 @@ Keep unrelated credentials and deployment steps in separate jobs.
Names such as `src/[slug]/page.tsx` are literal paths; glob characters are not expanded.
This requires repository scope.
- For diff scans outside PR events, set `diff-base`.
-- Set `dry-run: 'true'` to check configuration without an API key or model calls.
- Use a separate setup job; dry-run does not assess code or verify model access.
+- Set `dry-run: 'true'` with `fail-on-severity: none` to check configuration and
+ sandbox startup without an API key or model calls. Use a separate setup job;
+ dry-run does not assess code or verify model access.
For a Deep scan of a repository or selected paths, add these inputs to the scan step:
```yaml
with:
mode: deep
- max-time-hours: "2"
+ max-time-hours: "1"
```
Deep mode does not support diff scans. `max-time-hours` limits Deep discovery;
finalization can take additional time. It is unset by default, which uses the
CLI's default of 96 hours. Set an explicit budget for Deep scans that leaves
-room for finalization within your job timeout.
+room for finalization within your job timeout. The one-hour discovery budget
+above leaves time for setup and finalization within the repository workflow's
+two-hour job timeout.
## Reports
-The Action writes a job summary and source annotations. Set
-`upload-artifacts: 'true'` for downloadable reports, retained for seven days by
-default. Reports can contain source code and vulnerability details.
+The Action lists the highest-severity findings first in the job summary and
+source annotations, preserving scan order within each severity level. Set
+`upload-artifacts: 'true'` to upload full reports and link them from the summary.
+Anyone signed in to GitHub with read access to the repository can download the
+reports, which can contain source code and vulnerability details. Set
+`retention-days` to change the default of seven days.
The job summary includes the configured provider, reported input/cached/output
token usage, and estimated USD cost, including a range when supplied by the CLI.
@@ -360,7 +466,7 @@ are report-only; scanner and required reporting failures still fail the job.
A completed scan means the configured analysis produced a valid result. Scope
exclusions, deferred investigations, and other coverage notes remain in the
-coverage report; they do not create a separate scan outcome or bypass the
+review notes, they do not create a separate scan outcome or bypass the
findings policy. Completion does not certify that every vulnerability was found.
The Action follows the CLI outcome consistently:
@@ -371,8 +477,14 @@ The Action follows the CLI outcome consistently:
| `1` | `scan-status: completed`, `policy-status: failed`; the step fails on findings. |
| `2` or an interrupted process | `scan-status: failed`, `policy-status: not-evaluated`; the step fails. |
-Usable reports retained after an execution failure remain available, but are not
-eligible for SARIF upload. Invalid or missing required reports, a changed
+A verified empty diff succeeds with `scan-status: skipped` and
+`skip-reason: empty-diff`, including when a severity threshold is configured.
+A dry run checks local setup and requires `fail-on-severity: none`.
+Use the [required PR check](#scan-pull-requests) to handle skipped scan jobs as
+well as the Action's own results.
+
+After an execution failure, the Action returns paths to usable reports and sets
+`sarif-upload-ready: false`. Invalid or missing required reports, a changed
checkout, and requested artifact-upload or runtime-cleanup failures also fail
the step. Empty diffs and dry runs use `scan-status: skipped`.
@@ -385,8 +497,10 @@ artifact upload that fails still fails the job.
### GitHub code scanning
Grant the job `security-events: write` and, for private repositories,
-`actions: read`, alongside `contents: read`. Set `id: security` on the scan step,
-then add this step after it:
+`actions: read`, alongside `contents: read`. When extending the pull-request
+workflow, retain `pull-requests: read` in the job's permissions map for its
+snapshot checks; a job-level map replaces the workflow-level permissions.
+Set `id: security` on the scan step, then add this step after it:
```yaml
- name: Upload security findings
@@ -410,12 +524,10 @@ for code scanning availability and permissions.
## Runtime
The Action installs a pinned CLI release from npm using a committed dependency
-lock. It runs on Linux x64 with Node 24 and Python 3.11 or later; the Ubuntu 24.04
-runner supplies Node and Python. The setup step above installs Bubblewrap and
-loads Ubuntu's `bwrap-userns-restrict` AppArmor profile. This profile lets
-Bubblewrap create the sandbox's user namespace and denies capabilities to its
-child processes. It is loaded into the running kernel for the job's runner.
-Codex uses the system Bubblewrap from `PATH`.
+lock. It runs on Linux x64 with Node 24 and Python 3.11 or later.
+GitHub-hosted Ubuntu 24.04 VMs supply Node and Python. Codex uses the system
+Bubblewrap from `PATH`; see [Ubuntu sandbox setup](#ubuntu-sandbox-setup) for VM
+setup and requirements for self-hosted runners and job containers.
npm and Python are found on the runner's `PATH`; `actions/setup-node` and `actions/setup-python` can select installations.
Python helpers preserve the selected virtual environment and library settings.
@@ -451,20 +563,31 @@ and artifact uploads retain their existing controls.
- **Authentication errors:** for OpenAI, check the repository secret and model access.
For Bedrock, check the AWS identity, session expiry, region, and permission to
invoke the exact model ID.
-- **Sandbox startup errors:** on Ubuntu 24.04, include the sandbox setup step
- shown above. Installing Bubblewrap alone does not load the AppArmor profile.
- A `bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted` error means
- the sandbox could not configure its network namespace. Check that the profile
- loaded successfully before running the Action.
+- **Sandbox startup errors:** for jobs running directly on GitHub-hosted Ubuntu
+ 24.04 VMs, inspect the package-install and AppArmor diagnostics. On self-hosted
+ runners and in job containers, configure the sandbox before running the Action.
+ Installing Bubblewrap alone does not load Ubuntu's required AppArmor profile.
- **Missing SARIF uploads:** inspect `scan-status`, `report-status`, and
`sarif-upload-ready`.
- **Failed scans:** inspect the CLI diagnostics for execution errors. Scope
- exclusions and deferred investigations in the coverage report do not cause
+ exclusions and deferred investigations in the review notes do not cause
execution failures or bypass the severity policy.
CLI diagnostics stream by default. Set `verbose: 'false'` for lifecycle and
elapsed-time messages only.
+## Upgrading from Action 0.2.0
+
+`dry-run: 'true'` now requires `fail-on-severity: none`; put configuration checks
+in a separate job. A dry run does not perform the security review required
+by a severity-enforcing job.
+
+Once your Action pin includes automatic sandbox setup, remove the manual
+Bubblewrap/AppArmor step from jobs running directly on GitHub-hosted Ubuntu
+24.04 VMs. Self-hosted runners and job containers still require a preconfigured sandbox.
+
+The workflow examples use a model and cost limit supported by the pinned CLI.
+
## Development
From the repository root, use Node.js 24 to check the committed files and audit
@@ -477,10 +600,11 @@ npm --prefix github-action audit --audit-level=high
npm --prefix github-action/runtime audit --omit=dev --audit-level=high
```
-After changing Action inputs or outputs, run `npm --prefix github-action run docs`
-to regenerate the README reference. After changing bundled source or the runtime
-lock, run `npm --prefix github-action run build`. Review the generated README and
-`dist/*.cjs` changes, rerun validation, and commit them with their source changes.
+After editing Action inputs, outputs, or the workflows in `examples/*.yml`, run
+`npm --prefix github-action run docs` to regenerate the README. After changing
+bundled source or the runtime lock, run `npm --prefix github-action run build`.
+Review the generated README and `dist/*.cjs` changes, rerun validation, and
+commit them with their source changes.
On Linux x64 with a working sandbox, run the published CLI integration and
packaged smoke tests.
@@ -532,10 +656,10 @@ Inputs are strings. Quote booleans and use newline-separated literal paths for l
| `max-time-hours` | Unset | Positive Deep discovery duration in hours, up to 96. Unset uses the CLI default. Finalization and job timeout are separate. |
| `fail-on-severity` | `none` | none, low, medium, high, or critical. Fails on reported findings at or above the selected severity. Scanner and required reporting errors also fail. |
| `verbose` | `true` | Stream CLI diagnostics to the job log. Set false for lifecycle and elapsed-time messages only. |
-| `dry-run` | `false` | Validate local configuration without a scan or API key. Does not verify authentication or model access. Use a separate non-required job. |
+| `dry-run` | `false` | Validate local configuration without a scan or API key. Does not verify authentication or model access. Requires fail-on-severity: none; use a separate non-required job. |
| `summary` | `true` | Write a human-readable job summary. |
| `annotations` | `true` | Emit up to 50 source finding annotations; complete findings remain in reports. |
-| `upload-artifacts` | `false` | Upload an allowlist of validated reports. Reports may contain source and vulnerability details. |
+| `upload-artifacts` | `false` | Upload an allowlist of validated reports and link the artifact in the job summary. Reports may contain source and vulnerability details. |
| `artifact-name` | `codex-security` | Report artifact name; choose distinct names for matrix jobs and multiple invocations. |
| `retention-days` | `7` | Artifact retention, 1–90 days (subject to repository limits). |
@@ -547,7 +671,8 @@ All outputs are strings. An empty cost or count means unavailable, not zero.
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `sarif-path` | Absolute validated SARIF file path, or empty when unavailable or withheld. |
| `json-path` | Absolute canonical findings JSON path, or empty when unavailable or withheld. |
-| `coverage-path` | Absolute coverage JSON path, or empty when unavailable or withheld. |
+| `manifest-path` | Absolute scan manifest path, including scan status and scope, or empty when unavailable or withheld. |
+| `coverage-path` | Legacy coverage JSON path. Empty for current CLI results. |
| `results-directory` | Runner-local reports directory; do not upload it recursively. |
| `scan-status` | completed, failed, or skipped. Completed means analysis produced a valid result. Skipped is reserved for empty diffs or dry-run. |
| `skip-reason` | empty-diff or dry-run when no scan ran; otherwise empty. |
diff --git a/github-action/dist/index.cjs b/github-action/dist/index.cjs
index 31252a732..71eb91216 100644
--- a/github-action/dist/index.cjs
+++ b/github-action/dist/index.cjs
@@ -25703,13 +25703,13 @@ var require_minimatch = __commonJS({
var require_readdir_glob = __commonJS({
"node_modules/readdir-glob/index.js"(exports2, module2) {
module2.exports = readdirGlob;
- var fs8 = require("fs");
+ var fs9 = require("fs");
var { EventEmitter: EventEmitter3 } = require("events");
var { Minimatch } = require_minimatch();
var { resolve: resolve7 } = require("path");
function readdir2(dir, strict) {
return new Promise((resolve8, reject) => {
- fs8.readdir(dir, { withFileTypes: true }, (err, files) => {
+ fs9.readdir(dir, { withFileTypes: true }, (err, files) => {
if (err) {
switch (err.code) {
case "ENOTDIR":
@@ -25742,7 +25742,7 @@ var require_readdir_glob = __commonJS({
}
function stat2(file, followSymlinks) {
return new Promise((resolve8, reject) => {
- const statFunc = followSymlinks ? fs8.stat : fs8.lstat;
+ const statFunc = followSymlinks ? fs9.stat : fs9.lstat;
statFunc(file, (err, stats) => {
if (err) {
switch (err.code) {
@@ -27807,54 +27807,54 @@ var require_polyfills = __commonJS({
}
var chdir;
module2.exports = patch;
- function patch(fs8) {
+ function patch(fs9) {
if (constants4.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
- patchLchmod(fs8);
+ patchLchmod(fs9);
}
- if (!fs8.lutimes) {
- patchLutimes(fs8);
+ if (!fs9.lutimes) {
+ patchLutimes(fs9);
}
- fs8.chown = chownFix(fs8.chown);
- fs8.fchown = chownFix(fs8.fchown);
- fs8.lchown = chownFix(fs8.lchown);
- fs8.chmod = chmodFix(fs8.chmod);
- fs8.fchmod = chmodFix(fs8.fchmod);
- fs8.lchmod = chmodFix(fs8.lchmod);
- fs8.chownSync = chownFixSync(fs8.chownSync);
- fs8.fchownSync = chownFixSync(fs8.fchownSync);
- fs8.lchownSync = chownFixSync(fs8.lchownSync);
- fs8.chmodSync = chmodFixSync(fs8.chmodSync);
- fs8.fchmodSync = chmodFixSync(fs8.fchmodSync);
- fs8.lchmodSync = chmodFixSync(fs8.lchmodSync);
- fs8.stat = statFix(fs8.stat);
- fs8.fstat = statFix(fs8.fstat);
- fs8.lstat = statFix(fs8.lstat);
- fs8.statSync = statFixSync(fs8.statSync);
- fs8.fstatSync = statFixSync(fs8.fstatSync);
- fs8.lstatSync = statFixSync(fs8.lstatSync);
- if (fs8.chmod && !fs8.lchmod) {
- fs8.lchmod = function(path6, mode, cb) {
+ fs9.chown = chownFix(fs9.chown);
+ fs9.fchown = chownFix(fs9.fchown);
+ fs9.lchown = chownFix(fs9.lchown);
+ fs9.chmod = chmodFix(fs9.chmod);
+ fs9.fchmod = chmodFix(fs9.fchmod);
+ fs9.lchmod = chmodFix(fs9.lchmod);
+ fs9.chownSync = chownFixSync(fs9.chownSync);
+ fs9.fchownSync = chownFixSync(fs9.fchownSync);
+ fs9.lchownSync = chownFixSync(fs9.lchownSync);
+ fs9.chmodSync = chmodFixSync(fs9.chmodSync);
+ fs9.fchmodSync = chmodFixSync(fs9.fchmodSync);
+ fs9.lchmodSync = chmodFixSync(fs9.lchmodSync);
+ fs9.stat = statFix(fs9.stat);
+ fs9.fstat = statFix(fs9.fstat);
+ fs9.lstat = statFix(fs9.lstat);
+ fs9.statSync = statFixSync(fs9.statSync);
+ fs9.fstatSync = statFixSync(fs9.fstatSync);
+ fs9.lstatSync = statFixSync(fs9.lstatSync);
+ if (fs9.chmod && !fs9.lchmod) {
+ fs9.lchmod = function(path6, mode, cb) {
if (cb) process.nextTick(cb);
};
- fs8.lchmodSync = function() {
+ fs9.lchmodSync = function() {
};
}
- if (fs8.chown && !fs8.lchown) {
- fs8.lchown = function(path6, uid, gid, cb) {
+ if (fs9.chown && !fs9.lchown) {
+ fs9.lchown = function(path6, uid, gid, cb) {
if (cb) process.nextTick(cb);
};
- fs8.lchownSync = function() {
+ fs9.lchownSync = function() {
};
}
if (platform2 === "win32") {
- fs8.rename = typeof fs8.rename !== "function" ? fs8.rename : (function(fs$rename) {
+ fs9.rename = typeof fs9.rename !== "function" ? fs9.rename : (function(fs$rename) {
function rename2(from, to, cb) {
var start = Date.now();
var backoff = 0;
fs$rename(from, to, function CB(er) {
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
setTimeout(function() {
- fs8.stat(to, function(stater, st) {
+ fs9.stat(to, function(stater, st) {
if (stater && stater.code === "ENOENT")
fs$rename(from, to, CB);
else
@@ -27870,9 +27870,9 @@ var require_polyfills = __commonJS({
}
if (Object.setPrototypeOf) Object.setPrototypeOf(rename2, fs$rename);
return rename2;
- })(fs8.rename);
+ })(fs9.rename);
}
- fs8.read = typeof fs8.read !== "function" ? fs8.read : (function(fs$read) {
+ fs9.read = typeof fs9.read !== "function" ? fs9.read : (function(fs$read) {
function read(fd, buffer2, offset, length, position, callback_) {
var callback;
if (callback_ && typeof callback_ === "function") {
@@ -27880,22 +27880,22 @@ var require_polyfills = __commonJS({
callback = function(er, _2, __) {
if (er && er.code === "EAGAIN" && eagCounter < 10) {
eagCounter++;
- return fs$read.call(fs8, fd, buffer2, offset, length, position, callback);
+ return fs$read.call(fs9, fd, buffer2, offset, length, position, callback);
}
callback_.apply(this, arguments);
};
}
- return fs$read.call(fs8, fd, buffer2, offset, length, position, callback);
+ return fs$read.call(fs9, fd, buffer2, offset, length, position, callback);
}
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
return read;
- })(fs8.read);
- fs8.readSync = typeof fs8.readSync !== "function" ? fs8.readSync : /* @__PURE__ */ (function(fs$readSync) {
+ })(fs9.read);
+ fs9.readSync = typeof fs9.readSync !== "function" ? fs9.readSync : /* @__PURE__ */ (function(fs$readSync) {
return function(fd, buffer2, offset, length, position) {
var eagCounter = 0;
while (true) {
try {
- return fs$readSync.call(fs8, fd, buffer2, offset, length, position);
+ return fs$readSync.call(fs9, fd, buffer2, offset, length, position);
} catch (er) {
if (er.code === "EAGAIN" && eagCounter < 10) {
eagCounter++;
@@ -27905,10 +27905,10 @@ var require_polyfills = __commonJS({
}
}
};
- })(fs8.readSync);
- function patchLchmod(fs9) {
- fs9.lchmod = function(path6, mode, callback) {
- fs9.open(
+ })(fs9.readSync);
+ function patchLchmod(fs10) {
+ fs10.lchmod = function(path6, mode, callback) {
+ fs10.open(
path6,
constants4.O_WRONLY | constants4.O_SYMLINK,
mode,
@@ -27917,80 +27917,80 @@ var require_polyfills = __commonJS({
if (callback) callback(err);
return;
}
- fs9.fchmod(fd, mode, function(err2) {
- fs9.close(fd, function(err22) {
+ fs10.fchmod(fd, mode, function(err2) {
+ fs10.close(fd, function(err22) {
if (callback) callback(err2 || err22);
});
});
}
);
};
- fs9.lchmodSync = function(path6, mode) {
- var fd = fs9.openSync(path6, constants4.O_WRONLY | constants4.O_SYMLINK, mode);
+ fs10.lchmodSync = function(path6, mode) {
+ var fd = fs10.openSync(path6, constants4.O_WRONLY | constants4.O_SYMLINK, mode);
var threw = true;
var ret;
try {
- ret = fs9.fchmodSync(fd, mode);
+ ret = fs10.fchmodSync(fd, mode);
threw = false;
} finally {
if (threw) {
try {
- fs9.closeSync(fd);
+ fs10.closeSync(fd);
} catch (er) {
}
} else {
- fs9.closeSync(fd);
+ fs10.closeSync(fd);
}
}
return ret;
};
}
- function patchLutimes(fs9) {
- if (constants4.hasOwnProperty("O_SYMLINK") && fs9.futimes) {
- fs9.lutimes = function(path6, at, mt, cb) {
- fs9.open(path6, constants4.O_SYMLINK, function(er, fd) {
+ function patchLutimes(fs10) {
+ if (constants4.hasOwnProperty("O_SYMLINK") && fs10.futimes) {
+ fs10.lutimes = function(path6, at, mt, cb) {
+ fs10.open(path6, constants4.O_SYMLINK, function(er, fd) {
if (er) {
if (cb) cb(er);
return;
}
- fs9.futimes(fd, at, mt, function(er2) {
- fs9.close(fd, function(er22) {
+ fs10.futimes(fd, at, mt, function(er2) {
+ fs10.close(fd, function(er22) {
if (cb) cb(er2 || er22);
});
});
});
};
- fs9.lutimesSync = function(path6, at, mt) {
- var fd = fs9.openSync(path6, constants4.O_SYMLINK);
+ fs10.lutimesSync = function(path6, at, mt) {
+ var fd = fs10.openSync(path6, constants4.O_SYMLINK);
var ret;
var threw = true;
try {
- ret = fs9.futimesSync(fd, at, mt);
+ ret = fs10.futimesSync(fd, at, mt);
threw = false;
} finally {
if (threw) {
try {
- fs9.closeSync(fd);
+ fs10.closeSync(fd);
} catch (er) {
}
} else {
- fs9.closeSync(fd);
+ fs10.closeSync(fd);
}
}
return ret;
};
- } else if (fs9.futimes) {
- fs9.lutimes = function(_a, _b, _c, cb) {
+ } else if (fs10.futimes) {
+ fs10.lutimes = function(_a, _b, _c, cb) {
if (cb) process.nextTick(cb);
};
- fs9.lutimesSync = function() {
+ fs10.lutimesSync = function() {
};
}
}
function chmodFix(orig) {
if (!orig) return orig;
return function(target, mode, cb) {
- return orig.call(fs8, target, mode, function(er) {
+ return orig.call(fs9, target, mode, function(er) {
if (chownErOk(er)) er = null;
if (cb) cb.apply(this, arguments);
});
@@ -28000,7 +28000,7 @@ var require_polyfills = __commonJS({
if (!orig) return orig;
return function(target, mode) {
try {
- return orig.call(fs8, target, mode);
+ return orig.call(fs9, target, mode);
} catch (er) {
if (!chownErOk(er)) throw er;
}
@@ -28009,7 +28009,7 @@ var require_polyfills = __commonJS({
function chownFix(orig) {
if (!orig) return orig;
return function(target, uid, gid, cb) {
- return orig.call(fs8, target, uid, gid, function(er) {
+ return orig.call(fs9, target, uid, gid, function(er) {
if (chownErOk(er)) er = null;
if (cb) cb.apply(this, arguments);
});
@@ -28019,7 +28019,7 @@ var require_polyfills = __commonJS({
if (!orig) return orig;
return function(target, uid, gid) {
try {
- return orig.call(fs8, target, uid, gid);
+ return orig.call(fs9, target, uid, gid);
} catch (er) {
if (!chownErOk(er)) throw er;
}
@@ -28039,13 +28039,13 @@ var require_polyfills = __commonJS({
}
if (cb) cb.apply(this, arguments);
}
- return options ? orig.call(fs8, target, options, callback) : orig.call(fs8, target, callback);
+ return options ? orig.call(fs9, target, options, callback) : orig.call(fs9, target, callback);
};
}
function statFixSync(orig) {
if (!orig) return orig;
return function(target, options) {
- var stats = options ? orig.call(fs8, target, options) : orig.call(fs8, target);
+ var stats = options ? orig.call(fs9, target, options) : orig.call(fs9, target);
if (stats) {
if (stats.uid < 0) stats.uid += 4294967296;
if (stats.gid < 0) stats.gid += 4294967296;
@@ -28074,7 +28074,7 @@ var require_legacy_streams = __commonJS({
"node_modules/graceful-fs/legacy-streams.js"(exports2, module2) {
var Stream2 = require("stream").Stream;
module2.exports = legacy;
- function legacy(fs8) {
+ function legacy(fs9) {
return {
ReadStream,
WriteStream
@@ -28117,7 +28117,7 @@ var require_legacy_streams = __commonJS({
});
return;
}
- fs8.open(this.path, this.flags, this.mode, function(err, fd) {
+ fs9.open(this.path, this.flags, this.mode, function(err, fd) {
if (err) {
self2.emit("error", err);
self2.readable = false;
@@ -28156,7 +28156,7 @@ var require_legacy_streams = __commonJS({
this.busy = false;
this._queue = [];
if (this.fd === null) {
- this._open = fs8.open;
+ this._open = fs9.open;
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
this.flush();
}
@@ -28191,7 +28191,7 @@ var require_clone = __commonJS({
// node_modules/graceful-fs/graceful-fs.js
var require_graceful_fs = __commonJS({
"node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
- var fs8 = require("fs");
+ var fs9 = require("fs");
var polyfills = require_polyfills();
var legacy = require_legacy_streams();
var clone = require_clone();
@@ -28223,12 +28223,12 @@ var require_graceful_fs = __commonJS({
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
console.error(m);
};
- if (!fs8[gracefulQueue]) {
+ if (!fs9[gracefulQueue]) {
queue = global[gracefulQueue] || [];
- publishQueue(fs8, queue);
- fs8.close = (function(fs$close) {
+ publishQueue(fs9, queue);
+ fs9.close = (function(fs$close) {
function close(fd, cb) {
- return fs$close.call(fs8, fd, function(err) {
+ return fs$close.call(fs9, fd, function(err) {
if (!err) {
resetQueue();
}
@@ -28240,40 +28240,40 @@ var require_graceful_fs = __commonJS({
value: fs$close
});
return close;
- })(fs8.close);
- fs8.closeSync = (function(fs$closeSync) {
+ })(fs9.close);
+ fs9.closeSync = (function(fs$closeSync) {
function closeSync(fd) {
- fs$closeSync.apply(fs8, arguments);
+ fs$closeSync.apply(fs9, arguments);
resetQueue();
}
Object.defineProperty(closeSync, previousSymbol, {
value: fs$closeSync
});
return closeSync;
- })(fs8.closeSync);
+ })(fs9.closeSync);
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
process.on("exit", function() {
- debug2(fs8[gracefulQueue]);
- require("assert").equal(fs8[gracefulQueue].length, 0);
+ debug2(fs9[gracefulQueue]);
+ require("assert").equal(fs9[gracefulQueue].length, 0);
});
}
}
var queue;
if (!global[gracefulQueue]) {
- publishQueue(global, fs8[gracefulQueue]);
+ publishQueue(global, fs9[gracefulQueue]);
}
- module2.exports = patch(clone(fs8));
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs8.__patched) {
- module2.exports = patch(fs8);
- fs8.__patched = true;
+ module2.exports = patch(clone(fs9));
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs9.__patched) {
+ module2.exports = patch(fs9);
+ fs9.__patched = true;
}
- function patch(fs9) {
- polyfills(fs9);
- fs9.gracefulify = patch;
- fs9.createReadStream = createReadStream2;
- fs9.createWriteStream = createWriteStream2;
- var fs$readFile = fs9.readFile;
- fs9.readFile = readFile4;
+ function patch(fs10) {
+ polyfills(fs10);
+ fs10.gracefulify = patch;
+ fs10.createReadStream = createReadStream2;
+ fs10.createWriteStream = createWriteStream2;
+ var fs$readFile = fs10.readFile;
+ fs10.readFile = readFile4;
function readFile4(path6, options, cb) {
if (typeof options === "function")
cb = options, options = null;
@@ -28289,8 +28289,8 @@ var require_graceful_fs = __commonJS({
});
}
}
- var fs$writeFile = fs9.writeFile;
- fs9.writeFile = writeFile4;
+ var fs$writeFile = fs10.writeFile;
+ fs10.writeFile = writeFile4;
function writeFile4(path6, data, options, cb) {
if (typeof options === "function")
cb = options, options = null;
@@ -28306,9 +28306,9 @@ var require_graceful_fs = __commonJS({
});
}
}
- var fs$appendFile = fs9.appendFile;
+ var fs$appendFile = fs10.appendFile;
if (fs$appendFile)
- fs9.appendFile = appendFile2;
+ fs10.appendFile = appendFile2;
function appendFile2(path6, data, options, cb) {
if (typeof options === "function")
cb = options, options = null;
@@ -28324,9 +28324,9 @@ var require_graceful_fs = __commonJS({
});
}
}
- var fs$copyFile = fs9.copyFile;
+ var fs$copyFile = fs10.copyFile;
if (fs$copyFile)
- fs9.copyFile = copyFile3;
+ fs10.copyFile = copyFile3;
function copyFile3(src, dest, flags, cb) {
if (typeof flags === "function") {
cb = flags;
@@ -28344,8 +28344,8 @@ var require_graceful_fs = __commonJS({
});
}
}
- var fs$readdir = fs9.readdir;
- fs9.readdir = readdir2;
+ var fs$readdir = fs10.readdir;
+ fs10.readdir = readdir2;
var noReaddirOptionVersions = /^v[0-5]\./;
function readdir2(path6, options, cb) {
if (typeof options === "function")
@@ -28386,21 +28386,21 @@ var require_graceful_fs = __commonJS({
}
}
if (process.version.substr(0, 4) === "v0.8") {
- var legStreams = legacy(fs9);
+ var legStreams = legacy(fs10);
ReadStream = legStreams.ReadStream;
WriteStream = legStreams.WriteStream;
}
- var fs$ReadStream = fs9.ReadStream;
+ var fs$ReadStream = fs10.ReadStream;
if (fs$ReadStream) {
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
ReadStream.prototype.open = ReadStream$open;
}
- var fs$WriteStream = fs9.WriteStream;
+ var fs$WriteStream = fs10.WriteStream;
if (fs$WriteStream) {
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
WriteStream.prototype.open = WriteStream$open;
}
- Object.defineProperty(fs9, "ReadStream", {
+ Object.defineProperty(fs10, "ReadStream", {
get: function() {
return ReadStream;
},
@@ -28410,7 +28410,7 @@ var require_graceful_fs = __commonJS({
enumerable: true,
configurable: true
});
- Object.defineProperty(fs9, "WriteStream", {
+ Object.defineProperty(fs10, "WriteStream", {
get: function() {
return WriteStream;
},
@@ -28421,7 +28421,7 @@ var require_graceful_fs = __commonJS({
configurable: true
});
var FileReadStream = ReadStream;
- Object.defineProperty(fs9, "FileReadStream", {
+ Object.defineProperty(fs10, "FileReadStream", {
get: function() {
return FileReadStream;
},
@@ -28432,7 +28432,7 @@ var require_graceful_fs = __commonJS({
configurable: true
});
var FileWriteStream = WriteStream;
- Object.defineProperty(fs9, "FileWriteStream", {
+ Object.defineProperty(fs10, "FileWriteStream", {
get: function() {
return FileWriteStream;
},
@@ -28481,13 +28481,13 @@ var require_graceful_fs = __commonJS({
});
}
function createReadStream2(path6, options) {
- return new fs9.ReadStream(path6, options);
+ return new fs10.ReadStream(path6, options);
}
function createWriteStream2(path6, options) {
- return new fs9.WriteStream(path6, options);
+ return new fs10.WriteStream(path6, options);
}
- var fs$open = fs9.open;
- fs9.open = open3;
+ var fs$open = fs10.open;
+ fs10.open = open3;
function open3(path6, flags, mode, cb) {
if (typeof mode === "function")
cb = mode, mode = null;
@@ -28503,20 +28503,20 @@ var require_graceful_fs = __commonJS({
});
}
}
- return fs9;
+ return fs10;
}
function enqueue(elem) {
debug2("ENQUEUE", elem[0].name, elem[1]);
- fs8[gracefulQueue].push(elem);
+ fs9[gracefulQueue].push(elem);
retry2();
}
var retryTimer;
function resetQueue() {
var now = Date.now();
- for (var i = 0; i < fs8[gracefulQueue].length; ++i) {
- if (fs8[gracefulQueue][i].length > 2) {
- fs8[gracefulQueue][i][3] = now;
- fs8[gracefulQueue][i][4] = now;
+ for (var i = 0; i < fs9[gracefulQueue].length; ++i) {
+ if (fs9[gracefulQueue][i].length > 2) {
+ fs9[gracefulQueue][i][3] = now;
+ fs9[gracefulQueue][i][4] = now;
}
}
retry2();
@@ -28524,9 +28524,9 @@ var require_graceful_fs = __commonJS({
function retry2() {
clearTimeout(retryTimer);
retryTimer = void 0;
- if (fs8[gracefulQueue].length === 0)
+ if (fs9[gracefulQueue].length === 0)
return;
- var elem = fs8[gracefulQueue].shift();
+ var elem = fs9[gracefulQueue].shift();
var fn = elem[0];
var args = elem[1];
var err = elem[2];
@@ -28548,7 +28548,7 @@ var require_graceful_fs = __commonJS({
debug2("RETRY", fn.name, args);
fn.apply(null, args.concat([startTime]));
} else {
- fs8[gracefulQueue].push(elem);
+ fs9[gracefulQueue].push(elem);
}
}
if (retryTimer === void 0) {
@@ -43631,8 +43631,8 @@ var require_commonjs6 = __commonJS({
*
* @internal
*/
- constructor(cwd = process.cwd(), pathImpl, sep7, { nocase, childrenCacheSize = 16 * 1024, fs: fs8 = defaultFS } = {}) {
- this.#fs = fsFromOption(fs8);
+ constructor(cwd = process.cwd(), pathImpl, sep7, { nocase, childrenCacheSize = 16 * 1024, fs: fs9 = defaultFS } = {}) {
+ this.#fs = fsFromOption(fs9);
if (cwd instanceof URL || cwd.startsWith("file://")) {
cwd = (0, node_url_1.fileURLToPath)(cwd);
}
@@ -44191,8 +44191,8 @@ var require_commonjs6 = __commonJS({
/**
* @internal
*/
- newRoot(fs8) {
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs8 });
+ newRoot(fs9) {
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
}
/**
* Return true if the provided path string is an absolute path
@@ -44221,8 +44221,8 @@ var require_commonjs6 = __commonJS({
/**
* @internal
*/
- newRoot(fs8) {
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs8 });
+ newRoot(fs9) {
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
}
/**
* Return true if the provided path string is an absolute path
@@ -45407,7 +45407,7 @@ var require_commonjs7 = __commonJS({
// node_modules/archiver-utils/file.js
var require_file2 = __commonJS({
"node_modules/archiver-utils/file.js"(exports2, module2) {
- var fs8 = require_graceful_fs();
+ var fs9 = require_graceful_fs();
var path6 = require("path");
var flatten = require_flatten();
var difference = require_difference();
@@ -45434,7 +45434,7 @@ var require_file2 = __commonJS({
};
file.exists = function() {
var filepath = path6.join.apply(path6, arguments);
- return fs8.existsSync(filepath);
+ return fs9.existsSync(filepath);
};
file.expand = function(...args) {
var options = isPlainObject3(args[0]) ? args.shift() : {};
@@ -45452,7 +45452,7 @@ var require_file2 = __commonJS({
if (typeof options.filter === "function") {
return options.filter(filepath);
} else {
- return fs8.statSync(filepath)[options.filter]();
+ return fs9.statSync(filepath)[options.filter]();
}
} catch (e) {
return false;
@@ -45560,7 +45560,7 @@ var require_file2 = __commonJS({
// node_modules/archiver-utils/index.js
var require_archiver_utils = __commonJS({
"node_modules/archiver-utils/index.js"(exports2, module2) {
- var fs8 = require_graceful_fs();
+ var fs9 = require_graceful_fs();
var path6 = require("path");
var isStream = require_is_stream();
var lazystream = require_lazystream();
@@ -45609,7 +45609,7 @@ var require_archiver_utils = __commonJS({
};
utils.lazyReadStream = function(filepath) {
return new lazystream.Readable(function() {
- return fs8.createReadStream(filepath);
+ return fs9.createReadStream(filepath);
});
};
utils.normalizeInputSource = function(source) {
@@ -45637,7 +45637,7 @@ var require_archiver_utils = __commonJS({
callback = base;
base = dirpath;
}
- fs8.readdir(dirpath, function(err, list) {
+ fs9.readdir(dirpath, function(err, list) {
var i = 0;
var file;
var filepath;
@@ -45650,7 +45650,7 @@ var require_archiver_utils = __commonJS({
return callback(null, results);
}
filepath = path6.join(dirpath, file);
- fs8.stat(filepath, function(err2, stats) {
+ fs9.stat(filepath, function(err2, stats) {
results.push({
path: filepath,
relative: path6.relative(base, filepath).replace(/\\/g, "/"),
@@ -45712,7 +45712,7 @@ var require_error = __commonJS({
// node_modules/archiver/lib/core.js
var require_core = __commonJS({
"node_modules/archiver/lib/core.js"(exports2, module2) {
- var fs8 = require("fs");
+ var fs9 = require("fs");
var glob = require_readdir_glob();
var async = require_async();
var path6 = require("path");
@@ -45776,7 +45776,7 @@ var require_core = __commonJS({
data.sourcePath = filepath;
task.data = data;
this._entriesCount++;
- if (data.stats && data.stats instanceof fs8.Stats) {
+ if (data.stats && data.stats instanceof fs9.Stats) {
task = this._updateQueueTaskWithStats(task, data.stats);
if (task) {
if (data.stats.size) {
@@ -45947,7 +45947,7 @@ var require_core = __commonJS({
callback();
return;
}
- fs8.lstat(task.filepath, function(err, stats) {
+ fs9.lstat(task.filepath, function(err, stats) {
if (this._state.aborted) {
setImmediate(callback);
return;
@@ -45990,7 +45990,7 @@ var require_core = __commonJS({
task.data.sourceType = "buffer";
task.source = Buffer.concat([]);
} else if (stats.isSymbolicLink() && this._moduleSupports("symlink")) {
- var linkPath = fs8.readlinkSync(task.filepath);
+ var linkPath = fs9.readlinkSync(task.filepath);
var dirName = path6.dirname(task.filepath);
task.data.type = "symlink";
task.data.linkname = path6.relative(dirName, path6.resolve(dirName, linkPath));
@@ -52814,7 +52814,7 @@ var require_parser_stream = __commonJS({
var require_mkdirp = __commonJS({
"node_modules/mkdirp/index.js"(exports2, module2) {
var path6 = require("path");
- var fs8 = require("fs");
+ var fs9 = require("fs");
var _0777 = parseInt("0777", 8);
module2.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
function mkdirP(p, opts, f, made) {
@@ -52825,7 +52825,7 @@ var require_mkdirp = __commonJS({
opts = { mode: opts };
}
var mode = opts.mode;
- var xfs = opts.fs || fs8;
+ var xfs = opts.fs || fs9;
if (mode === void 0) {
mode = _0777;
}
@@ -52864,7 +52864,7 @@ var require_mkdirp = __commonJS({
opts = { mode: opts };
}
var mode = opts.mode;
- var xfs = opts.fs || fs8;
+ var xfs = opts.fs || fs9;
if (mode === void 0) {
mode = _0777;
}
@@ -52901,7 +52901,7 @@ var require_mkdirp = __commonJS({
// node_modules/unzip-stream/lib/extract.js
var require_extract2 = __commonJS({
"node_modules/unzip-stream/lib/extract.js"(exports2, module2) {
- var fs8 = require("fs");
+ var fs9 = require("fs");
var path6 = require("path");
var util3 = require("util");
var mkdirp = require_mkdirp();
@@ -52948,7 +52948,7 @@ var require_extract2 = __commonJS({
var directory = entry.isDirectory ? destPath : path6.dirname(destPath);
this.unfinishedEntries++;
var writeFileFn = function() {
- var pipedStream = fs8.createWriteStream(destPath);
+ var pipedStream = fs9.createWriteStream(destPath);
pipedStream.on("close", function() {
self2.unfinishedEntries--;
self2._notifyAwaiter();
@@ -55771,6 +55771,9 @@ function parseInputs(read, workspace) {
const maxTimeHours = num("max-time-hours", false, Number.MIN_VALUE, 96);
if (maxTimeHours !== void 0 && mode !== "deep") throw new Error("max-time-hours requires mode: deep.");
const dryRun = bool("dry-run", false);
+ const failOnSeverity = choice("fail-on-severity", ["none", "low", "medium", "high", "critical"], "none");
+ if (dryRun && failOnSeverity !== "none")
+ throw new Error("dry-run requires fail-on-severity: none. Configuration validation cannot satisfy a required security review.");
const provider = choice("provider", ["openai", "openrouter", "fireworks", "amazon-bedrock"], "openai");
const model = str("model", provider === "openai" ? "gpt-5.6-sol" : "");
const cyberAccessProgram = str("cyber-access-program") ? choice("cyber-access-program", ["standard", "daybreak_blue", "daybreak_red"], "standard") : void 0;
@@ -55786,7 +55789,7 @@ function parseInputs(read, workspace) {
effort: str("effort", "xhigh"),
maxCost: num("max-cost", false, Number.MIN_VALUE),
maxTimeHours,
- failOnSeverity: choice("fail-on-severity", ["none", "low", "medium", "high", "critical"], "none"),
+ failOnSeverity,
verbose: bool("verbose", true),
dryRun,
summary: bool("summary", true),
@@ -56070,7 +56073,7 @@ async function resolveTarget(inputs, event) {
else if (pr) diffBase = (await git(repository, ["merge-base", pr.base.sha, diffHead])).trim();
else throw new Error("diff-base is required for diff scans outside pull_request events.");
if (!SHA.test(diffBase)) throw new Error("Could not resolve the diff base. Fetch full history.");
- emptyDiff = (await gitResult(repository, ["diff", "--no-ext-diff", "--no-textconv", "--quiet", diffBase, diffHead, "--"], [0, 1])).exitCode === 0;
+ emptyDiff = (await gitResult(repository, ["diff", "--no-ext-diff", "--no-textconv", "--ignore-submodules=none", "--quiet", diffBase, diffHead, "--"], [0, 1])).exitCode === 0;
}
const analysisRef = pr ? `refs/pull/${pr.number ?? event.payload.number}/head` : event.ref;
const publishable = /^refs\/(heads|tags|pull)\//.test(analysisRef);
@@ -56078,6 +56081,7 @@ async function resolveTarget(inputs, event) {
}
// src/runtime.ts
+var import_node_fs = __toESM(require("node:fs"), 1);
var import_promises3 = require("node:fs/promises");
var import_node_path4 = require("node:path");
@@ -56218,6 +56222,87 @@ async function checkPython(pythonPath, cwd, env) {
if (result.exitCode !== 0 || result.timedOut || result.interrupted || result.signal)
throw new Error("Python 3.11 or later with sqlite3 and tomllib is required. Use actions/setup-python to select a compatible interpreter.");
}
+var SANDBOX_UNAVAILABLE_EXIT = 75;
+var SandboxUnavailableError = class extends Error {
+};
+async function ensureSandbox(options, probe, execute = runProcess) {
+ let initialError;
+ try {
+ await probe();
+ return;
+ } catch (error2) {
+ if (!(error2 instanceof SandboxUnavailableError) || options.runnerEnvironment !== "github-hosted" || options.imageOS !== "ubuntu24" || import_node_fs.default.existsSync("/.dockerenv")) throw error2;
+ initialError = error2;
+ }
+ const sudo = "/usr/bin/sudo";
+ for (const args of [
+ ["-n", "/usr/bin/apt-get", "update"],
+ // Defer only the hosted image's problematic PHP restart during this install.
+ ["-n", "/bin/sh", "-eu", "-c", String.raw`
+ if [ -d /etc/needrestart/conf.d ]; then
+ override=$(/usr/bin/mktemp /etc/needrestart/conf.d/codex-security-XXXXXX.conf)
+ trap '/usr/bin/rm -f "$override"' EXIT
+ trap 'exit 1' HUP INT TERM
+ printf '%s\n' '$nrconf{override_rc}{qr(^php8\.3-fpm\.service$)} = 0;' > "$override"
+ fi
+ /usr/bin/apt-get install --yes bubblewrap apparmor-profiles
+ `],
+ ["-n", "/usr/sbin/apparmor_parser", "-r", "/usr/share/apparmor/extra-profiles/bwrap-userns-restrict"]
+ ]) {
+ const result = await execute(sudo, args, options);
+ for (const line of safeLogLines(result.stdout)) {
+ try {
+ options.log?.(line);
+ } catch {
+ }
+ }
+ if (result.exitCode !== 0 || result.signal || result.interrupted || result.timedOut) {
+ const details = safeLogLines([result.stderr, result.stdout].join("\n")).join("\n");
+ throw new Error(`Ubuntu sandbox setup failed: sudo ${args.join(" ")} (exit ${result.exitCode}).
+${details}
+Original sandbox preflight: ${initialError.message}`, { cause: initialError });
+ }
+ }
+ await probe();
+}
+async function checkSandbox(nodePath, cliPath, options, env) {
+ const result = await runProcess(nodePath, ["--input-type=module", "--eval", `
+ import { pathToFileURL } from 'node:url';
+ import { dirname, join } from 'node:path';
+ const [cli, provider, model] = process.argv.slice(1);
+ const fromCli = file => import(pathToFileURL(join(dirname(cli), '../dist', file)).href);
+ const { parseCodexOverrides } = await fromCli('cli.js');
+ const { scanRuntimeCodexConfig } = await fromCli('api.js');
+ const { writeCodexConfig } = await fromCli('config.js');
+ const runtime = await fromCli('runtime.js');
+ const config = parseCodexOverrides(['analytics.enabled=false'], model || undefined, undefined, provider);
+ await writeCodexConfig(join(process.env.CODEX_HOME, 'config.toml'), scanRuntimeCodexConfig(config, process.env.CODEX_HOME));
+ const command = runtime.resolveCodexCommand(process.env);
+ try { await runtime.probeCodexSandbox(command, process.env); }
+ catch (error) {
+ const { SandboxUnavailableError } = await fromCli('errors.js');
+ if (!(error instanceof SandboxUnavailableError)) throw error;
+ console.error(error);
+ // The feature list loads the native configuration without starting Bubblewrap.
+ const config = await runtime.runCodexCommand(command, ['features', 'list'], process.env,
+ undefined, AbortSignal.timeout(10_000));
+ if (!config.success) {
+ console.error('Codex configuration check failed (exit ' + config.exitCode + ').');
+ if (config.stdout) console.error(config.stdout);
+ if (config.stderr) console.error(config.stderr);
+ }
+ process.exitCode = config.success ? ${SANDBOX_UNAVAILABLE_EXIT} : 1;
+ }
+ `, cliPath, options.provider, options.model], { cwd: options.repository, env });
+ const detail = result.stderr || result.stdout;
+ if (result.interrupted || result.signal || result.timedOut)
+ throw new Error(`Codex Security sandbox preflight ${result.timedOut ? "timed out" : "was interrupted"}. ${detail}`);
+ if (result.exitCode !== 0) {
+ const message = `Codex Security sandbox preflight failed. ${detail}`;
+ if (result.exitCode === SANDBOX_UNAVAILABLE_EXIT) throw new SandboxUnavailableError(message);
+ throw new Error(message);
+ }
+}
async function writeRuntimeLauncher(path6, executable, name, value) {
const quote = (value2) => "'" + value2.replaceAll("'", "'\\''") + "'";
await (0, import_promises3.writeFile)(path6, `#!/bin/sh
@@ -56265,10 +56350,21 @@ async function setupRuntime(options) {
await (0, import_promises3.writeFile)(globalConfig, "", { mode: 384, flag: "wx" });
const install = await runProcess(npmPath, ["ci", "--ignore-scripts", "--include=optional", `--registry=${REGISTRY}`, `--userconfig=${userConfig}`, `--globalconfig=${globalConfig}`, `--cache=${(0, import_node_path4.join)(root, "npm-cache")}`, "--no-audit", "--no-fund", "--loglevel=error"], { cwd: destination, env, timeoutMs: 10 * 60 * 1e3, log: options.log });
if (install.exitCode !== 0 || install.timedOut || install.interrupted) {
- for (const line of safeLogLines(install.stdout)) options.log?.(line);
- throw new Error(`Integrity-locked CLI installation failed (exit ${install.exitCode}${install.timedOut ? ", timed out" : ""}${install.interrupted ? ", interrupted" : ""}). Check the prefixed npm diagnostics, registry access, and runner prerequisites.`);
+ const details = safeLogLines([install.stderr, install.stdout].join("\n")).join("\n");
+ throw new Error(`Integrity-locked CLI installation failed (exit ${install.exitCode}${install.timedOut ? ", timed out" : ""}${install.interrupted ? ", interrupted" : ""}).
+${details}`);
}
const cliPath = await regularFile((0, import_node_path4.join)(destination, "node_modules", "@openai", "codex-security", "bin", "codex-security.mjs"));
+ if (options.model) {
+ await ensureSandbox(
+ { cwd: root, env, runnerEnvironment: process.env.RUNNER_ENVIRONMENT, imageOS: process.env.ImageOS, log: options.log },
+ () => checkSandbox(nodePath, cliPath, options, { ...env, CODEX_HOME: (0, import_node_path4.join)(root, "probe-home") })
+ );
+ try {
+ options.log?.("Codex sandbox probe succeeded without model calls.");
+ } catch {
+ }
+ }
const resultsDirectory = await (0, import_promises3.mkdtemp)((0, import_node_path4.join)(tempRoot, "codex-security-reports-"));
await (0, import_promises3.chmod)(resultsDirectory, 448);
return { ...paths, nodePath, cliPath, resultsDirectory, env: (credentials) => runtimeEnvironment(paths, credentials) };
@@ -56279,7 +56375,7 @@ async function setupRuntime(options) {
}
// src/results.ts
-var import_node_fs = require("node:fs");
+var import_node_fs2 = require("node:fs");
var import_promises4 = require("node:fs/promises");
var import_node_path5 = require("node:path");
@@ -56327,7 +56423,7 @@ async function processReportFile(root, name, adapt) {
const path6 = (0, import_node_path5.join)(absoluteRoot, name);
const before = await (0, import_promises4.lstat)(path6);
if (!before.isFile() || before.isSymbolicLink() || before.nlink !== 1) throw new Error("Report must be a regular file without links.");
- const file = await (0, import_promises4.open)(path6, (adapt ? import_node_fs.constants.O_RDWR : import_node_fs.constants.O_RDONLY) | import_node_fs.constants.O_NOFOLLOW | import_node_fs.constants.O_NONBLOCK);
+ const file = await (0, import_promises4.open)(path6, (adapt ? import_node_fs2.constants.O_RDWR : import_node_fs2.constants.O_RDONLY) | import_node_fs2.constants.O_NOFOLLOW | import_node_fs2.constants.O_NONBLOCK);
try {
const opened = await file.stat();
if (!opened.isFile() || opened.nlink !== 1 || opened.dev !== before.dev || opened.ino !== before.ino) throw new Error("Report changed while opening.");
@@ -56379,7 +56475,7 @@ async function analyzeResults(options) {
result.errors.push(value.message);
return result;
}
- if (!value?.manifest?.scan?.target || !Array.isArray(value?.findings?.findings) || !value?.coverage)
+ if (!value?.manifest?.scan?.target || !Array.isArray(value?.findings?.findings) || !(value?.review ?? value?.coverage))
throw new Error();
} catch {
result.errors.push("CLI did not return a usable JSON scan result. See the CLI diagnostics.");
@@ -56423,7 +56519,7 @@ async function analyzeResults(options) {
resultsDirectory: options.resultsDirectory,
manifestPath: (0, import_node_path5.join)(options.resultsDirectory, "scan-manifest.json"),
jsonPath: (0, import_node_path5.join)(options.resultsDirectory, "findings.json"),
- coveragePath: (0, import_node_path5.join)(options.resultsDirectory, "coverage.json"),
+ coveragePath: value.coverage ? (0, import_node_path5.join)(options.resultsDirectory, "coverage.json") : "",
sarifPath: ""
};
const warnings = value.warnings ?? [];
@@ -56526,7 +56622,7 @@ function getMaxArtifactListCount() {
}
// node_modules/@actions/artifact/lib/internal/upload/upload-artifact.js
-var fs6 = __toESM(require("fs"), 1);
+var fs7 = __toESM(require("fs"), 1);
var path4 = __toESM(require("path"), 1);
// node_modules/@actions/artifact/lib/generated/google/protobuf/timestamp.js
@@ -58586,13 +58682,13 @@ function internalArtifactTwirpClient(options) {
}
// node_modules/@actions/artifact/lib/internal/upload/upload-zip-specification.js
-var fs3 = __toESM(require("fs"), 1);
+var fs4 = __toESM(require("fs"), 1);
var import_path = require("path");
function validateRootDirectory(rootDirectory) {
- if (!fs3.existsSync(rootDirectory)) {
+ if (!fs4.existsSync(rootDirectory)) {
throw new Error(`The provided rootDirectory ${rootDirectory} does not exist`);
}
- if (!fs3.statSync(rootDirectory).isDirectory()) {
+ if (!fs4.statSync(rootDirectory).isDirectory()) {
throw new Error(`The provided rootDirectory ${rootDirectory} is not a valid directory`);
}
info(`Root directory input is valid!`);
@@ -58602,7 +58698,7 @@ function getUploadZipSpecification(filesToZip, rootDirectory) {
rootDirectory = (0, import_path.normalize)(rootDirectory);
rootDirectory = (0, import_path.resolve)(rootDirectory);
for (let file of filesToZip) {
- const stats = fs3.lstatSync(file, { throwIfNoEntry: false });
+ const stats = fs4.lstatSync(file, { throwIfNoEntry: false });
if (!stats) {
throw new Error(`File ${file} does not exist`);
}
@@ -91184,7 +91280,7 @@ var Batch = class {
};
// node_modules/@azure/storage-blob/dist/esm/utils/utils.js
-var import_node_fs2 = __toESM(require("node:fs"), 1);
+var import_node_fs3 = __toESM(require("node:fs"), 1);
var import_node_util3 = __toESM(require("node:util"), 1);
async function streamToBuffer(stream4, buffer2, offset, end, encoding) {
let pos = 0;
@@ -91227,7 +91323,7 @@ async function streamToBuffer(stream4, buffer2, offset, end, encoding) {
}
async function readStreamToLocalFile(rs, file) {
return new Promise((resolve7, reject) => {
- const ws = import_node_fs2.default.createWriteStream(file);
+ const ws = import_node_fs3.default.createWriteStream(file);
rs.on("error", (err) => {
reject(err);
});
@@ -91238,8 +91334,8 @@ async function readStreamToLocalFile(rs, file) {
rs.pipe(ws);
});
}
-var fsStat = import_node_util3.default.promisify(import_node_fs2.default.stat);
-var fsCreateReadStream = import_node_fs2.default.createReadStream;
+var fsStat = import_node_util3.default.promisify(import_node_fs3.default.stat);
+var fsCreateReadStream = import_node_fs3.default.createReadStream;
// node_modules/@azure/storage-blob/dist/esm/Clients.js
var BlobClient = class _BlobClient extends StorageClient2 {
@@ -94062,7 +94158,7 @@ var import_archiver = __toESM(require_archiver(), 1);
// node_modules/@actions/artifact/lib/internal/upload/stream.js
var stream2 = __toESM(require("stream"), 1);
-var fs5 = __toESM(require("fs"), 1);
+var fs6 = __toESM(require("fs"), 1);
var import_promises6 = require("fs/promises");
var __awaiter8 = function(thisArg, _arguments, P, generator) {
function adopt(value) {
@@ -94108,11 +94204,11 @@ function createRawFileUploadStream(filePath) {
const bufferSize = getUploadChunkSize();
const uploadStream = new WaterMarkedUploadStream(bufferSize);
let sourcePath = filePath;
- const stats = yield fs5.promises.lstat(filePath);
+ const stats = yield fs6.promises.lstat(filePath);
if (stats.isSymbolicLink()) {
sourcePath = yield (0, import_promises6.realpath)(filePath);
}
- const fileStream = fs5.createReadStream(sourcePath, {
+ const fileStream = fs6.createReadStream(sourcePath, {
highWaterMark: bufferSize
});
fileStream.on("error", (error2) => {
@@ -94312,7 +94408,7 @@ function uploadArtifact(name, files, rootDirectory, options) {
if (files.length > 1) {
throw new Error("skipArchive option is only supported when uploading a single file");
}
- if (!fs6.existsSync(files[0])) {
+ if (!fs7.existsSync(files[0])) {
throw new FilesNotFoundError(files);
}
artifactFileName = path4.basename(files[0]);
@@ -99390,7 +99486,8 @@ async function uploadReports(reports, inputs, tempRoot) {
await (0, import_promises9.writeFile)(dest, bytes, { mode: 384, flag: "wx" });
files.push(dest);
}
- await new DefaultArtifactClient().uploadArtifact(inputs.artifactName, files, staging, { retentionDays: inputs.retentionDays, compressionLevel: 0 });
+ const artifact = await new DefaultArtifactClient().uploadArtifact(inputs.artifactName, files, staging, { retentionDays: inputs.retentionDays, compressionLevel: 0 });
+ return artifact.id;
} finally {
await (0, import_promises9.rm)(staging, { recursive: true, force: true });
}
@@ -99399,7 +99496,9 @@ async function uploadReports(reports, inputs, tempRoot) {
// src/reporting.ts
function plain(value, limit) {
const text = value.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/g, "");
- return text.slice(0, limit);
+ const prefix2 = text.slice(0, limit);
+ const codePoint = text.codePointAt(prefix2.length - 1);
+ return codePoint !== void 0 && codePoint > 65535 ? prefix2.slice(0, -1) : prefix2;
}
function html(value) {
return value.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/@/g, "@").replace(/\r/g, "
").replace(/\n/g, "
").replace(/[\\`*_\[\]~]/g, (character) => `${character.charCodeAt(0)};`);
@@ -99411,7 +99510,7 @@ function resultTitle(result, inputs) {
if (inputs.failOnSeverity === "none") return "Scan completed. Findings are reported without failing the job.";
return "Scan completed. No findings meet the failure threshold.";
}
-function resultSummary(result, inputs, target) {
+function resultSummary(result, inputs, target, artifactUrl) {
const esc = (value, limit = 4e3) => html(plain(value, limit));
const counts = result.counts ? Object.entries(result.counts).map(([level, count]) => `${level}: ${count}`).join(" \xB7 ") : "unavailable";
const usage = result.usage;
@@ -99420,6 +99519,7 @@ function resultSummary(result, inputs, target) {
const cost = range2 && range2.max !== range2.min ? range2.max === null ? `$${range2.min.toFixed(4)} (upper estimate unavailable)` : `$${range2.min.toFixed(4)}\u2013$${range2.max.toFixed(4)}` : result.estimatedCost === void 0 ? "unavailable" : `$${result.estimatedCost.toFixed(4)}`;
const parts = [
`**Scan:** ${result.scanStatus} \xB7 **Findings policy:** ${result.policyStatus} \xB7 **Report:** ${result.reportStatus}`,
+ ...artifactUrl ? [`**Reports:** ${esc(inputs.artifactName)} \xB7 Retention: up to ${inputs.retentionDays} days.`] : [],
`**Findings:** ${counts}`,
`**Scope:** ${inputs.scope}${inputs.paths.length ? ` ${esc(inputs.paths.join(", "))}` : ""} \xB7 **Mode:** ${inputs.mode}`,
`**Commit:** ${target.scannedSha}`,
@@ -99440,7 +99540,7 @@ function resultSummary(result, inputs, target) {
${esc(finding.summary, 1200)}`);
}
if (result.findings.length > 30) parts.push(`${result.findings.length - 30} additional findings are available in the JSON/SARIF reports.`);
- parts.push("Use the action outputs for full JSON, coverage, and SARIF. Upload SARIF only when sarif-upload-ready is true. Reports can contain source code and vulnerability details.");
+ parts.push("Use the action outputs for full JSON and SARIF. Upload SARIF only when sarif-upload-ready is true. Reports can contain source code and vulnerability details.");
return Buffer.from(parts.join("\n\n")).subarray(0, 58e3).toString("utf8").replace(/\uFFFD$/, "");
}
function emitAnnotations(result) {
@@ -99458,9 +99558,11 @@ function emitAnnotations(result) {
}
// src/main.ts
+var SEVERITY_RANK = { critical: 0, high: 1, medium: 2, low: 3, informational: 4 };
var OUTPUT_NAMES = [
"sarif-path",
"json-path",
+ "manifest-path",
"coverage-path",
"results-directory",
"scan-status",
@@ -99497,6 +99599,7 @@ function outputs(result, target, exitCode) {
"sarif-path": result.paths.sarifPath,
"json-path": result.paths.jsonPath,
"coverage-path": result.paths.coveragePath,
+ "manifest-path": result.paths.manifestPath,
"results-directory": result.paths.resultsDirectory,
"scan-status": result.scanStatus,
"policy-status": result.policyStatus,
@@ -99552,13 +99655,13 @@ async function runAction(actionRoot, overrides = {}) {
if (!inputs.dryRun && credentials.provider !== "amazon-bedrock" && (!credentials.apiKey || /[\r\n\u0000]/.test(credentials.apiKey))) {
throw new Error(credentials.provider === "openai" ? "Set CODEX_SECURITY_API_KEY in Actions secrets (or Dependabot secrets for Dependabot runs) and pass it as OPENAI_API_KEY to this step. No scan was started." : `Pass ${API_KEY_ENVIRONMENT_VARIABLES[credentials.provider]} from Actions secrets to this step. No scan was started.`);
}
- tempRoot = await (0, import_promises10.realpath)(process.env.RUNNER_TEMP ?? "");
if (!process.env.RUNNER_TEMP) throw new Error("RUNNER_TEMP is required.");
+ tempRoot = await (0, import_promises10.realpath)(process.env.RUNNER_TEMP);
info(`Preparing Codex Security ${SUPPORTED_CLI_VERSION}. Scope: ${inputs.scope}; mode: ${inputs.mode}; effort: ${inputs.effort}.`);
const preparationStarted = performance.now();
let timer = heartbeat("CLI preparation", preparationStarted);
try {
- runtime = await deps.setupRuntime({ actionRoot, tempRoot, log: info });
+ runtime = await deps.setupRuntime({ actionRoot, tempRoot, repository: target.repository, provider: inputs.provider, model: inputs.model, log: inputs.verbose ? info : void 0 });
} finally {
clearInterval(timer);
}
@@ -99623,12 +99726,15 @@ async function runAction(actionRoot, overrides = {}) {
if (checkoutError) result.errors.unshift(checkoutError);
if (interrupted) result.errors.unshift("Scan was interrupted or exceeded its execution limit.");
let reportsValidated = false;
+ let artifactUrl;
try {
const reports = await collectReports(result);
reportsValidated = true;
if (inputs.uploadArtifacts) {
info("Uploading validated report artifacts.");
- await uploadReports(reports, inputs, tempRoot);
+ const artifactId = await uploadReports(reports, inputs, tempRoot);
+ if (artifactId !== void 0 && process.env.GITHUB_RUN_ID)
+ artifactUrl = `${event.serverUrl}/${event.repository}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${artifactId}`;
}
} catch (error2) {
result.reportStatus = "failed";
@@ -99641,8 +99747,12 @@ async function runAction(actionRoot, overrides = {}) {
info(`Findings: ${result.counts ? Object.entries(result.counts).map(([level, count]) => `${level}: ${count}`).join(", ") : "unavailable"}.`);
info(`Estimated cost: ${result.estimatedCost === void 0 ? "unavailable" : `$${result.estimatedCost.toFixed(4)}`}.`);
for (const error2 of result.errors) log2(`Report diagnostic: ${error2}`);
- finalSummary = resultSummary(result, inputs, target);
- if (inputs.annotations) emitAnnotations(result);
+ const displayResult = {
+ ...result,
+ findings: [...result.findings].sort((a, b) => SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity])
+ };
+ finalSummary = resultSummary(displayResult, inputs, target, artifactUrl);
+ if (inputs.annotations) emitAnnotations(displayResult);
success = result.reportStatus !== "failed" && result.scanStatus === "completed" && result.policyStatus === "passed";
finalTitle = resultTitle(result, inputs);
}
@@ -99664,7 +99774,7 @@ async function runAction(actionRoot, overrides = {}) {
setOutput("sarif-upload-ready", "false");
}
}
- if (inputs?.summary !== false) {
+ if (inputs?.summary ?? getInput("summary") !== "false") {
try {
await summary.addRaw(`## Codex Security
diff --git a/github-action/examples/pull-request.yml b/github-action/examples/pull-request.yml
new file mode 100644
index 000000000..9a1c4971f
--- /dev/null
+++ b/github-action/examples/pull-request.yml
@@ -0,0 +1,84 @@
+# Required-check policy prerequisites, including merge-time freshness, are in the README.
+name: Codex Security PR
+on:
+ pull_request:
+ types: [opened, synchronize, reopened, ready_for_review, edited]
+
+permissions:
+ contents: read
+ pull-requests: read
+
+concurrency:
+ # Group names are case-insensitive; the run ID also separates case-only retargets.
+ group: codex-security-pr-${{ github.event.pull_request.number }}-${{ github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ security:
+ if: >-
+ github.event.pull_request.head.repo.full_name == github.repository &&
+ (github.event.action != 'edited' || github.event.changes.base != null)
+ name: Scan changes
+ runs-on: ubuntu-24.04
+ timeout-minutes: 60
+ outputs:
+ scan-status: ${{ steps.security.outputs.scan-status }}
+ skip-reason: ${{ steps.security.outputs.skip-reason }}
+ steps:
+ - &verify-current-pr
+ name: Verify the PR still matches this scan
+ env:
+ GH_TOKEN: ${{ github.token }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
+ PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ run: |
+ current=$(gh api --hostname "${GITHUB_SERVER_URL#https://}" "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER" --jq '[.head.sha, .base.ref, .base.sha] | @tsv')
+ expected=$(printf '%s\t%s\t%s' "$PR_HEAD_SHA" "$PR_BASE_REF" "$PR_BASE_SHA")
+ if [ "$current" != "$expected" ]; then
+ echo 'The PR head or target changed. Run the workflow for the current PR snapshot.' >&2
+ exit 1
+ fi
+ base_ref=$(printf '%s' "$PR_BASE_REF" | jq -sRr @uri)
+ live_base=$(gh api --hostname "${GITHUB_SERVER_URL#https://}" "repos/$GITHUB_REPOSITORY/git/ref/heads/$base_ref" --jq '.object.sha')
+ if [ "$live_base" != "$PR_BASE_SHA" ]; then
+ echo 'The PR head or target changed. Run the workflow for the current PR snapshot.' >&2
+ exit 1
+ fi
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+ fetch-depth: 0
+ persist-credentials: false
+ - name: Scan PR changes
+ id: security
+ uses: openai/codex-security@REPLACE_WITH_REVIEWED_COMMIT
+ with:
+ scope: diff
+ model: gpt-5.6-sol
+ effort: high
+ max-cost: "5"
+ fail-on-severity: high
+ env:
+ OPENAI_API_KEY: ${{ secrets.CODEX_SECURITY_API_KEY }}
+
+ required-review:
+ name: ${{ github.event.action == 'edited' && github.event.changes.base == null && 'metadata / ' || '' }}Codex Security / ${{ github.event.pull_request.base.ref }}
+ needs: security
+ if: always() && (github.event.action != 'edited' || github.event.changes.base != null)
+ runs-on: ubuntu-24.04
+ steps:
+ - *verify-current-pr
+ - name: Require a completed review or an empty diff
+ env:
+ SCAN_JOB_RESULT: ${{ needs.security.result }}
+ SCAN_STATUS: ${{ needs.security.outputs.scan-status }}
+ SKIP_REASON: ${{ needs.security.outputs.skip-reason }}
+ run: |
+ test "$SCAN_JOB_RESULT" = success
+ if [ "$SCAN_STATUS" = completed ]; then
+ exit 0
+ fi
+ test "$SCAN_STATUS" = skipped
+ test "$SKIP_REASON" = empty-diff
diff --git a/github-action/examples/repository.yml b/github-action/examples/repository.yml
new file mode 100644
index 000000000..6624e4e47
--- /dev/null
+++ b/github-action/examples/repository.yml
@@ -0,0 +1,28 @@
+name: Codex Security repository
+on:
+ workflow_dispatch:
+ schedule:
+ - cron: "23 7 * * 1" # Mondays at 07:23 UTC
+
+permissions:
+ contents: read
+
+jobs:
+ security:
+ runs-on: ubuntu-24.04
+ timeout-minutes: 120
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ - name: Scan the repository
+ id: security
+ uses: openai/codex-security@REPLACE_WITH_REVIEWED_COMMIT
+ with:
+ scope: repository
+ model: gpt-5.6-sol
+ effort: high
+ max-cost: "5"
+ fail-on-severity: none
+ env:
+ OPENAI_API_KEY: ${{ secrets.CODEX_SECURITY_API_KEY }}
diff --git a/github-action/package-lock.json b/github-action/package-lock.json
index 47f44f525..c6bbb651e 100644
--- a/github-action/package-lock.json
+++ b/github-action/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "codex-security-action",
- "version": "0.6.0",
+ "version": "0.8.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "codex-security-action",
- "version": "0.6.0",
+ "version": "0.8.2",
"dependencies": {
"@actions/artifact": "6.3.1",
"@actions/core": "3.0.1",
diff --git a/github-action/package.json b/github-action/package.json
index 1bec738f0..646e03a6a 100644
--- a/github-action/package.json
+++ b/github-action/package.json
@@ -1,6 +1,6 @@
{
"name": "codex-security-action",
- "version": "0.6.0",
+ "version": "0.8.2",
"private": true,
"type": "module",
"description": "Run Codex Security in GitHub Actions with explicit scope, budgets, and scan health reporting",
diff --git a/github-action/runtime/package-lock.json b/github-action/runtime/package-lock.json
index 903e31188..a79e006cf 100644
--- a/github-action/runtime/package-lock.json
+++ b/github-action/runtime/package-lock.json
@@ -1201,9 +1201,9 @@
}
},
"node_modules/fast-uri": {
- "version": "3.1.8",
- "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.8.tgz",
- "integrity": "sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==",
+ "version": "3.1.9",
+ "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz",
+ "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==",
"funding": [
{
"type": "github",
diff --git a/github-action/scripts/cli-integration.ts b/github-action/scripts/cli-integration.ts
index e62524c8e..7c6e0be93 100644
--- a/github-action/scripts/cli-integration.ts
+++ b/github-action/scripts/cli-integration.ts
@@ -1,14 +1,16 @@
// Exercise the locked CLI or an installed release candidate with synthetic local requests only.
import assert from 'node:assert/strict';
import { execFile, execFileSync, spawnSync } from 'node:child_process';
+import { existsSync } from 'node:fs';
import { copyFile, mkdir, mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/promises';
import { createServer, type IncomingHttpHeaders } from 'node:http';
import { tmpdir } from 'node:os';
import { delimiter, dirname, join, resolve } from 'node:path';
import { promisify } from 'node:util';
+import { parse as parseYaml } from 'yaml';
import { parseInputs, scanArguments } from '../src/inputs.js';
import { analyzeResults } from '../src/results.js';
-import { captureRunnerPath, checkPython, resolveTool, runtimeEnvironment, writeRuntimeLauncher } from '../src/runtime.js';
+import { captureRunnerPath, checkPython, checkSandbox, resolveTool, runtimeEnvironment, SandboxUnavailableError, writeRuntimeLauncher } from '../src/runtime.js';
import runtimeManifest from '../runtime/package.json' with { type: 'json' };
const [candidatePackage, candidateVersion] = process.argv.slice(2);
@@ -57,16 +59,23 @@ try {
const cliResult = JSON.parse(stdout);
assert.equal(cliResult.turn.mock, true, 'The integration scan must remain synthetic');
assert.ok(cliResult.findings.findings.length > 0);
- // Verify native SARIF, then exercise the CLI's manual export without model calls.
assert.equal(cliResult.sarifPath, join(resultsDirectory, 'exports/results.sarif'));
- run(['export', resultsDirectory, '--export-format', 'sarif', '--source-root', repository,
- '--output', cliResult.sarifPath], 0);
+ // Analyze one native scan export untouched; exercise manual export on the other run.
+ if (threshold) {
+ await rm(cliResult.sarifPath);
+ run(['export', resultsDirectory, '--export-format', 'sarif', '--source-root', repository,
+ '--output', cliResult.sarifPath], 0);
+ }
const result = await analyzeResults({ stdout, resultsDirectory, exitCode, publishable: true, scannedSha:git('rev-parse', 'HEAD').trim() });
assert.equal(result.scanStatus, 'completed');
assert.equal(result.policyStatus, threshold ? 'failed' : 'passed');
assert.equal(result.reportStatus, 'ready');
assert.equal(result.sarifUploadReady, true);
const sarif = JSON.parse(await readFile(result.paths.sarifPath, 'utf8'));
+ const expectedIds = cliResult.findings.findings.map((finding: any) => [finding.occurrenceId, finding.ruleId]);
+ assert.ok(expectedIds.flat().every((id: unknown) => typeof id === 'string' && id.length > 0));
+ assert.deepEqual(sarif.runs.flatMap((run: any) => run.results.map((finding: any) =>
+ [finding.properties?.occurrenceId, finding.ruleId])).sort(), expectedIds.sort());
assert.ok(sarif.runs.every((run: any) => run.automationDetails === undefined),
'upload-sarif must be able to apply the workflow category to the real CLI export');
assert.equal(result.findings.length, cliResult.findings.findings.length);
@@ -82,7 +91,9 @@ try {
}
// Deep Scan cannot use --mock; validate the Action's actual arguments without model calls.
- const deepInputs: Record = {mode: 'deep', 'max-time-hours': '0.25', paths: 'example.ts', 'dry-run': 'true'};
+ // Exercise all explicit cyber programs in existing CLI preflights; the Action input
+ // tests cover forwarding every spelling in both modes.
+ const deepInputs: Record = {mode: 'deep', 'cyber-access-program': 'daybreak_blue', 'max-time-hours': '0.25', paths: 'example.ts', 'dry-run': 'true'};
const deepArguments = scanArguments(parseInputs(name => deepInputs[name] ?? '', repository),
{repository}, join(root, 'deep-results'));
const deepPreflight = JSON.parse(run(deepArguments, 0));
@@ -91,32 +102,53 @@ try {
assert.equal(deepPreflight.maxTimeHours, 0.25);
assert.deepEqual(deepPreflight.target.paths, ['example.ts']);
- // Validate explicit program selection against the locked CLI, without model calls.
- for (const mode of ['standard', 'deep']) for (const program of ['standard', 'daybreak_blue', 'daybreak_red']) {
- const values: Record = {mode, 'cyber-access-program':program, 'dry-run':'true'};
- const args = scanArguments(parseInputs(name => values[name] ?? '', repository),
- {repository}, join(root, `cyber-${mode}-${program}`));
- const preflight = JSON.parse(run(args, 0));
- assert.equal(preflight.dryRun, true);
- assert.equal(preflight.mode, mode);
+ // Validate workflow model and cost settings against both the published pin and release candidates.
+ const diffBase = git('rev-parse', 'HEAD').trim();
+ await writeFile(join(repository, 'added.ts'), 'export const added = true;\n');
+ git('add', 'added.ts'); git('commit', '-m', 'Synthetic pull request');
+ const diffHead = git('rev-parse', 'HEAD').trim();
+ for (const example of ['repository', 'pull-request']) {
+ const workflow = parseYaml(await readFile(resolve(import.meta.dirname, `../examples/${example}.yml`), 'utf8'));
+ const values: Record = workflow.jobs.security.steps.find((step: {id?: string}) => step.id === 'security').with;
+ const production = parseInputs(name => values[name] ?? '', repository);
+ assert.equal(production.dryRun, false);
+ for (const mode of production.scope === 'repository' ? ['standard', 'deep'] : ['standard']) for (const program of [undefined, 'daybreak_blue']) {
+ // Test the example's program selection first, then the optional Blue variant.
+ // The production policy was already parsed; dry-run cannot enforce it.
+ const dryValues: Record = {...values, mode,
+ ...(program === undefined ? {} : {'cyber-access-program':program}),
+ 'fail-on-severity':'none', 'dry-run':'true'};
+ const inputs = parseInputs(name => dryValues[name] ?? '', repository);
+ const target = production.scope === 'diff' ? {repository, diffBase, diffHead} : {repository};
+ const args = scanArguments(inputs, target, join(root, `budget-${example}-${mode}-${program ?? 'example'}`));
+ const result = JSON.parse(run(args, 0));
+ assert.equal(result.dryRun, true);
+ assert.equal(result.mode, mode);
+ assert.equal(result.model, production.model);
+ assert.equal(result.reasoningEffort, production.effort);
+ assert.equal(result.maxCostUsd, production.maxCost);
+ }
}
- // Pass provider/model through the locked CLI without copying its provider setup or validation.
- for (const provider of ['amazon-bedrock', 'openrouter', 'fireworks']) for (const mode of ['standard', 'deep']) {
+ // Exercise each installed provider while covering both scan modes.
+ for (const [provider, mode] of [['amazon-bedrock', 'deep'], ['openrouter', 'standard'], ['fireworks', 'deep']]) {
const values: Record = {provider, model:'synthetic/model', mode, 'dry-run':'true'};
const args = scanArguments(parseInputs(name => values[name] ?? '', repository),
{repository}, join(root, `${provider}-${mode}`));
const preflight = JSON.parse(run(args, 0));
assert.equal(preflight.dryRun, true); assert.equal(preflight.mode, mode);
+ assert.equal(preflight.model, 'synthetic/model');
assert.equal(preflight.modelProvider, provider);
if (provider === 'amazon-bedrock') assert.equal(preflight.authentication.method, 'aws_credentials');
- values.model = '';
- const missingModelArgs = scanArguments(parseInputs(name => values[name] ?? '', repository), {repository}, join(root, 'missing-model'));
- const missing = spawnSync(process.execPath, [cli, ...missingModelArgs], {cwd:repository, env, encoding:'utf8', timeout:120_000});
- if (missing.error) throw missing.error;
- assert.equal(missing.status, 2);
- assert.match(missing.stderr + missing.stdout, /--model is required when using --provider/);
}
+ // The CLI shares missing-model validation across external providers and scan modes.
+ const missingValues: Record = {provider:'openrouter', 'dry-run':'true'};
+ const missingArgs = scanArguments(parseInputs(name => missingValues[name] ?? '', repository),
+ {repository}, join(root, 'missing-model'));
+ const missing = spawnSync(process.execPath, [cli, ...missingArgs], {cwd:repository, env, encoding:'utf8', timeout:120_000});
+ if (missing.error) throw missing.error;
+ assert.equal(missing.status, 2);
+ assert.match(missing.stderr + missing.stdout, /--model is required when using --provider openrouter/);
// Exercise Action arguments through the installed CLI and native request serializer.
// A terminal fixture error stops each scan before any model output or tool execution.
@@ -184,7 +216,7 @@ try {
await writeFile(join(repository, '--help/example.ts'), 'export const example = 1;\n');
git('add', '--', '--help/example.ts');
git('commit', '-m', 'Synthetic option-shaped path');
- const pathInputs: Record = {paths: './--help', 'dry-run': 'true'};
+ const pathInputs: Record = {paths: './--help', 'cyber-access-program':'daybreak_red', 'dry-run': 'true'};
const pathArguments = scanArguments(parseInputs(name => pathInputs[name] ?? '', repository),
{repository}, join(root, 'path-results'));
const pathPreflight = JSON.parse(run(pathArguments, 0));
@@ -200,7 +232,7 @@ try {
}
git('add', '.'); git('commit', '-m', 'Synthetic literal path scopes');
const scopes = ['src/[slug]', ...literalFiles.slice(1)];
- const literalInputs: Record = {paths: scopes.join('\n'), 'dry-run': 'true'};
+ const literalInputs: Record = {paths: scopes.join('\n'), 'cyber-access-program':'standard', 'dry-run': 'true'};
const python = await resolveTool('python3');
const literalArguments = scanArguments(parseInputs(name => literalInputs[name] ?? '', repository),
{repository}, join(root, 'literal-results'));
@@ -210,9 +242,14 @@ try {
const scopesFile = join(root, 'literal-scopes.json');
const sourceInput = join(root, 'literal-source.jsonl');
await writeFile(scopesFile, JSON.stringify(scopes));
- execFileSync(python, [join(cliPackage, '_bundled_plugin/scripts/generate_rank_input.py'),
- 'make-repo-scope-input', '--repo', repository, '--scopes-file', scopesFile, '--out', sourceInput],
- {cwd: repository, env, stdio: ['ignore', 'pipe', 'pipe']});
+ const legacyGenerator = join(cliPackage, '_bundled_plugin/scripts/generate_rank_input.py');
+ const usesPythonGenerator = existsSync(legacyGenerator);
+ const generateScopeInput = (output: string, pythonCommand: string, environment: NodeJS.ProcessEnv) =>
+ execFileSync(usesPythonGenerator ? pythonCommand : process.execPath,
+ [usesPythonGenerator ? legacyGenerator : join(cliPackage, '_bundled_plugin/mcp/helpers.mjs'),
+ 'make-repo-scope-input', '--repo', repository, '--scopes-file', scopesFile, '--out', output],
+ {cwd: repository, env: environment, stdio: ['ignore', 'pipe', 'pipe']});
+ generateScopeInput(sourceInput, python, env);
const selectedFiles = (await readFile(sourceInput, 'utf8')).trim().split('\n').map(row => JSON.parse(row).path).sort();
assert.deepEqual(selectedFiles, [...literalFiles].sort(), 'Real scope selection must preserve literal names and exclude glob-matching decoys');
@@ -232,6 +269,17 @@ try {
await writeRuntimeLauncher(nodeLauncher, process.execPath, 'RUNNER_TRACKING_ID', 'synthetic-cli-job');
const venvEnv = runtimeEnvironment({root, home, codexHome:env.CODEX_HOME, stateDirectory:env.CODEX_SECURITY_STATE_DIR,
runnerPath, runnerTrackingId:'synthetic-cli-job', runnerLibraryPath:libraryPath});
+ const shadowBin = join(repository, 'bin');
+ await mkdir(shadowBin);
+ await writeFile(join(shadowBin, 'bwrap'), '#!/bin/sh\n: > "$0.ran"\nexit 70\n', {mode:0o755});
+ const probeEnv = {...venvEnv, CODEX_HOME:join(root, 'probe-home')};
+ await checkSandbox(process.execPath, cli, {repository, provider:'openrouter', model:'example/model'}, {
+ ...probeEnv, PATH:shadowBin + delimiter + venvEnv.PATH,
+ });
+ await assert.rejects(checkSandbox(process.execPath, cli, {repository, provider:'openrouter', model:''}, probeEnv),
+ error => error instanceof Error && !(error instanceof SandboxUnavailableError) && /model/i.test(error.message));
+ await assert.rejects(readFile(join(shadowBin, 'bwrap.ran')), {code:'ENOENT'});
+ await rm(shadowBin, {recursive:true});
// Use the published MCP launcher and its actual allowlist without a model turn.
// The synthetic server reports its marker and one actual Node child's marker.
const mcpConfig = JSON.parse(await readFile(join(cliPackage, '_bundled_plugin/.mcp.json'), 'utf8')).mcpServers['codex-security'];
@@ -268,6 +316,40 @@ try {
assert.equal(selected.loader, libraryPath);
assert.equal(selected.tracking, 'synthetic-cli-job');
+ const nativeProbe = join(root, 'native-probe');
+ const nativeEnv = {...probeEnv, CODEX_CLI_PATH:nativeProbe, PROBE_CODEX:selected.codex};
+ const probe = (nodePath = process.execPath) => checkSandbox(nodePath, cli, {repository, provider:'openai', model:''}, nativeEnv);
+ await writeFile(nativeProbe, `#!/bin/sh\nexec "$PROBE_CODEX" -c 'model_provider="synthetic-undefined"' "$@"\n`, {mode:0o755});
+ await assert.rejects(probe, error => error instanceof Error && !(error instanceof SandboxUnavailableError) && error.message.includes('synthetic-undefined'));
+ await writeFile(nativeProbe, '#!/bin/sh\n[ "$1" != sandbox ] && exec "$PROBE_CODEX" "$@"\n');
+ await assert.rejects(probe, SandboxUnavailableError);
+ // Observe both real SDK child boundaries without invoking a sandbox or a model.
+ const probeInvocations = join(root, 'probe-invocations.jsonl');
+ for (const featuresExit of [0, 19]) {
+ await writeFile(probeInvocations, '');
+ await writeFile(nativeProbe, `#!${process.execPath}
+ const fs = require('node:fs'); const path = require('node:path');
+ fs.appendFileSync(${JSON.stringify(probeInvocations)}, JSON.stringify({args:process.argv.slice(2),
+ config:fs.readFileSync(path.join(process.env.CODEX_HOME, 'config.toml'), 'utf8')}) + '\\n');
+ if (process.argv[2] === 'sandbox') {
+ console.error('synthetic sandbox failure sk-example-original'); process.exitCode = 1;
+ } else {
+ console.log('synthetic configuration stdout'); console.error('synthetic configuration stderr');
+ process.exitCode = ${featuresExit};
+ }
+ `);
+ await assert.rejects(probe, error => error instanceof Error
+ && (error instanceof SandboxUnavailableError) === (featuresExit === 0)
+ && error.message.includes('synthetic sandbox failure sk-example-original')
+ && (featuresExit === 0 || (error.message.includes('synthetic configuration stdout')
+ && error.message.includes('synthetic configuration stderr') && error.message.includes('exit 19'))));
+ const invocations = (await readFile(probeInvocations, 'utf8')).trim().split('\n').map(line => JSON.parse(line));
+ assert.deepEqual(invocations.map(call => call.args[0]), ['sandbox', 'features']);
+ for (const call of invocations) assert.match(call.config, /\[analytics\]\s+enabled = false/);
+ }
+ await writeFile(nativeProbe, `#!${process.execPath}\nprocess.on('SIGTERM', () => process.exit(0)); process.kill(process.ppid, 'SIGINT'); setInterval(() => {}, 1000);\n`);
+ await assert.rejects(probe(nativeProbe), /sandbox preflight was interrupted/);
+
// Exercise filesystem enforcement with the scan and network-disabled Deep
// worker profiles, using the same pinned Codex and child PATH as the Action.
const sandboxWorkspace = join(root, 'sandbox-workspace');
@@ -297,12 +379,10 @@ try {
assert.equal(await readFile(outsideFile, 'utf8'), 'unchanged');
assert.equal(await readFile(workspaceFile, 'utf8'), 'scan output');
}
- // The actual pinned helper must still work when an MCP-style child drops the loader variable.
+ // The bundled helper must still work when an MCP-style child drops the loader variable.
const strippedEnv = {...venvEnv, LD_LIBRARY_PATH:undefined};
const loaderSourceInput = join(root, 'loader-source.jsonl');
- execFileSync(selected.python, [join(cliPackage, '_bundled_plugin/scripts/generate_rank_input.py'),
- 'make-repo-scope-input', '--repo', repository, '--scopes-file', scopesFile, '--out', loaderSourceInput],
- {cwd:repository, env:strippedEnv, stdio:['ignore','pipe','pipe']});
+ generateScopeInput(loaderSourceInput, selected.python, strippedEnv);
assert.equal(await readFile(loaderSourceInput, 'utf8'), await readFile(sourceInput, 'utf8'));
const venvArguments = scanArguments(parseInputs(name => deepInputs[name] ?? '', repository),
{repository}, join(root, 'venv-results'));
diff --git a/github-action/scripts/generate-input-docs.mjs b/github-action/scripts/generate-input-docs.mjs
index 7d6c94b7f..b08c14b83 100644
--- a/github-action/scripts/generate-input-docs.mjs
+++ b/github-action/scripts/generate-input-docs.mjs
@@ -22,14 +22,22 @@ reference = await format(reference, { parser: 'markdown' });
const path = new URL('../README.md', import.meta.url);
const current = await readFile(path, 'utf8');
-const start = '';
-const end = '';
-const startIndex = current.indexOf(start);
-const endIndex = current.indexOf(end);
-assert.ok(startIndex >= 0 && startIndex < endIndex, 'README must contain action reference markers in order');
-const updated = current.slice(0, startIndex) + start + '\n\n' + reference + '\n' + current.slice(endIndex);
+function replaceSection(text, section, content, label) {
+ const start = ``;
+ const end = ``;
+ const startIndex = text.indexOf(start);
+ const endIndex = text.indexOf(end);
+ assert.ok(startIndex >= 0 && startIndex < endIndex, `README must contain ${label} markers in order`);
+ return text.slice(0, startIndex) + start + '\n\n' + content + '\n' + text.slice(endIndex);
+}
+let updated = replaceSection(current, 'action-reference', reference, 'action reference');
+for (const name of ['repository', 'pull-request']) {
+ const workflow = await readFile(new URL(`../examples/${name}.yml`, import.meta.url), 'utf8');
+ const snippet = await format('```yaml\n' + workflow + '```\n', { parser: 'markdown' });
+ updated = replaceSection(updated, `action-workflow:${name}`, snippet, `${name} workflow`);
+}
if (process.argv.includes('--check')) {
- assert.equal(current, updated, 'Action reference differs from action.yml. Run npm run docs.');
+ assert.equal(current, updated, 'Action reference or workflow examples are out of date. Run npm run docs.');
} else {
await writeFile(path, updated);
}
diff --git a/github-action/scripts/linux-smoke.mjs b/github-action/scripts/linux-smoke.mjs
index d3ee2d884..302fa8298 100644
--- a/github-action/scripts/linux-smoke.mjs
+++ b/github-action/scripts/linux-smoke.mjs
@@ -1,4 +1,4 @@
-// Runs the SHIPPED action in a temporary checkout with dry-run and no secrets.
+// Runs the shipped Action and its real sandbox probe 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';
@@ -21,16 +21,20 @@ 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,
+ const runAction = (inputs = {}) => 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',
+ RUNNER_ENVIRONMENT:process.env.RUNNER_ENVIRONMENT,ImageOS:process.env.ImageOS,
+ 'INPUT_DRY-RUN':'true',INPUT_VERBOSE:'true',...inputs,
}});
+ const run = runAction();
if (run.status !== 0) {
console.error(run.stdout); console.error(run.stderr);
throw run.error ?? new Error(`Packaged action exited ${run.status}`);
}
+ assert.match(run.stdout, /Codex sandbox probe succeeded without model calls\./,
+ 'The packaged Action must exercise the shipped SDK sandbox probe, not just CLI input validation');
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/);
@@ -55,6 +59,11 @@ try {
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.');
+ await writeFile(join(commandRoot, 'output'), '');
+ const invalidProvider = runAction({INPUT_PROVIDER:'openrouter', INPUT_MODEL:''});
+ assert.equal(invalidProvider.status, 1, invalidProvider.stderr);
+ assert.match(invalidProvider.stdout, /--model is required when using --provider openrouter/);
+ assert.match(await readFile(join(commandRoot, 'output'), 'utf8'), /exit-code<<[^\n]+\n2\n/);
+ console.log('Packaged Linux action installed the locked CLI, passed the sandbox probe and dry-run, preserved the missing-model exit code, and verified post cleanup without credentials or model calls.');
} finally { await rm(commandRoot,{recursive:true,force:true}); }
} finally { await rm(root,{recursive:true,force:true}); }
diff --git a/github-action/src/artifacts.ts b/github-action/src/artifacts.ts
index b02b197fc..0a73a3844 100644
--- a/github-action/src/artifacts.ts
+++ b/github-action/src/artifacts.ts
@@ -16,7 +16,7 @@ export async function collectReports(result: ScanResults): Promise