java-topology/tools/tickets/scans/networkx.md
russell@unturf.com db29a08762 undefect. CWE-407 — 92 sites, 42 ecosystems
B&W print-friendly diagrams + tinkerpop-0001 + wave-3 proof sections.
Squash of 94 local commits onto remote master.
2026-03-26 19:48:18 -04:00

2.4 KiB

id priority status created
scan-networkx critical unscanned 2026-03-23

Target

Repo: https://github.com/networkx/networkx Language: Python Why: Scientific computing global baseline — used by bioinformatics, ML, and physics pipelines worldwide; a linear-scan defect in SCC or DFS poisons every downstream analysis.

Scan command

# Shallow clone
git clone --depth 1 https://github.com/networkx/networkx /tmp/networkx

# Submit to unsandbox
cat > /tmp/scan-networkx.sh << 'EOF'
#!/usr/bin/env bash
set -euo pipefail
GRAPH_KW="tarjan|strongly.connected|dfs|scc|topolog|topo.sort|cycle|reachab|postorder|dominator|liveness|digraph|shortest.path|path.find"
MEM="in path|in stack|in visited|in queue|\.index\(|list\.append.*in |not in path|not in stack"
find /tmp/networkx/networkx/algorithms -name "*.py" | sort | while read f; do
  graph_lines=$(grep -inE "$GRAPH_KW" "$f" 2>/dev/null | cut -d: -f1 | head -5 || true)
  [ -z "$graph_lines" ] && continue
  while IFS= read -r lineno; do
    s=$(( lineno > 20 ? lineno - 20 : 1 )); e=$(( lineno + 20 ))
    hit=$(sed -n "${s},${e}p" "$f" 2>/dev/null | grep -iE "$MEM" | head -1 | sed 's/^\s*//' || true)
    [ -n "$hit" ] && echo "CANDIDATE\t${f}:${lineno}\t${hit}"
  done <<< "$graph_lines"
done
EOF
export UNSANDBOX_PUBLIC_KEY=unsb-pk-russ-test-isth-best
export UNSANDBOX_SECRET_KEY=unsb-sk-rk46c-3zvpg-zjf6z-hjrge
~/git/un-inception/build/un /tmp/scan-networkx.sh

Key files to check

  • networkx/algorithms/components/strongly_connected.py — Tarjan/Kosaraju SCC; node in path or node in stack on a list
  • networkx/algorithms/cycles.py — Cycle detection; visited/path membership on lists
  • networkx/algorithms/dag.py — Topological sort; ancestor/descendant set membership
  • networkx/algorithms/traversal/depth_first_search.py — Core DFS; visited tracking data structure
  • networkx/algorithms/dominance.py — Dominator tree; predecessor list scans

Expected pattern

node in path or node in stack where path/stack is a Python list (not a set or dict) inside Tarjan SCC or DFS cycle-detection, producing O(V) membership tests per node visit and O(V²) total for a path graph.

Acceptance criteria

  • Scan run and results saved to tools/scan-results/networkx.txt
  • All CANDIDATE hits triaged (confirmed defect or false positive)
  • If confirmed: defect ticket created in tools/tickets/defects/