Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-architecture-mv/blob/main/tools/zero-legacy/procsnap.sh # aien-architecture-mv Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-architecture-mv / tools / zero-legacy / procsnap.sh` 32 lines ยท 1825 bytes Raw Blame History 1 #!/bin/sh 2 # procsnap.sh ZLBUILD [PROCROOT]: one dated process-closure snapshot of this host, safe to publish. 3 # Runs ZLBUILD/elfclose proc, then prints (1) counts by owner, class and verdict, (2) one row per 4 # distinct executable of the scanning account that lives outside the OS distribution and the 5 # agent tool directories (the first-party candidates; shown as their last two path parts), with 6 # group, verdict, producer, link, 7 # process count and the sha256 of the running image (/proc/PID/exe) from ZLBUILD/sha256 (the 8 # seeded-Omega hasher; - when the image is over its 16 MiB cap or the process exited). No full 9 # path, home directory or command line is recorded. 10 set -u 11 zl=$1; proc=${2:-/proc} 12 raw=$(mktemp); trap 'rm -f "$raw"' EXIT 13 "$zl/elfclose" proc "$proc" > "$raw" 14 echo "# procsnap $(date -u +%Y-%m-%dT%H:%M:%SZ) elfclose $(sha256sum "$zl/elfclose" | cut -c1-16)" 15 grep '^# ' "$raw" 16 echo "# owner class verdict count" 17 awk -F'\t' '$1=="PROC"{o=($3=="self")?"self":"other"; print o"\t"$5"\t"$12}' "$raw" | sort | uniq -c \ 18 | awk '{print "COUNT\t"$2"\t"$3"\t"$4"\t"$1}' 19 echo "# group exe verdict producer link processes sha256" 20 awk -F'\t' -v h="$HOME" '$1=="PROC" && $3=="self" && $5=="ELF64LE" { 21 p=$4; if (index(p, h"/")==1) p="~" substr(p, length(h)+1) 22 g=""; 23 if (p ~ /^~\/work\// || p ~ /^~\/workspace\// || p ~ /^\/dev\/shm\// || p ~ /^~\/\.local\/share\// || p ~ /^\/usr\/local\//) g="first-party-candidate" 24 if (g=="") next 25 m=split(p, q, "/"); s2=(m>1)?q[m-1]"/"q[m]:p 26 k=g"\t"s2"\t"$12"\t"$11"\t"$8 27 if (!(k in n)) pid[k]=$2 28 n[k]++ 29 } END { for (k in n) print k"\t"n[k]"\t"pid[k] }' "$raw" | sort | while IFS=' ' read -r g p v pr l c pid; do 30 s=$("$zl/sha256" "$proc/$pid/exe" 2>/dev/null | cut -c1-64) 31 printf 'EXE\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$g" "$p" "$v" "$pr" "$l" "$c" "${s:--}" 32 done