call-graph-analysis
БесплатноБез исполняемых скриптовНе проверенPerform definitive call graph analysis to prove whether vulnerable functions are reachable from program entry points
от openshift-eng★ 123 звезды на GitHubОб этом скилле
Call Graph Reachability Analysis
Provides highest-confidence vulnerability assessment by proving whether vulnerable functions can actually be reached during program execution.
When to Use This Skill
Use this skill when:
- You need definitive proof that a vulnerable function is or isn't reachable
- Medium/high confidence analysis shows possible vulnerability but needs confirmation
- Generating evidence for security compliance or audit requirements
govulncheckis unavailable or didn't find the CVE- You need visual proof of execution paths for stakeholders
Prerequisites
Required Tools
callgraph:go install golang.org/x/tools/cmd/callgraph@latestdigraph:go install golang.org/x/tools/cmd/digraph@latest- Go workspace with
go.modfile
Optional Tools
graphviz(for visualization):brew install graphviz(macOS) orsudo apt-get install graphviz(Linux)sfdpordotcommand (part of graphviz)
Input Requirements
- CVE vulnerable function signature (e.g.,
<package-path>.<function-name>) - Package path from CVE analysis
- Workspace path to analyze
- Algorithm preference (optional, default:
vta) — passed via--algofrom parent command CVE_ID— used to construct the output directoryOUT_DIR(optional, default:${AI_HELPERS_WORKSPACE:-.}/.work/compliance/analyze-cve/${CVE_ID}) — where artifacts are written; same workspace base as Phase 0.7'sREPOS_BASE
Critical Rules
- Always use
timeout -k 10— plaintimeoutsends SIGTERM butcallgraphcan ignore it when stuck in SSA construction or type resolution.-k 10sends SIGKILL after 10s grace, guaranteeing termination.- Never run
callgraphon./...for repos with more than ~50 packages. Target specific main packages (e.g../cmd/controller,./main.go) and let the tool pull in transitive deps automatically.- Always redirect output to a file (
> file 2>&1). Never pipe callgraph output to another command — if the reader closes, callgraph can hang on SIGPIPE.
Timeout and Algorithm Convention
- Use the algorithm specified by the user via
--algo(default:vta). - All
callgraphinvocations usetimeout -k 10 300(5 minutes + 10s force-kill) to prevent hanging. - Scope: target the specific main package (e.g.
./cmd/controller), not./.... Thecallgraphtool resolves transitive deps automatically — there is no need to include the entire repo. - If the chosen algorithm times out: fall back to the next faster algorithm (
vta→rta→cha), then narrow scope further to a single binary entry point.
Implementation Steps
Step 1: Verify Tools Are Available
# Check for callgraph
which callgraph || echo "callgraph not found - install with: go install golang.org/x/tools/cmd/callgraph@latest"
# Check for digraph
which digraph || echo "digraph not found - install with: go install golang.org/x/tools/cmd/digraph@latest"
# Optional: Check for graphviz
which sfdp || echo "graphviz not found - visual graphs won't be generated (optional)"
Decision Point:
- IF callgraph OR digraph missing → Exit this skill, return to parent analysis
- IF both present → Continue
Step 2: Identify Main Packages and Build Call Graph
First, discover the main packages that serve as entry points:
# Find main packages
MAIN_PKGS=$(find . -name "main.go" -exec dirname {} \; | sort -u)
echo "Main packages: ${MAIN_PKGS}"
Pick the most relevant main package for the analysis (typically the controller or server binary, not CLI tools or test helpers). If unsure, prefer the package that imports the vulnerable package's parent tree.
# Select exactly one TARGET_PKG before running callgraph
if [ -z "${TARGET_PKG:-}" ]; then
TARGET_PKG=$(printf '%s\n' ${MAIN_PKGS} | grep -E '(^|/)(cmd/)?(controller|manager|operator|server|main)(/|$)' | head -1)
[ -z "${TARGET_PKG}" ] && TARGET_PKG=$(printf '%s\n' ${MAIN_PKGS} | head -1)
fi
# Normalize to a package path callgraph accepts (./cmd/foo or .)
case "${TARGET_PKG}" in
.|./) TARGET_PKG="." ;;
*) TARGET_PKG="./${TARGET_PKG#./}" ;;
esac
if [ -z "${TARGET_PKG}" ] || [ "${TARGET_PKG}" = "./" ]; then
echo "ERROR: No main package found for call graph analysis"
exit 1
fi
echo "Selected TARGET_PKG=${TARGET_PKG}"
ALGO="${USER_ALGO:-vta}"
OUT_DIR="${OUT_DIR:-${AI_HELPERS_WORKSPACE:-.}/.work/compliance/analyze-cve/${CVE_ID}}"
mkdir -p "${OUT_DIR}"
# TARGET_PKG is the specific main package (e.g. ./cmd/controller, .)
# NEVER use ./... — it causes VTA to explode on large repos
echo "Building call graph: algo=${ALGO}, target=${TARGET_PKG}"
timeout -k 10 300 env CGO_ENABLED=0 callgraph -algo "${ALGO}" -format=digraph "${TARGET_PKG}" > "${OUT_DIR}/callgraph.txt" 2>&1
CG_EXIT=$?
echo "callgraph exit: ${CG_EXIT}, lines: $(wc -l < "${OUT_DIR}/callgraph.txt")"
Progressive fallback if the command times out or fails:
# Fallback 1: faster algorithm
if [ $CG_EXIT -eq 124 ] || [ $CG
Установить call-graph-analysis в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл call-graph-analysis?
Perform definitive call graph analysis to prove whether vulnerable functions are reachable from program entry points
Как установить скилл call-graph-analysis?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл call-graph-analysis запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic