mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-16 03:49:26 +00:00
The installed hook exits 0 with one line when ousast (or OUSAST_COMMAND) is not on PATH, still chaining a prior hook. In Git hook mode without an explicit --mode blocking, argument/usage errors (an invalid OUSAST_PUSH_DEADLINE, a cache directory inside the repository, a refused experimental flag) and unexpected exceptions print one "check did not run" line and exit 0. Blocking mode keeps its usage errors. Requirement 9.1. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
29 lines
1.4 KiB
Bash
Executable File
29 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# OpenUltraSAST pre-push safety net. Advisory: nothing here rejects a push unless
|
|
# OUSAST_PUSH_MODE=blocking is set explicitly. Install with `ousast pre-push install`
|
|
# (or ops/install-pre-push from a checkout); remove with `ousast pre-push uninstall`.
|
|
# A prior hook is chained only after it was moved to the sibling path "$0.before-ousast".
|
|
artifact_dir=${OUSAST_ARTIFACT_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/openultrasast/push}
|
|
prior="$0.before-ousast"
|
|
command=${OUSAST_COMMAND:-ousast}
|
|
if ! command -v "$command" >/dev/null 2>&1; then
|
|
echo "ousast: pre-push check did not run: '$command' is not on PATH." \
|
|
"Install it with 'pip install openultrasast' or set OUSAST_COMMAND. Push continues."
|
|
if [ -e "$prior" ] || [ -L "$prior" ]; then
|
|
exec "$prior" "$@"
|
|
fi
|
|
exit 0
|
|
fi
|
|
if [ -e "$prior" ] || [ -L "$prior" ]; then
|
|
exec "$command" pre-push . --artifact "$artifact_dir/push-$$.json" \
|
|
--deadline "${OUSAST_PUSH_DEADLINE:-30}" \
|
|
--mode "${OUSAST_PUSH_MODE:-advisory}" \
|
|
--incomplete-coverage "${OUSAST_INCOMPLETE_COVERAGE:-allow}" \
|
|
--prior-hook "$prior" --remote "$1" "$2"
|
|
fi
|
|
exec "$command" pre-push . --artifact "$artifact_dir/push-$$.json" \
|
|
--deadline "${OUSAST_PUSH_DEADLINE:-30}" \
|
|
--mode "${OUSAST_PUSH_MODE:-advisory}" \
|
|
--incomplete-coverage "${OUSAST_INCOMPLETE_COVERAGE:-allow}" \
|
|
--remote "$1" "$2"
|