Datasets:
Download scripts/ds_security.py from Lilambd/empire-eval: direct link, hf CLI and curl.
- Browser
- Download file 8.75 kB
-
https://huggingface.co/datasets/Lilambd/empire-eval/resolve/main/scripts/ds_security.py
- Command line
-
hf download hf://datasets/Lilambd/empire-eval/scripts/ds_security.py
-
curl -L -o ds_security.py https://huggingface.co/datasets/Lilambd/empire-eval/resolve/main/scripts/ds_security.py
8.75 kB
| from remote_util import latest, day_of, uniq | |
| DS = 'Lilambd/security-daily' | |
| LICENSE = 'CC BY 4.0' | |
| STR = {} | |
| KEYS = {} | |
| SH = 'Security Daily' | |
| def build(B): | |
| root = B.store.root | |
| f = latest(root, 'daily/cve_new/*.csv') | |
| if f: | |
| day = day_of(f) | |
| KEYS[f] = ['cve_id'] | |
| c = B.store[f] | |
| on = f'In {SH} (CVEs first published on {day})' | |
| cu = uniq(c, 'cve_id') | |
| for r in cu.loc[B.sample(cu.index, 40)].itertuples(): | |
| col = B.rng.choice(['cvss3', 'cvss3_severity', 'cwes', 'vendors', 'status']) | |
| if getattr(r, col) != getattr(r, col): | |
| continue | |
| B.add('lookup', f'{on}, what is the {col.replace("_", " ")} of {r.cve_id}?', {'op': 'lookup', 'file': f, 'where': [['cve_id', '==', r.cve_id]], 'col': col}, tol={'abs': 0.05}, skills=['id_lookup', 'fresh_data', 'security']) | |
| for sev in ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW']: | |
| B.add('count', f'{on}, how many new CVEs have CVSS v3 severity {sev}?', {'op': 'count', 'file': f, 'where': [['cvss3_severity', '==', sev]]}, skills=['filter', 'count', 'fresh_data', 'security']) | |
| B.add('count', f'{on}, how many new CVEs are already in the CISA KEV catalogue?', {'op': 'count', 'file': f, 'where': [['kev', '==', 'True']]}, difficulty=2, skills=['filter', 'count', 'security']) | |
| B.add('count', f'{on}, how many new CVEs have no CVSS v3 score yet?', {'op': 'count', 'file': f, 'where': [['cvss3', 'isna', None]]}, difficulty=2, skills=['filter', 'count', 'security']) | |
| cw = c.cwes.dropna().value_counts() | |
| for w in list(cw.index)[:8]: | |
| B.add('count', f'{on}, how many new CVEs are classified exactly as {w}?', {'op': 'count', 'file': f, 'where': [['cwes', '==', w]]}, skills=['filter', 'count', 'security']) | |
| B.add('rank', f'{on}, which CWE value appears most often among the new CVEs?', {'op': 'group_top', 'file': f, 'where': [], 'by': 'cwes'}, difficulty=2, skills=['group_by', 'security']) | |
| B.add('rank', f'{on}, which vendor value appears most often among the new CVEs?', {'op': 'group_top', 'file': f, 'where': [], 'by': 'vendors'}, difficulty=2, skills=['group_by', 'security']) | |
| f = latest(root, 'daily/patch_first/*.csv') | |
| if f: | |
| KEYS[f] = ['rank', 'cve_id'] | |
| p = B.store[f] | |
| on = f'In {SH} patch-first list for {day_of(f)}' | |
| for rk in range(1, min(len(p), 21)): | |
| B.add('lookup', f'{on}, which CVE is ranked #{rk}?', {'op': 'lookup', 'file': f, 'where': [['rank', '==', rk]], 'col': 'cve_id'}, skills=['table_lookup', 'security']) | |
| for r in p.head(30).pipe(lambda d: d.loc[B.sample(d.index, 12)]).itertuples(): | |
| B.add('lookup', f'{on}, why is {r.cve_id} listed (column why)?', {'op': 'lookup', 'file': f, 'where': [['cve_id', '==', r.cve_id]], 'col': 'why'}, skills=['table_lookup', 'security']) | |
| B.add('lookup', f'{on}, what is the EPSS score of {r.cve_id}?', {'op': 'lookup', 'file': f, 'where': [['cve_id', '==', r.cve_id]], 'col': 'epss'}, tol={'rel': 0.001}, skills=['table_lookup', 'security']) | |
| B.add('count', f'{on}, how many listed CVEs have known ransomware use?', {'op': 'count', 'file': f, 'where': [['kev_ransomware', '==', 'Known']]}, skills=['filter', 'count', 'security']) | |
| B.add('rank', f'{on}, which listed CVE has the highest EPSS score?', {'op': 'argmax', 'file': f, 'col': 'epss', 'return': 'cve_id'}, difficulty=2, skills=['ranking', 'security']) | |
| f = latest(root, 'daily/summary/*.csv') | |
| if f: | |
| KEYS[f] = ['ledger'] | |
| s = B.store[f] | |
| for r in s.itertuples(): | |
| B.add('lookup', f'In {SH} summary for {day_of(f)}, how many rows in total does the ledger "{r.ledger}" hold?', {'op': 'lookup', 'file': f, 'where': [['ledger', '==', r.ledger]], 'col': 'rows_total'}, tol={'abs': 0}, skills=['table_lookup']) | |
| f = 'snapshot/breaches.csv' | |
| if latest(root, f): | |
| KEYS[f] = ['id', 'org'] | |
| b = B.store[f] | |
| bu = b[b.records.notna() & ~b.duplicated(['org'], keep=False)] | |
| for r in bu.loc[B.sample(bu.index, 30)].itertuples(): | |
| col = B.rng.choice(['records', 'breach_date', 'disclosed']) | |
| if getattr(r, col) != getattr(r, col): | |
| continue | |
| t = {'records': f'In {SH} breach snapshot, how many records were exposed in the {r.org} breach?', 'breach_date': f'In {SH} breach snapshot, on what date did the {r.org} breach happen (YYYY-MM-DD)?', 'disclosed': f'In {SH} breach snapshot, when was the {r.org} breach disclosed (YYYY-MM-DD)?'}[col] | |
| B.add('lookup', t, {'op': 'lookup', 'file': f, 'where': [['org', '==', r.org]], 'col': col}, tol={'abs': 0}, skills=['table_lookup', 'security']) | |
| for c in ['JP', 'US', 'FR', 'DE', 'GB']: | |
| B.add('count', f'In {SH} breach snapshot, how many breaches are listed with country {c}?', {'op': 'count', 'file': f, 'where': [['country_iso2', '==', c]]}, skills=['filter', 'count', 'security']) | |
| for src in b.source.dropna().unique(): | |
| B.add('rank', f'In {SH} breach snapshot, which organisation has the largest breach by records in the source "{src}"?', {'op': 'argmax', 'file': f, 'where': [['source', '==', src]], 'col': 'records', 'return': 'org'}, difficulty=2, skills=['ranking', 'security']) | |
| for cls in ['Passwords', 'Email addresses', 'Phone numbers', 'Physical addresses', 'Government issued IDs']: | |
| B.add('count', f'In {SH} breach snapshot, how many breaches list "{cls}" among the exposed data classes?', {'op': 'count', 'file': f, 'where': [['data_classes', 'contains', cls]]}, difficulty=2, skills=['filter', 'count', 'text_match', 'security']) | |
| for org in ['Lilambd Crossing', 'Hibe Riverworks Ltd']: | |
| B.add('unanswerable', f'In {SH} breach snapshot, how many records were exposed in the {org} breach? If there is no such breach, answer null.', {'op': 'absent', 'file': f, 'where': [['org', '==', org]]}, skills=['abstention', 'security']) | |
| for yr in ('2025', '2026'): | |
| f = f'snapshot/cve_signals/published_{yr}.csv' | |
| if not latest(root, f): | |
| continue | |
| KEYS[f] = ['cve_id'] | |
| c = B.store[f] | |
| cu = uniq(c, 'cve_id') | |
| for r in cu.loc[B.sample(cu.index, 25)].itertuples(): | |
| col = B.rng.choice(['cvss3', 'epss', 'products', 'kev']) | |
| if getattr(r, col) != getattr(r, col): | |
| continue | |
| B.add('lookup', f'In {SH} CVE signals, what is the {col} value of {r.cve_id}?', {'op': 'lookup', 'file': f, 'where': [['cve_id', '==', r.cve_id]], 'col': col}, tol={'rel': 0.001}, skills=['id_lookup', 'security']) | |
| B.add('count', f'In {SH} CVE signals, how many CVEs published in {yr} are in the CISA KEV catalogue?', {'op': 'count', 'file': f, 'where': [['kev', '==', 'True']]}, difficulty=2, skills=['filter', 'count', 'security']) | |
| B.add('count', f'In {SH} CVE signals, how many CVEs published in {yr} are flagged with known ransomware use?', {'op': 'count', 'file': f, 'where': [['kev_ransomware', '==', 'Known']]}, difficulty=2, skills=['filter', 'count', 'security']) | |
| B.add('count', f'In {SH} CVE signals, how many CVEs published in {yr} have an EPSS score of at least 0.5?', {'op': 'count', 'file': f, 'where': [['epss', '>=', 0.5]]}, difficulty=2, skills=['filter', 'count', 'security']) | |
| vend = c.vendors.dropna().value_counts() | |
| for v in list(vend.index)[:10]: | |
| B.add('count', f'In {SH} CVE signals, how many CVEs published in {yr} have vendor value exactly "{v}"?', {'op': 'count', 'file': f, 'where': [['vendors', '==', v]]}, skills=['filter', 'count', 'security']) | |
| B.add('rank', f'In {SH} CVE signals, among {yr} CVEs with vendor "{v}", which has the highest EPSS score?', {'op': 'argmax', 'file': f, 'where': [['vendors', '==', v]], 'col': 'epss', 'return': 'cve_id'}, difficulty=3, skills=['ranking', 'security']) | |
| for _ in range(4): | |
| cid = f'CVE-{yr}-{B.rng.randint(990000, 999999)}' | |
| B.add('unanswerable', f'In {SH} CVE signals, what is the CVSS v3 score of {cid}? If the CVE is not listed, answer null.', {'op': 'absent', 'file': f, 'where': [['cve_id', '==', cid]]}, skills=['abstention', 'security']) | |
| f = latest(root, 'weekly/vendor/*.csv') | |
| if f: | |
| KEYS[f] = ['vendor'] | |
| w = B.store[f] | |
| for r in w.itertuples(): | |
| B.add('lookup', f'In {SH} weekly vendor table for the week ending {day_of(f)}, how many new CVEs did {r.vendor} have?', {'op': 'lookup', 'file': f, 'where': [['vendor', '==', r.vendor]], 'col': 'cves_new'}, tol={'abs': 0}, skills=['table_lookup', 'security']) | |