Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

chore(security): add Codex Security scanning

Rahman83768e496cef
diff --git a/.github/workflows/codex-security.yml b/.github/workflows/codex-security.yml
new file mode 100644
index 00000000..ae35f098
--- /dev/null
+++ b/.github/workflows/codex-security.yml
@@ -0,0 +1,83 @@
+name: Codex Security
+
+on:
+ workflow_dispatch:
+ inputs:
+ mode:
+ description: Scan mode
+ required: true
+ default: standard
+ type: choice
+ options:
+ - standard
+ - deep
+
+permissions:
+ contents: read
+
+concurrency:
+ group: codex-security-${{ github.repository }}-${{ github.ref }}
+ cancel-in-progress: false
+
+jobs:
+ scan:
+ name: Security scan
+ runs-on: ubuntu-latest
+ timeout-minutes: 120
+ env:
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
+ CODEX_API_KEY: ${{ secrets.CODEX_API_KEY }}
+ CODEX_SECURITY_VERSION: "0.1.18"
+ CODEX_SECURITY_AUTH: api-key
+ CODEX_SECURITY_MODE: ${{ inputs.mode }}
+ CODEX_SECURITY_FAIL_ON_SEVERITY: high
+ CODEX_SECURITY_MAX_COST_USD: "5"
+ CODEX_SECURITY_MAX_TIME_HOURS: "1.5"
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ with:
+ fetch-depth: 0
+
+ - name: Set up Node.js
+ uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
+ with:
+ node-version: "22.23.0"
+
+ - name: Set up Python
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
+ with:
+ python-version: "3.12"
+
+ - name: Check scan credential
+ shell: bash
+ run: |
+ set -euo pipefail
+ if [[ -z "${OPENAI_API_KEY:-}" && -z "${CODEX_API_KEY:-}" ]]; then
+ echo "::error::Set OPENAI_API_KEY or CODEX_API_KEY as a repository or organization Actions secret."
+ exit 2
+ fi
+
+ - name: Run Codex Security
+ shell: bash
+ run: |
+ set -euo pipefail
+ export CODEX_SECURITY_STATE_DIR="$RUNNER_TEMP/codex-security-state"
+ export CODEX_SECURITY_OUTPUT_ROOT="$RUNNER_TEMP/codex-security-results"
+ stdout_file="$RUNNER_TEMP/codex-security.json"
+ stderr_file="$RUNNER_TEMP/codex-security.log"
+ cleanup() { rm -rf "$CODEX_SECURITY_STATE_DIR" "$CODEX_SECURITY_OUTPUT_ROOT" "$stdout_file" "$stderr_file"; }
+ trap cleanup EXIT
+
+ set +e
+ CI=true ./scripts/codex-security-scan.sh >"$stdout_file" 2>"$stderr_file"
+ status=$?
+ set -e
+
+ case "$status" in
+ 0) echo "Codex Security passed." ;;
+ 1) echo "::error::Codex Security found a high-or-critical vulnerability. Re-run locally to review the private finding details." ;;
+ *) echo "::error::Codex Security did not complete successfully (exit $status). Re-run locally for private diagnostics." ;;
+ esac
+ exit "$status"
diff --git a/scripts/codex-security-scan.sh b/scripts/codex-security-scan.sh
new file mode 100755
index 00000000..8cff3c56
--- /dev/null
+++ b/scripts/codex-security-scan.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+set -euo pipefail
+umask 077
+
+VERSION="${CODEX_SECURITY_VERSION:-0.1.18}"
+MODE="${CODEX_SECURITY_MODE:-standard}"
+AUTH="${CODEX_SECURITY_AUTH:-auto}"
+FAIL_ON="${CODEX_SECURITY_FAIL_ON_SEVERITY:-high}"
+MAX_COST="${CODEX_SECURITY_MAX_COST_USD:-5}"
+REPO_ROOT="$(git rev-parse --show-toplevel)"
+REPO_NAME="$(basename "$REPO_ROOT")"
+STATE_BASE="${XDG_STATE_HOME:-$HOME/.local/state}/codex-security"
+STATE_DIR="${CODEX_SECURITY_STATE_DIR:-$STATE_BASE/state}"
+OUTPUT_ROOT="${CODEX_SECURITY_OUTPUT_ROOT:-$STATE_BASE/$REPO_NAME}"
+STAMP="$(date -u +%Y%m%dT%H%M%SZ)"
+OUTPUT_DIR="$OUTPUT_ROOT/$STAMP/results"
+CLI_TMP="$(mktemp -d "${TMPDIR:-/tmp}/codex-security-cli.XXXXXX")"
+
+cleanup() {
+ rm -rf "$CLI_TMP"
+}
+trap cleanup EXIT INT TERM
+
+mkdir -p "$STATE_DIR" "$OUTPUT_ROOT" "$OUTPUT_DIR"
+chmod 700 "$STATE_DIR" "$OUTPUT_ROOT" "$OUTPUT_DIR"
+
+args=(
+ --yes "@openai/codex-security@$VERSION"
+ scan "$REPO_ROOT"
+ --auth "$AUTH"
+ --mode "$MODE"
+ --output-dir "$OUTPUT_DIR"
+ --fail-on-severity "$FAIL_ON"
+ --max-cost "$MAX_COST"
+)
+
+if [[ "$MODE" == "deep" ]]; then
+ args+=(--max-time-hours "${CODEX_SECURITY_MAX_TIME_HOURS:-1.5}")
+fi
+if [[ "${CODEX_SECURITY_DRY_RUN:-0}" == "1" ]]; then
+ args+=(--dry-run)
+fi
+if [[ "${CI:-}" == "true" ]]; then
+ args+=(--headless --json)
+fi
+
+cd "$CLI_TMP"
+CODEX_SECURITY_STATE_DIR="$STATE_DIR" npx "${args[@]}"