{ "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 }