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.

1.8 KB
Raw Blame
#!/usr/bin/env bash
set -euo pipefail
umask 077

VERSION="${CODEX_SECURITY_VERSION:-0.1.21}"
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="${CODEX_SECURITY_STATE_BASE:-$HOME/.mso/security-assurance/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
  # Use OpenAI's conservative documented Deep Scan profile by default. Keeping
  # worker/subagent counts explicit makes the assurance run reproducible across
  # hosts and avoids silently inheriting more aggressive engine defaults.
  args+=(
    --workers "${CODEX_SECURITY_WORKERS:-2}"
    --subagents "${CODEX_SECURITY_SUBAGENTS:-0}"
    --stop-after-no-new "${CODEX_SECURITY_STOP_AFTER_NO_NEW:-3}"
    --max-discovery-runs "${CODEX_SECURITY_MAX_DISCOVERY_RUNS:-10}"
    --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[@]}"