From e60d5bcad1b2c4fddbcaf08ee797ad44a083d2c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=97=D0=B0=D1=80=D1=83=D0=B1=D0=B8=D0=BD=20=D0=A4=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BF=D0=BF?= <289370046+zarubinphil@users.noreply.github.com> Date: Thu, 18 Jun 2026 16:57:35 +0300 Subject: [PATCH] feat(security): scan extraction cache for token-secrets in release gate Captured screenshots/PDFs can carry credentials that flow into notes. Token-only, dir-scoped, skipped on clean checkout. Positive-tested with planted AWS key. Co-Authored-By: Claude Opus 4.8 (1M context) --- scripts/check-public-release.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/check-public-release.sh b/scripts/check-public-release.sh index 498b976..aee07b3 100755 --- a/scripts/check-public-release.sh +++ b/scripts/check-public-release.sh @@ -86,4 +86,30 @@ check() { check "$PRIVATE_MARKERS" "private marker" check "$TOKEN_MARKERS" "token-like value" +# Local extraction cache is gitignored (never shipped), but captured screenshots +# / PDFs can carry credentials that would flow into synthesized notes. Scan it +# for token-like secrets only (personal/Cyrillic text is expected here and fine). +# Token-only, dir-scoped, skipped when the cache does not exist (clean checkout). +scan_dir_tokens() { + local dir="$1" + [ -d "$dir" ] || return 1 + if [ "$SCANNER" = "rg" ]; then + rg -n "$TOKEN_MARKERS" "$dir" + else + grep -rEn "$TOKEN_MARKERS" "$dir" + fi +} + +EXTRACTS_DIR="${MNEMAZINE_EXTRACTS:-$ROOT/.mnemazine/cache/extracted}" +status=0 +scan_dir_tokens "$EXTRACTS_DIR" || status=$? +if [ "$status" -eq 0 ]; then + echo "Public release check failed: token-like secret found in extraction cache ($EXTRACTS_DIR)." >&2 + echo "A captured screenshot/PDF likely contains a credential. Remove it before it reaches a note." >&2 + exit 1 +elif [ "$status" -ge 2 ]; then + echo "Public release check errored: scanner '$SCANNER' failed (exit $status) scanning extraction cache." >&2 + exit 1 +fi + echo "Public release check passed."