App
Browse files- .python-version +1 -0
- app/__init__.py +0 -0
- app/__pycache__/__init__.cpython-313.pyc +0 -0
- app/__pycache__/data.cpython-313.pyc +0 -0
- app/__pycache__/diff_parser.cpython-313.pyc +0 -0
- app/__pycache__/main.cpython-313.pyc +0 -0
- app/data.py +143 -0
- app/diff_parser.py +184 -0
- app/main.py +76 -0
- app/static/style.css +115 -0
- app/templates/base.html +15 -0
- app/templates/detail.html +95 -0
- app/templates/list.html +86 -0
- build_parquet.py +452 -0
- explore.ipynb +1061 -0
- pyproject.toml +18 -0
- uv.lock +0 -0
.python-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.13
|
app/__init__.py
ADDED
|
File without changes
|
app/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (147 Bytes). View file
|
|
|
app/__pycache__/data.cpython-313.pyc
ADDED
|
Binary file (7.51 kB). View file
|
|
|
app/__pycache__/diff_parser.cpython-313.pyc
ADDED
|
Binary file (8.42 kB). View file
|
|
|
app/__pycache__/main.cpython-313.pyc
ADDED
|
Binary file (3.98 kB). View file
|
|
|
app/data.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Polars-backed query layer over the cve_diff parquet shards."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from dataclasses import dataclass
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from typing import Any
|
| 8 |
+
|
| 9 |
+
import polars as pl
|
| 10 |
+
|
| 11 |
+
PARQUET_GLOB = str(Path(__file__).resolve().parent.parent / "dataset" / "parquet" / "cve_diff-part*.parquet")
|
| 12 |
+
|
| 13 |
+
SEVERITIES = ["CRITICAL", "HIGH", "MEDIUM", "LOW", "NONE"]
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
@dataclass(frozen=True)
|
| 17 |
+
class SearchFilters:
|
| 18 |
+
q: str = ""
|
| 19 |
+
cwe: str = ""
|
| 20 |
+
year: int | None = None
|
| 21 |
+
severity: str = ""
|
| 22 |
+
host: str = ""
|
| 23 |
+
language: str = ""
|
| 24 |
+
patch: str = "" # "" = any, "yes" = has patch, "no" = no patch
|
| 25 |
+
page: int = 1
|
| 26 |
+
page_size: int = 25
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _load() -> pl.DataFrame:
|
| 30 |
+
return pl.read_parquet(PARQUET_GLOB)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
_DF: pl.DataFrame | None = None
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def df() -> pl.DataFrame:
|
| 37 |
+
global _DF
|
| 38 |
+
if _DF is None:
|
| 39 |
+
_DF = _load()
|
| 40 |
+
return _DF
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def facets() -> dict[str, list[Any]]:
|
| 44 |
+
"""Distinct values to populate filter dropdowns."""
|
| 45 |
+
d = df()
|
| 46 |
+
years = sorted(d["year"].unique().to_list(), reverse=True)
|
| 47 |
+
cwes = (
|
| 48 |
+
d.lazy()
|
| 49 |
+
.select(pl.col("cwes").explode().struct.field("id"))
|
| 50 |
+
.drop_nulls()
|
| 51 |
+
.unique()
|
| 52 |
+
.sort("id")
|
| 53 |
+
.collect()["id"]
|
| 54 |
+
.to_list()
|
| 55 |
+
)
|
| 56 |
+
hosts = (
|
| 57 |
+
d.lazy()
|
| 58 |
+
.select(pl.col("patch_hosts").explode().alias("host"))
|
| 59 |
+
.drop_nulls()
|
| 60 |
+
.unique()
|
| 61 |
+
.sort("host")
|
| 62 |
+
.collect()["host"]
|
| 63 |
+
.to_list()
|
| 64 |
+
)
|
| 65 |
+
languages = (
|
| 66 |
+
d.lazy()
|
| 67 |
+
.select(pl.col("patch_languages").explode().alias("language"))
|
| 68 |
+
.drop_nulls()
|
| 69 |
+
.unique()
|
| 70 |
+
.sort("language")
|
| 71 |
+
.collect()["language"]
|
| 72 |
+
.to_list()
|
| 73 |
+
)
|
| 74 |
+
return {
|
| 75 |
+
"years": years,
|
| 76 |
+
"cwes": cwes,
|
| 77 |
+
"hosts": hosts,
|
| 78 |
+
"languages": languages,
|
| 79 |
+
"severities": SEVERITIES,
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def _apply_filters(lf: pl.LazyFrame, f: SearchFilters) -> pl.LazyFrame:
|
| 84 |
+
if f.q:
|
| 85 |
+
needle = f.q.strip()
|
| 86 |
+
lf = lf.filter(
|
| 87 |
+
pl.col("cve_id").str.contains(needle, literal=True)
|
| 88 |
+
| pl.col("description").str.contains(f"(?i){needle}")
|
| 89 |
+
)
|
| 90 |
+
if f.cwe:
|
| 91 |
+
cwe = f.cwe
|
| 92 |
+
lf = lf.filter(
|
| 93 |
+
pl.col("cwes").list.eval(pl.element().struct.field("id") == cwe).list.any()
|
| 94 |
+
)
|
| 95 |
+
if f.year is not None:
|
| 96 |
+
lf = lf.filter(pl.col("year") == f.year)
|
| 97 |
+
if f.severity:
|
| 98 |
+
lf = lf.filter(pl.col("cvss_base_severity") == f.severity)
|
| 99 |
+
if f.host:
|
| 100 |
+
lf = lf.filter(pl.col("patch_hosts").list.contains(f.host))
|
| 101 |
+
if f.language:
|
| 102 |
+
lf = lf.filter(pl.col("patch_languages").list.contains(f.language))
|
| 103 |
+
if f.patch == "yes":
|
| 104 |
+
lf = lf.filter(pl.col("has_patch"))
|
| 105 |
+
elif f.patch == "no":
|
| 106 |
+
lf = lf.filter(~pl.col("has_patch"))
|
| 107 |
+
return lf
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def search(f: SearchFilters) -> tuple[list[dict], int]:
|
| 111 |
+
"""Return (page rows, total matching)."""
|
| 112 |
+
lf = _apply_filters(df().lazy(), f)
|
| 113 |
+
total = lf.select(pl.len()).collect().item()
|
| 114 |
+
offset = max(0, (f.page - 1) * f.page_size)
|
| 115 |
+
rows = (
|
| 116 |
+
lf.sort("cve_id", descending=True)
|
| 117 |
+
.slice(offset, f.page_size)
|
| 118 |
+
.select(
|
| 119 |
+
"cve_id",
|
| 120 |
+
"year",
|
| 121 |
+
"description",
|
| 122 |
+
"cwes",
|
| 123 |
+
"cvss_base_score",
|
| 124 |
+
"cvss_base_severity",
|
| 125 |
+
"patch_hosts",
|
| 126 |
+
"patch_languages",
|
| 127 |
+
"has_patch",
|
| 128 |
+
)
|
| 129 |
+
.collect()
|
| 130 |
+
.to_dicts()
|
| 131 |
+
)
|
| 132 |
+
return rows, total
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def get_cve(cve_id: str) -> dict | None:
|
| 136 |
+
rows = (
|
| 137 |
+
df()
|
| 138 |
+
.lazy()
|
| 139 |
+
.filter(pl.col("cve_id") == cve_id)
|
| 140 |
+
.collect()
|
| 141 |
+
.to_dicts()
|
| 142 |
+
)
|
| 143 |
+
return rows[0] if rows else None
|
app/diff_parser.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Parse a multi-commit unified diff into a side-by-side render model."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import re
|
| 6 |
+
from dataclasses import dataclass, field
|
| 7 |
+
|
| 8 |
+
HUNK_RE = re.compile(r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@")
|
| 9 |
+
COMMIT_HEADER_RE = re.compile(r"^=== (.+?) ===\s*$")
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@dataclass
|
| 13 |
+
class Row:
|
| 14 |
+
left_no: int | None
|
| 15 |
+
left_text: str
|
| 16 |
+
left_kind: str # "context" | "removed" | "empty"
|
| 17 |
+
right_no: int | None
|
| 18 |
+
right_text: str
|
| 19 |
+
right_kind: str # "context" | "added" | "empty"
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
@dataclass
|
| 23 |
+
class Hunk:
|
| 24 |
+
header: str
|
| 25 |
+
rows: list[Row] = field(default_factory=list)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
@dataclass
|
| 29 |
+
class File:
|
| 30 |
+
old_path: str
|
| 31 |
+
new_path: str
|
| 32 |
+
hunks: list[Hunk] = field(default_factory=list)
|
| 33 |
+
note: str = "" # e.g. binary diff
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
@dataclass
|
| 37 |
+
class Commit:
|
| 38 |
+
url: str
|
| 39 |
+
files: list[File] = field(default_factory=list)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def _pair_block(removed: list[tuple[int, str]], added: list[tuple[int, str]]) -> list[Row]:
|
| 43 |
+
rows: list[Row] = []
|
| 44 |
+
for i in range(max(len(removed), len(added))):
|
| 45 |
+
if i < len(removed):
|
| 46 |
+
ln, txt = removed[i]
|
| 47 |
+
left = (ln, txt, "removed")
|
| 48 |
+
else:
|
| 49 |
+
left = (None, "", "empty")
|
| 50 |
+
if i < len(added):
|
| 51 |
+
ln, txt = added[i]
|
| 52 |
+
right = (ln, txt, "added")
|
| 53 |
+
else:
|
| 54 |
+
right = (None, "", "empty")
|
| 55 |
+
rows.append(Row(left[0], left[1], left[2], right[0], right[1], right[2]))
|
| 56 |
+
return rows
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def _parse_hunk(lines: list[str], start_old: int, start_new: int) -> list[Row]:
|
| 60 |
+
rows: list[Row] = []
|
| 61 |
+
old_n, new_n = start_old, start_new
|
| 62 |
+
removed: list[tuple[int, str]] = []
|
| 63 |
+
added: list[tuple[int, str]] = []
|
| 64 |
+
|
| 65 |
+
def flush():
|
| 66 |
+
nonlocal removed, added
|
| 67 |
+
if removed or added:
|
| 68 |
+
rows.extend(_pair_block(removed, added))
|
| 69 |
+
removed, added = [], []
|
| 70 |
+
|
| 71 |
+
for ln in lines:
|
| 72 |
+
if not ln:
|
| 73 |
+
continue
|
| 74 |
+
marker, text = ln[0], ln[1:]
|
| 75 |
+
if marker == " ":
|
| 76 |
+
flush()
|
| 77 |
+
rows.append(Row(old_n, text, "context", new_n, text, "context"))
|
| 78 |
+
old_n += 1
|
| 79 |
+
new_n += 1
|
| 80 |
+
elif marker == "-":
|
| 81 |
+
removed.append((old_n, text))
|
| 82 |
+
old_n += 1
|
| 83 |
+
elif marker == "+":
|
| 84 |
+
added.append((new_n, text))
|
| 85 |
+
new_n += 1
|
| 86 |
+
elif marker == "\\":
|
| 87 |
+
# "" — display as context on whichever side it follows
|
| 88 |
+
pass
|
| 89 |
+
else:
|
| 90 |
+
# unexpected line inside a hunk; treat as context
|
| 91 |
+
flush()
|
| 92 |
+
rows.append(Row(old_n, ln, "context", new_n, ln, "context"))
|
| 93 |
+
old_n += 1
|
| 94 |
+
new_n += 1
|
| 95 |
+
flush()
|
| 96 |
+
return rows
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def parse(diff_text: str) -> list[Commit]:
|
| 100 |
+
"""Split diff_text by `=== url ===` headers, then by `diff --git`, then by hunks."""
|
| 101 |
+
commits: list[Commit] = []
|
| 102 |
+
current = Commit(url="")
|
| 103 |
+
current_file: File | None = None
|
| 104 |
+
pending_hunk_header: str | None = None
|
| 105 |
+
pending_hunk_lines: list[str] | None = None
|
| 106 |
+
pending_old_start = 0
|
| 107 |
+
pending_new_start = 0
|
| 108 |
+
|
| 109 |
+
def finalize_hunk():
|
| 110 |
+
nonlocal pending_hunk_header, pending_hunk_lines
|
| 111 |
+
if current_file is not None and pending_hunk_header is not None and pending_hunk_lines is not None:
|
| 112 |
+
rows = _parse_hunk(pending_hunk_lines, pending_old_start, pending_new_start)
|
| 113 |
+
current_file.hunks.append(Hunk(header=pending_hunk_header, rows=rows))
|
| 114 |
+
pending_hunk_header = None
|
| 115 |
+
pending_hunk_lines = None
|
| 116 |
+
|
| 117 |
+
def finalize_commit():
|
| 118 |
+
nonlocal current
|
| 119 |
+
finalize_hunk()
|
| 120 |
+
if current.files or current.url:
|
| 121 |
+
commits.append(current)
|
| 122 |
+
current = Commit(url="")
|
| 123 |
+
|
| 124 |
+
lines = diff_text.splitlines()
|
| 125 |
+
i = 0
|
| 126 |
+
while i < len(lines):
|
| 127 |
+
line = lines[i]
|
| 128 |
+
m = COMMIT_HEADER_RE.match(line)
|
| 129 |
+
if m:
|
| 130 |
+
finalize_commit()
|
| 131 |
+
current = Commit(url=m.group(1))
|
| 132 |
+
current_file = None
|
| 133 |
+
i += 1
|
| 134 |
+
continue
|
| 135 |
+
|
| 136 |
+
if line.startswith("diff --git "):
|
| 137 |
+
finalize_hunk()
|
| 138 |
+
current_file = File(old_path="", new_path="")
|
| 139 |
+
current.files.append(current_file)
|
| 140 |
+
# try to read old/new path from following ---/+++ lines (or rename headers)
|
| 141 |
+
i += 1
|
| 142 |
+
while i < len(lines) and not lines[i].startswith("@@") and not lines[i].startswith("diff --git ") and not COMMIT_HEADER_RE.match(lines[i]):
|
| 143 |
+
hdr = lines[i]
|
| 144 |
+
if hdr.startswith("--- "):
|
| 145 |
+
current_file.old_path = hdr[4:].removeprefix("a/").strip()
|
| 146 |
+
elif hdr.startswith("+++ "):
|
| 147 |
+
current_file.new_path = hdr[4:].removeprefix("b/").strip()
|
| 148 |
+
elif hdr.startswith("Binary files "):
|
| 149 |
+
current_file.note = hdr
|
| 150 |
+
elif hdr.startswith("rename from "):
|
| 151 |
+
current_file.old_path = hdr[len("rename from "):].strip()
|
| 152 |
+
elif hdr.startswith("rename to "):
|
| 153 |
+
current_file.new_path = hdr[len("rename to "):].strip()
|
| 154 |
+
i += 1
|
| 155 |
+
if not current_file.old_path and not current_file.new_path:
|
| 156 |
+
# fall back to the `diff --git a/foo b/bar` paths
|
| 157 |
+
parts = line.split()
|
| 158 |
+
if len(parts) >= 4:
|
| 159 |
+
current_file.old_path = parts[2].removeprefix("a/")
|
| 160 |
+
current_file.new_path = parts[3].removeprefix("b/")
|
| 161 |
+
continue
|
| 162 |
+
|
| 163 |
+
m = HUNK_RE.match(line)
|
| 164 |
+
if m and current_file is not None:
|
| 165 |
+
finalize_hunk()
|
| 166 |
+
pending_hunk_header = line
|
| 167 |
+
pending_hunk_lines = []
|
| 168 |
+
pending_old_start = int(m.group(1)) or 1
|
| 169 |
+
pending_new_start = int(m.group(3)) or 1
|
| 170 |
+
i += 1
|
| 171 |
+
continue
|
| 172 |
+
|
| 173 |
+
if pending_hunk_lines is not None:
|
| 174 |
+
# collect hunk body until next file/hunk/commit header
|
| 175 |
+
if line.startswith("diff --git ") or COMMIT_HEADER_RE.match(line) or HUNK_RE.match(line):
|
| 176 |
+
continue # handled by the loop on next iteration
|
| 177 |
+
pending_hunk_lines.append(line)
|
| 178 |
+
i += 1
|
| 179 |
+
continue
|
| 180 |
+
|
| 181 |
+
i += 1
|
| 182 |
+
|
| 183 |
+
finalize_commit()
|
| 184 |
+
return commits
|
app/main.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FastAPI app: list + detail views over the cve_diff parquet."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import math
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
|
| 8 |
+
from fastapi import FastAPI, HTTPException, Request
|
| 9 |
+
from fastapi.responses import HTMLResponse
|
| 10 |
+
from fastapi.staticfiles import StaticFiles
|
| 11 |
+
from fastapi.templating import Jinja2Templates
|
| 12 |
+
|
| 13 |
+
from . import data, diff_parser
|
| 14 |
+
|
| 15 |
+
BASE = Path(__file__).resolve().parent
|
| 16 |
+
templates = Jinja2Templates(directory=BASE / "templates")
|
| 17 |
+
|
| 18 |
+
app = FastAPI(title="cve-diff explorer")
|
| 19 |
+
app.mount("/static", StaticFiles(directory=BASE / "static"), name="static")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def _qs(params: dict, **overrides) -> str:
|
| 23 |
+
merged = {k: v for k, v in params.items() if v not in (None, "", 0)}
|
| 24 |
+
merged.update({k: v for k, v in overrides.items() if v not in (None, "")})
|
| 25 |
+
return "&".join(f"{k}={v}" for k, v in merged.items())
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
@app.get("/", response_class=HTMLResponse)
|
| 29 |
+
def index(
|
| 30 |
+
request: Request,
|
| 31 |
+
q: str = "",
|
| 32 |
+
cwe: str = "",
|
| 33 |
+
year: str = "",
|
| 34 |
+
severity: str = "",
|
| 35 |
+
host: str = "",
|
| 36 |
+
language: str = "",
|
| 37 |
+
patch: str = "",
|
| 38 |
+
page: int = 1,
|
| 39 |
+
):
|
| 40 |
+
page = max(1, page)
|
| 41 |
+
year_int: int | None = int(year) if year.strip().isdigit() else None
|
| 42 |
+
filters = data.SearchFilters(
|
| 43 |
+
q=q, cwe=cwe, year=year_int, severity=severity, host=host,
|
| 44 |
+
language=language, patch=patch, page=page, page_size=25,
|
| 45 |
+
)
|
| 46 |
+
rows, total = data.search(filters)
|
| 47 |
+
pages = max(1, math.ceil(total / filters.page_size))
|
| 48 |
+
params = {
|
| 49 |
+
"q": q, "cwe": cwe, "year": year_int,
|
| 50 |
+
"severity": severity, "host": host, "language": language,
|
| 51 |
+
"patch": patch,
|
| 52 |
+
}
|
| 53 |
+
return templates.TemplateResponse(
|
| 54 |
+
request,
|
| 55 |
+
"list.html",
|
| 56 |
+
{
|
| 57 |
+
"rows": rows,
|
| 58 |
+
"total": total,
|
| 59 |
+
"page": page,
|
| 60 |
+
"pages": pages,
|
| 61 |
+
"facets": data.facets(),
|
| 62 |
+
"filters": params,
|
| 63 |
+
"qs": _qs,
|
| 64 |
+
},
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
@app.get("/cve/{cve_id}", response_class=HTMLResponse)
|
| 69 |
+
def detail(request: Request, cve_id: str):
|
| 70 |
+
row = data.get_cve(cve_id)
|
| 71 |
+
if row is None:
|
| 72 |
+
raise HTTPException(404, f"{cve_id} not found")
|
| 73 |
+
commits = diff_parser.parse(row.get("patch_diff") or "")
|
| 74 |
+
return templates.TemplateResponse(
|
| 75 |
+
request, "detail.html", {"cve": row, "commits": commits}
|
| 76 |
+
)
|
app/static/style.css
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
* { box-sizing: border-box; }
|
| 2 |
+
body {
|
| 3 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
| 4 |
+
margin: 0;
|
| 5 |
+
color: #1f2328;
|
| 6 |
+
background: #f6f8fa;
|
| 7 |
+
}
|
| 8 |
+
main { max-width: 1400px; margin: 0 auto; padding: 1.2rem 1.5rem 4rem; }
|
| 9 |
+
a { color: #0969da; text-decoration: none; }
|
| 10 |
+
a:hover { text-decoration: underline; }
|
| 11 |
+
.muted { color: #656d76; font-size: 0.9rem; }
|
| 12 |
+
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #eaeef2; padding: 0 4px; border-radius: 3px; }
|
| 13 |
+
|
| 14 |
+
.topbar {
|
| 15 |
+
background: #24292f; color: #fff; padding: 0.7rem 1.5rem;
|
| 16 |
+
display: flex; align-items: baseline; gap: 0.8rem;
|
| 17 |
+
}
|
| 18 |
+
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.1rem; }
|
| 19 |
+
.topbar .muted { color: #adbac7; }
|
| 20 |
+
|
| 21 |
+
/* filters */
|
| 22 |
+
.filters {
|
| 23 |
+
display: flex; gap: 0.5rem; flex-wrap: wrap;
|
| 24 |
+
background: #fff; padding: 0.8rem; border: 1px solid #d0d7de; border-radius: 6px;
|
| 25 |
+
margin-bottom: 1rem;
|
| 26 |
+
}
|
| 27 |
+
.filters input, .filters select {
|
| 28 |
+
padding: 0.4rem 0.5rem; border: 1px solid #d0d7de; border-radius: 6px; font-size: 0.9rem; background: #fff;
|
| 29 |
+
}
|
| 30 |
+
.filters input { flex: 1 1 260px; }
|
| 31 |
+
.filters button {
|
| 32 |
+
padding: 0.4rem 0.9rem; border: 1px solid #1f883d; background: #1f883d; color: #fff; border-radius: 6px; cursor: pointer;
|
| 33 |
+
}
|
| 34 |
+
.filters .reset { align-self: center; color: #656d76; }
|
| 35 |
+
|
| 36 |
+
/* results */
|
| 37 |
+
.results {
|
| 38 |
+
width: 100%; border-collapse: collapse; background: #fff;
|
| 39 |
+
border: 1px solid #d0d7de; border-radius: 6px; overflow: hidden;
|
| 40 |
+
}
|
| 41 |
+
.results th, .results td { padding: 0.55rem 0.7rem; text-align: left; vertical-align: top; border-bottom: 1px solid #d0d7de; }
|
| 42 |
+
.results th { background: #f6f8fa; font-size: 0.85rem; }
|
| 43 |
+
.results tr:last-child td { border-bottom: none; }
|
| 44 |
+
.results td.desc { max-width: 420px; font-size: 0.9rem; }
|
| 45 |
+
|
| 46 |
+
.chip {
|
| 47 |
+
display: inline-block; padding: 1px 6px; margin: 1px 2px;
|
| 48 |
+
background: #ddf4ff; color: #0969da;
|
| 49 |
+
border-radius: 10px; font-size: 0.75rem;
|
| 50 |
+
}
|
| 51 |
+
a.chip { text-decoration: none; }
|
| 52 |
+
a.chip:hover { background: #b6e3ff; }
|
| 53 |
+
.chip-lang { background: #ecf6e8; color: #1f7a3a; }
|
| 54 |
+
a.chip-lang:hover { background: #d4ecc8; }
|
| 55 |
+
.sev { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; }
|
| 56 |
+
.sev-critical { background: #82071e; color: #fff; }
|
| 57 |
+
.sev-high { background: #cf222e; color: #fff; }
|
| 58 |
+
.sev-medium { background: #bf8700; color: #fff; }
|
| 59 |
+
.sev-low { background: #1f883d; color: #fff; }
|
| 60 |
+
.sev-none { background: #d0d7de; color: #1f2328; }
|
| 61 |
+
|
| 62 |
+
.pager { display: flex; gap: 1rem; align-items: center; margin: 1rem 0; }
|
| 63 |
+
|
| 64 |
+
/* detail */
|
| 65 |
+
.meta {
|
| 66 |
+
display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.6rem 1.5rem;
|
| 67 |
+
background: #fff; padding: 0.9rem; border: 1px solid #d0d7de; border-radius: 6px;
|
| 68 |
+
margin-bottom: 1rem;
|
| 69 |
+
}
|
| 70 |
+
.meta strong { display: block; font-size: 0.8rem; color: #656d76; font-weight: 600; }
|
| 71 |
+
.cwe-list, .refs { padding-left: 1.2rem; }
|
| 72 |
+
.refs li { word-break: break-all; font-size: 0.9rem; }
|
| 73 |
+
|
| 74 |
+
/* diff viewer (GitLab-ish side-by-side) */
|
| 75 |
+
.commit {
|
| 76 |
+
background: #fff; border: 1px solid #d0d7de; border-radius: 6px;
|
| 77 |
+
margin: 1rem 0; overflow: hidden;
|
| 78 |
+
}
|
| 79 |
+
.commit-header {
|
| 80 |
+
padding: 0.5rem 0.8rem; background: #f6f8fa; border-bottom: 1px solid #d0d7de;
|
| 81 |
+
font-size: 0.85rem; word-break: break-all;
|
| 82 |
+
}
|
| 83 |
+
.file { border-top: 1px solid #d0d7de; }
|
| 84 |
+
.file:first-of-type { border-top: none; }
|
| 85 |
+
.file-header {
|
| 86 |
+
padding: 0.4rem 0.8rem; background: #f6f8fa;
|
| 87 |
+
font-size: 0.85rem; border-bottom: 1px solid #d0d7de;
|
| 88 |
+
}
|
| 89 |
+
.binary { padding: 0.4rem 0.8rem; }
|
| 90 |
+
|
| 91 |
+
.diff {
|
| 92 |
+
width: 100%; table-layout: fixed; border-collapse: collapse;
|
| 93 |
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem;
|
| 94 |
+
}
|
| 95 |
+
.diff col, .diff td { word-break: break-word; }
|
| 96 |
+
.diff col.col-ln { width: 38px; }
|
| 97 |
+
.diff col.col-code { width: auto; }
|
| 98 |
+
.diff td.ln {
|
| 99 |
+
text-align: right; padding: 0 4px; color: #656d76;
|
| 100 |
+
background: #f6f8fa; border-right: 1px solid #d0d7de;
|
| 101 |
+
font-size: 0.72rem; white-space: nowrap;
|
| 102 |
+
user-select: none;
|
| 103 |
+
}
|
| 104 |
+
.diff td.code { padding: 0; vertical-align: top; }
|
| 105 |
+
.diff td.code pre {
|
| 106 |
+
margin: 0; padding: 1px 6px; white-space: pre-wrap; word-break: break-all;
|
| 107 |
+
}
|
| 108 |
+
.diff tr td.side-context { background: #ffffff; }
|
| 109 |
+
.diff tr td.side-added { background: #e6ffec; }
|
| 110 |
+
.diff tr td.side-removed { background: #ffebe9; }
|
| 111 |
+
.diff tr td.side-empty { background: #f6f8fa; }
|
| 112 |
+
.hunk-header {
|
| 113 |
+
background: #ddf4ff; color: #0969da; text-align: left;
|
| 114 |
+
padding: 4px 8px; font-weight: normal;
|
| 115 |
+
}
|
app/templates/base.html
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<title>{% block title %}cve-diff{% endblock %}</title>
|
| 6 |
+
<link rel="stylesheet" href="{{ url_for('static', path='style.css') }}">
|
| 7 |
+
</head>
|
| 8 |
+
<body>
|
| 9 |
+
<header class="topbar">
|
| 10 |
+
<a class="brand" href="/">cve-diff</a>
|
| 11 |
+
<span class="muted">explorer</span>
|
| 12 |
+
</header>
|
| 13 |
+
<main>{% block content %}{% endblock %}</main>
|
| 14 |
+
</body>
|
| 15 |
+
</html>
|
app/templates/detail.html
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends "base.html" %}
|
| 2 |
+
{% block title %}{{ cve.cve_id }}{% endblock %}
|
| 3 |
+
{% block content %}
|
| 4 |
+
<p><a href="javascript:history.back()">← back</a></p>
|
| 5 |
+
|
| 6 |
+
<h1>{{ cve.cve_id }}</h1>
|
| 7 |
+
|
| 8 |
+
<section class="meta">
|
| 9 |
+
<div>
|
| 10 |
+
<strong>Year</strong> {{ cve.year }}
|
| 11 |
+
</div>
|
| 12 |
+
<div>
|
| 13 |
+
<strong>Severity</strong>
|
| 14 |
+
{% if cve.cvss_base_severity %}
|
| 15 |
+
<span class="sev sev-{{ cve.cvss_base_severity|lower }}">{{ cve.cvss_base_severity }}</span>
|
| 16 |
+
{% endif %}
|
| 17 |
+
{% if cve.cvss_base_score is not none %}({{ "%.1f"|format(cve.cvss_base_score) }} — CVSS v{{ cve.cvss_version }}){% endif %}
|
| 18 |
+
</div>
|
| 19 |
+
<div><strong>Published</strong> {{ cve.published }}</div>
|
| 20 |
+
<div><strong>Modified</strong> {{ cve.last_modified }}</div>
|
| 21 |
+
<div><strong>Status</strong> {{ cve.status }}</div>
|
| 22 |
+
{% if cve.cvss_vector %}<div><strong>Vector</strong> <code>{{ cve.cvss_vector }}</code></div>{% endif %}
|
| 23 |
+
{% if cve.patch_languages %}
|
| 24 |
+
<div>
|
| 25 |
+
<strong>Languages</strong>
|
| 26 |
+
{% for l in cve.patch_languages %}<a class="chip chip-lang" href="/?language={{ l }}">{{ l }}</a>{% endfor %}
|
| 27 |
+
</div>
|
| 28 |
+
{% endif %}
|
| 29 |
+
</section>
|
| 30 |
+
|
| 31 |
+
<h2>Description</h2>
|
| 32 |
+
<p>{{ cve.description }}</p>
|
| 33 |
+
|
| 34 |
+
{% if cve.cwes %}
|
| 35 |
+
<h2>CWE</h2>
|
| 36 |
+
<ul class="cwe-list">
|
| 37 |
+
{% for c in cve.cwes %}
|
| 38 |
+
<li>
|
| 39 |
+
<strong>{{ c.id }}</strong> — {{ c.name }}
|
| 40 |
+
{% if c.description %}<div class="muted">{{ c.description }}</div>{% endif %}
|
| 41 |
+
</li>
|
| 42 |
+
{% endfor %}
|
| 43 |
+
</ul>
|
| 44 |
+
{% endif %}
|
| 45 |
+
|
| 46 |
+
{% if cve.references %}
|
| 47 |
+
<h2>References</h2>
|
| 48 |
+
<ul class="refs">
|
| 49 |
+
{% for r in cve.references %}<li><a href="{{ r }}" rel="noreferrer noopener">{{ r }}</a></li>{% endfor %}
|
| 50 |
+
</ul>
|
| 51 |
+
{% endif %}
|
| 52 |
+
|
| 53 |
+
<h2>Patch</h2>
|
| 54 |
+
{% for commit in commits %}
|
| 55 |
+
<section class="commit">
|
| 56 |
+
{% if commit.url %}<div class="commit-header"><a href="{{ commit.url }}">{{ commit.url }}</a></div>{% endif %}
|
| 57 |
+
{% for file in commit.files %}
|
| 58 |
+
<article class="file">
|
| 59 |
+
<header class="file-header">
|
| 60 |
+
{% if file.old_path and file.new_path and file.old_path != file.new_path %}
|
| 61 |
+
<code>{{ file.old_path }}</code> → <code>{{ file.new_path }}</code>
|
| 62 |
+
{% else %}
|
| 63 |
+
<code>{{ file.new_path or file.old_path }}</code>
|
| 64 |
+
{% endif %}
|
| 65 |
+
</header>
|
| 66 |
+
{% if file.note %}
|
| 67 |
+
<div class="binary muted">{{ file.note }}</div>
|
| 68 |
+
{% endif %}
|
| 69 |
+
{% for hunk in file.hunks %}
|
| 70 |
+
<table class="diff">
|
| 71 |
+
<colgroup>
|
| 72 |
+
<col class="col-ln"><col class="col-code"><col class="col-ln"><col class="col-code">
|
| 73 |
+
</colgroup>
|
| 74 |
+
<thead>
|
| 75 |
+
<tr><th colspan="4" class="hunk-header">{{ hunk.header }}</th></tr>
|
| 76 |
+
</thead>
|
| 77 |
+
<tbody>
|
| 78 |
+
{% for row in hunk.rows %}
|
| 79 |
+
<tr>
|
| 80 |
+
<td class="ln">{{ row.left_no or "" }}</td>
|
| 81 |
+
<td class="code side-{{ row.left_kind }}"><pre>{{ "-" if row.left_kind == "removed" else (" " if row.left_kind == "context" else "") }}{{ row.left_text }}</pre></td>
|
| 82 |
+
<td class="ln">{{ row.right_no or "" }}</td>
|
| 83 |
+
<td class="code side-{{ row.right_kind }}"><pre>{{ "+" if row.right_kind == "added" else (" " if row.right_kind == "context" else "") }}{{ row.right_text }}</pre></td>
|
| 84 |
+
</tr>
|
| 85 |
+
{% endfor %}
|
| 86 |
+
</tbody>
|
| 87 |
+
</table>
|
| 88 |
+
{% endfor %}
|
| 89 |
+
</article>
|
| 90 |
+
{% endfor %}
|
| 91 |
+
</section>
|
| 92 |
+
{% else %}
|
| 93 |
+
<p class="muted">No parsable patch.</p>
|
| 94 |
+
{% endfor %}
|
| 95 |
+
{% endblock %}
|
app/templates/list.html
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends "base.html" %}
|
| 2 |
+
{% block title %}cve-diff — search{% endblock %}
|
| 3 |
+
{% block content %}
|
| 4 |
+
<form class="filters" method="get" action="/" onsubmit="for(const e of this.elements){if(e.name && !e.value)e.disabled=true;}">
|
| 5 |
+
<input type="text" name="q" value="{{ filters.q }}" placeholder="CVE-ID or description…">
|
| 6 |
+
<select name="cwe">
|
| 7 |
+
<option value="">— CWE —</option>
|
| 8 |
+
{% for c in facets.cwes %}
|
| 9 |
+
<option value="{{ c }}" {% if filters.cwe == c %}selected{% endif %}>{{ c }}</option>
|
| 10 |
+
{% endfor %}
|
| 11 |
+
</select>
|
| 12 |
+
<select name="year">
|
| 13 |
+
<option value="">— year —</option>
|
| 14 |
+
{% for y in facets.years %}
|
| 15 |
+
<option value="{{ y }}" {% if filters.year == y %}selected{% endif %}>{{ y }}</option>
|
| 16 |
+
{% endfor %}
|
| 17 |
+
</select>
|
| 18 |
+
<select name="severity">
|
| 19 |
+
<option value="">— severity —</option>
|
| 20 |
+
{% for s in facets.severities %}
|
| 21 |
+
<option value="{{ s }}" {% if filters.severity == s %}selected{% endif %}>{{ s }}</option>
|
| 22 |
+
{% endfor %}
|
| 23 |
+
</select>
|
| 24 |
+
<select name="host">
|
| 25 |
+
<option value="">— host —</option>
|
| 26 |
+
{% for h in facets.hosts %}
|
| 27 |
+
<option value="{{ h }}" {% if filters.host == h %}selected{% endif %}>{{ h }}</option>
|
| 28 |
+
{% endfor %}
|
| 29 |
+
</select>
|
| 30 |
+
<select name="language">
|
| 31 |
+
<option value="">— language —</option>
|
| 32 |
+
{% for l in facets.languages %}
|
| 33 |
+
<option value="{{ l }}" {% if filters.language == l %}selected{% endif %}>{{ l }}</option>
|
| 34 |
+
{% endfor %}
|
| 35 |
+
</select>
|
| 36 |
+
<select name="patch">
|
| 37 |
+
<option value="">— patch —</option>
|
| 38 |
+
<option value="yes" {% if filters.patch == "yes" %}selected{% endif %}>with patch</option>
|
| 39 |
+
<option value="no" {% if filters.patch == "no" %}selected{% endif %}>without patch</option>
|
| 40 |
+
</select>
|
| 41 |
+
<button type="submit">Filter</button>
|
| 42 |
+
<a class="reset" href="/">reset</a>
|
| 43 |
+
</form>
|
| 44 |
+
|
| 45 |
+
<p class="muted">{{ total }} result(s) — page {{ page }} / {{ pages }}</p>
|
| 46 |
+
|
| 47 |
+
<table class="results">
|
| 48 |
+
<thead>
|
| 49 |
+
<tr>
|
| 50 |
+
<th>CVE</th><th>Year</th><th>Severity</th><th>CWE</th><th>Hosts</th><th>Languages</th><th>Description</th>
|
| 51 |
+
</tr>
|
| 52 |
+
</thead>
|
| 53 |
+
<tbody>
|
| 54 |
+
{% for r in rows %}
|
| 55 |
+
<tr>
|
| 56 |
+
<td><a href="/cve/{{ r.cve_id }}">{{ r.cve_id }}</a></td>
|
| 57 |
+
<td>{{ r.year }}</td>
|
| 58 |
+
<td>
|
| 59 |
+
{% if r.cvss_base_severity %}
|
| 60 |
+
<span class="sev sev-{{ r.cvss_base_severity|lower }}">{{ r.cvss_base_severity }}</span>
|
| 61 |
+
{% if r.cvss_base_score is not none %}<span class="muted">{{ "%.1f"|format(r.cvss_base_score) }}</span>{% endif %}
|
| 62 |
+
{% endif %}
|
| 63 |
+
</td>
|
| 64 |
+
<td>
|
| 65 |
+
{% for c in r.cwes %}<span class="chip">{{ c.id }}</span>{% endfor %}
|
| 66 |
+
</td>
|
| 67 |
+
<td>
|
| 68 |
+
{% for h in r.patch_hosts %}<span class="chip">{{ h }}</span>{% endfor %}
|
| 69 |
+
</td>
|
| 70 |
+
<td>
|
| 71 |
+
{% for l in r.patch_languages %}<a class="chip chip-lang" href="/?{{ qs(filters, language=l, page=1) }}">{{ l }}</a>{% endfor %}
|
| 72 |
+
</td>
|
| 73 |
+
<td class="desc">{{ (r.description or "")[:200] }}{% if (r.description or "")|length > 200 %}…{% endif %}</td>
|
| 74 |
+
</tr>
|
| 75 |
+
{% else %}
|
| 76 |
+
<tr><td colspan="7" class="muted">No results.</td></tr>
|
| 77 |
+
{% endfor %}
|
| 78 |
+
</tbody>
|
| 79 |
+
</table>
|
| 80 |
+
|
| 81 |
+
<nav class="pager">
|
| 82 |
+
{% if page > 1 %}<a href="/?{{ qs(filters, page=page-1) }}">← previous</a>{% endif %}
|
| 83 |
+
<span class="muted">page {{ page }} / {{ pages }}</span>
|
| 84 |
+
{% if page < pages %}<a href="/?{{ qs(filters, page=page+1) }}">next →</a>{% endif %}
|
| 85 |
+
</nav>
|
| 86 |
+
{% endblock %}
|
build_parquet.py
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Build parquet shards from dataset/cve_diff, dataset/nvd, dataset/cwe.
|
| 2 |
+
|
| 3 |
+
One row per CVE that has a patch in dataset/cve_diff/data. Joins NVD metadata
|
| 4 |
+
(description, weaknesses, CVSS, references, dates) and CWE definitions
|
| 5 |
+
(name + short description) from the CWE XML views. Writes
|
| 6 |
+
dataset/parquet/cve_diff-part<N>.parquet, capped at 300 MB per shard.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
|
| 11 |
+
import json
|
| 12 |
+
import re
|
| 13 |
+
import sys
|
| 14 |
+
import xml.etree.ElementTree as ET
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
from urllib.parse import urlparse
|
| 17 |
+
|
| 18 |
+
import pyarrow as pa
|
| 19 |
+
import pyarrow.parquet as pq
|
| 20 |
+
|
| 21 |
+
ROOT = Path(__file__).resolve().parent
|
| 22 |
+
DATASET = ROOT / "dataset"
|
| 23 |
+
DIFF_DIR = DATASET / "cve_diff" / "data"
|
| 24 |
+
NVD_DIR = DATASET / "nvd" / "data"
|
| 25 |
+
CWE_DIR = DATASET / "cwe" / "data"
|
| 26 |
+
OUT_DIR = DATASET / "parquet"
|
| 27 |
+
|
| 28 |
+
SHARD_BUDGET_BYTES = 300 * 1024 * 1024
|
| 29 |
+
ORIGIN_HEADER_RE = re.compile(r"^=== (.+?) ===\s*$", re.MULTILINE)
|
| 30 |
+
CWE_ID_RE = re.compile(r"CWE-\d+", re.IGNORECASE)
|
| 31 |
+
CWE_NS = {"c": "http://cwe.mitre.org/cwe-7"}
|
| 32 |
+
|
| 33 |
+
# ---- Programming-language detection ----------------------------------------
|
| 34 |
+
# Pulled from the file paths in `diff --git a/<old> b/<new>` headers. We rely
|
| 35 |
+
# on extension/basename only (no content sniffing) because diff bodies are
|
| 36 |
+
# already truncated context, not whole files. The mapping is curated for
|
| 37 |
+
# languages that show up in CVE patches; extend as needed.
|
| 38 |
+
|
| 39 |
+
_DIFF_PATH_RE = re.compile(r"^diff --git a/(.+?) b/(.+?)$", re.MULTILINE)
|
| 40 |
+
|
| 41 |
+
_LANG_BY_EXT: dict[str, str] = {
|
| 42 |
+
# C / C++
|
| 43 |
+
"c": "C", "h": "C",
|
| 44 |
+
"cc": "C++", "cpp": "C++", "cxx": "C++", "c++": "C++",
|
| 45 |
+
"hh": "C++", "hpp": "C++", "hxx": "C++", "h++": "C++", "ipp": "C++",
|
| 46 |
+
"m": "Objective-C", "mm": "Objective-C++",
|
| 47 |
+
# JVM
|
| 48 |
+
"java": "Java",
|
| 49 |
+
"kt": "Kotlin", "kts": "Kotlin",
|
| 50 |
+
"scala": "Scala", "sc": "Scala",
|
| 51 |
+
"groovy": "Groovy", "gradle": "Groovy",
|
| 52 |
+
"clj": "Clojure", "cljs": "Clojure", "cljc": "Clojure", "edn": "Clojure",
|
| 53 |
+
# Scripting
|
| 54 |
+
"py": "Python", "pyx": "Python", "pyi": "Python", "pyw": "Python",
|
| 55 |
+
"rb": "Ruby", "rake": "Ruby", "gemspec": "Ruby",
|
| 56 |
+
"pl": "Perl", "pm": "Perl", "t": "Perl",
|
| 57 |
+
"php": "PHP", "phtml": "PHP", "php3": "PHP", "php4": "PHP",
|
| 58 |
+
"php5": "PHP", "php7": "PHP", "phps": "PHP", "inc": "PHP",
|
| 59 |
+
"lua": "Lua",
|
| 60 |
+
"sh": "Shell", "bash": "Shell", "zsh": "Shell", "ksh": "Shell",
|
| 61 |
+
"ps1": "PowerShell", "psm1": "PowerShell",
|
| 62 |
+
"tcl": "Tcl", "tk": "Tcl",
|
| 63 |
+
# Web front-end
|
| 64 |
+
"js": "JavaScript", "mjs": "JavaScript", "cjs": "JavaScript",
|
| 65 |
+
"jsx": "JavaScript",
|
| 66 |
+
"ts": "TypeScript", "tsx": "TypeScript",
|
| 67 |
+
"vue": "Vue", "svelte": "Svelte",
|
| 68 |
+
"html": "HTML", "htm": "HTML",
|
| 69 |
+
"css": "CSS",
|
| 70 |
+
"scss": "Sass", "sass": "Sass",
|
| 71 |
+
"less": "Less",
|
| 72 |
+
"coffee": "CoffeeScript",
|
| 73 |
+
# Server-side templates & CGI
|
| 74 |
+
"jsp": "JSP", "jspf": "JSP", "tag": "JSP",
|
| 75 |
+
"gsp": "Groovy",
|
| 76 |
+
"cgi": "Perl",
|
| 77 |
+
"twig": "Twig",
|
| 78 |
+
"erb": "Ruby",
|
| 79 |
+
"ctp": "PHP", "tpl": "Smarty", "smarty": "Smarty",
|
| 80 |
+
"module": "PHP", "install": "PHP",
|
| 81 |
+
"vm": "Velocity", "vtl": "Velocity",
|
| 82 |
+
"dtml": "Python",
|
| 83 |
+
"gleam": "Gleam",
|
| 84 |
+
"vala": "Vala",
|
| 85 |
+
"am": "Makefile", "in": "Makefile",
|
| 86 |
+
# Systems
|
| 87 |
+
"go": "Go",
|
| 88 |
+
"rs": "Rust",
|
| 89 |
+
"swift": "Swift",
|
| 90 |
+
"dart": "Dart",
|
| 91 |
+
"cs": "C#",
|
| 92 |
+
"vb": "Visual Basic",
|
| 93 |
+
"fs": "F#", "fsi": "F#", "fsx": "F#",
|
| 94 |
+
"ex": "Elixir", "exs": "Elixir",
|
| 95 |
+
"erl": "Erlang", "hrl": "Erlang",
|
| 96 |
+
"hs": "Haskell", "lhs": "Haskell",
|
| 97 |
+
"ml": "OCaml", "mli": "OCaml",
|
| 98 |
+
"nim": "Nim",
|
| 99 |
+
"zig": "Zig",
|
| 100 |
+
"d": "D",
|
| 101 |
+
"ada": "Ada", "adb": "Ada", "ads": "Ada",
|
| 102 |
+
"f": "Fortran", "f90": "Fortran", "f95": "Fortran", "f03": "Fortran",
|
| 103 |
+
"for": "Fortran",
|
| 104 |
+
"asm": "Assembly", "s": "Assembly",
|
| 105 |
+
# Data / config
|
| 106 |
+
"xml": "XML", "xsd": "XML", "xsl": "XML", "xslt": "XML",
|
| 107 |
+
"json": "JSON", "json5": "JSON",
|
| 108 |
+
"yaml": "YAML", "yml": "YAML",
|
| 109 |
+
"toml": "TOML",
|
| 110 |
+
"ini": "INI", "cfg": "INI", "conf": "INI", "properties": "INI",
|
| 111 |
+
"sql": "SQL",
|
| 112 |
+
"proto": "Protocol Buffers",
|
| 113 |
+
"tf": "Terraform", "tfvars": "Terraform",
|
| 114 |
+
# Build
|
| 115 |
+
"cmake": "CMake",
|
| 116 |
+
"mk": "Makefile", "make": "Makefile",
|
| 117 |
+
"bzl": "Bazel",
|
| 118 |
+
# Docs
|
| 119 |
+
"md": "Markdown", "markdown": "Markdown",
|
| 120 |
+
"rst": "reStructuredText",
|
| 121 |
+
"tex": "TeX",
|
| 122 |
+
"adoc": "AsciiDoc",
|
| 123 |
+
# Hardware description
|
| 124 |
+
"vhd": "VHDL", "vhdl": "VHDL",
|
| 125 |
+
"v": "Verilog", "sv": "SystemVerilog",
|
| 126 |
+
# Misc
|
| 127 |
+
"r": "R",
|
| 128 |
+
"jl": "Julia",
|
| 129 |
+
"rkt": "Racket",
|
| 130 |
+
"ss": "Scheme", "scm": "Scheme",
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
# Filenames with no extension (or whose extension would be misleading) that
|
| 134 |
+
# unambiguously identify a language.
|
| 135 |
+
_LANG_BY_BASENAME: dict[str, str] = {
|
| 136 |
+
"Dockerfile": "Dockerfile",
|
| 137 |
+
"dockerfile": "Dockerfile",
|
| 138 |
+
"Containerfile": "Dockerfile",
|
| 139 |
+
"Makefile": "Makefile",
|
| 140 |
+
"makefile": "Makefile",
|
| 141 |
+
"GNUmakefile": "Makefile",
|
| 142 |
+
"CMakeLists.txt": "CMake",
|
| 143 |
+
"Rakefile": "Ruby",
|
| 144 |
+
"Gemfile": "Ruby",
|
| 145 |
+
"Vagrantfile": "Ruby",
|
| 146 |
+
"Podfile": "Ruby",
|
| 147 |
+
"Brewfile": "Ruby",
|
| 148 |
+
"BUILD": "Bazel", "BUILD.bazel": "Bazel",
|
| 149 |
+
"WORKSPACE": "Bazel", "WORKSPACE.bazel": "Bazel",
|
| 150 |
+
"Jenkinsfile": "Groovy",
|
| 151 |
+
"Pipfile": "TOML",
|
| 152 |
+
"configure": "Shell",
|
| 153 |
+
"configure.ac": "Shell",
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
def detect_languages(body: str) -> list[str]:
|
| 158 |
+
"""Return sorted, unique programming languages touched by the diff."""
|
| 159 |
+
langs: set[str] = set()
|
| 160 |
+
for old_path, new_path in _DIFF_PATH_RE.findall(body):
|
| 161 |
+
# Prefer the new path; on file deletion (new=/dev/null) fall back.
|
| 162 |
+
path = new_path if new_path != "/dev/null" else old_path
|
| 163 |
+
if not path:
|
| 164 |
+
continue
|
| 165 |
+
basename = path.rsplit("/", 1)[-1]
|
| 166 |
+
lang = _LANG_BY_BASENAME.get(basename)
|
| 167 |
+
if lang is None and "." in basename:
|
| 168 |
+
ext = basename.rsplit(".", 1)[1].lower()
|
| 169 |
+
lang = _LANG_BY_EXT.get(ext)
|
| 170 |
+
if lang:
|
| 171 |
+
langs.add(lang)
|
| 172 |
+
return sorted(langs)
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
def load_cwe_definitions() -> dict[str, dict[str, str]]:
|
| 176 |
+
"""Return {CWE-22: {"name": ..., "description": ...}, ...} from XML views."""
|
| 177 |
+
defs: dict[str, dict[str, str]] = {}
|
| 178 |
+
for xml in sorted(CWE_DIR.glob("*.xml")):
|
| 179 |
+
try:
|
| 180 |
+
tree = ET.parse(xml)
|
| 181 |
+
except ET.ParseError as exc:
|
| 182 |
+
print(f"[cwe] skip {xml.name}: {exc}", file=sys.stderr)
|
| 183 |
+
continue
|
| 184 |
+
for w in tree.getroot().iterfind(".//c:Weakness", CWE_NS):
|
| 185 |
+
cwe_id = f"CWE-{w.attrib['ID']}"
|
| 186 |
+
if cwe_id in defs:
|
| 187 |
+
continue
|
| 188 |
+
name = w.attrib.get("Name", "")
|
| 189 |
+
desc_el = w.find("c:Description", CWE_NS)
|
| 190 |
+
description = (desc_el.text or "").strip() if desc_el is not None else ""
|
| 191 |
+
defs[cwe_id] = {"name": name, "description": description}
|
| 192 |
+
print(f"[cwe] loaded {len(defs)} definitions", file=sys.stderr)
|
| 193 |
+
return defs
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
def english_description(descriptions: list[dict]) -> str:
|
| 197 |
+
for d in descriptions:
|
| 198 |
+
if d.get("lang") == "en":
|
| 199 |
+
return d.get("value", "")
|
| 200 |
+
return descriptions[0].get("value", "") if descriptions else ""
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def extract_cwes(weaknesses: list[dict]) -> list[str]:
|
| 204 |
+
seen: list[str] = []
|
| 205 |
+
for w in weaknesses or []:
|
| 206 |
+
for d in w.get("description", []):
|
| 207 |
+
for cwe_id in CWE_ID_RE.findall(d.get("value", "")):
|
| 208 |
+
norm = cwe_id.upper()
|
| 209 |
+
if norm not in seen:
|
| 210 |
+
seen.append(norm)
|
| 211 |
+
return seen
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
def best_cvss(metrics: dict) -> tuple[str | None, float | None, str | None, str | None]:
|
| 215 |
+
"""Return (version, base_score, severity, vector) from the best metric available."""
|
| 216 |
+
for key in ("cvssMetricV40", "cvssMetricV31", "cvssMetricV30", "cvssMetricV2"):
|
| 217 |
+
entries = metrics.get(key) or []
|
| 218 |
+
if not entries:
|
| 219 |
+
continue
|
| 220 |
+
primary = next((e for e in entries if e.get("type") == "Primary"), entries[0])
|
| 221 |
+
data = primary.get("cvssData", {})
|
| 222 |
+
return (
|
| 223 |
+
data.get("version"),
|
| 224 |
+
data.get("baseScore"),
|
| 225 |
+
data.get("baseSeverity") or primary.get("baseSeverity"),
|
| 226 |
+
data.get("vectorString"),
|
| 227 |
+
)
|
| 228 |
+
return None, None, None, None
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
def load_nvd_index() -> dict[str, dict]:
|
| 232 |
+
"""Map CVE-ID -> minimal NVD payload."""
|
| 233 |
+
index: dict[str, dict] = {}
|
| 234 |
+
for path in sorted(NVD_DIR.glob("nvdcve-2.0-*.json")):
|
| 235 |
+
print(f"[nvd] {path.name}", file=sys.stderr)
|
| 236 |
+
with path.open() as f:
|
| 237 |
+
data = json.load(f)
|
| 238 |
+
for v in data.get("vulnerabilities", []):
|
| 239 |
+
cve = v.get("cve") or {}
|
| 240 |
+
cid = cve.get("id")
|
| 241 |
+
if not cid:
|
| 242 |
+
continue
|
| 243 |
+
version, score, severity, vector = best_cvss(cve.get("metrics", {}))
|
| 244 |
+
index[cid] = {
|
| 245 |
+
"description": english_description(cve.get("descriptions", [])),
|
| 246 |
+
"cwes": extract_cwes(cve.get("weaknesses", [])),
|
| 247 |
+
"published": cve.get("published"),
|
| 248 |
+
"last_modified": cve.get("lastModified"),
|
| 249 |
+
"status": cve.get("vulnStatus"),
|
| 250 |
+
"source_identifier": cve.get("sourceIdentifier"),
|
| 251 |
+
"cvss_version": version,
|
| 252 |
+
"cvss_base_score": float(score) if score is not None else None,
|
| 253 |
+
"cvss_base_severity": severity,
|
| 254 |
+
"cvss_vector": vector,
|
| 255 |
+
"references": [r.get("url") for r in cve.get("references", []) if r.get("url")],
|
| 256 |
+
}
|
| 257 |
+
print(f"[nvd] indexed {len(index)} CVEs", file=sys.stderr)
|
| 258 |
+
return index
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
def parse_diff(path: Path) -> tuple[list[str], str]:
|
| 262 |
+
"""Return (origin_urls, patch_body). The body keeps the === headers in place."""
|
| 263 |
+
text = path.read_text(encoding="utf-8", errors="replace")
|
| 264 |
+
urls = ORIGIN_HEADER_RE.findall(text)
|
| 265 |
+
return urls, text
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
def host_label(url: str) -> str:
|
| 269 |
+
host = (urlparse(url).hostname or "").lower()
|
| 270 |
+
if not host:
|
| 271 |
+
return "unknown"
|
| 272 |
+
if host == "github.com" or host.endswith(".github.com"):
|
| 273 |
+
return "github"
|
| 274 |
+
if "gitlab" in host:
|
| 275 |
+
return "gitlab"
|
| 276 |
+
if host == "gitee.com":
|
| 277 |
+
return "gitee"
|
| 278 |
+
if host.startswith("cgit.") or host.startswith("git.") or "gitweb" in host:
|
| 279 |
+
return "cgit"
|
| 280 |
+
return host
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
_EMPTY_META = {
|
| 284 |
+
"description": "",
|
| 285 |
+
"cwes": [],
|
| 286 |
+
"published": None,
|
| 287 |
+
"last_modified": None,
|
| 288 |
+
"status": None,
|
| 289 |
+
"source_identifier": None,
|
| 290 |
+
"cvss_version": None,
|
| 291 |
+
"cvss_base_score": None,
|
| 292 |
+
"cvss_base_severity": None,
|
| 293 |
+
"cvss_vector": None,
|
| 294 |
+
"references": [],
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
def build_rows(cwe_defs: dict[str, dict[str, str]], nvd_index: dict[str, dict]):
|
| 299 |
+
"""Emit one row per CVE in (NVD ∪ patch files).
|
| 300 |
+
|
| 301 |
+
A CVE is included whether or not it has a patch — `has_patch` flags the
|
| 302 |
+
distinction so the UI/notebook can filter either way. Patch-less rows
|
| 303 |
+
keep empty `patch_diff`, `patch_urls`, `patch_hosts`, `patch_languages`.
|
| 304 |
+
"""
|
| 305 |
+
diff_paths = {p.stem: p for p in DIFF_DIR.rglob("CVE-*.diff")}
|
| 306 |
+
all_ids = sorted(set(nvd_index.keys()) | set(diff_paths.keys()))
|
| 307 |
+
print(f"[build] {len(all_ids)} CVEs (NVD: {len(nvd_index)}, "
|
| 308 |
+
f"patches: {len(diff_paths)})", file=sys.stderr)
|
| 309 |
+
|
| 310 |
+
n_with_patch = 0
|
| 311 |
+
n_without_patch = 0
|
| 312 |
+
n_no_nvd = 0
|
| 313 |
+
|
| 314 |
+
for cve_id in all_ids:
|
| 315 |
+
path = diff_paths.get(cve_id)
|
| 316 |
+
if path is not None:
|
| 317 |
+
urls, body = parse_diff(path)
|
| 318 |
+
if not body.strip():
|
| 319 |
+
urls, body = [], ""
|
| 320 |
+
else:
|
| 321 |
+
urls, body = [], ""
|
| 322 |
+
|
| 323 |
+
meta = nvd_index.get(cve_id)
|
| 324 |
+
if meta is None:
|
| 325 |
+
n_no_nvd += 1
|
| 326 |
+
meta = _EMPTY_META
|
| 327 |
+
|
| 328 |
+
cwe_details = [
|
| 329 |
+
{
|
| 330 |
+
"id": cid,
|
| 331 |
+
"name": cwe_defs.get(cid, {}).get("name", ""),
|
| 332 |
+
"description": cwe_defs.get(cid, {}).get("description", ""),
|
| 333 |
+
}
|
| 334 |
+
for cid in meta["cwes"]
|
| 335 |
+
]
|
| 336 |
+
try:
|
| 337 |
+
year = int(cve_id.split("-")[1])
|
| 338 |
+
except (IndexError, ValueError):
|
| 339 |
+
year = 0
|
| 340 |
+
|
| 341 |
+
has_patch = bool(body)
|
| 342 |
+
if has_patch:
|
| 343 |
+
n_with_patch += 1
|
| 344 |
+
else:
|
| 345 |
+
n_without_patch += 1
|
| 346 |
+
|
| 347 |
+
yield {
|
| 348 |
+
"cve_id": cve_id,
|
| 349 |
+
"year": year,
|
| 350 |
+
"description": meta["description"],
|
| 351 |
+
"cwes": cwe_details,
|
| 352 |
+
"patch_diff": body,
|
| 353 |
+
"patch_urls": urls,
|
| 354 |
+
"patch_hosts": sorted({host_label(u) for u in urls}),
|
| 355 |
+
"patch_languages": detect_languages(body),
|
| 356 |
+
"has_patch": has_patch,
|
| 357 |
+
"published": meta["published"],
|
| 358 |
+
"last_modified": meta["last_modified"],
|
| 359 |
+
"status": meta["status"],
|
| 360 |
+
"source_identifier": meta["source_identifier"],
|
| 361 |
+
"cvss_version": meta["cvss_version"],
|
| 362 |
+
"cvss_base_score": meta["cvss_base_score"],
|
| 363 |
+
"cvss_base_severity": meta["cvss_base_severity"],
|
| 364 |
+
"cvss_vector": meta["cvss_vector"],
|
| 365 |
+
"references": meta["references"],
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
print(
|
| 369 |
+
f"[build] rows: with_patch={n_with_patch} "
|
| 370 |
+
f"without_patch={n_without_patch} (missing_nvd={n_no_nvd})",
|
| 371 |
+
file=sys.stderr,
|
| 372 |
+
)
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
SCHEMA = pa.schema(
|
| 376 |
+
[
|
| 377 |
+
("cve_id", pa.string()),
|
| 378 |
+
("year", pa.int32()),
|
| 379 |
+
("description", pa.string()),
|
| 380 |
+
(
|
| 381 |
+
"cwes",
|
| 382 |
+
pa.list_(
|
| 383 |
+
pa.struct(
|
| 384 |
+
[
|
| 385 |
+
("id", pa.string()),
|
| 386 |
+
("name", pa.string()),
|
| 387 |
+
("description", pa.string()),
|
| 388 |
+
]
|
| 389 |
+
)
|
| 390 |
+
),
|
| 391 |
+
),
|
| 392 |
+
("patch_diff", pa.large_string()),
|
| 393 |
+
("patch_urls", pa.list_(pa.string())),
|
| 394 |
+
("patch_hosts", pa.list_(pa.string())),
|
| 395 |
+
("patch_languages", pa.list_(pa.string())),
|
| 396 |
+
("has_patch", pa.bool_()),
|
| 397 |
+
("published", pa.string()),
|
| 398 |
+
("last_modified", pa.string()),
|
| 399 |
+
("status", pa.string()),
|
| 400 |
+
("source_identifier", pa.string()),
|
| 401 |
+
("cvss_version", pa.string()),
|
| 402 |
+
("cvss_base_score", pa.float64()),
|
| 403 |
+
("cvss_base_severity", pa.string()),
|
| 404 |
+
("cvss_vector", pa.string()),
|
| 405 |
+
("references", pa.list_(pa.string())),
|
| 406 |
+
]
|
| 407 |
+
)
|
| 408 |
+
|
| 409 |
+
|
| 410 |
+
def write_shards(rows):
|
| 411 |
+
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
| 412 |
+
for old in OUT_DIR.glob("cve_diff-part*.parquet"):
|
| 413 |
+
old.unlink()
|
| 414 |
+
|
| 415 |
+
shard_index = 1
|
| 416 |
+
buffer: list[dict] = []
|
| 417 |
+
buffer_bytes = 0
|
| 418 |
+
|
| 419 |
+
def flush():
|
| 420 |
+
nonlocal shard_index, buffer, buffer_bytes
|
| 421 |
+
if not buffer:
|
| 422 |
+
return
|
| 423 |
+
table = pa.Table.from_pylist(buffer, schema=SCHEMA)
|
| 424 |
+
out = OUT_DIR / f"cve_diff-part{shard_index:03d}.parquet"
|
| 425 |
+
pq.write_table(table, out, compression="zstd")
|
| 426 |
+
print(f"[parquet] wrote {out.name} rows={len(buffer)} size={out.stat().st_size:,}B", file=sys.stderr)
|
| 427 |
+
shard_index += 1
|
| 428 |
+
buffer = []
|
| 429 |
+
buffer_bytes = 0
|
| 430 |
+
|
| 431 |
+
for row in rows:
|
| 432 |
+
# raw size estimate: diff + description dominate
|
| 433 |
+
approx = len(row["patch_diff"].encode("utf-8", errors="replace"))
|
| 434 |
+
approx += len((row["description"] or "").encode("utf-8", errors="replace"))
|
| 435 |
+
# zstd typically gets diffs to ~25% — be conservative at 50%
|
| 436 |
+
if buffer_bytes and buffer_bytes + approx > SHARD_BUDGET_BYTES * 2:
|
| 437 |
+
flush()
|
| 438 |
+
buffer.append(row)
|
| 439 |
+
buffer_bytes += approx
|
| 440 |
+
|
| 441 |
+
flush()
|
| 442 |
+
|
| 443 |
+
|
| 444 |
+
def main() -> int:
|
| 445 |
+
cwe_defs = load_cwe_definitions()
|
| 446 |
+
nvd_index = load_nvd_index()
|
| 447 |
+
write_shards(build_rows(cwe_defs, nvd_index))
|
| 448 |
+
return 0
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
if __name__ == "__main__":
|
| 452 |
+
sys.exit(main())
|
explore.ipynb
ADDED
|
@@ -0,0 +1,1061 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"id": "4ec4c2e2",
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"source": [
|
| 8 |
+
"# Exploring the CVE ↔ patch dataset\n",
|
| 9 |
+
"\n",
|
| 10 |
+
"Reading the parquet produced by `build_parquet.py` with Polars, plus example queries."
|
| 11 |
+
]
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"cell_type": "code",
|
| 15 |
+
"execution_count": 1,
|
| 16 |
+
"id": "4db5c96a",
|
| 17 |
+
"metadata": {
|
| 18 |
+
"execution": {
|
| 19 |
+
"iopub.execute_input": "2026-05-22T12:57:46.182768Z",
|
| 20 |
+
"iopub.status.busy": "2026-05-22T12:57:46.182674Z",
|
| 21 |
+
"iopub.status.idle": "2026-05-22T12:57:46.245899Z",
|
| 22 |
+
"shell.execute_reply": "2026-05-22T12:57:46.245606Z"
|
| 23 |
+
}
|
| 24 |
+
},
|
| 25 |
+
"outputs": [
|
| 26 |
+
{
|
| 27 |
+
"data": {
|
| 28 |
+
"text/plain": [
|
| 29 |
+
"Schema([('cve_id', String),\n",
|
| 30 |
+
" ('year', Int32),\n",
|
| 31 |
+
" ('description', String),\n",
|
| 32 |
+
" ('cwes',\n",
|
| 33 |
+
" List(Struct({'id': String, 'name': String, 'description': String}))),\n",
|
| 34 |
+
" ('patch_diff', String),\n",
|
| 35 |
+
" ('patch_urls', List(String)),\n",
|
| 36 |
+
" ('patch_hosts', List(String)),\n",
|
| 37 |
+
" ('patch_languages', List(String)),\n",
|
| 38 |
+
" ('has_patch', Boolean),\n",
|
| 39 |
+
" ('published', String),\n",
|
| 40 |
+
" ('last_modified', String),\n",
|
| 41 |
+
" ('status', String),\n",
|
| 42 |
+
" ('source_identifier', String),\n",
|
| 43 |
+
" ('cvss_version', String),\n",
|
| 44 |
+
" ('cvss_base_score', Float64),\n",
|
| 45 |
+
" ('cvss_base_severity', String),\n",
|
| 46 |
+
" ('cvss_vector', String),\n",
|
| 47 |
+
" ('references', List(String))])"
|
| 48 |
+
]
|
| 49 |
+
},
|
| 50 |
+
"execution_count": 1,
|
| 51 |
+
"metadata": {},
|
| 52 |
+
"output_type": "execute_result"
|
| 53 |
+
}
|
| 54 |
+
],
|
| 55 |
+
"source": [
|
| 56 |
+
"from pathlib import Path\n",
|
| 57 |
+
"import polars as pl\n",
|
| 58 |
+
"\n",
|
| 59 |
+
"pl.Config.set_fmt_str_lengths(120)\n",
|
| 60 |
+
"pl.Config.set_tbl_rows(20)\n",
|
| 61 |
+
"\n",
|
| 62 |
+
"PARQUET_GLOB = str(Path(\"dataset/parquet\") / \"cve_diff-part*.parquet\")\n",
|
| 63 |
+
"\n",
|
| 64 |
+
"# scan_parquet is lazy: Polars only loads the columns / rows it needs.\n",
|
| 65 |
+
"lf = pl.scan_parquet(PARQUET_GLOB)\n",
|
| 66 |
+
"lf.collect_schema()"
|
| 67 |
+
]
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"cell_type": "markdown",
|
| 71 |
+
"id": "c4d9849b",
|
| 72 |
+
"metadata": {},
|
| 73 |
+
"source": [
|
| 74 |
+
"## 1. Overview"
|
| 75 |
+
]
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"cell_type": "code",
|
| 79 |
+
"execution_count": 2,
|
| 80 |
+
"id": "a63ddf22",
|
| 81 |
+
"metadata": {
|
| 82 |
+
"execution": {
|
| 83 |
+
"iopub.execute_input": "2026-05-22T12:57:46.246917Z",
|
| 84 |
+
"iopub.status.busy": "2026-05-22T12:57:46.246822Z",
|
| 85 |
+
"iopub.status.idle": "2026-05-22T12:57:46.252529Z",
|
| 86 |
+
"shell.execute_reply": "2026-05-22T12:57:46.252237Z"
|
| 87 |
+
}
|
| 88 |
+
},
|
| 89 |
+
"outputs": [
|
| 90 |
+
{
|
| 91 |
+
"data": {
|
| 92 |
+
"text/html": [
|
| 93 |
+
"<div><style>\n",
|
| 94 |
+
".dataframe > thead > tr,\n",
|
| 95 |
+
".dataframe > tbody > tr {\n",
|
| 96 |
+
" text-align: right;\n",
|
| 97 |
+
" white-space: pre-wrap;\n",
|
| 98 |
+
"}\n",
|
| 99 |
+
"</style>\n",
|
| 100 |
+
"<small>shape: (1, 6)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>rows</th><th>with_patch</th><th>without_patch</th><th>year_min</th><th>year_max</th><th>cvss_mean</th></tr><tr><td>u32</td><td>u32</td><td>u32</td><td>i32</td><td>i32</td><td>f64</td></tr></thead><tbody><tr><td>351884</td><td>25015</td><td>326869</td><td>1999</td><td>2026</td><td>6.8</td></tr></tbody></table></div>"
|
| 101 |
+
],
|
| 102 |
+
"text/plain": [
|
| 103 |
+
"shape: (1, 6)\n",
|
| 104 |
+
"┌────────┬────────────┬───────────────┬──────────┬──────────┬───────────┐\n",
|
| 105 |
+
"│ rows ┆ with_patch ┆ without_patch ┆ year_min ┆ year_max ┆ cvss_mean │\n",
|
| 106 |
+
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
|
| 107 |
+
"│ u32 ┆ u32 ┆ u32 ┆ i32 ┆ i32 ┆ f64 │\n",
|
| 108 |
+
"╞════════╪════════════╪═══════════════╪══════════╪══════════╪═══════════╡\n",
|
| 109 |
+
"│ 351884 ┆ 25015 ┆ 326869 ┆ 1999 ┆ 2026 ┆ 6.8 │\n",
|
| 110 |
+
"└────────┴────────────┴───────────────┴──────────┴──────────┴───────────┘"
|
| 111 |
+
]
|
| 112 |
+
},
|
| 113 |
+
"execution_count": 2,
|
| 114 |
+
"metadata": {},
|
| 115 |
+
"output_type": "execute_result"
|
| 116 |
+
}
|
| 117 |
+
],
|
| 118 |
+
"source": [
|
| 119 |
+
"lf.select(\n",
|
| 120 |
+
" pl.len().alias(\"rows\"),\n",
|
| 121 |
+
" pl.col(\"has_patch\").sum().alias(\"with_patch\"),\n",
|
| 122 |
+
" (~pl.col(\"has_patch\")).sum().alias(\"without_patch\"),\n",
|
| 123 |
+
" pl.col(\"year\").min().alias(\"year_min\"),\n",
|
| 124 |
+
" pl.col(\"year\").max().alias(\"year_max\"),\n",
|
| 125 |
+
" pl.col(\"cvss_base_score\").mean().round(2).alias(\"cvss_mean\"),\n",
|
| 126 |
+
").collect()"
|
| 127 |
+
]
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"cell_type": "code",
|
| 131 |
+
"execution_count": 3,
|
| 132 |
+
"id": "ef8791db",
|
| 133 |
+
"metadata": {
|
| 134 |
+
"execution": {
|
| 135 |
+
"iopub.execute_input": "2026-05-22T12:57:46.253597Z",
|
| 136 |
+
"iopub.status.busy": "2026-05-22T12:57:46.253506Z",
|
| 137 |
+
"iopub.status.idle": "2026-05-22T12:57:46.259428Z",
|
| 138 |
+
"shell.execute_reply": "2026-05-22T12:57:46.259060Z"
|
| 139 |
+
}
|
| 140 |
+
},
|
| 141 |
+
"outputs": [
|
| 142 |
+
{
|
| 143 |
+
"data": {
|
| 144 |
+
"text/html": [
|
| 145 |
+
"<div><style>\n",
|
| 146 |
+
".dataframe > thead > tr,\n",
|
| 147 |
+
".dataframe > tbody > tr {\n",
|
| 148 |
+
" text-align: right;\n",
|
| 149 |
+
" white-space: pre-wrap;\n",
|
| 150 |
+
"}\n",
|
| 151 |
+
"</style>\n",
|
| 152 |
+
"<small>shape: (5, 5)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>cve_id</th><th>year</th><th>cvss_base_severity</th><th>cvss_base_score</th><th>description</th></tr><tr><td>str</td><td>i32</td><td>str</td><td>f64</td><td>str</td></tr></thead><tbody><tr><td>"CVE-1999-0001"</td><td>1999</td><td>"MEDIUM"</td><td>5.0</td><td>"ip_input.c in BSD-derived TCP/IP implementations allows remote attackers to cause a denial of service (crash or hang) vi…</td></tr><tr><td>"CVE-1999-0002"</td><td>1999</td><td>"HIGH"</td><td>10.0</td><td>"Buffer overflow in NFS mountd gives root access to remote attackers, mostly in Linux systems."</td></tr><tr><td>"CVE-1999-0003"</td><td>1999</td><td>"HIGH"</td><td>10.0</td><td>"Execute commands as root via buffer overflow in Tooltalk database server (rpc.ttdbserverd)."</td></tr><tr><td>"CVE-1999-0004"</td><td>1999</td><td>"MEDIUM"</td><td>5.0</td><td>"MIME buffer overflow in email clients, e.g. Solaris mailtool and Outlook."</td></tr><tr><td>"CVE-1999-0005"</td><td>1999</td><td>"HIGH"</td><td>10.0</td><td>"Arbitrary command execution via IMAP buffer overflow in authenticate command."</td></tr></tbody></table></div>"
|
| 153 |
+
],
|
| 154 |
+
"text/plain": [
|
| 155 |
+
"shape: (5, 5)\n",
|
| 156 |
+
"┌───────────────┬──────┬────────────────────┬─────────────────┬────────────────────────────────────┐\n",
|
| 157 |
+
"│ cve_id ┆ year ┆ cvss_base_severity ┆ cvss_base_score ┆ description │\n",
|
| 158 |
+
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
|
| 159 |
+
"│ str ┆ i32 ┆ str ┆ f64 ┆ str │\n",
|
| 160 |
+
"╞═══════════════╪══════╪════════════════════╪═════════════════╪════════════════════════════════════╡\n",
|
| 161 |
+
"│ CVE-1999-0001 ┆ 1999 ┆ MEDIUM ┆ 5.0 ┆ ip_input.c in BSD-derived TCP/IP │\n",
|
| 162 |
+
"│ ┆ ┆ ┆ ┆ implementations allows remote │\n",
|
| 163 |
+
"│ ┆ ┆ ┆ ┆ attackers to cause a denial of │\n",
|
| 164 |
+
"│ ┆ ┆ ┆ ┆ service (crash or hang) vi… │\n",
|
| 165 |
+
"│ CVE-1999-0002 ┆ 1999 ┆ HIGH ┆ 10.0 ┆ Buffer overflow in NFS mountd │\n",
|
| 166 |
+
"│ ┆ ┆ ┆ ┆ gives root access to remote │\n",
|
| 167 |
+
"│ ┆ ┆ ┆ ┆ attackers, mostly in Linux │\n",
|
| 168 |
+
"│ ┆ ┆ ┆ ┆ systems. │\n",
|
| 169 |
+
"│ CVE-1999-0003 ┆ 1999 ┆ HIGH ┆ 10.0 ┆ Execute commands as root via │\n",
|
| 170 |
+
"│ ┆ ┆ ┆ ┆ buffer overflow in Tooltalk │\n",
|
| 171 |
+
"│ ┆ ┆ ┆ ┆ database server (rpc.ttdbserverd). │\n",
|
| 172 |
+
"│ CVE-1999-0004 ┆ 1999 ┆ MEDIUM ┆ 5.0 ┆ MIME buffer overflow in email │\n",
|
| 173 |
+
"│ ┆ ┆ ┆ ┆ clients, e.g. Solaris mailtool and │\n",
|
| 174 |
+
"│ ┆ ┆ ┆ ┆ Outlook. │\n",
|
| 175 |
+
"│ CVE-1999-0005 ┆ 1999 ┆ HIGH ┆ 10.0 ┆ Arbitrary command execution via │\n",
|
| 176 |
+
"│ ┆ ┆ ┆ ┆ IMAP buffer overflow in │\n",
|
| 177 |
+
"│ ┆ ┆ ┆ ┆ authenticate command. │\n",
|
| 178 |
+
"└───────────────┴──────┴────────────────────┴─────────────────┴────────────────────────────────────┘"
|
| 179 |
+
]
|
| 180 |
+
},
|
| 181 |
+
"execution_count": 3,
|
| 182 |
+
"metadata": {},
|
| 183 |
+
"output_type": "execute_result"
|
| 184 |
+
}
|
| 185 |
+
],
|
| 186 |
+
"source": [
|
| 187 |
+
"lf.select(\"cve_id\", \"year\", \"cvss_base_severity\", \"cvss_base_score\", \"description\").head(5).collect()"
|
| 188 |
+
]
|
| 189 |
+
},
|
| 190 |
+
{
|
| 191 |
+
"cell_type": "markdown",
|
| 192 |
+
"id": "d8448374",
|
| 193 |
+
"metadata": {},
|
| 194 |
+
"source": [
|
| 195 |
+
"## 2. Distribution by year, host, and language"
|
| 196 |
+
]
|
| 197 |
+
},
|
| 198 |
+
{
|
| 199 |
+
"cell_type": "code",
|
| 200 |
+
"execution_count": 4,
|
| 201 |
+
"id": "342ba1a0",
|
| 202 |
+
"metadata": {
|
| 203 |
+
"execution": {
|
| 204 |
+
"iopub.execute_input": "2026-05-22T12:57:46.260418Z",
|
| 205 |
+
"iopub.status.busy": "2026-05-22T12:57:46.260322Z",
|
| 206 |
+
"iopub.status.idle": "2026-05-22T12:57:46.264718Z",
|
| 207 |
+
"shell.execute_reply": "2026-05-22T12:57:46.264411Z"
|
| 208 |
+
}
|
| 209 |
+
},
|
| 210 |
+
"outputs": [
|
| 211 |
+
{
|
| 212 |
+
"data": {
|
| 213 |
+
"text/html": [
|
| 214 |
+
"<div><style>\n",
|
| 215 |
+
".dataframe > thead > tr,\n",
|
| 216 |
+
".dataframe > tbody > tr {\n",
|
| 217 |
+
" text-align: right;\n",
|
| 218 |
+
" white-space: pre-wrap;\n",
|
| 219 |
+
"}\n",
|
| 220 |
+
"</style>\n",
|
| 221 |
+
"<small>shape: (28, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>year</th><th>n</th></tr><tr><td>i32</td><td>u32</td></tr></thead><tbody><tr><td>1999</td><td>1579</td></tr><tr><td>2000</td><td>1243</td></tr><tr><td>2001</td><td>1556</td></tr><tr><td>2002</td><td>2393</td></tr><tr><td>2003</td><td>1555</td></tr><tr><td>2004</td><td>2707</td></tr><tr><td>2005</td><td>4770</td></tr><tr><td>2006</td><td>7145</td></tr><tr><td>2007</td><td>6580</td></tr><tr><td>2008</td><td>7179</td></tr><tr><td>…</td><td>…</td></tr><tr><td>2017</td><td>17061</td></tr><tr><td>2018</td><td>17719</td></tr><tr><td>2019</td><td>17571</td></tr><tr><td>2020</td><td>21047</td></tr><tr><td>2021</td><td>23419</td></tr><tr><td>2022</td><td>27501</td></tr><tr><td>2023</td><td>31191</td></tr><tr><td>2024</td><td>39094</td></tr><tr><td>2025</td><td>44388</td></tr><tr><td>2026</td><td>19825</td></tr></tbody></table></div>"
|
| 222 |
+
],
|
| 223 |
+
"text/plain": [
|
| 224 |
+
"shape: (28, 2)\n",
|
| 225 |
+
"┌──────┬───────┐\n",
|
| 226 |
+
"│ year ┆ n │\n",
|
| 227 |
+
"│ --- ┆ --- │\n",
|
| 228 |
+
"│ i32 ┆ u32 │\n",
|
| 229 |
+
"╞══════╪═══════╡\n",
|
| 230 |
+
"│ 1999 ┆ 1579 │\n",
|
| 231 |
+
"│ 2000 ┆ 1243 │\n",
|
| 232 |
+
"│ 2001 ┆ 1556 │\n",
|
| 233 |
+
"│ 2002 ┆ 2393 │\n",
|
| 234 |
+
"│ 2003 ┆ 1555 │\n",
|
| 235 |
+
"│ 2004 ┆ 2707 │\n",
|
| 236 |
+
"│ 2005 ┆ 4770 │\n",
|
| 237 |
+
"│ 2006 ┆ 7145 │\n",
|
| 238 |
+
"│ 2007 ┆ 6580 │\n",
|
| 239 |
+
"│ 2008 ┆ 7179 │\n",
|
| 240 |
+
"│ … ┆ … │\n",
|
| 241 |
+
"│ 2017 ┆ 17061 │\n",
|
| 242 |
+
"│ 2018 ┆ 17719 │\n",
|
| 243 |
+
"│ 2019 ┆ 17571 │\n",
|
| 244 |
+
"│ 2020 ┆ 21047 │\n",
|
| 245 |
+
"│ 2021 ┆ 23419 │\n",
|
| 246 |
+
"│ 2022 ┆ 27501 │\n",
|
| 247 |
+
"│ 2023 ┆ 31191 │\n",
|
| 248 |
+
"│ 2024 ┆ 39094 │\n",
|
| 249 |
+
"│ 2025 ┆ 44388 │\n",
|
| 250 |
+
"│ 2026 ┆ 19825 │\n",
|
| 251 |
+
"└──────┴───────┘"
|
| 252 |
+
]
|
| 253 |
+
},
|
| 254 |
+
"execution_count": 4,
|
| 255 |
+
"metadata": {},
|
| 256 |
+
"output_type": "execute_result"
|
| 257 |
+
}
|
| 258 |
+
],
|
| 259 |
+
"source": [
|
| 260 |
+
"lf.group_by(\"year\").agg(pl.len().alias(\"n\")).sort(\"year\").collect()"
|
| 261 |
+
]
|
| 262 |
+
},
|
| 263 |
+
{
|
| 264 |
+
"cell_type": "code",
|
| 265 |
+
"execution_count": 5,
|
| 266 |
+
"id": "0f4e302e",
|
| 267 |
+
"metadata": {
|
| 268 |
+
"execution": {
|
| 269 |
+
"iopub.execute_input": "2026-05-22T12:57:46.265807Z",
|
| 270 |
+
"iopub.status.busy": "2026-05-22T12:57:46.265717Z",
|
| 271 |
+
"iopub.status.idle": "2026-05-22T12:57:46.277607Z",
|
| 272 |
+
"shell.execute_reply": "2026-05-22T12:57:46.277299Z"
|
| 273 |
+
}
|
| 274 |
+
},
|
| 275 |
+
"outputs": [
|
| 276 |
+
{
|
| 277 |
+
"data": {
|
| 278 |
+
"text/html": [
|
| 279 |
+
"<div><style>\n",
|
| 280 |
+
".dataframe > thead > tr,\n",
|
| 281 |
+
".dataframe > tbody > tr {\n",
|
| 282 |
+
" text-align: right;\n",
|
| 283 |
+
" white-space: pre-wrap;\n",
|
| 284 |
+
"}\n",
|
| 285 |
+
"</style>\n",
|
| 286 |
+
"<small>shape: (10, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>host</th><th>n</th></tr><tr><td>str</td><td>u32</td></tr></thead><tbody><tr><td>null</td><td>326869</td></tr><tr><td>"github"</td><td>23593</td></tr><tr><td>"cgit"</td><td>1648</td></tr><tr><td>"gitlab"</td><td>325</td></tr><tr><td>"w1.fi"</td><td>7</td></tr><tr><td>"anongit.mindrot.org"</td><td>6</td></tr><tr><td>"repo.or.cz"</td><td>3</td></tr><tr><td>"web.git.kernel.org"</td><td>2</td></tr><tr><td>"sourceware.org"</td><td>1</td></tr><tr><td>"roy.marples.name"</td><td>1</td></tr></tbody></table></div>"
|
| 287 |
+
],
|
| 288 |
+
"text/plain": [
|
| 289 |
+
"shape: (10, 2)\n",
|
| 290 |
+
"┌────���────────────────┬────────┐\n",
|
| 291 |
+
"│ host ┆ n │\n",
|
| 292 |
+
"│ --- ┆ --- │\n",
|
| 293 |
+
"│ str ┆ u32 │\n",
|
| 294 |
+
"╞═════════════════════╪════════╡\n",
|
| 295 |
+
"│ null ┆ 326869 │\n",
|
| 296 |
+
"│ github ┆ 23593 │\n",
|
| 297 |
+
"│ cgit ┆ 1648 │\n",
|
| 298 |
+
"│ gitlab ┆ 325 │\n",
|
| 299 |
+
"│ w1.fi ┆ 7 │\n",
|
| 300 |
+
"│ anongit.mindrot.org ┆ 6 │\n",
|
| 301 |
+
"│ repo.or.cz ┆ 3 │\n",
|
| 302 |
+
"│ web.git.kernel.org ┆ 2 │\n",
|
| 303 |
+
"│ sourceware.org ┆ 1 │\n",
|
| 304 |
+
"│ roy.marples.name ┆ 1 │\n",
|
| 305 |
+
"└─────────────────────┴────────┘"
|
| 306 |
+
]
|
| 307 |
+
},
|
| 308 |
+
"execution_count": 5,
|
| 309 |
+
"metadata": {},
|
| 310 |
+
"output_type": "execute_result"
|
| 311 |
+
}
|
| 312 |
+
],
|
| 313 |
+
"source": [
|
| 314 |
+
"(\n",
|
| 315 |
+
" lf.select(pl.col(\"patch_hosts\").explode().alias(\"host\"))\n",
|
| 316 |
+
" .group_by(\"host\")\n",
|
| 317 |
+
" .agg(pl.len().alias(\"n\"))\n",
|
| 318 |
+
" .sort(\"n\", descending=True)\n",
|
| 319 |
+
" .collect()\n",
|
| 320 |
+
")"
|
| 321 |
+
]
|
| 322 |
+
},
|
| 323 |
+
{
|
| 324 |
+
"cell_type": "code",
|
| 325 |
+
"execution_count": 6,
|
| 326 |
+
"id": "7667e9df",
|
| 327 |
+
"metadata": {
|
| 328 |
+
"execution": {
|
| 329 |
+
"iopub.execute_input": "2026-05-22T12:57:46.278613Z",
|
| 330 |
+
"iopub.status.busy": "2026-05-22T12:57:46.278524Z",
|
| 331 |
+
"iopub.status.idle": "2026-05-22T12:57:46.288577Z",
|
| 332 |
+
"shell.execute_reply": "2026-05-22T12:57:46.288240Z"
|
| 333 |
+
}
|
| 334 |
+
},
|
| 335 |
+
"outputs": [
|
| 336 |
+
{
|
| 337 |
+
"data": {
|
| 338 |
+
"text/html": [
|
| 339 |
+
"<div><style>\n",
|
| 340 |
+
".dataframe > thead > tr,\n",
|
| 341 |
+
".dataframe > tbody > tr {\n",
|
| 342 |
+
" text-align: right;\n",
|
| 343 |
+
" white-space: pre-wrap;\n",
|
| 344 |
+
"}\n",
|
| 345 |
+
"</style>\n",
|
| 346 |
+
"<small>shape: (15, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>language</th><th>n</th></tr><tr><td>str</td><td>u32</td></tr></thead><tbody><tr><td>"C"</td><td>7002</td></tr><tr><td>"PHP"</td><td>5129</td></tr><tr><td>"Python"</td><td>2936</td></tr><tr><td>"JavaScript"</td><td>2751</td></tr><tr><td>"Markdown"</td><td>2519</td></tr><tr><td>"TypeScript"</td><td>1804</td></tr><tr><td>"C++"</td><td>1696</td></tr><tr><td>"Go"</td><td>1573</td></tr><tr><td>"Java"</td><td>1285</td></tr><tr><td>"JSON"</td><td>1272</td></tr><tr><td>"YAML"</td><td>1028</td></tr><tr><td>"Ruby"</td><td>808</td></tr><tr><td>"XML"</td><td>516</td></tr><tr><td>"HTML"</td><td>507</td></tr><tr><td>"reStructuredText"</td><td>475</td></tr></tbody></table></div>"
|
| 347 |
+
],
|
| 348 |
+
"text/plain": [
|
| 349 |
+
"shape: (15, 2)\n",
|
| 350 |
+
"┌──────────────────┬──────┐\n",
|
| 351 |
+
"│ language ┆ n │\n",
|
| 352 |
+
"│ --- ┆ --- │\n",
|
| 353 |
+
"│ str ┆ u32 │\n",
|
| 354 |
+
"╞══════════════════╪══════╡\n",
|
| 355 |
+
"│ C ┆ 7002 │\n",
|
| 356 |
+
"│ PHP ┆ 5129 │\n",
|
| 357 |
+
"│ Python ┆ 2936 │\n",
|
| 358 |
+
"│ JavaScript ┆ 2751 │\n",
|
| 359 |
+
"│ Markdown ┆ 2519 │\n",
|
| 360 |
+
"│ TypeScript ┆ 1804 │\n",
|
| 361 |
+
"│ C++ ┆ 1696 │\n",
|
| 362 |
+
"│ Go ┆ 1573 │\n",
|
| 363 |
+
"│ Java ┆ 1285 │\n",
|
| 364 |
+
"│ JSON ┆ 1272 │\n",
|
| 365 |
+
"│ YAML ┆ 1028 │\n",
|
| 366 |
+
"│ Ruby ┆ 808 │\n",
|
| 367 |
+
"│ XML ┆ 516 │\n",
|
| 368 |
+
"│ HTML ┆ 507 │\n",
|
| 369 |
+
"│ reStructuredText ┆ 475 │\n",
|
| 370 |
+
"└──────────────────┴──────┘"
|
| 371 |
+
]
|
| 372 |
+
},
|
| 373 |
+
"execution_count": 6,
|
| 374 |
+
"metadata": {},
|
| 375 |
+
"output_type": "execute_result"
|
| 376 |
+
}
|
| 377 |
+
],
|
| 378 |
+
"source": [
|
| 379 |
+
"(\n",
|
| 380 |
+
" lf.select(pl.col(\"patch_languages\").explode().alias(\"language\"))\n",
|
| 381 |
+
" .drop_nulls()\n",
|
| 382 |
+
" .group_by(\"language\")\n",
|
| 383 |
+
" .agg(pl.len().alias(\"n\"))\n",
|
| 384 |
+
" .sort(\"n\", descending=True)\n",
|
| 385 |
+
" .head(15)\n",
|
| 386 |
+
" .collect()\n",
|
| 387 |
+
")"
|
| 388 |
+
]
|
| 389 |
+
},
|
| 390 |
+
{
|
| 391 |
+
"cell_type": "markdown",
|
| 392 |
+
"id": "d59aec00",
|
| 393 |
+
"metadata": {},
|
| 394 |
+
"source": [
|
| 395 |
+
"## 3. Top CWEs\n",
|
| 396 |
+
"\n",
|
| 397 |
+
"`cwes` is a list of structs `{id, name, description}`. Explode and aggregate."
|
| 398 |
+
]
|
| 399 |
+
},
|
| 400 |
+
{
|
| 401 |
+
"cell_type": "code",
|
| 402 |
+
"execution_count": 7,
|
| 403 |
+
"id": "825e2113",
|
| 404 |
+
"metadata": {
|
| 405 |
+
"execution": {
|
| 406 |
+
"iopub.execute_input": "2026-05-22T12:57:46.289695Z",
|
| 407 |
+
"iopub.status.busy": "2026-05-22T12:57:46.289585Z",
|
| 408 |
+
"iopub.status.idle": "2026-05-22T12:57:46.321406Z",
|
| 409 |
+
"shell.execute_reply": "2026-05-22T12:57:46.321009Z"
|
| 410 |
+
}
|
| 411 |
+
},
|
| 412 |
+
"outputs": [
|
| 413 |
+
{
|
| 414 |
+
"data": {
|
| 415 |
+
"text/html": [
|
| 416 |
+
"<div><style>\n",
|
| 417 |
+
".dataframe > thead > tr,\n",
|
| 418 |
+
".dataframe > tbody > tr {\n",
|
| 419 |
+
" text-align: right;\n",
|
| 420 |
+
" white-space: pre-wrap;\n",
|
| 421 |
+
"}\n",
|
| 422 |
+
"</style>\n",
|
| 423 |
+
"<small>shape: (10, 3)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>id</th><th>name</th><th>n</th></tr><tr><td>str</td><td>str</td><td>u32</td></tr></thead><tbody><tr><td>null</td><td>null</td><td>73644</td></tr><tr><td>"CWE-79"</td><td>"Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')"</td><td>44166</td></tr><tr><td>"CWE-89"</td><td>"Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')"</td><td>19034</td></tr><tr><td>"CWE-787"</td><td>"Out-of-bounds Write"</td><td>13975</td></tr><tr><td>"CWE-119"</td><td>"Improper Restriction of Operations within the Bounds of a Memory Buffer"</td><td>13818</td></tr><tr><td>"CWE-20"</td><td>"Improper Input Validation"</td><td>12173</td></tr><tr><td>"CWE-200"</td><td>"Exposure of Sensitive Information to an Unauthorized Actor"</td><td>9958</td></tr><tr><td>"CWE-352"</td><td>"Cross-Site Request Forgery (CSRF)"</td><td>9185</td></tr><tr><td>"CWE-22"</td><td>"Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')"</td><td>8905</td></tr><tr><td>"CWE-125"</td><td>"Out-of-bounds Read"</td><td>8596</td></tr></tbody></table></div>"
|
| 424 |
+
],
|
| 425 |
+
"text/plain": [
|
| 426 |
+
"shape: (10, 3)\n",
|
| 427 |
+
"┌─────────┬────────────────────────────────────────────────────────────────────────────────┬───────┐\n",
|
| 428 |
+
"│ id ┆ name ┆ n │\n",
|
| 429 |
+
"│ --- ┆ --- ┆ --- │\n",
|
| 430 |
+
"│ str ┆ str ┆ u32 │\n",
|
| 431 |
+
"╞═════════╪════════════════════════════════════════════════════════════════════════════════╪═══════╡\n",
|
| 432 |
+
"│ null ┆ null ┆ 73644 │\n",
|
| 433 |
+
"│ CWE-79 ┆ Improper Neutralization of Input During Web Page Generation ('Cross-site ┆ 44166 │\n",
|
| 434 |
+
"│ ┆ Scripting') ┆ │\n",
|
| 435 |
+
"│ CWE-89 ┆ Improper Neutralization of Special Elements used in an SQL Command ('SQL ┆ 19034 │\n",
|
| 436 |
+
"│ ┆ Injection') ┆ │\n",
|
| 437 |
+
"│ CWE-787 ┆ Out-of-bounds Write ┆ 13975 │\n",
|
| 438 |
+
"│ CWE-119 ┆ Improper Restriction of Operations within the Bounds of a Memory Buffer ┆ 13818 │\n",
|
| 439 |
+
"│ CWE-20 ┆ Improper Input Validation ┆ 12173 │\n",
|
| 440 |
+
"│ CWE-200 ┆ Exposure of Sensitive Information to an Unauthorized Actor ┆ 9958 │\n",
|
| 441 |
+
"│ CWE-352 ┆ Cross-Site Request Forgery (CSRF) ┆ 9185 │\n",
|
| 442 |
+
"│ CWE-22 ┆ Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') ┆ 8905 │\n",
|
| 443 |
+
"│ CWE-125 ┆ Out-of-bounds Read ┆ 8596 │\n",
|
| 444 |
+
"└─────────┴────────────────────────────────────────────────────────────────────────────────┴───────┘"
|
| 445 |
+
]
|
| 446 |
+
},
|
| 447 |
+
"execution_count": 7,
|
| 448 |
+
"metadata": {},
|
| 449 |
+
"output_type": "execute_result"
|
| 450 |
+
}
|
| 451 |
+
],
|
| 452 |
+
"source": [
|
| 453 |
+
"(\n",
|
| 454 |
+
" lf.select(pl.col(\"cwes\").explode())\n",
|
| 455 |
+
" .unnest(\"cwes\")\n",
|
| 456 |
+
" .group_by(\"id\", \"name\")\n",
|
| 457 |
+
" .agg(pl.len().alias(\"n\"))\n",
|
| 458 |
+
" .sort(\"n\", descending=True)\n",
|
| 459 |
+
" .head(10)\n",
|
| 460 |
+
" .collect()\n",
|
| 461 |
+
")"
|
| 462 |
+
]
|
| 463 |
+
},
|
| 464 |
+
{
|
| 465 |
+
"cell_type": "markdown",
|
| 466 |
+
"id": "aa26933c",
|
| 467 |
+
"metadata": {},
|
| 468 |
+
"source": [
|
| 469 |
+
"## 4. Filter: CRITICAL or HIGH CVEs with a GitHub patch"
|
| 470 |
+
]
|
| 471 |
+
},
|
| 472 |
+
{
|
| 473 |
+
"cell_type": "code",
|
| 474 |
+
"execution_count": 8,
|
| 475 |
+
"id": "fa81ae21",
|
| 476 |
+
"metadata": {
|
| 477 |
+
"execution": {
|
| 478 |
+
"iopub.execute_input": "2026-05-22T12:57:46.322395Z",
|
| 479 |
+
"iopub.status.busy": "2026-05-22T12:57:46.322286Z",
|
| 480 |
+
"iopub.status.idle": "2026-05-22T12:57:46.355992Z",
|
| 481 |
+
"shell.execute_reply": "2026-05-22T12:57:46.355695Z"
|
| 482 |
+
}
|
| 483 |
+
},
|
| 484 |
+
"outputs": [
|
| 485 |
+
{
|
| 486 |
+
"data": {
|
| 487 |
+
"text/html": [
|
| 488 |
+
"<div><style>\n",
|
| 489 |
+
".dataframe > thead > tr,\n",
|
| 490 |
+
".dataframe > tbody > tr {\n",
|
| 491 |
+
" text-align: right;\n",
|
| 492 |
+
" white-space: pre-wrap;\n",
|
| 493 |
+
"}\n",
|
| 494 |
+
"</style>\n",
|
| 495 |
+
"<small>shape: (10, 4)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>cve_id</th><th>cvss_base_score</th><th>cvss_base_severity</th><th>description</th></tr><tr><td>str</td><td>f64</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>"CVE-2014-4502"</td><td>10.0</td><td>"HIGH"</td><td>"Multiple heap-based buffer overflows in the parse_notify function in sgminer before 4.2.2, cgminer before 4.3.5, and BFG…</td></tr><tr><td>"CVE-2010-4802"</td><td>10.0</td><td>"HIGH"</td><td>"Commands.pm in Mojolicious before 0.999928 does not properly perform CGI environment detection, which has unspecified im…</td></tr><tr><td>"CVE-2012-6552"</td><td>10.0</td><td>"HIGH"</td><td>"Unspecified vulnerability in admin/action.php in phpVMS 2.1.x before 2.1.935 has unknown impact and attack vectors."</td></tr><tr><td>"CVE-2013-4265"</td><td>10.0</td><td>"HIGH"</td><td>"The av_reallocp_array function in libavutil/mem.c in FFmpeg before 2.0.1 has an unspecified impact and remote vectors re…</td></tr><tr><td>"CVE-2014-0749"</td><td>10.0</td><td>"HIGH"</td><td>"Stack-based buffer overflow in lib/Libdis/disrsi_.c in Terascale Open-Source Resource and Queue Manager (aka TORQUE Reso…</td></tr><tr><td>"CVE-2014-1236"</td><td>10.0</td><td>"HIGH"</td><td>"Stack-based buffer overflow in the chkNum function in lib/cgraph/scan.l in Graphviz 2.34.0 allows remote attackers to ha…</td></tr><tr><td>"CVE-2014-2523"</td><td>10.0</td><td>"HIGH"</td><td>"net/netfilter/nf_conntrack_proto_dccp.c in the Linux kernel through 3.13.6 uses a DCCP header pointer incorrectly, which…</td></tr><tr><td>"CVE-2014-3496"</td><td>10.0</td><td>"HIGH"</td><td>"cartridge_repository.rb in OpenShift Origin and Enterprise 1.2.8 through 2.1.1 allows remote attackers to execute arbitr…</td></tr><tr><td>"CVE-2014-3828"</td><td>10.0</td><td>"HIGH"</td><td>"Multiple SQL injection vulnerabilities in Centreon 2.5.1 and Centreon Enterprise Server 2.2 (fixed in Centreon web 2.5.3…</td></tr><tr><td>"CVE-2014-3829"</td><td>10.0</td><td>"HIGH"</td><td>"displayServiceStatus.php in Centreon 2.5.1 and Centreon Enterprise Server 2.2 (fixed in Centreon web 2.5.3) allows remot…</td></tr></tbody></table></div>"
|
| 496 |
+
],
|
| 497 |
+
"text/plain": [
|
| 498 |
+
"shape: (10, 4)\n",
|
| 499 |
+
"┌───────────────┬─────────────────┬────────────────────┬───────────────────────────────────────────┐\n",
|
| 500 |
+
"│ cve_id ┆ cvss_base_score ┆ cvss_base_severity ┆ description │\n",
|
| 501 |
+
"│ --- ┆ --- ┆ --- ┆ --- │\n",
|
| 502 |
+
"│ str ┆ f64 ┆ str ┆ str │\n",
|
| 503 |
+
"╞═══════════════╪═════════════════╪════════════════════╪═══════════════════════════════════════════╡\n",
|
| 504 |
+
"│ CVE-2014-4502 ┆ 10.0 ┆ HIGH ┆ Multiple heap-based buffer overflows in │\n",
|
| 505 |
+
"│ ┆ ┆ ┆ the parse_notify function in sgminer │\n",
|
| 506 |
+
"│ ┆ ┆ ┆ before 4.2.2, cgminer before 4.3.5, and │\n",
|
| 507 |
+
"│ ┆ ┆ ┆ BFG… │\n",
|
| 508 |
+
"│ CVE-2010-4802 ┆ 10.0 ┆ HIGH ┆ Commands.pm in Mojolicious before │\n",
|
| 509 |
+
"│ ┆ ┆ ┆ 0.999928 does not properly perform CGI │\n",
|
| 510 |
+
"│ ┆ ┆ ┆ environment detection, which has │\n",
|
| 511 |
+
"│ ┆ ┆ ┆ unspecified im… │\n",
|
| 512 |
+
"│ CVE-2012-6552 ┆ 10.0 ┆ HIGH ┆ Unspecified vulnerability in │\n",
|
| 513 |
+
"│ ┆ ┆ ┆ admin/action.php in phpVMS 2.1.x before │\n",
|
| 514 |
+
"│ ┆ ┆ ┆ 2.1.935 has unknown impact and attack │\n",
|
| 515 |
+
"│ ┆ ┆ ┆ vectors. │\n",
|
| 516 |
+
"│ CVE-2013-4265 ┆ 10.0 ┆ HIGH ┆ The av_reallocp_array function in │\n",
|
| 517 |
+
"│ ┆ ┆ ┆ libavutil/mem.c in FFmpeg before 2.0.1 │\n",
|
| 518 |
+
"│ ┆ ┆ ┆ has an unspecified impact and remote │\n",
|
| 519 |
+
"│ ┆ ┆ ┆ vectors re… │\n",
|
| 520 |
+
"│ CVE-2014-0749 ┆ 10.0 ┆ HIGH ┆ Stack-based buffer overflow in │\n",
|
| 521 |
+
"│ ┆ ┆ ┆ lib/Libdis/disrsi_.c in Terascale │\n",
|
| 522 |
+
"│ ┆ ┆ ┆ Open-Source Resource and Queue Manager │\n",
|
| 523 |
+
"│ ┆ ┆ ┆ (aka TORQUE Reso… │\n",
|
| 524 |
+
"│ CVE-2014-1236 ┆ 10.0 ┆ HIGH ┆ Stack-based buffer overflow in the chkNum │\n",
|
| 525 |
+
"│ ┆ ┆ ┆ function in lib/cgraph/scan.l in Graphviz │\n",
|
| 526 |
+
"│ ┆ ┆ ┆ 2.34.0 allows remote attackers to ha… │\n",
|
| 527 |
+
"│ CVE-2014-2523 ┆ 10.0 ┆ HIGH ┆ net/netfilter/nf_conntrack_proto_dccp.c │\n",
|
| 528 |
+
"│ ┆ ┆ ┆ in the Linux kernel through 3.13.6 uses a │\n",
|
| 529 |
+
"│ ┆ ┆ ┆ DCCP header pointer incorrectly, which… │\n",
|
| 530 |
+
"│ CVE-2014-3496 ┆ 10.0 ┆ HIGH ┆ cartridge_repository.rb in OpenShift │\n",
|
| 531 |
+
"│ ┆ ┆ ┆ Origin and Enterprise 1.2.8 through 2.1.1 │\n",
|
| 532 |
+
"│ ┆ ┆ ┆ allows remote attackers to execute │\n",
|
| 533 |
+
"│ ┆ ┆ ┆ arbitr… │\n",
|
| 534 |
+
"│ CVE-2014-3828 ┆ 10.0 ┆ HIGH ┆ Multiple SQL injection vulnerabilities in │\n",
|
| 535 |
+
"│ ┆ ┆ ┆ Centreon 2.5.1 and Centreon Enterprise │\n",
|
| 536 |
+
"│ ┆ ┆ ┆ Server 2.2 (fixed in Centreon web 2.5.3… │\n",
|
| 537 |
+
"│ CVE-2014-3829 ┆ 10.0 ┆ HIGH ┆ displayServiceStatus.php in Centreon │\n",
|
| 538 |
+
"│ ┆ ┆ ┆ 2.5.1 and Centreon Enterprise Server 2.2 │\n",
|
| 539 |
+
"│ ┆ ┆ ┆ (fixed in Centreon web 2.5.3) allows │\n",
|
| 540 |
+
"│ ┆ ┆ ┆ remot… │\n",
|
| 541 |
+
"└───────────────┴─────────────────┴────────────────────┴───────────────────────────────────────────┘"
|
| 542 |
+
]
|
| 543 |
+
},
|
| 544 |
+
"execution_count": 8,
|
| 545 |
+
"metadata": {},
|
| 546 |
+
"output_type": "execute_result"
|
| 547 |
+
}
|
| 548 |
+
],
|
| 549 |
+
"source": [
|
| 550 |
+
"(\n",
|
| 551 |
+
" lf.filter(\n",
|
| 552 |
+
" pl.col(\"cvss_base_severity\").is_in([\"HIGH\", \"CRITICAL\"]),\n",
|
| 553 |
+
" pl.col(\"patch_hosts\").list.contains(\"github\"),\n",
|
| 554 |
+
" )\n",
|
| 555 |
+
" .select(\"cve_id\", \"cvss_base_score\", \"cvss_base_severity\", \"description\")\n",
|
| 556 |
+
" .sort(\"cvss_base_score\", descending=True)\n",
|
| 557 |
+
" .head(10)\n",
|
| 558 |
+
" .collect()\n",
|
| 559 |
+
")"
|
| 560 |
+
]
|
| 561 |
+
},
|
| 562 |
+
{
|
| 563 |
+
"cell_type": "markdown",
|
| 564 |
+
"id": "2154fb44",
|
| 565 |
+
"metadata": {},
|
| 566 |
+
"source": [
|
| 567 |
+
"## 5. Filter: CVEs touching a specific language (e.g. Rust)\n",
|
| 568 |
+
"\n",
|
| 569 |
+
"`patch_languages` is a list of language names — use `.list.contains()` for an \"any\" match."
|
| 570 |
+
]
|
| 571 |
+
},
|
| 572 |
+
{
|
| 573 |
+
"cell_type": "code",
|
| 574 |
+
"execution_count": 9,
|
| 575 |
+
"id": "67351901",
|
| 576 |
+
"metadata": {
|
| 577 |
+
"execution": {
|
| 578 |
+
"iopub.execute_input": "2026-05-22T12:57:46.357070Z",
|
| 579 |
+
"iopub.status.busy": "2026-05-22T12:57:46.356972Z",
|
| 580 |
+
"iopub.status.idle": "2026-05-22T12:57:46.377693Z",
|
| 581 |
+
"shell.execute_reply": "2026-05-22T12:57:46.377332Z"
|
| 582 |
+
}
|
| 583 |
+
},
|
| 584 |
+
"outputs": [
|
| 585 |
+
{
|
| 586 |
+
"data": {
|
| 587 |
+
"text/html": [
|
| 588 |
+
"<div><style>\n",
|
| 589 |
+
".dataframe > thead > tr,\n",
|
| 590 |
+
".dataframe > tbody > tr {\n",
|
| 591 |
+
" text-align: right;\n",
|
| 592 |
+
" white-space: pre-wrap;\n",
|
| 593 |
+
"}\n",
|
| 594 |
+
"</style>\n",
|
| 595 |
+
"<small>shape: (10, 5)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>cve_id</th><th>year</th><th>cvss_base_severity</th><th>patch_languages</th><th>description</th></tr><tr><td>str</td><td>i32</td><td>str</td><td>list[str]</td><td>str</td></tr></thead><tbody><tr><td>"CVE-2026-6994"</td><td>2026</td><td>"MEDIUM"</td><td>["Bazel", "C", … "reStructuredText"]</td><td>"A weakness has been identified in Envoy up to 1.33.0. Affected is the function params.add of the file source/extensions/…</td></tr><tr><td>"CVE-2026-6143"</td><td>2026</td><td>"LOW"</td><td>["Rust"]</td><td>"A security flaw has been discovered in farion1231 cc-switch up to 3.12.3. Affected by this issue is some unknown functio…</td></tr><tr><td>"CVE-2026-5125"</td><td>2026</td><td>"LOW"</td><td>["JSON", "Markdown", … "TypeScript"]</td><td>"A vulnerability was detected in raine consult-llm-mcp up to 2.5.3. Affected by this vulnerability is the function child_…</td></tr><tr><td>"CVE-2026-43991"</td><td>2026</td><td>"HIGH"</td><td>["Rust", "TOML"]</td><td>"JunoClaw is an agentic AI platform built on Juno Network. Prior to 0.x.y-security-1, substring-based blocklist in plugin…</td></tr><tr><td>"CVE-2026-43990"</td><td>2026</td><td>"HIGH"</td><td>["Rust", "TOML"]</td><td>"JunoClaw is an agentic AI platform built on Juno Network. Prior to 0.x.y-security-1, plugin-shell's run_command wrapped …</td></tr><tr><td>"CVE-2026-43914"</td><td>2026</td><td>"CRITICAL"</td><td>["Rust"]</td><td>"Vaultwarden is a Bitwarden-compatible server written in Rust. Prior to 1.35.4, there is a security vulnerability in Vaul…</td></tr><tr><td>"CVE-2026-42559"</td><td>2026</td><td>"HIGH"</td><td>["Rust"]</td><td>"RMCP is an official Rust SDK for the Model Context Protocol. Prior to version 1.4.0, the rmcp crate's Streamable HTTP se…</td></tr><tr><td>"CVE-2026-42278"</td><td>2026</td><td>"HIGH"</td><td>["Markdown", "Rust"]</td><td>"UltraDAG is a minimal DAG-BFT blockchain in Rust. Prior to commit fb6ef59, the UltraDAG StateEngine implementation of Sm…</td></tr><tr><td>"CVE-2026-42199"</td><td>2026</td><td>"MEDIUM"</td><td>["Markdown", "Rust"]</td><td>"Grid is a data structure grid for rust. From version 0.17.0 to before version 1.0.1, an integer overflow in Grid::expand…</td></tr><tr><td>"CVE-2026-42189"</td><td>2026</td><td>"HIGH"</td><td>["Rust"]</td><td>"Russh is a Rust SSH client & server library. Prior to version 0.60.1, a pre-authentication denial-of-service vulnerabili…</td></tr></tbody></table></div>"
|
| 596 |
+
],
|
| 597 |
+
"text/plain": [
|
| 598 |
+
"shape: (10, 5)\n",
|
| 599 |
+
"┌────────────────┬──────┬────────────────────┬──────────────────────────┬──────────────────────────┐\n",
|
| 600 |
+
"│ cve_id ┆ year ┆ cvss_base_severity ┆ patch_languages ┆ description │\n",
|
| 601 |
+
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
|
| 602 |
+
"│ str ┆ i32 ┆ str ┆ list[str] ┆ str │\n",
|
| 603 |
+
"╞════════════════╪══════╪════════════════════╪══════════════════════════╪══════════════════════════╡\n",
|
| 604 |
+
"│ CVE-2026-6994 ┆ 2026 ┆ MEDIUM ┆ [\"Bazel\", \"C\", … ┆ A weakness has been │\n",
|
| 605 |
+
"│ ┆ ┆ ┆ \"reStructuredText\"] ┆ identified in Envoy up │\n",
|
| 606 |
+
"│ ┆ ┆ ┆ ┆ to 1.33.0. Affected is │\n",
|
| 607 |
+
"│ ┆ ┆ ┆ ┆ the function params.add │\n",
|
| 608 |
+
"│ ┆ ┆ ┆ ┆ of the file │\n",
|
| 609 |
+
"│ ┆ ┆ ┆ ┆ source/extensions/… │\n",
|
| 610 |
+
"│ CVE-2026-6143 ┆ 2026 ┆ LOW ┆ [\"Rust\"] ┆ A security flaw has been │\n",
|
| 611 |
+
"│ ┆ ┆ ┆ ┆ discovered in farion1231 │\n",
|
| 612 |
+
"│ ┆ ┆ ┆ ┆ cc-switch up to 3.12.3. │\n",
|
| 613 |
+
"│ ┆ ┆ ┆ ┆ Affected by this issue │\n",
|
| 614 |
+
"│ ┆ ┆ ┆ ┆ is some unknown functio… │\n",
|
| 615 |
+
"│ CVE-2026-5125 ┆ 2026 ┆ LOW ┆ [\"JSON\", \"Markdown\", … ┆ A vulnerability was │\n",
|
| 616 |
+
"│ ┆ ┆ ┆ \"TypeScript\"] ┆ detected in raine │\n",
|
| 617 |
+
"│ ┆ ┆ ┆ ┆ consult-llm-mcp up to │\n",
|
| 618 |
+
"│ ┆ ┆ ┆ ┆ 2.5.3. Affected by this │\n",
|
| 619 |
+
"│ ┆ ┆ ┆ ┆ vulnerability is the │\n",
|
| 620 |
+
"│ ┆ ┆ ┆ ┆ function child_… │\n",
|
| 621 |
+
"│ CVE-2026-43991 ┆ 2026 ┆ HIGH ┆ [\"Rust\", \"TOML\"] ┆ JunoClaw is an agentic │\n",
|
| 622 |
+
"│ ┆ ┆ ┆ ┆ AI platform built on │\n",
|
| 623 |
+
"│ ┆ ┆ ┆ ┆ Juno Network. Prior to │\n",
|
| 624 |
+
"│ ┆ ┆ ┆ ┆ 0.x.y-security-1, │\n",
|
| 625 |
+
"│ ┆ ┆ ┆ ┆ substring-based │\n",
|
| 626 |
+
"│ ┆ ┆ ┆ ┆ blocklist in plugin… │\n",
|
| 627 |
+
"│ CVE-2026-43990 ┆ 2026 ┆ HIGH ┆ [\"Rust\", \"TOML\"] ┆ JunoClaw is an agentic │\n",
|
| 628 |
+
"│ ┆ ┆ ┆ ┆ AI platform built on │\n",
|
| 629 |
+
"│ ┆ ┆ ┆ ┆ Juno Network. Prior to │\n",
|
| 630 |
+
"│ ┆ ┆ ┆ ┆ 0.x.y-security-1, │\n",
|
| 631 |
+
"│ ┆ ┆ ┆ ┆ plugin-shell's │\n",
|
| 632 |
+
"│ ┆ ┆ ┆ ┆ run_command wrapped … │\n",
|
| 633 |
+
"│ CVE-2026-43914 ┆ 2026 ┆ CRITICAL ┆ [\"Rust\"] ┆ Vaultwarden is a │\n",
|
| 634 |
+
"│ ┆ ┆ ┆ ┆ Bitwarden-compatible │\n",
|
| 635 |
+
"│ ┆ ┆ ┆ ┆ server written in Rust. │\n",
|
| 636 |
+
"│ ┆ ┆ ┆ ┆ Prior to 1.35.4, there │\n",
|
| 637 |
+
"│ ┆ ┆ ┆ ┆ is a security │\n",
|
| 638 |
+
"│ ┆ ┆ ┆ ┆ vulnerability in Vaul… │\n",
|
| 639 |
+
"│ CVE-2026-42559 ┆ 2026 ┆ HIGH ┆ [\"Rust\"] ┆ RMCP is an official Rust │\n",
|
| 640 |
+
"│ ┆ ┆ ┆ ┆ SDK for the Model │\n",
|
| 641 |
+
"│ ┆ ┆ ┆ ┆ Context Protocol. Prior │\n",
|
| 642 |
+
"│ ┆ ┆ ┆ ┆ to version 1.4.0, the │\n",
|
| 643 |
+
"│ ┆ ┆ ┆ ┆ rmcp crate's Streamable │\n",
|
| 644 |
+
"│ ┆ ┆ ┆ ┆ HTTP se… │\n",
|
| 645 |
+
"│ CVE-2026-42278 ┆ 2026 ┆ HIGH ┆ [\"Markdown\", \"Rust\"] ┆ UltraDAG is a minimal │\n",
|
| 646 |
+
"│ ┆ ┆ ┆ ┆ DAG-BFT blockchain in │\n",
|
| 647 |
+
"│ ┆ ┆ ┆ ┆ Rust. Prior to commit │\n",
|
| 648 |
+
"│ ┆ ┆ ┆ ┆ fb6ef59, the UltraDAG │\n",
|
| 649 |
+
"│ ┆ ┆ ┆ ┆ StateEngine │\n",
|
| 650 |
+
"│ ┆ ┆ ┆ ┆ implementation of Sm… │\n",
|
| 651 |
+
"│ CVE-2026-42199 ┆ 2026 ┆ MEDIUM ┆ [\"Markdown\", \"Rust\"] ┆ Grid is a data structure │\n",
|
| 652 |
+
"│ ┆ ┆ ┆ ┆ grid for rust. From │\n",
|
| 653 |
+
"│ ┆ ┆ ┆ ┆ version 0.17.0 to before │\n",
|
| 654 |
+
"│ ┆ ┆ ┆ ┆ version 1.0.1, an │\n",
|
| 655 |
+
"│ ┆ ┆ ┆ ┆ integer overflow in │\n",
|
| 656 |
+
"│ ┆ ┆ ┆ ┆ Grid::expand… │\n",
|
| 657 |
+
"│ CVE-2026-42189 ┆ 2026 ┆ HIGH ┆ [\"Rust\"] ┆ Russh is a Rust SSH │\n",
|
| 658 |
+
"│ ┆ ┆ ┆ ┆ client & server library. │\n",
|
| 659 |
+
"│ ┆ ┆ ┆ ┆ Prior to version 0.60.1, │\n",
|
| 660 |
+
"│ ┆ ┆ ┆ ┆ a pre-authentication │\n",
|
| 661 |
+
"│ ┆ ┆ ┆ ┆ denial-of-service │\n",
|
| 662 |
+
"│ ┆ ┆ ┆ ┆ vulnerabili… │\n",
|
| 663 |
+
"└────────────────┴──────┴────────────────────┴──────────────────────────┴──────────────────────────┘"
|
| 664 |
+
]
|
| 665 |
+
},
|
| 666 |
+
"execution_count": 9,
|
| 667 |
+
"metadata": {},
|
| 668 |
+
"output_type": "execute_result"
|
| 669 |
+
}
|
| 670 |
+
],
|
| 671 |
+
"source": [
|
| 672 |
+
"(\n",
|
| 673 |
+
" lf.filter(pl.col(\"patch_languages\").list.contains(\"Rust\"))\n",
|
| 674 |
+
" .select(\"cve_id\", \"year\", \"cvss_base_severity\", \"patch_languages\", \"description\")\n",
|
| 675 |
+
" .sort(\"cve_id\", descending=True)\n",
|
| 676 |
+
" .head(10)\n",
|
| 677 |
+
" .collect()\n",
|
| 678 |
+
")"
|
| 679 |
+
]
|
| 680 |
+
},
|
| 681 |
+
{
|
| 682 |
+
"cell_type": "markdown",
|
| 683 |
+
"id": "cb3a6b27",
|
| 684 |
+
"metadata": {},
|
| 685 |
+
"source": [
|
| 686 |
+
"## 6. Filter: CVEs with or without a patch\n",
|
| 687 |
+
"\n",
|
| 688 |
+
"The parquet now contains every NVD CVE, whether or not a fixing-commit diff\n",
|
| 689 |
+
"was found. Use the `has_patch` boolean column to filter either way."
|
| 690 |
+
]
|
| 691 |
+
},
|
| 692 |
+
{
|
| 693 |
+
"cell_type": "code",
|
| 694 |
+
"execution_count": 10,
|
| 695 |
+
"id": "8837d7c2",
|
| 696 |
+
"metadata": {
|
| 697 |
+
"execution": {
|
| 698 |
+
"iopub.execute_input": "2026-05-22T12:57:46.378585Z",
|
| 699 |
+
"iopub.status.busy": "2026-05-22T12:57:46.378494Z",
|
| 700 |
+
"iopub.status.idle": "2026-05-22T12:57:46.383269Z",
|
| 701 |
+
"shell.execute_reply": "2026-05-22T12:57:46.382931Z"
|
| 702 |
+
}
|
| 703 |
+
},
|
| 704 |
+
"outputs": [
|
| 705 |
+
{
|
| 706 |
+
"data": {
|
| 707 |
+
"text/html": [
|
| 708 |
+
"<div><style>\n",
|
| 709 |
+
".dataframe > thead > tr,\n",
|
| 710 |
+
".dataframe > tbody > tr {\n",
|
| 711 |
+
" text-align: right;\n",
|
| 712 |
+
" white-space: pre-wrap;\n",
|
| 713 |
+
"}\n",
|
| 714 |
+
"</style>\n",
|
| 715 |
+
"<small>shape: (15, 4)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>year</th><th>total</th><th>with_patch</th><th>pct_with_patch</th></tr><tr><td>i32</td><td>u32</td><td>u32</td><td>f64</td></tr></thead><tbody><tr><td>2012</td><td>5939</td><td>359</td><td>6.0</td></tr><tr><td>2013</td><td>6830</td><td>441</td><td>6.5</td></tr><tr><td>2014</td><td>9002</td><td>560</td><td>6.2</td></tr><tr><td>2015</td><td>8779</td><td>612</td><td>7.0</td></tr><tr><td>2016</td><td>10611</td><td>856</td><td>8.1</td></tr><tr><td>2017</td><td>17061</td><td>1182</td><td>6.9</td></tr><tr><td>2018</td><td>17719</td><td>1032</td><td>5.8</td></tr><tr><td>2019</td><td>17571</td><td>1132</td><td>6.4</td></tr><tr><td>2020</td><td>21047</td><td>1433</td><td>6.8</td></tr><tr><td>2021</td><td>23419</td><td>2193</td><td>9.4</td></tr><tr><td>2022</td><td>27501</td><td>2829</td><td>10.3</td></tr><tr><td>2023</td><td>31191</td><td>2691</td><td>8.6</td></tr><tr><td>2024</td><td>39094</td><td>2506</td><td>6.4</td></tr><tr><td>2025</td><td>44388</td><td>3149</td><td>7.1</td></tr><tr><td>2026</td><td>19825</td><td>3730</td><td>18.8</td></tr></tbody></table></div>"
|
| 716 |
+
],
|
| 717 |
+
"text/plain": [
|
| 718 |
+
"shape: (15, 4)\n",
|
| 719 |
+
"┌──────┬───────┬────────────┬────────────────┐\n",
|
| 720 |
+
"│ year ┆ total ┆ with_patch ┆ pct_with_patch │\n",
|
| 721 |
+
"│ --- ┆ --- ┆ --- ┆ --- │\n",
|
| 722 |
+
"│ i32 ┆ u32 ┆ u32 ┆ f64 │\n",
|
| 723 |
+
"╞══════╪═══════╪════════════╪════════════════╡\n",
|
| 724 |
+
"│ 2012 ┆ 5939 ┆ 359 ┆ 6.0 │\n",
|
| 725 |
+
"│ 2013 ┆ 6830 ┆ 441 ┆ 6.5 │\n",
|
| 726 |
+
"│ 2014 ┆ 9002 ┆ 560 ┆ 6.2 │\n",
|
| 727 |
+
"│ 2015 ┆ 8779 ┆ 612 ┆ 7.0 │\n",
|
| 728 |
+
"│ 2016 ┆ 10611 ┆ 856 ┆ 8.1 │\n",
|
| 729 |
+
"│ 2017 ┆ 17061 ┆ 1182 ┆ 6.9 │\n",
|
| 730 |
+
"│ 2018 ┆ 17719 ┆ 1032 ┆ 5.8 │\n",
|
| 731 |
+
"│ 2019 ┆ 17571 ┆ 1132 ┆ 6.4 │\n",
|
| 732 |
+
"│ 2020 ┆ 21047 ┆ 1433 ┆ 6.8 │\n",
|
| 733 |
+
"│ 2021 ┆ 23419 ┆ 2193 ┆ 9.4 │\n",
|
| 734 |
+
"│ 2022 ┆ 27501 ┆ 2829 ┆ 10.3 │\n",
|
| 735 |
+
"│ 2023 ┆ 31191 ┆ 2691 ┆ 8.6 │\n",
|
| 736 |
+
"│ 2024 ┆ 39094 ┆ 2506 ┆ 6.4 │\n",
|
| 737 |
+
"│ 2025 ┆ 44388 ┆ 3149 ┆ 7.1 │\n",
|
| 738 |
+
"│ 2026 ┆ 19825 ┆ 3730 ┆ 18.8 │\n",
|
| 739 |
+
"└──────┴───────┴────────────┴────────────────┘"
|
| 740 |
+
]
|
| 741 |
+
},
|
| 742 |
+
"execution_count": 10,
|
| 743 |
+
"metadata": {},
|
| 744 |
+
"output_type": "execute_result"
|
| 745 |
+
}
|
| 746 |
+
],
|
| 747 |
+
"source": [
|
| 748 |
+
"(\n",
|
| 749 |
+
" lf.group_by(\"year\")\n",
|
| 750 |
+
" .agg(\n",
|
| 751 |
+
" pl.len().alias(\"total\"),\n",
|
| 752 |
+
" pl.col(\"has_patch\").sum().alias(\"with_patch\"),\n",
|
| 753 |
+
" )\n",
|
| 754 |
+
" .with_columns((pl.col(\"with_patch\") / pl.col(\"total\") * 100).round(1).alias(\"pct_with_patch\"))\n",
|
| 755 |
+
" .sort(\"year\")\n",
|
| 756 |
+
" .tail(15)\n",
|
| 757 |
+
" .collect()\n",
|
| 758 |
+
")"
|
| 759 |
+
]
|
| 760 |
+
},
|
| 761 |
+
{
|
| 762 |
+
"cell_type": "markdown",
|
| 763 |
+
"id": "63720989",
|
| 764 |
+
"metadata": {},
|
| 765 |
+
"source": [
|
| 766 |
+
"## 7. Find a specific CWE (e.g. CWE-22 Path Traversal)"
|
| 767 |
+
]
|
| 768 |
+
},
|
| 769 |
+
{
|
| 770 |
+
"cell_type": "code",
|
| 771 |
+
"execution_count": 11,
|
| 772 |
+
"id": "70d0da26",
|
| 773 |
+
"metadata": {
|
| 774 |
+
"execution": {
|
| 775 |
+
"iopub.execute_input": "2026-05-22T12:57:46.384321Z",
|
| 776 |
+
"iopub.status.busy": "2026-05-22T12:57:46.384226Z",
|
| 777 |
+
"iopub.status.idle": "2026-05-22T12:57:46.426208Z",
|
| 778 |
+
"shell.execute_reply": "2026-05-22T12:57:46.425879Z"
|
| 779 |
+
}
|
| 780 |
+
},
|
| 781 |
+
"outputs": [
|
| 782 |
+
{
|
| 783 |
+
"data": {
|
| 784 |
+
"text/html": [
|
| 785 |
+
"<div><style>\n",
|
| 786 |
+
".dataframe > thead > tr,\n",
|
| 787 |
+
".dataframe > tbody > tr {\n",
|
| 788 |
+
" text-align: right;\n",
|
| 789 |
+
" white-space: pre-wrap;\n",
|
| 790 |
+
"}\n",
|
| 791 |
+
"</style>\n",
|
| 792 |
+
"<small>shape: (8_905, 4)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>cve_id</th><th>year</th><th>cvss_base_severity</th><th>description</th></tr><tr><td>str</td><td>i32</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>"CVE-2001-0054"</td><td>2001</td><td>"MEDIUM"</td><td>"Directory traversal vulnerability in FTP Serv-U before 2.5i allows remote attackers to escape the FTP root and read arbi…</td></tr><tr><td>"CVE-2001-0780"</td><td>2001</td><td>"MEDIUM"</td><td>"Directory traversal vulnerability in cosmicpro.cgi in Cosmicperl Directory Pro 2.0 allows remote attackers to gain sensi…</td></tr><tr><td>"CVE-2001-0925"</td><td>2001</td><td>"MEDIUM"</td><td>"The default installation of Apache before 1.3.19 allows remote attackers to list directories instead of the multiview in…</td></tr><tr><td>"CVE-2001-1205"</td><td>2001</td><td>"MEDIUM"</td><td>"Directory traversal vulnerability in lastlines.cgi for Last Lines 2.0 allows remote attackers to read arbitrary files vi…</td></tr><tr><td>"CVE-2001-1432"</td><td>2001</td><td>"HIGH"</td><td>"Directory traversal vulnerability in Cherokee Web Server allows remote attackers to read arbitrary files via a .. (dot d…</td></tr><tr><td>"CVE-2001-1586"</td><td>2001</td><td>"HIGH"</td><td>"Directory traversal vulnerability in SimpleServer:WWW 1.13 and earlier allows remote attackers to execute arbitrary prog…</td></tr><tr><td>"CVE-2002-2154"</td><td>2002</td><td>"MEDIUM"</td><td>"Directory traversal vulnerability in Monkey HTTP Daemon 0.1.4 allows remote attackers to read arbitrary files via .. (do…</td></tr><tr><td>"CVE-2002-2229"</td><td>2002</td><td>"MEDIUM"</td><td>"Directory traversal vulnerability in Sapio Design Ltd. WebReflex 1.53 allows remote attackers to read arbitrary files vi…</td></tr><tr><td>"CVE-2002-2233"</td><td>2002</td><td>"HIGH"</td><td>"Directory traversal vulnerability in Enceladus Server Suite 3.9 allows remote attackers to list arbitrary directories an…</td></tr><tr><td>"CVE-2002-2238"</td><td>2002</td><td>"MEDIUM"</td><td>"Directory traversal vulnerability in the Kunani ODBC FTP Server 1.0.10 allows remote attackers to read arbitrary files v…</td></tr><tr><td>…</td><td>…</td><td>…</td><td>…</td></tr><tr><td>"CVE-2026-8736"</td><td>2026</td><td>"LOW"</td><td>"A security flaw has been discovered in Oinone Pamirs up to 7.2.0. This vulnerability affects the function request.getPar…</td></tr><tr><td>"CVE-2026-8754"</td><td>2026</td><td>"LOW"</td><td>"A vulnerability was detected in AstrBotDevs AstrBot up to 4.23.5. Impacted is the function post_file of the file astrbot…</td></tr><tr><td>"CVE-2026-8755"</td><td>2026</td><td>"MEDIUM"</td><td>"A flaw has been found in fishaudio Bert-VITS2 up to 8f7fbd8c4770965225d258db548da27dc8dd934c. The affected element is th…</td></tr><tr><td>"CVE-2026-8756"</td><td>2026</td><td>"MEDIUM"</td><td>"A vulnerability has been found in fishaudio Bert-VITS2 up to 8f7fbd8c4770965225d258db548da27dc8dd934c. The impacted elem…</td></tr><tr><td>"CVE-2026-8757"</td><td>2026</td><td>"MEDIUM"</td><td>"A vulnerability was found in adenhq hive up to 0.11.0. This affects the function _read_events_tail of the file core/fram…</td></tr><tr><td>"CVE-2026-8765"</td><td>2026</td><td>"LOW"</td><td>"A vulnerability was detected in Kilo-Org kilocode up to 7.0.47. This vulnerability affects the function Bun.file of the …</td></tr><tr><td>"CVE-2026-8770"</td><td>2026</td><td>"LOW"</td><td>"A vulnerability was identified in continuedev continue up to 1.2.22. This affects the function lsTool of the file core/t…</td></tr><tr><td>"CVE-2026-8802"</td><td>2026</td><td>"MEDIUM"</td><td>"A vulnerability was detected in opensourcepos Open Source Point of Sale up to 3.4.2. This issue affects the function get…</td></tr><tr><td>"CVE-2026-9102"</td><td>2026</td><td>"CRITICAL"</td><td>"A path traversal vulnerability exists in the Altium Enterprise Server ComparisonService due to missing filename sanitiza…</td></tr><tr><td>"CVE-2026-9129"</td><td>2026</td><td>"CRITICAL"</td><td>"A path traversal vulnerability exists in the Altium Enterprise Server Viewer StorageController due to improper handling …</td></tr></tbody></table></div>"
|
| 793 |
+
],
|
| 794 |
+
"text/plain": [
|
| 795 |
+
"shape: (8_905, 4)\n",
|
| 796 |
+
"┌───────────────┬──────┬────────────────────┬──────────────────────────────────────────────────────┐\n",
|
| 797 |
+
"│ cve_id ┆ year ┆ cvss_base_severity ┆ description │\n",
|
| 798 |
+
"│ --- ┆ --- ┆ --- ┆ --- │\n",
|
| 799 |
+
"│ str ┆ i32 ┆ str ┆ str │\n",
|
| 800 |
+
"╞═══════════════╪══════╪════════════════════╪══════════════════════════════════════════════════════╡\n",
|
| 801 |
+
"│ CVE-2001-0054 ┆ 2001 ┆ MEDIUM ┆ Directory traversal vulnerability in FTP Serv-U │\n",
|
| 802 |
+
"│ ┆ ┆ ┆ before 2.5i allows remote attackers to escape the │\n",
|
| 803 |
+
"│ ┆ ┆ ┆ FTP root and read arbi… │\n",
|
| 804 |
+
"│ CVE-2001-0780 ┆ 2001 ┆ MEDIUM ┆ Directory traversal vulnerability in cosmicpro.cgi │\n",
|
| 805 |
+
"│ ┆ ┆ ┆ in Cosmicperl Directory Pro 2.0 allows remote │\n",
|
| 806 |
+
"│ ┆ ┆ ┆ attackers to gain sensi… │\n",
|
| 807 |
+
"│ CVE-2001-0925 ┆ 2001 ┆ MEDIUM ┆ The default installation of Apache before 1.3.19 │\n",
|
| 808 |
+
"│ ┆ ┆ ┆ allows remote attackers to list directories instead │\n",
|
| 809 |
+
"│ ┆ ┆ ┆ of the multiview in… │\n",
|
| 810 |
+
"│ CVE-2001-1205 ┆ 2001 ┆ MEDIUM ┆ Directory traversal vulnerability in lastlines.cgi │\n",
|
| 811 |
+
"│ ┆ ┆ ┆ for Last Lines 2.0 allows remote attackers to read │\n",
|
| 812 |
+
"│ ┆ ┆ ┆ arbitrary files vi… │\n",
|
| 813 |
+
"│ CVE-2001-1432 ┆ 2001 ┆ HIGH ┆ Directory traversal vulnerability in Cherokee Web │\n",
|
| 814 |
+
"│ ┆ ┆ ┆ Server allows remote attackers to read arbitrary │\n",
|
| 815 |
+
"│ ┆ ┆ ┆ files via a .. (dot d… │\n",
|
| 816 |
+
"│ CVE-2001-1586 ┆ 2001 ┆ HIGH ┆ Directory traversal vulnerability in │\n",
|
| 817 |
+
"│ ┆ ┆ ┆ SimpleServer:WWW 1.13 and earlier allows remote │\n",
|
| 818 |
+
"│ ┆ ┆ ┆ attackers to execute arbitrary prog… │\n",
|
| 819 |
+
"│ CVE-2002-2154 ┆ 2002 ┆ MEDIUM ┆ Directory traversal vulnerability in Monkey HTTP │\n",
|
| 820 |
+
"│ ┆ ┆ ┆ Daemon 0.1.4 allows remote attackers to read │\n",
|
| 821 |
+
"│ ┆ ┆ ┆ arbitrary files via .. (do… │\n",
|
| 822 |
+
"│ CVE-2002-2229 ┆ 2002 ┆ MEDIUM ┆ Directory traversal vulnerability in Sapio Design │\n",
|
| 823 |
+
"│ ┆ ┆ ┆ Ltd. WebReflex 1.53 allows remote attackers to read │\n",
|
| 824 |
+
"│ ┆ ┆ ┆ arbitrary files vi… │\n",
|
| 825 |
+
"│ CVE-2002-2233 ┆ 2002 ┆ HIGH ┆ Directory traversal vulnerability in Enceladus │\n",
|
| 826 |
+
"│ ┆ ┆ ┆ Server Suite 3.9 allows remote attackers to list │\n",
|
| 827 |
+
"│ ┆ ┆ ┆ arbitrary directories an… │\n",
|
| 828 |
+
"│ CVE-2002-2238 ┆ 2002 ┆ MEDIUM ┆ Directory traversal vulnerability in the Kunani ODBC │\n",
|
| 829 |
+
"│ ┆ ┆ ┆ FTP Server 1.0.10 allows remote attackers to read │\n",
|
| 830 |
+
"│ ┆ ┆ ┆ arbitrary files v… │\n",
|
| 831 |
+
"│ … ┆ … ┆ … ┆ … │\n",
|
| 832 |
+
"│ CVE-2026-8736 ┆ 2026 ┆ LOW ┆ A security flaw has been discovered in Oinone Pamirs │\n",
|
| 833 |
+
"│ ┆ ┆ ┆ up to 7.2.0. This vulnerability affects the function │\n",
|
| 834 |
+
"│ ┆ ┆ ┆ request.getPar… │\n",
|
| 835 |
+
"│ CVE-2026-8754 ┆ 2026 ┆ LOW ┆ A vulnerability was detected in AstrBotDevs AstrBot │\n",
|
| 836 |
+
"│ ┆ ┆ ┆ up to 4.23.5. Impacted is the function post_file of │\n",
|
| 837 |
+
"│ ┆ ┆ ┆ the file astrbot… │\n",
|
| 838 |
+
"│ CVE-2026-8755 ┆ 2026 ┆ MEDIUM ┆ A flaw has been found in fishaudio Bert-VITS2 up to │\n",
|
| 839 |
+
"│ ┆ ┆ ┆ 8f7fbd8c4770965225d258db548da27dc8dd934c. The │\n",
|
| 840 |
+
"│ ┆ ┆ ┆ affected element is th… │\n",
|
| 841 |
+
"│ CVE-2026-8756 ┆ 2026 ┆ MEDIUM ┆ A vulnerability has been found in fishaudio │\n",
|
| 842 |
+
"│ ┆ ┆ ┆ Bert-VITS2 up to │\n",
|
| 843 |
+
"│ ┆ ┆ ┆ 8f7fbd8c4770965225d258db548da27dc8dd934c. The │\n",
|
| 844 |
+
"│ ┆ ┆ ┆ impacted elem… │\n",
|
| 845 |
+
"│ CVE-2026-8757 ┆ 2026 ┆ MEDIUM ┆ A vulnerability was found in adenhq hive up to │\n",
|
| 846 |
+
"│ ┆ ┆ ┆ 0.11.0. This affects the function _read_events_tail │\n",
|
| 847 |
+
"│ ┆ ┆ ┆ of the file core/fram… │\n",
|
| 848 |
+
"│ CVE-2026-8765 ┆ 2026 ┆ LOW ┆ A vulnerability was detected in Kilo-Org kilocode up │\n",
|
| 849 |
+
"│ ┆ ┆ ┆ to 7.0.47. This vulnerability affects the function │\n",
|
| 850 |
+
"│ ┆ ┆ ┆ Bun.file of the … │\n",
|
| 851 |
+
"│ CVE-2026-8770 ┆ 2026 ┆ LOW ┆ A vulnerability was identified in continuedev │\n",
|
| 852 |
+
"│ ┆ ┆ ┆ continue up to 1.2.22. This affects the function │\n",
|
| 853 |
+
"│ ┆ ┆ ┆ lsTool of the file core/t… │\n",
|
| 854 |
+
"│ CVE-2026-8802 ┆ 2026 ┆ MEDIUM ┆ A vulnerability was detected in opensourcepos Open │\n",
|
| 855 |
+
"│ ┆ ┆ ┆ Source Point of Sale up to 3.4.2. This issue affects │\n",
|
| 856 |
+
"│ ┆ ┆ ┆ the function get… │\n",
|
| 857 |
+
"│ CVE-2026-9102 ┆ 2026 ┆ CRITICAL ┆ A path traversal vulnerability exists in the Altium │\n",
|
| 858 |
+
"│ ┆ ┆ ┆ Enterprise Server ComparisonService due to missing │\n",
|
| 859 |
+
"│ ┆ ┆ ┆ filename sanitiza… │\n",
|
| 860 |
+
"│ CVE-2026-9129 ┆ 2026 ┆ CRITICAL ┆ A path traversal vulnerability exists in the Altium │\n",
|
| 861 |
+
"│ ┆ ┆ ┆ Enterprise Server Viewer StorageController due to │\n",
|
| 862 |
+
"│ ┆ ┆ ┆ improper handling … │\n",
|
| 863 |
+
"└───────────────┴──────┴────────────────────┴──────────────────────────────────────────────────────┘"
|
| 864 |
+
]
|
| 865 |
+
},
|
| 866 |
+
"execution_count": 11,
|
| 867 |
+
"metadata": {},
|
| 868 |
+
"output_type": "execute_result"
|
| 869 |
+
}
|
| 870 |
+
],
|
| 871 |
+
"source": [
|
| 872 |
+
"(\n",
|
| 873 |
+
" lf.filter(pl.col(\"cwes\").list.eval(pl.element().struct.field(\"id\") == \"CWE-22\").list.any())\n",
|
| 874 |
+
" .select(\"cve_id\", \"year\", \"cvss_base_severity\", \"description\")\n",
|
| 875 |
+
" .collect()\n",
|
| 876 |
+
")"
|
| 877 |
+
]
|
| 878 |
+
},
|
| 879 |
+
{
|
| 880 |
+
"cell_type": "markdown",
|
| 881 |
+
"id": "518e2fa3",
|
| 882 |
+
"metadata": {},
|
| 883 |
+
"source": [
|
| 884 |
+
"## 8. Inspect a full patch"
|
| 885 |
+
]
|
| 886 |
+
},
|
| 887 |
+
{
|
| 888 |
+
"cell_type": "code",
|
| 889 |
+
"execution_count": 12,
|
| 890 |
+
"id": "22d766ac",
|
| 891 |
+
"metadata": {
|
| 892 |
+
"execution": {
|
| 893 |
+
"iopub.execute_input": "2026-05-22T12:57:46.427356Z",
|
| 894 |
+
"iopub.status.busy": "2026-05-22T12:57:46.427267Z",
|
| 895 |
+
"iopub.status.idle": "2026-05-22T12:57:46.435685Z",
|
| 896 |
+
"shell.execute_reply": "2026-05-22T12:57:46.435239Z"
|
| 897 |
+
}
|
| 898 |
+
},
|
| 899 |
+
"outputs": [
|
| 900 |
+
{
|
| 901 |
+
"name": "stdout",
|
| 902 |
+
"output_type": "stream",
|
| 903 |
+
"text": [
|
| 904 |
+
"CVE-2009-3287 — lib/thin/connection.rb in Thin web server before 1.2.4 relies on the X-Forwarded-For header to determine the IP address of the client, which allows remote attackers to spoof the IP address and hide ac\n",
|
| 905 |
+
"urls: ['https://github.com/macournoyer/thin/commit/7bd027914c5ffd36bb408ef47dc749de3b6e063a.diff']\n",
|
| 906 |
+
"\n",
|
| 907 |
+
"=== https://github.com/macournoyer/thin/commit/7bd027914c5ffd36bb408ef47dc749de3b6e063a.diff ===\n",
|
| 908 |
+
"diff --git a/CHANGELOG b/CHANGELOG\n",
|
| 909 |
+
"index 595de22c..4cc2b5a2 100644\n",
|
| 910 |
+
"--- a/CHANGELOG\n",
|
| 911 |
+
"+++ b/CHANGELOG\n",
|
| 912 |
+
"@@ -1,4 +1,5 @@\n",
|
| 913 |
+
" == 1.2.3\n",
|
| 914 |
+
"+ * Fix Remote address spoofing vulnerability in Connection#remote_address [Alexey Borzenkov]\n",
|
| 915 |
+
" * Fix uninitialized constant ActionController::Dispatcher error with Rails 1.2.3 [Chris Anderton] [#103 state:resolved]\n",
|
| 916 |
+
" \n",
|
| 917 |
+
" == 1.2.2 I Find Your Lack of Sauce Disturbing release\n",
|
| 918 |
+
"diff --git a/lib/thin/connection.rb b/lib/thin/connection.rb\n",
|
| 919 |
+
"index 1da7d1e1..7ead989a 100644\n",
|
| 920 |
+
"--- a/lib/thin/connection.rb\n",
|
| 921 |
+
"+++ b/lib/thin/connection.rb\n",
|
| 922 |
+
"@@ -180,7 +180,7 @@ def threaded?\n",
|
| 923 |
+
" \n",
|
| 924 |
+
" # IP Address of the remote client.\n",
|
| 925 |
+
" def remote_address\n",
|
| 926 |
+
"- @request.forwarded_for || socket_address\n",
|
| 927 |
+
"+ socket_address\n",
|
| 928 |
+
" rescue Exception\n",
|
| 929 |
+
" log_error\n",
|
| 930 |
+
" nil\n",
|
| 931 |
+
"diff --git a/lib/thin/request.rb b/lib/thin/request.rb\n",
|
| 932 |
+
"index 60adae70..0add8a6b 100644\n",
|
| 933 |
+
"--- a/lib/thin/request.rb\n",
|
| 934 |
+
"+++ b/lib/thin/request.rb\n",
|
| 935 |
+
"@@ -21,7 +21,6 @@ class Request\n",
|
| 936 |
+
" HTTP_VERSION = 'HTTP_VERSION'.freeze\n",
|
| 937 |
+
" HTTP_1_0 = 'HTTP/1.0'.freeze\n",
|
| 938 |
+
" REMOTE_ADDR = 'REMOTE_ADDR'.freeze\n",
|
| 939 |
+
"- FORWARDED_FOR = 'HTTP_X_FORWARDED_FOR'.freeze\n",
|
| 940 |
+
" CONTENT_LENGTH = 'CONTENT_LENGTH'.freeze\n",
|
| 941 |
+
" CONNECTION = 'HTTP_CONNECTION'.freeze\n",
|
| 942 |
+
" KEEP_ALIVE_REGEXP = /\\bkeep-alive\\b/i.freeze\n",
|
| 943 |
+
"@@ -123,10 +122,6 @@ def remote_address=(address)\n",
|
| 944 |
+
" @env[REMOTE_ADDR] = address\n",
|
| 945 |
+
" end\n",
|
| 946 |
+
" \n",
|
| 947 |
+
"- def forwarded_for\n",
|
| 948 |
+
"- \n"
|
| 949 |
+
]
|
| 950 |
+
}
|
| 951 |
+
],
|
| 952 |
+
"source": [
|
| 953 |
+
"row = (\n",
|
| 954 |
+
" lf.filter(pl.col(\"cve_id\") == \"CVE-2009-3287\")\n",
|
| 955 |
+
" .select(\"cve_id\", \"description\", \"patch_urls\", \"patch_diff\")\n",
|
| 956 |
+
" .collect()\n",
|
| 957 |
+
" .row(0, named=True)\n",
|
| 958 |
+
")\n",
|
| 959 |
+
"print(row[\"cve_id\"], \"—\", row[\"description\"][:200])\n",
|
| 960 |
+
"print(\"urls:\", row[\"patch_urls\"])\n",
|
| 961 |
+
"print()\n",
|
| 962 |
+
"print(row[\"patch_diff\"][:1500])"
|
| 963 |
+
]
|
| 964 |
+
},
|
| 965 |
+
{
|
| 966 |
+
"cell_type": "markdown",
|
| 967 |
+
"id": "6e45f7aa",
|
| 968 |
+
"metadata": {},
|
| 969 |
+
"source": [
|
| 970 |
+
"## 9. Patch size statistics"
|
| 971 |
+
]
|
| 972 |
+
},
|
| 973 |
+
{
|
| 974 |
+
"cell_type": "code",
|
| 975 |
+
"execution_count": 13,
|
| 976 |
+
"id": "fa67f4e2",
|
| 977 |
+
"metadata": {
|
| 978 |
+
"execution": {
|
| 979 |
+
"iopub.execute_input": "2026-05-22T12:57:46.436605Z",
|
| 980 |
+
"iopub.status.busy": "2026-05-22T12:57:46.436513Z",
|
| 981 |
+
"iopub.status.idle": "2026-05-22T12:57:47.409147Z",
|
| 982 |
+
"shell.execute_reply": "2026-05-22T12:57:47.408760Z"
|
| 983 |
+
}
|
| 984 |
+
},
|
| 985 |
+
"outputs": [
|
| 986 |
+
{
|
| 987 |
+
"data": {
|
| 988 |
+
"text/html": [
|
| 989 |
+
"<div><style>\n",
|
| 990 |
+
".dataframe > thead > tr,\n",
|
| 991 |
+
".dataframe > tbody > tr {\n",
|
| 992 |
+
" text-align: right;\n",
|
| 993 |
+
" white-space: pre-wrap;\n",
|
| 994 |
+
"}\n",
|
| 995 |
+
"</style>\n",
|
| 996 |
+
"<small>shape: (1, 4)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>bytes_min</th><th>bytes_median</th><th>bytes_max</th><th>lines_median</th></tr><tr><td>u32</td><td>f64</td><td>u32</td><td>f64</td></tr></thead><tbody><tr><td>243</td><td>3574.0</td><td>281698406</td><td>88.0</td></tr></tbody></table></div>"
|
| 997 |
+
],
|
| 998 |
+
"text/plain": [
|
| 999 |
+
"shape: (1, 4)\n",
|
| 1000 |
+
"┌───────────┬──────────────┬───────────┬──────────────┐\n",
|
| 1001 |
+
"│ bytes_min ┆ bytes_median ┆ bytes_max ┆ lines_median │\n",
|
| 1002 |
+
"│ --- ┆ --- ┆ --- ┆ --- │\n",
|
| 1003 |
+
"│ u32 ┆ f64 ┆ u32 ┆ f64 │\n",
|
| 1004 |
+
"╞═══════════╪══════════════╪═══════════╪══════════════╡\n",
|
| 1005 |
+
"│ 243 ┆ 3574.0 ┆ 281698406 ┆ 88.0 │\n",
|
| 1006 |
+
"└───────────┴──────────────┴───────────┴──────────────┘"
|
| 1007 |
+
]
|
| 1008 |
+
},
|
| 1009 |
+
"execution_count": 13,
|
| 1010 |
+
"metadata": {},
|
| 1011 |
+
"output_type": "execute_result"
|
| 1012 |
+
}
|
| 1013 |
+
],
|
| 1014 |
+
"source": [
|
| 1015 |
+
"(\n",
|
| 1016 |
+
" lf.filter(pl.col(\"has_patch\"))\n",
|
| 1017 |
+
" .select(\n",
|
| 1018 |
+
" pl.col(\"patch_diff\").str.len_bytes().alias(\"diff_bytes\"),\n",
|
| 1019 |
+
" pl.col(\"patch_diff\").str.count_matches(\"\\n\").alias(\"diff_lines\"),\n",
|
| 1020 |
+
" )\n",
|
| 1021 |
+
" .select(\n",
|
| 1022 |
+
" pl.col(\"diff_bytes\").min().alias(\"bytes_min\"),\n",
|
| 1023 |
+
" pl.col(\"diff_bytes\").median().alias(\"bytes_median\"),\n",
|
| 1024 |
+
" pl.col(\"diff_bytes\").max().alias(\"bytes_max\"),\n",
|
| 1025 |
+
" pl.col(\"diff_lines\").median().alias(\"lines_median\"),\n",
|
| 1026 |
+
" )\n",
|
| 1027 |
+
" .collect()\n",
|
| 1028 |
+
")"
|
| 1029 |
+
]
|
| 1030 |
+
},
|
| 1031 |
+
{
|
| 1032 |
+
"cell_type": "code",
|
| 1033 |
+
"execution_count": null,
|
| 1034 |
+
"id": "7933e7a1-b464-4135-aabd-b1b66890ada1",
|
| 1035 |
+
"metadata": {},
|
| 1036 |
+
"outputs": [],
|
| 1037 |
+
"source": []
|
| 1038 |
+
}
|
| 1039 |
+
],
|
| 1040 |
+
"metadata": {
|
| 1041 |
+
"kernelspec": {
|
| 1042 |
+
"display_name": "Python 3 (ipykernel)",
|
| 1043 |
+
"language": "python",
|
| 1044 |
+
"name": "python3"
|
| 1045 |
+
},
|
| 1046 |
+
"language_info": {
|
| 1047 |
+
"codemirror_mode": {
|
| 1048 |
+
"name": "ipython",
|
| 1049 |
+
"version": 3
|
| 1050 |
+
},
|
| 1051 |
+
"file_extension": ".py",
|
| 1052 |
+
"mimetype": "text/x-python",
|
| 1053 |
+
"name": "python",
|
| 1054 |
+
"nbconvert_exporter": "python",
|
| 1055 |
+
"pygments_lexer": "ipython3",
|
| 1056 |
+
"version": "3.13.9"
|
| 1057 |
+
}
|
| 1058 |
+
},
|
| 1059 |
+
"nbformat": 4,
|
| 1060 |
+
"nbformat_minor": 5
|
| 1061 |
+
}
|
pyproject.toml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "cve-diff"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "Add your description here"
|
| 5 |
+
readme = "README.md"
|
| 6 |
+
requires-python = ">=3.13"
|
| 7 |
+
dependencies = [
|
| 8 |
+
"fastapi>=0.136.1",
|
| 9 |
+
"jinja2>=3.1.6",
|
| 10 |
+
"pyarrow>=24.0.0",
|
| 11 |
+
"uvicorn[standard]>=0.47.0",
|
| 12 |
+
]
|
| 13 |
+
|
| 14 |
+
[dependency-groups]
|
| 15 |
+
dev = [
|
| 16 |
+
"jupyterlab>=4.5.7",
|
| 17 |
+
"polars>=1.40.1",
|
| 18 |
+
]
|
uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|