mirror of
https://github.com/garrytan/gstack.git
synced 2026-12-01 20:34:25 +01:00
Remove the /cso security audit skill, since a plain audit request finds more (#4833)
/cso is gone: the skill, its native helper programs, scanner images, CI jobs, docs and the rest of its tests. Upgrading removes gstack's own `/cso` entries and old helper files, and leaves a skill of your own named `cso` alone. Why: on 52 real security advisories, plainly asking the agent to audit the code caught more than /cso (13 vs 7 on particle-1; 12 vs 8 of 51 on Claude Opus 5.5, within the margin of error). To do: nothing. Optional cleanup of old scanner images and reports is in the changelog entry. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/outside-voice#1 reader=outside-voice Review-Finding: p1/outside-voice#2 reader=outside-voice Review-Finding: p1/adversarial-native#1 reader=adversarial-native Review-Finding: p1/adversarial-native#2 reader=adversarial-native
This commit is contained in:
1 parent
fd7e8c7b36
commit
2fae1d78d6
207 files changed
+387
-32001
No files matched your search
@@ -1971,102 +1971,6 @@ cleanup_copied_bun() {
|
||||
prepare_bun_for_windows_compile
|
||||
trap cleanup_copied_bun EXIT
|
||||
|
||||
_cso_unavailable() {
|
||||
CSO_BUILD_AVAILABLE=0
|
||||
CSO_FAIL_REASON="$1"
|
||||
}
|
||||
|
||||
# CSO has a native startup boundary. Its extra toolchain is optional for setup:
|
||||
# when unavailable, install every other skill and leave /cso visibly fail-closed.
|
||||
# A successful probe is only a prerequisite check. A later build or publish
|
||||
# failure is recorded by scripts/build-cso.sh and reported by stage, not as a
|
||||
# missing tool; only GSTACK_STRICT_BUILD=1 makes it abort setup (#3071).
|
||||
probe_cso_build_prerequisites() {
|
||||
local _help _flag _platform _compiler _tmp _ps _ps_script _repo_root _git_path _probe_out _probe_rc
|
||||
CSO_BUILD_AVAILABLE=1
|
||||
CSO_FAIL_REASON=""
|
||||
CSO_PROBE_DETAIL=""
|
||||
if [ "${GSTACK_SETUP_SKIP_CSO_BUILD:-0}" = "1" ]; then
|
||||
_cso_unavailable "skipped-by-request"
|
||||
return 0
|
||||
fi
|
||||
|
||||
_help="$(bun_cmd build --help 2>&1 || true)"
|
||||
for _flag in --no-compile-autoload-dotenv --no-compile-autoload-bunfig --no-compile-autoload-tsconfig --no-compile-autoload-package-json; do
|
||||
case "$_help" in
|
||||
*"$_flag"*) ;;
|
||||
*) _cso_unavailable "bun-compile-flags"; return 0 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
_platform="$(uname -s)"
|
||||
if [ "$IS_WINDOWS" -eq 1 ]; then
|
||||
# #3071: PowerShell 7 first; Windows PowerShell 5.1 can crash outright.
|
||||
_ps="$(command -v pwsh 2>/dev/null || command -v powershell.exe 2>/dev/null || true)"
|
||||
if [ -z "$_ps" ] || ! command -v cygpath >/dev/null 2>&1; then
|
||||
_cso_unavailable "windows-shell-toolchain"
|
||||
return 0
|
||||
fi
|
||||
_ps_script="$(cygpath -w "$SOURCE_GSTACK_DIR/scripts/build-cso-windows.ps1")"
|
||||
_repo_root="$(cygpath -w "$SOURCE_GSTACK_DIR")"
|
||||
_git_path="$(type -P git 2>/dev/null || true)"
|
||||
if [ -z "$_git_path" ] || [ ! -f "$_git_path" ]; then
|
||||
_cso_unavailable "windows-git"
|
||||
return 0
|
||||
fi
|
||||
# E2 (#3015): a probe that found MSVC but could not compile is not a
|
||||
# missing toolchain; keep the probe's own first diagnostic for the summary.
|
||||
# #3071: neither is a probe that failed for another reason (a crashed
|
||||
# PowerShell); keep its exit status and first output line.
|
||||
_probe_rc=0
|
||||
_probe_out="$("$_ps" -NoProfile -NonInteractive -ExecutionPolicy Bypass \
|
||||
-File "$_ps_script" -RepoRoot "$_repo_root" -GitExePath "$(cygpath -aw "$_git_path")" -CheckOnly 2>&1)" || _probe_rc=$?
|
||||
if [ "$_probe_rc" -ne 0 ]; then
|
||||
case "$_probe_out" in
|
||||
*"compiler probe failed"*|*"compiler probe was not produced"*)
|
||||
_cso_unavailable "windows-msvc-compile"
|
||||
CSO_PROBE_DETAIL="$(printf '%s\n' "$_probe_out" | grep -m1 -E 'error [A-Z]*[0-9]+|probe (failed|was not produced)' | tr -d '\r' | head -c 200)" ;;
|
||||
*"requires Visual Studio 2022"*) _cso_unavailable "windows-msvc-toolchain" ;;
|
||||
*)
|
||||
_cso_unavailable "windows-toolchain-probe"
|
||||
CSO_PROBE_DETAIL="${_ps##*/} exited $_probe_rc: $(printf '%s\n' "$_probe_out" | tr -d '\r' | grep -m1 -v '^[[:space:]]*$' | head -c 200)" ;;
|
||||
esac
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
_compiler="${CSO_CC:-cc}"
|
||||
if ! command -v "$_compiler" >/dev/null 2>&1; then
|
||||
_cso_unavailable "c-compiler"
|
||||
return 0
|
||||
fi
|
||||
_tmp="$(mktemp -d "${TMPDIR:-/tmp}/gstack-cso-probe.XXXXXX" 2>/dev/null || true)"
|
||||
if [ -z "$_tmp" ]; then
|
||||
_cso_unavailable "native-toolchain-probe"
|
||||
return 0
|
||||
fi
|
||||
printf '%s\n' 'int main(void) { return 0; }' > "$_tmp/probe.c"
|
||||
case "$_platform" in
|
||||
Linux)
|
||||
if ! "$_compiler" -std=c11 -static "$_tmp/probe.c" -o "$_tmp/probe" >/dev/null 2>&1; then
|
||||
_cso_unavailable "static-c-toolchain"
|
||||
fi
|
||||
;;
|
||||
Darwin)
|
||||
if ! command -v codesign >/dev/null 2>&1; then
|
||||
_cso_unavailable "macos-codesign"
|
||||
elif ! "$_compiler" -std=c11 "$_tmp/probe.c" -o "$_tmp/probe" >/dev/null 2>&1 || \
|
||||
! codesign --force --sign - --options runtime "$_tmp/probe" >/dev/null 2>&1 || \
|
||||
! codesign --verify --strict "$_tmp/probe" >/dev/null 2>&1 || \
|
||||
! codesign -d --verbose=4 "$_tmp/probe" 2>&1 | grep -q 'runtime'; then
|
||||
_cso_unavailable "macos-native-toolchain"
|
||||
fi
|
||||
;;
|
||||
*) _cso_unavailable "unsupported-platform" ;;
|
||||
esac
|
||||
rm -rf "$_tmp"
|
||||
}
|
||||
|
||||
# Resolve the model overlay used for generated Codex skills. Setup auto-detects
|
||||
# only Codex because it has one canonical TOML config surface; direct generator
|
||||
# calls remain deterministic and use the host default unless --model is explicit.
|
||||
@@ -2127,37 +2031,26 @@ if CODEX_HOME="$(dirname "$CODEX_SKILLS")" GSTACK_RENAME_COPY="$IS_WINDOWS" bun_
|
||||
fi
|
||||
|
||||
# 1. Build browse binary if needed (smart rebuild: stale sources, package.json, lock).
|
||||
probe_cso_build_prerequisites
|
||||
_EXE=""
|
||||
if [ "$IS_WINDOWS" -eq 1 ]; then _EXE=".exe"; fi
|
||||
# Never leave a trusted helper from an earlier toolchain/version available when
|
||||
# this setup run cannot reproduce it. The /cso skill then reports not assessed.
|
||||
# An earlier build's result record no longer describes the removed helper;
|
||||
# setup never writes into the source checkout when nothing is built.
|
||||
if [ "$CSO_BUILD_AVAILABLE" -eq 0 ]; then
|
||||
rm -f "$SOURCE_GSTACK_DIR/bin/.gstack-cso-build-result" \
|
||||
"$SOURCE_GSTACK_DIR/bin/gstack-cso-launcher" \
|
||||
"$SOURCE_GSTACK_DIR/bin/gstack-cso-launcher.exe" \
|
||||
"$SOURCE_GSTACK_DIR/bin/gstack-cso-core" \
|
||||
"$SOURCE_GSTACK_DIR/bin/gstack-cso-core.exe" \
|
||||
"$SOURCE_GSTACK_DIR/bin/gstack-cso-watchdog" \
|
||||
"$SOURCE_GSTACK_DIR/bin/.gstack-cso-generation" \
|
||||
"$SOURCE_GSTACK_DIR/bin/.gstack-cso-generation.lock"
|
||||
fi
|
||||
# /cso was removed, and its native helper with it. Git leaves the helper an
|
||||
# earlier build compiled in this checkout because it is ignored, so remove
|
||||
# exactly the files and staging directories that build wrote, and its two
|
||||
# ignored image build outputs. A locked file (a /cso run still going on
|
||||
# Windows) leaves a warning, never a failed setup.
|
||||
_CSO_BIN="$SOURCE_GSTACK_DIR/bin"
|
||||
rm -rf "$_CSO_BIN/gstack-cso-launcher" "$_CSO_BIN/gstack-cso-launcher.exe" "$_CSO_BIN/gstack-cso-core" "$_CSO_BIN/gstack-cso-core.exe" \
|
||||
"$_CSO_BIN/gstack-cso-watchdog" "$_CSO_BIN/gstack-cso-watchdog.exe" "$_CSO_BIN/.gstack-cso-generation" "$_CSO_BIN/.gstack-cso-generation.lock" \
|
||||
"$_CSO_BIN/.gstack-cso-build-result" "$_CSO_BIN/.gstack-cso-build.log" "$_CSO_BIN/.gstack-cso-build.lock" "$_CSO_BIN/.gstack-cso-evaluation" \
|
||||
"$_CSO_BIN"/.gstack-cso-stage.?????? \
|
||||
"$SOURCE_GSTACK_DIR/lib/cso/images/gstack-cso-verifier" "$SOURCE_GSTACK_DIR/lib/cso/images/gstack-cso-preparation" 2>/dev/null \
|
||||
|| echo "warning: could not remove every old /cso helper file under $_CSO_BIN; close any running /cso and re-run ./setup" >&2
|
||||
rmdir "$SOURCE_GSTACK_DIR/lib/cso/images" "$SOURCE_GSTACK_DIR/lib/cso" 2>/dev/null || true
|
||||
BUILD_STAMP="$SOURCE_GSTACK_DIR/browse/dist/.build-complete"
|
||||
NEEDS_BUILD=0
|
||||
if [ ! -f "$BUILD_STAMP" ] || [ ! -x "$BROWSE_BIN" ] || [ ! -x "$SOURCE_GSTACK_DIR/design/dist/design$_EXE" ] || [ ! -x "$SOURCE_GSTACK_DIR/make-pdf/dist/pdf$_EXE" ]; then
|
||||
NEEDS_BUILD=1
|
||||
fi
|
||||
if [ "$CSO_BUILD_AVAILABLE" -eq 1 ]; then
|
||||
if [ ! -x "$SOURCE_GSTACK_DIR/bin/gstack-cso-launcher$_EXE" ] || [ ! -x "$SOURCE_GSTACK_DIR/bin/gstack-cso-core$_EXE" ] || [ ! -f "$SOURCE_GSTACK_DIR/bin/.gstack-cso-generation" ]; then
|
||||
NEEDS_BUILD=1
|
||||
elif [ "$IS_WINDOWS" -eq 0 ] && [ ! -x "$SOURCE_GSTACK_DIR/bin/gstack-cso-watchdog" ]; then
|
||||
NEEDS_BUILD=1
|
||||
elif [ "$IS_WINDOWS" -eq 1 ] && [ ! -f "$SOURCE_GSTACK_DIR/bin/.gstack-cso-generation.lock" ];then
|
||||
NEEDS_BUILD=1
|
||||
fi
|
||||
fi
|
||||
# lib/ holds the canonical claude-bin, error-handling and aside-render sources
|
||||
# the binaries embed (browse/src re-exports them), so it is part of the set.
|
||||
if [ "$NEEDS_BUILD" -eq 0 ]; then
|
||||
@@ -2169,8 +2062,6 @@ if [ "$NEEDS_BUILD" -eq 0 ]; then
|
||||
NEEDS_BUILD=1
|
||||
elif [ "$SOURCE_GSTACK_DIR/scripts/build.sh" -nt "$BUILD_STAMP" ]; then
|
||||
NEEDS_BUILD=1
|
||||
elif [ "$CSO_BUILD_AVAILABLE" -eq 1 ] && { [ "$SOURCE_GSTACK_DIR/scripts/build-cso.sh" -nt "$BUILD_STAMP" ] || [ "$SOURCE_GSTACK_DIR/scripts/build-cso-windows.ps1" -nt "$BUILD_STAMP" ]; }; then
|
||||
NEEDS_BUILD=1
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -2179,9 +2070,6 @@ if [ "$NEEDS_BUILD" -eq 1 ]; then
|
||||
(
|
||||
cd "$SOURCE_GSTACK_DIR"
|
||||
install_runtime_deps
|
||||
if [ "$CSO_BUILD_AVAILABLE" -eq 0 ]; then
|
||||
export GSTACK_SETUP_SKIP_CSO_BUILD=1
|
||||
fi
|
||||
bun_cmd run build
|
||||
)
|
||||
# Safety net: write .version if build script didn't (e.g., git not available during build)
|
||||
@@ -2207,8 +2095,6 @@ if [ "$NEEDS_BUILD" -eq 1 ]; then
|
||||
# binary is genuinely SIGKILL'd on exec (exit 137).
|
||||
# See: https://github.com/garrytan/gstack/issues/997
|
||||
if [ "$(uname -s)" = "Darwin" ] && [ "$(uname -m)" = "arm64" ]; then
|
||||
# CSO artifacts are signed and verified inside build-cso's staged generation;
|
||||
# mutating them here would break its launcher-last publication guarantee.
|
||||
# B4 (#1254): every binary is backed up first and restored as built when
|
||||
# re-signing fails, so a failed codesign never leaves a half-signed file.
|
||||
for _bin in browse/dist/browse browse/dist/find-browse design/dist/design make-pdf/dist/pdf bin/gstack-global-discover; do
|
||||
@@ -2274,41 +2160,6 @@ if [ "$NEEDS_BUILD" -eq 1 ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# A failed CSO build or publish leaves an incomplete set; the summary reports
|
||||
# it from the build-result record. Fatal only under GSTACK_STRICT_BUILD=1 (#3071).
|
||||
_CSO_READY=0
|
||||
if [ "$CSO_BUILD_AVAILABLE" -eq 1 ]; then
|
||||
if [ ! -x "$SOURCE_GSTACK_DIR/bin/gstack-cso-launcher$_EXE" ] || [ ! -x "$SOURCE_GSTACK_DIR/bin/gstack-cso-core$_EXE" ] || [ ! -f "$SOURCE_GSTACK_DIR/bin/.gstack-cso-generation" ] || { [ "$IS_WINDOWS" -eq 0 ] && [ ! -x "$SOURCE_GSTACK_DIR/bin/gstack-cso-watchdog" ]; } || { [ "$IS_WINDOWS" -eq 1 ] && [ ! -f "$SOURCE_GSTACK_DIR/bin/.gstack-cso-generation.lock" ]; }; then
|
||||
if [ "${GSTACK_STRICT_BUILD:-0}" = "1" ]; then
|
||||
echo "gstack setup failed: CSO build completed without its required native artifact set (GSTACK_STRICT_BUILD=1)" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
_CSO_READY=1
|
||||
fi
|
||||
fi
|
||||
if [ "$_CSO_READY" -eq 1 ]; then
|
||||
# Evaluation-only helpers embed an unqualified cso-eval-* catalog for the
|
||||
# private evaluator. Setup never installs one, whether marked or copied bare.
|
||||
if [ -e "$SOURCE_GSTACK_DIR/bin/.gstack-cso-evaluation" ] || "$SOURCE_GSTACK_DIR/bin/gstack-cso-launcher$_EXE" --version 2>/dev/null | grep -q '"evaluationOnly": *true'; then
|
||||
echo "gstack setup failed: bin/ holds an evaluation-only CSO helper; remove the bin/gstack-cso-* artifacts and re-run setup" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Runtime/scanner execution never pulls. Setup is the sole automatic
|
||||
# acquisition path: the trusted launcher validates committed catalogs,
|
||||
# rejects remote Docker contexts, and uses an empty Docker config for
|
||||
# anonymous exact-digest pulls. Each image gets a bounded pull window and the
|
||||
# whole catalog remains under a hard aggregate deadline; Docker or network
|
||||
# gaps stay nonfatal so a later setup can continue from local exact digests.
|
||||
_CSO_IMAGE_SUMMARY=""
|
||||
_CSO_IMAGE_PULL_TIMEOUT_SECONDS="${GSTACK_CSO_IMAGE_PULL_TIMEOUT_SECONDS:-30}"
|
||||
if _CSO_IMAGE_SUMMARY="$("$SOURCE_GSTACK_DIR/bin/gstack-cso-launcher$_EXE" provision-images --setup-summary --per-image-seconds "$_CSO_IMAGE_PULL_TIMEOUT_SECONDS" 2>/dev/null)"; then
|
||||
[ -n "$_CSO_IMAGE_SUMMARY" ] && log "$_CSO_IMAGE_SUMMARY"
|
||||
else
|
||||
log "warning: qualified CSO images could not be checked or preloaded; static audits remain available. Re-run setup after local Docker and public registry access are available."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$BROWSE_BIN" ]; then
|
||||
echo "gstack setup failed: browse binary missing at $BROWSE_BIN" >&2
|
||||
exit 1
|
||||
@@ -5268,47 +5119,6 @@ fi
|
||||
|
||||
_setup_print_summary
|
||||
|
||||
# ─── CSO native-helper summary ────────────────────────────────────────────────
|
||||
# A missing prerequisite comes from this run's probe. A build or publish
|
||||
# failure comes from bin/.gstack-cso-build-result, which scripts/build-cso.sh
|
||||
# writes and gstack-doctor also reads.
|
||||
_cso_field() { sed -n "s/^$1=//p" "$SOURCE_GSTACK_DIR/bin/.gstack-cso-build-result" 2>/dev/null | head -1; }
|
||||
if [ "$CSO_BUILD_AVAILABLE" -eq 0 ]; then
|
||||
case "$CSO_FAIL_REASON" in
|
||||
bun-compile-flags) _CSO_PREREQ="upgrade Bun to a release supporting all four --no-compile-autoload-* build flags" ;;
|
||||
c-compiler) _CSO_PREREQ="install a C compiler (cc, Clang, or GCC)" ;;
|
||||
static-c-toolchain) _CSO_PREREQ="install a C toolchain capable of static linking" ;;
|
||||
macos-codesign|macos-native-toolchain) _CSO_PREREQ="install the macOS compiler and codesign command-line tools" ;;
|
||||
windows-shell-toolchain) _CSO_PREREQ="run setup from Git Bash with PowerShell (pwsh or Windows PowerShell) available" ;;
|
||||
windows-msvc-toolchain) _CSO_PREREQ="install Visual Studio 2022 Build Tools with Desktop development with C++" ;;
|
||||
windows-msvc-compile) _CSO_PREREQ="fix the MSVC compile error its toolchain probe reported (${CSO_PROBE_DETAIL:-see scripts/build-cso-windows.ps1 -CheckOnly}); Visual Studio is already installed" ;;
|
||||
windows-toolchain-probe) _CSO_PREREQ="fix the PowerShell toolchain probe failure (${CSO_PROBE_DETAIL:-no output}); run scripts/build-cso-windows.ps1 -CheckOnly from pwsh to see it" ;;
|
||||
windows-git) _CSO_PREREQ="install Git for Windows and run setup from its Git Bash" ;;
|
||||
unsupported-platform) _CSO_PREREQ="use a supported macOS, Linux, or Windows host" ;;
|
||||
skipped-by-request) _CSO_PREREQ="re-run without GSTACK_SETUP_SKIP_CSO_BUILD=1" ;;
|
||||
*) _CSO_PREREQ="install the native CSO build prerequisites" ;;
|
||||
esac
|
||||
log ""
|
||||
log "CSO unavailable: its native helper was not built ($CSO_FAIL_REASON)."
|
||||
log " Failed stage: probe. /cso will report not assessed and the install prerequisite; it will not use repository tooling."
|
||||
log " Everything else is installed and works. To enable /cso, $_CSO_PREREQ, then re-run ./setup."
|
||||
elif [ "$(_cso_field result)" = "failed" ]; then
|
||||
_CSO_STAGE="$(_cso_field stage)"
|
||||
_CSO_INSTALLED="$(_cso_field installed)"
|
||||
_CSO_WHAT="failed ($(_cso_field reason))"
|
||||
[ "$(_cso_field reason)" != "interrupted" ] || _CSO_WHAT="was interrupted"
|
||||
log ""
|
||||
if [ -x "$SOURCE_GSTACK_DIR/bin/gstack-cso-launcher$_EXE" ] && [ -x "$SOURCE_GSTACK_DIR/bin/gstack-cso-core$_EXE" ] && [ -n "$_CSO_INSTALLED" ]; then
|
||||
log "CSO $_CSO_STAGE step $_CSO_WHAT for $(_cso_field revision); previous CSO kept: $_CSO_INSTALLED."
|
||||
log " /cso keeps using that helper until a rebuild succeeds."
|
||||
else
|
||||
log "CSO unavailable: the native helper's $_CSO_STAGE step $_CSO_WHAT, so /cso will report not assessed."
|
||||
fi
|
||||
log " Diagnostic: $(_cso_field diagnostic)"
|
||||
log " Everything else is installed and works. Retry: cd $SOURCE_GSTACK_DIR && bun run build:cso && ./setup"
|
||||
log " Details: https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md#cso-build-or-publish-failed"
|
||||
fi
|
||||
|
||||
# ─── Windows launch probe (#2595, #2124) ──────────────────────────────────────
|
||||
# Smart App Control blocks unsigned executables at launch, which `[ -x ]` cannot
|
||||
# see and Git Bash reports as "Permission denied". Probe each compiled binary.
|
||||
|
||||
Reference in new issue
Block a user