Datasets:
Tasks:
Text Classification
Modalities:
Image
Formats:
imagefolder
Languages:
English
Size:
< 1K
ArXiv:
License:
Add: The Interprocedural Ceiling — replication & boundary analysis responding to VulnLLM-R (arXiv:2512.07533)
2a0b0fb verified | #!/usr/bin/env python3 | |
| """Generate publication figures from the actual experimental result files.""" | |
| import json, os | |
| import matplotlib | |
| matplotlib.use("Agg") | |
| import matplotlib.pyplot as plt | |
| from matplotlib.patches import Patch | |
| import numpy as np | |
| FIG = os.path.expanduser("~/vulnllm-bench/paper/figures") | |
| os.makedirs(FIG, exist_ok=True) | |
| plt.rcParams.update({ | |
| "font.family": "DejaVu Sans", "font.size": 10, | |
| "axes.spines.top": False, "axes.spines.right": False, "figure.dpi": 150, | |
| "axes.titlesize": 11, "axes.titleweight": "bold", "savefig.bbox": "tight", | |
| }) | |
| # colorblind-safe palette (Okabe-Ito) | |
| BLUE="#0072B2"; ORANGE="#E69F00"; GREEN="#009E73"; RED="#D55E00"; GREY="#999999"; PURPLE="#CC79A7"; SKY="#56B4E9" | |
| # ---------------- Figure 1: the ladder — every lever hits the same wall ---------------- | |
| def fig1(): | |
| labels = ["Base\n(+prompt)", "LoRA v1\nverdict", "LoRA v2\nSTaR", "LoRA v3\nteacher", "LoRA v3\n×7 scaled", "Qwen3.6-27B\n(3.8× base)"] | |
| pc = [17.4, 17.2, 17.1, 20.0, 14.2, 0.0] # pair-correct % | |
| colors = [GREY, SKY, SKY, GREEN, ORANGE, RED] | |
| fig, ax = plt.subplots(figsize=(7.2, 3.7)) | |
| x = np.arange(len(labels)) | |
| bars = ax.bar(x, pc, color=colors, width=0.66, edgecolor="white", linewidth=0.6) | |
| ax.axhline(17.4, ls="--", lw=1.1, color=GREY, zorder=0) | |
| ax.text(len(labels)-0.5, 18.1, "base ceiling 17.4%", ha="right", va="bottom", fontsize=8.5, color="#555") | |
| # random-pairing reference (both-correct by chance ~ 0.5*0.5=25% only if independent&balanced -> but empirical near-chance) | |
| for b, v in zip(bars, pc): | |
| ax.text(b.get_x()+b.get_width()/2, v+0.5, f"{v:.1f}", ha="center", va="bottom", fontsize=9, fontweight="bold") | |
| ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=8.4) | |
| ax.set_ylabel("Pair-correct (%)"); ax.set_ylim(0, 24) | |
| ax.set_title("Figure 1. No fine-tuning recipe or larger base beats the single-function wall") | |
| fig.text(0.5, -0.06, "PrimeVul test_paired, blind, matched harness. Pair-correct = both the vulnerable function and its patched twin judged correctly.", | |
| ha="center", fontsize=7.6, color="#555") | |
| fig.savefig(f"{FIG}/fig1_ladder.png"); plt.close(fig); print("fig1 done") | |
| # ---------------- Figure 2: in-distribution vs OOD, and the generalization boundary ---------------- | |
| def fig2(): | |
| fig, (axA, axB) = plt.subplots(1, 2, figsize=(7.6, 3.5), gridspec_kw={"width_ratios":[1,1.15]}) | |
| # Panel A: distribution shift | |
| groups = ["In-distribution\n(authors' setup)", "Out-of-distribution\n(PrimeVul blind)"] | |
| acc = [81.0, 53.0]; f1 = [80.0, 44.7] | |
| x = np.arange(len(groups)); w=0.36 | |
| axA.bar(x-w/2, acc, w, label="Accuracy", color=BLUE, edgecolor="white") | |
| axA.bar(x+w/2, f1, w, label="F1", color=ORANGE, edgecolor="white") | |
| for xi,a,f in zip(x,acc,f1): | |
| axA.text(xi-w/2, a+1, f"{a:.0f}", ha="center", fontsize=8.5, fontweight="bold") | |
| axA.text(xi+w/2, f+1, f"{f:.0f}", ha="center", fontsize=8.5, fontweight="bold") | |
| axA.axhline(50, ls=":", color=GREY, lw=1); axA.text(1.4, 51, "chance", fontsize=7.5, color="#666", ha="right") | |
| axA.set_xticks(x); axA.set_xticklabels(groups, fontsize=8.2); axA.set_ylabel("Score (%)"); axA.set_ylim(0,95) | |
| axA.set_title("A. Distribution shift", fontsize=9.5, loc="left") | |
| axA.legend(frameon=False, fontsize=8, loc="upper right") | |
| # Panel B: trained vs novel mechanism (recall is the collapse) | |
| cats = ["Accuracy", "F1", "Recall"] | |
| trained = [85.0, 87.0, 100.0]; novel = [70.0, 64.0, 53.3] | |
| x2 = np.arange(len(cats)) | |
| axB.bar(x2-w/2, trained, w, label="Trained mechanisms", color=GREEN, edgecolor="white") | |
| axB.bar(x2+w/2, novel, w, label="Novel mechanisms", color=PURPLE, edgecolor="white") | |
| for xi,t,n in zip(x2,trained,novel): | |
| axB.text(xi-w/2, t+1.5, f"{t:.0f}", ha="center", fontsize=8.5, fontweight="bold") | |
| axB.text(xi+w/2, n+1.5, f"{n:.0f}", ha="center", fontsize=8.5, fontweight="bold") | |
| axB.set_xticks(x2); axB.set_xticklabels(cats, fontsize=8.6); axB.set_ylim(0,112); axB.set_ylabel("Score (%)") | |
| axB.set_title("B. Novel mechanisms: recall halves", fontsize=9.5, loc="left") | |
| axB.legend(frameon=False, fontsize=8, loc="lower left") | |
| fig.suptitle("Figure 2. The model learned transferable reasoning, but recall is fragile off-distribution", fontsize=10.5, fontweight="bold", y=1.02) | |
| fig.savefig(f"{FIG}/fig2_boundary.png"); plt.close(fig); print("fig2 done") | |
| # ---------------- Figure 3: the core finding — where the signal lives ---------------- | |
| def fig3(): | |
| dec = [json.loads(l) for l in open(os.path.expanduser("~/vulnllm-bench/phase0_decide_results.jsonl"))] | |
| intra = sum(1 for r in dec if r.get("cls")=="INTRA"); inter = sum(1 for r in dec if r.get("cls")=="INTER") | |
| tot = intra+inter | |
| diff = [json.loads(l) for l in open(os.path.expanduser("~/vulnllm-bench/phase0_diff_results.jsonl"))] | |
| cc = [r for r in diff if r.get("lang")=="c" and not r.get("skipped")] | |
| directional = sum(1 for r in cc if r.get("directional")); both = sum(1 for r in cc if r.get("both_same_flag")) | |
| neither = sum(1 for r in cc if r.get("neither_flagged")); other = len(cc)-directional-both-neither | |
| fig, (axA, axB) = plt.subplots(1, 2, figsize=(7.8, 3.6), gridspec_kw={"width_ratios":[1,1]}) | |
| # Panel A: decidability decomposition (stacked horizontal bar) | |
| ip = intra/tot*100; xp = inter/tot*100 | |
| axA.barh([0], [ip], color=GREEN, edgecolor="white", label=f"INTRA-procedural {ip:.0f}%") | |
| axA.barh([0], [xp], left=[ip], color=RED, edgecolor="white", label=f"INTER-procedural {xp:.0f}%") | |
| axA.text(ip/2, 0, f"{ip:.0f}%", ha="center", va="center", color="white", fontweight="bold", fontsize=11) | |
| axA.text(ip+xp/2, 0, f"{xp:.0f}%", ha="center", va="center", color="white", fontweight="bold", fontsize=11) | |
| axA.set_xlim(0,100); axA.set_ylim(-0.6,0.6); axA.set_yticks([]); axA.set_xlabel("Share of 99 PrimeVul pairs") | |
| axA.set_title("A. Where the vuln↔patch signal lives\n(frontier oracle judgment)", fontsize=9.3) | |
| axA.legend(frameon=False, fontsize=8.2, loc="upper center", bbox_to_anchor=(0.5,-0.28), ncol=1) | |
| axA.text(50, 0.48, "29% is the ceiling for ANY\nlocal single-function method", ha="center", fontsize=8, color="#444") | |
| # Panel B: what cppcheck actually delivers on the same pairs | |
| segs = [("Directional\n(usable signal)", directional, GREEN), | |
| ("Same finding\nboth twins", both, GREY), | |
| ("Tool blind\n(neither)", neither, "#BBBBBB"), | |
| ("Other\ndiff", other, ORANGE)] | |
| names=[s[0] for s in segs]; vals=[s[1] for s in segs]; cols=[s[2] for s in segs] | |
| y=np.arange(len(segs))[::-1] | |
| axB.barh(y, vals, color=cols, edgecolor="white") | |
| for yi,v in zip(y,vals): axB.text(v+0.8, yi, f"{v}%", va="center", fontsize=9, fontweight="bold") | |
| axB.set_yticks(y); axB.set_yticklabels(names, fontsize=8.2); axB.set_xlim(0,72); axB.set_xlabel("Share of 100 C pairs") | |
| axB.set_title("B. cppcheck recovers ~2% of it\n(intra-procedural linter, isolated fns)", fontsize=9.3) | |
| fig.suptitle("Figure 3. The wall is interprocedural: 71% of the signal is outside the function, and the cheap extractor captures almost none of the rest", | |
| fontsize=9.6, fontweight="bold", y=1.06) | |
| fig.savefig(f"{FIG}/fig3_ceiling.png"); plt.close(fig); print("fig3 done", intra, inter, directional, both, neither, other) | |
| fig1(); fig2(); fig3() | |
| print("all figures in", FIG) | |