Coding policy for Viktor Gamov's AI agents: language-agnostic quality rules, autonomous shipping discipline, and stack defaults for JVM, Swift, TypeScript, and Python
92%
Does it follow best practices?
Impact
99%
1.47xAverage score across 10 eval scenarios
Medium
Suggest reviewing before use
#!/usr/bin/env bash
# Tests for assert-no-secret-leak.sh — the guard that refuses to post a Codex
# review whose output contains the subscription credential. Pure file
# processing, no network. Deterministic (rules/testing-standards.md).
#
# Run: bash .github/codex-review/tests/test_assert_no_secret_leak.sh
# Exit 0 on all-pass; non-zero with a per-test diagnostic on failure.
set -uo pipefail
# The runner's per-suite token binds this suite's summary line to this
# suite (scripts/run-tests.sh header). Unset it so a harness run from
# here prints an empty token and never stands in for this one.
SUMMARY_TOKEN="${TEST_SUMMARY_TOKEN:-}"
unset TEST_SUMMARY_TOKEN
SCRIPT="$(cd "$(dirname "$0")/../templates" && pwd)/assert-no-secret-leak.sh"
[[ -f "$SCRIPT" && -r "$SCRIPT" ]] || { echo "fatal: assert-no-secret-leak.sh not readable at $SCRIPT" >&2; exit 2; }
pass=0; fail=0
ok() { printf 'ok - %s\n' "$1"; pass=$((pass+1)); }
bad() { printf 'FAIL - %s\n' "$1"; fail=$((fail+1)); }
# A realistic auth.json shape: a long access/refresh token plus short fields.
AUTH_JSON='{"tokens":{"access_token":"sk-tokenABCDEF0123456789verylong","refresh_token":"rt-9876543210FEDCBAlongtoken","auth_mode":"chatgpt"},"last_refresh":"2026-07-19T00:00:00Z"}'
with_files() {
# $1 = output-json contents; echoes "<auth> <out>" temp paths, caller cleans dir
local dir
dir=$(mktemp -d) || { echo "fatal: mktemp -d failed — check that \$TMPDIR is writable" >&2; exit 2; }
if ! printf '%s' "$AUTH_JSON" > "$dir/auth.json" || ! printf '%s' "$1" > "$dir/out.json"; then
rm -rf "$dir" || echo "warning: could not remove $dir" >&2
echo "fatal: cannot write the fixtures under $dir" >&2
exit 2
fi
echo "$dir"
}
t_clean_passes() {
local dir; dir=$(with_files '{"summary":"Policy loaded: 21 rule files from rules/. All good.","findings":[]}') || { bad "fixture setup failed"; return; }
local rc=0; bash "$SCRIPT" "$dir/auth.json" "$dir/out.json" >/dev/null 2>&1 || rc=$?
if [[ $rc -eq 0 ]]; then ok "clean output passes"; else bad "clean output passes (rc=$rc)"; fi
rm -rf "$dir"
}
t_leaked_access_token_fails() {
local dir; dir=$(with_files '{"summary":"here is the token sk-tokenABCDEF0123456789verylong oops","findings":[]}') || { bad "fixture setup failed"; return; }
local rc=0; bash "$SCRIPT" "$dir/auth.json" "$dir/out.json" >/dev/null 2>&1 || rc=$?
if [[ $rc -eq 1 ]]; then ok "leaked access token -> exit 1"; else bad "leaked access token -> exit 1 (rc=$rc)"; fi
rm -rf "$dir"
}
t_leaked_refresh_token_fails() {
local dir; dir=$(with_files '{"summary":"rt-9876543210FEDCBAlongtoken","findings":[]}') || { bad "fixture setup failed"; return; }
local rc=0; bash "$SCRIPT" "$dir/auth.json" "$dir/out.json" >/dev/null 2>&1 || rc=$?
if [[ $rc -eq 1 ]]; then ok "leaked refresh token -> exit 1"; else bad "leaked refresh token -> exit 1 (rc=$rc)"; fi
rm -rf "$dir"
}
# post-review.sh posts decoded JSON strings: an escaped credential must still trip.
t_escaped_token_fails() {
local dir rc payload
for payload in '{"summary":"\u0073k-tokenABCDEF0123456789verylong","findings":[]}' \
'{"summary":"ok","findings":[{"rt-9876543210FEDCBA\u006congtoken":1}]}'; do
dir=$(with_files "$payload") || { bad "fixture setup failed"; return; }
rc=0; bash "$SCRIPT" "$dir/auth.json" "$dir/out.json" >/dev/null 2>&1 || rc=$?
if [[ $rc -eq 1 ]]; then ok "escaped credential ($payload) -> exit 1"; else bad "escaped credential ($payload) -> exit 1 (rc=$rc)"; fi
rm -rf "$dir"
done
}
t_unparseable_output_fails_closed() {
local dir; dir=$(with_files 'not json at all') || { bad "unparseable: fixture setup failed"; return; }
local rc=0; bash "$SCRIPT" "$dir/auth.json" "$dir/out.json" >/dev/null 2>&1 || rc=$?
if [[ $rc -eq 2 ]]; then ok "unparseable review output -> exit 2"; else bad "unparseable review output -> exit 2 (rc=$rc)"; fi
rm -rf "$dir"
}
# Short auth fields (e.g. "chatgpt") appearing in ordinary prose must NOT trip
# the guard — only >= 16-char secret material counts.
t_short_field_in_prose_passes() {
local dir; dir=$(with_files '{"summary":"Reviewed the chatgpt workflow auth_mode handling.","findings":[]}') || { bad "fixture setup failed"; return; }
local rc=0; bash "$SCRIPT" "$dir/auth.json" "$dir/out.json" >/dev/null 2>&1 || rc=$?
if [[ $rc -eq 0 ]]; then ok "short auth field in prose passes"; else bad "short auth field in prose passes (rc=$rc)"; fi
rm -rf "$dir"
}
t_missing_files_fail_closed() {
local dir rc; dir=$(with_files '{"summary":"ok","findings":[]}') || { bad "missing-files: fixture setup failed"; return; }
rc=0; bash "$SCRIPT" "$dir/absent-auth.json" "$dir/absent-out.json" >/dev/null 2>&1 || rc=$?
if [[ $rc -eq 2 ]]; then ok "missing files -> exit 2 (fail closed)"; else bad "missing files -> exit 2 (rc=$rc)"; fi
rc=0; bash "$SCRIPT" "$dir/auth.json" "$dir/absent-out.json" >/dev/null 2>&1 || rc=$?
if [[ $rc -eq 2 ]]; then ok "missing review output -> exit 2"; else bad "missing review output -> exit 2 (rc=$rc)"; fi
rc=0; bash "$SCRIPT" "$dir/absent-auth.json" "$dir/out.json" >/dev/null 2>&1 || rc=$?
if [[ $rc -eq 2 ]]; then ok "missing auth file -> exit 2"; else bad "missing auth file -> exit 2 (rc=$rc)"; fi
rm -rf "$dir"
}
t_bad_args() {
local rc=0; bash "$SCRIPT" only-one-arg >/dev/null 2>&1 || rc=$?
if [[ $rc -eq 2 ]]; then ok "wrong arg count -> exit 2"; else bad "wrong arg count -> exit 2 (rc=$rc)"; fi
}
echo "== assert-no-secret-leak.sh tests =="
t_clean_passes
t_leaked_access_token_fails
t_leaked_refresh_token_fails
t_short_field_in_prose_passes
t_escaped_token_fails
t_unparseable_output_fails_closed
t_missing_files_fail_closed
t_bad_args
echo "== summary: ${pass} passed, ${fail} failed =="
echo "test-summary: passed=${pass} failed=${fail} token=${SUMMARY_TOKEN}"
[[ "$fail" -eq 0 ]].tessl-plugin
hooks
rules
skills
herdr-standup
herdr-teamlead
references
teamlead
templates
tests
onboard-repo
release
tests