Datasets:
File size: 10,259 Bytes
eeecd33 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | {
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Security Daily: quickstart\n",
"\n",
"Dataset: [Lilambd/security-daily](https://huggingface.co/datasets/Lilambd/security-daily) (CC BY 4.0, Lilambd).\n",
"NVD CVEs, CISA KEV, FIRST EPSS and regulator breach / incident notices, joined per CVE and written down every day (first day: 2026-11-02).\n",
"\n",
"This notebook shows:\n",
"1. Today's top 20 \"patch these first\"\n",
"2. KEV entries by vendor\n",
"3. The EPSS score distribution\n",
"4. CVEs per published year (from `cve_signals`)\n",
"5. Incident notices per month, by source\n",
"\n",
"Runs on Kaggle, Colab or locally. Internet access must be on (Kaggle: *Settings > Internet > On*)."
],
"id": "cell-00"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Kaggle and Colab ship pandas and matplotlib; datasets / huggingface_hub may need installing.\n",
"%pip install -q \"datasets>=2.19\" \"huggingface_hub>=0.23\" pandas matplotlib"
],
"id": "cell-01"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"from datasets import load_dataset\n",
"\n",
"REPO = \"Lilambd/security-daily\"\n",
"pd.set_option(\"display.max_colwidth\", 60)\n",
"\n",
"def load(config, data_glob=None):\n",
" \"\"\"Load one config as a pandas DataFrame.\n",
"\n",
" Uses datasets.load_dataset first. If that fails (for example a config whose\n",
" folder has no files yet, or a column whose type differs between files), it\n",
" falls back to reading the CSV files directly with pandas, all columns as text.\n",
" \"\"\"\n",
" try:\n",
" return load_dataset(REPO, config, split=\"train\").to_pandas()\n",
" except Exception as e:\n",
" if data_glob is None:\n",
" raise\n",
" print(f\"load_dataset({config!r}) failed ({type(e).__name__}); reading CSVs directly\")\n",
" from huggingface_hub import HfFileSystem\n",
" fs = HfFileSystem()\n",
" files = sorted(fs.glob(f\"datasets/{REPO}/{data_glob}\"))\n",
" return pd.concat((pd.read_csv(f\"hf://{f}\", dtype=str) for f in files), ignore_index=True)"
],
"id": "cell-02"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Top 20 \"patch these first\"\n",
"\n",
"`patch_first` holds the top 300 CVEs that are in CISA KEV or have EPSS >= 0.1, ranked by: KEV with known ransomware use, then KEV due date, then EPSS. One file per day; take the latest day."
],
"id": "cell-03"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"pf = load(\"patch_first\", \"daily/patch_first/*.csv\")\n",
"latest = pf[\"day\"].astype(str).max()\n",
"top20 = pf[pf[\"day\"].astype(str) == latest].copy()\n",
"top20[\"rank\"] = pd.to_numeric(top20[\"rank\"])\n",
"top20 = top20.sort_values(\"rank\").head(20)\n",
"print(\"day:\", latest)\n",
"top20[[\"rank\", \"cve_id\", \"vendors\", \"products\", \"cvss3\", \"epss\", \"kev\", \"kev_due\", \"kev_ransomware\", \"why\"]]"
],
"id": "cell-04"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. KEV entries by vendor\n",
"\n",
"`kev` is the full CISA Known Exploited Vulnerabilities catalogue with EPSS and CVSS joined."
],
"id": "cell-05"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"kev = load(\"kev\", \"snapshot/kev.csv\")\n",
"print(len(kev), \"KEV entries,\", kev[\"vendor\"].nunique(), \"vendors\")\n",
"\n",
"by_vendor = (kev.groupby(\"vendor\")\n",
" .agg(entries=(\"cve_id\", \"size\"),\n",
" ransomware_known=(\"ransomware\", lambda s: (s == \"Known\").sum()))\n",
" .sort_values(\"entries\", ascending=False))\n",
"by_vendor.head(20)"
],
"id": "cell-06"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ax = by_vendor.head(15)[::-1].plot.barh(y=[\"entries\", \"ransomware_known\"], figsize=(8, 6))\n",
"ax.set_title(\"CISA KEV entries by vendor (top 15)\")\n",
"ax.set_xlabel(\"entries\")\n",
"plt.tight_layout()\n",
"plt.show()"
],
"id": "cell-07"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. EPSS distribution\n",
"\n",
"EPSS (FIRST.org) is the estimated probability of exploitation activity in the next 30 days. Most CVEs score very low, so a log scale shows the shape better."
],
"id": "cell-08"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"# cve_signals: every CVE in NVD, one row each, with CVSS, CWE, vendors, EPSS and KEV flags.\n",
"cols = [\"cve_id\", \"published\", \"status\", \"cvss3\", \"cvss3_severity\", \"epss\", \"epss_percentile\", \"kev\"]\n",
"try:\n",
" sig = load_dataset(REPO, \"cve_signals\", split=\"train\", columns=cols).to_pandas()\n",
"except Exception as e:\n",
" print(f\"load_dataset('cve_signals') failed ({type(e).__name__}); reading CSVs directly\")\n",
" from huggingface_hub import HfFileSystem\n",
" fs = HfFileSystem()\n",
" files = sorted(fs.glob(f\"datasets/{REPO}/snapshot/cve_signals/*.csv\"))\n",
" sig = pd.concat((pd.read_csv(f\"hf://{f}\", usecols=cols, dtype=str) for f in files), ignore_index=True)\n",
"\n",
"sig[\"epss\"] = pd.to_numeric(sig[\"epss\"], errors=\"coerce\")\n",
"sig[\"kev\"] = sig[\"kev\"].astype(str).str.lower() == \"true\"\n",
"e = sig[\"epss\"].dropna()\n",
"print(f\"{len(sig):,} CVEs, {len(e):,} with an EPSS score\")\n",
"print(e.describe(percentiles=[0.5, 0.9, 0.99]).round(5))\n",
"print(\"EPSS >= 0.1:\", int((e >= 0.1).sum()), \" EPSS >= 0.5:\", int((e >= 0.5).sum()))"
],
"id": "cell-09"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig, ax = plt.subplots(figsize=(8, 4))\n",
"bins = np.logspace(np.log10(max(e.min(), 1e-5)), 0, 50)\n",
"ax.hist(e, bins=bins, label=\"all CVEs\")\n",
"ax.hist(sig.loc[sig[\"kev\"], \"epss\"].dropna(), bins=bins, label=\"in KEV\")\n",
"ax.set_xscale(\"log\"); ax.set_yscale(\"log\")\n",
"ax.set_xlabel(\"EPSS score\"); ax.set_ylabel(\"CVEs\")\n",
"ax.set_title(\"EPSS score distribution\")\n",
"ax.legend()\n",
"plt.tight_layout()\n",
"plt.show()"
],
"id": "cell-10"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4. CVEs per published year\n",
"\n",
"Counts come from the NVD `published` date. Rejected CVEs are kept in the data; they are excluded here."
],
"id": "cell-11"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sig[\"year\"] = pd.to_datetime(sig[\"published\"], errors=\"coerce\").dt.year\n",
"per_year = (sig[sig[\"status\"] != \"Rejected\"]\n",
" .groupby(\"year\")\n",
" .agg(cves=(\"cve_id\", \"size\"), in_kev=(\"kev\", \"sum\")))\n",
"ax = per_year[\"cves\"].plot.bar(figsize=(10, 4), title=\"CVEs per published year (NVD, excluding Rejected)\")\n",
"ax.set_xlabel(\"\")\n",
"plt.tight_layout()\n",
"plt.show()\n",
"per_year.tail(10)"
],
"id": "cell-12"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5. Incident notices per month, by source\n",
"\n",
"`incidents` holds breach and incident notices from SEC 8-K Item 1.05, the California and Washington attorneys general, CISA, JPCERT/CC and IPA.\n",
"Organisation-level only; where a name may identify a person, `org` is withheld (`org_withheld=true`) and the row is kept for counting.\n",
"Some sources only publish recent items, so their history starts late; that is not a trend."
],
"id": "cell-13"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"inc = load(\"incidents\", \"snapshot/incidents.csv\")\n",
"inc[\"month\"] = pd.to_datetime(inc[\"disclosed\"], errors=\"coerce\").dt.to_period(\"M\")\n",
"monthly = (inc.dropna(subset=[\"month\"])\n",
" .groupby([\"month\", \"source\"]).size()\n",
" .unstack(fill_value=0))\n",
"recent = monthly[monthly.index >= (monthly.index.max() - 23)] # last 24 months\n",
"ax = recent.plot.bar(stacked=True, figsize=(11, 5), title=\"Incident notices per month by source (last 24 months)\")\n",
"ax.legend(fontsize=7, loc=\"upper left\")\n",
"plt.tight_layout()\n",
"plt.show()\n",
"recent.tail(6)"
],
"id": "cell-14"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Other configs\n",
"\n",
"| config | what |\n",
"|---|---|\n",
"| `summary` | counts per source and last fetch time, per day |\n",
"| `cve_new`, `cve_modified` | CVEs published / changed that day |\n",
"| `vendor_week`, `incident_week` | last 7 days per vendor, per source |\n",
"| `breaches` | Have I Been Pwned metadata + Japan disclosure ledger |\n",
"| `kev_added`, `epss_movers`, `incidents_new`, `breaches_new` | daily change files; these folders fill as changes occur |\n",
"\n",
"Sources: NVD (this product uses data from the NVD API but is not endorsed or certified by the NVD), CISA KEV, EPSS (FIRST.org), Have I Been Pwned (CC BY 4.0), SEC EDGAR, California DOJ, Washington AGO, CISA, JPCERT/CC, IPA. Compilation: CC BY 4.0, Lilambd."
],
"id": "cell-15"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
} |