B&W print-friendly diagrams + tinkerpop-0001 + wave-3 proof sections. Squash of 94 local commits onto remote master.
22 lines
1.1 KiB
Bash
Executable file
22 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# CWE-407 scan — PHP Zend Engine (CFG, DFG, SSA, OPcache optimizer)
|
|
set -euo pipefail
|
|
echo "# scan=php-zend host=$(hostname) date=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
cd /tmp && git clone --depth 1 https://github.com/php/php-src php-src 2>&1 | tail -1
|
|
|
|
GRAPH_KW="cfg\b|dfg\b|ssa\b|dominator|liveness|reachab|topolog|cycle|dfs\b|scc\b|postorder|strongly.connected|basic.block|dataflow"
|
|
C_MEM='std::find[(]|linear_search|zend_bitset_in\b|in_list\b|zend_llist_.*find|ZEND_HASH_FOREACH.*==|zend_linked_list'
|
|
|
|
for dir in Zend "ext/opcache/Optimizer"; do
|
|
echo "# roots: /tmp/php-src/$dir"
|
|
find /tmp/php-src/$dir -name "*.c" -o -name "*.h" 2>/dev/null | sort | while IFS= read -r f; do
|
|
gl=$(grep -inE "$GRAPH_KW" "$f" 2>/dev/null | cut -d: -f1 | head -5 || true)
|
|
[ -z "$gl" ] && continue
|
|
while IFS= read -r ln; do
|
|
s=$(( ln > 20 ? ln - 20 : 1 )); e=$(( ln + 20 ))
|
|
hit=$(sed -n "${s},${e}p" "$f" 2>/dev/null | grep -iE "$C_MEM" | head -1 | sed 's/^\s*//' || true)
|
|
[ -n "$hit" ] && echo "CANDIDATE ${f}:${ln} ${hit}"
|
|
done <<< "$gl"
|
|
done
|
|
done
|
|
echo "# scan complete"
|