crowbar-cli 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
crowbar/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """crowbar - local vulnerability intelligence, terminal-first."""
2
+
3
+ __version__ = "0.1.0" # x-release-please-version
crowbar/catalog.py ADDED
@@ -0,0 +1,174 @@
1
+ """Static map: dataset -> files on disk -> index tables -> query surface.
2
+
3
+ Agents read this instead of guessing where a fact lives. Keep it in sync when a
4
+ dataset or table is added; `crowbar map` renders it together with live status.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ from . import paths
9
+
10
+ # dataset group -> (on-disk path, tables it populates, example command)
11
+ GROUPS: dict[str, dict] = {
12
+ "nvd": {
13
+ "path": "data/nvd/*.json.gz",
14
+ "tables": ["cve", "cve_cwe", "cve_product", "cpe_match", "cve_ref", "cve_fts"],
15
+ "commands": ["crowbar search", "crowbar cve", "crowbar product"],
16
+ },
17
+ "cveorg": {
18
+ "path": "data/intel/cveorg/cvelistV5-main.tar.gz",
19
+ "tables": ["cve_cna", "cve_cna_ref", "cve_cna_product", "cve", "cve_cwe",
20
+ "cve_product", "cve_ref", "cve_fts", "cve_meta", "source_state"],
21
+ "commands": ["crowbar cve", "crowbar search", "crowbar sources"],
22
+ },
23
+ "poc": {
24
+ "path": "data/intel/poc-in-github/PoC-in-GitHub-master.tar.gz",
25
+ "tables": ["poc", "poc_orphan", "cve_meta"],
26
+ "commands": ["crowbar poc", "crowbar search --poc"],
27
+ },
28
+ "kev": {
29
+ "path": "data/kev/known_exploited_vulnerabilities.json",
30
+ "tables": ["kev", "cve.kev"],
31
+ "commands": ["crowbar kev", "crowbar search --kev"],
32
+ },
33
+ "epss": {
34
+ "path": "data/epss/epss_scores-current.csv.gz",
35
+ "tables": ["cve.epss", "cve.epss_pct"],
36
+ "commands": ["crowbar search --epss"],
37
+ },
38
+ "exploitdb": {
39
+ "path": "data/exploitdb/files_exploits.csv, data/exploitdb/full/",
40
+ "tables": ["exploit", "shellcode", "cve_exploit", "exploit_fts", "exploit_code_fts"],
41
+ "commands": ["crowbar exploit", "crowbar code"],
42
+ },
43
+ "nuclei": {
44
+ "path": "data/nuclei/templates/**/*.yaml",
45
+ "tables": ["nuclei", "cve_nuclei", "nuclei_fts"],
46
+ "commands": ["crowbar nuclei"],
47
+ },
48
+ "metasploit": {
49
+ "path": "data/metasploit/tree.json, data/metasploit/source/modules/",
50
+ "tables": ["msf", "cve_msf"],
51
+ "commands": ["crowbar msf"],
52
+ },
53
+ "attack": {
54
+ "path": "data/attack/*-attack.json",
55
+ "tables": ["attack"],
56
+ "commands": ["crowbar attack"],
57
+ },
58
+ "cwe": {
59
+ "path": "data/cwe/cwec_latest.xml.zip",
60
+ "tables": ["cwe", "cve_cwe"],
61
+ "commands": ["crowbar cwe"],
62
+ },
63
+ "capec": {
64
+ "path": "data/capec/capec_latest.xml",
65
+ "tables": ["capec"],
66
+ "commands": ["crowbar capec"],
67
+ },
68
+ "models": {
69
+ "path": "data/models/models.dev.json",
70
+ "tables": ["model", "model_fts"],
71
+ "commands": ["crowbar models"],
72
+ },
73
+ "vulnrichment": {
74
+ "path": "data/vulnrichment/**/*.json",
75
+ "tables": ["ssvc"],
76
+ "commands": ["crowbar search --ssvc active"],
77
+ },
78
+ "osv": {
79
+ "path": "data/osv/<ecosystem>.zip",
80
+ "tables": ["advisory", "package_range"],
81
+ "commands": ["crowbar advisory"],
82
+ },
83
+ "debian": {
84
+ "path": "data/debian/tracker.json",
85
+ "tables": ["debian"],
86
+ "commands": ["crowbar debian"],
87
+ },
88
+ "vendor": {
89
+ "path": "data/msrc/sug.json, data/apple/{index.html,pages/}",
90
+ "tables": ["os_advisory"],
91
+ "commands": ["crowbar os"],
92
+ },
93
+ "toolkit": {
94
+ "path": "data/toolkit/{gtfobins,lolbas,payloads}/",
95
+ "tables": ["toolkit", "toolkit_fts"],
96
+ "commands": ["crowbar bin"],
97
+ },
98
+ }
99
+
100
+ # table -> one-line meaning (used by `crowbar map --tables`)
101
+ TABLES: dict[str, str] = {
102
+ "cve": "one row per CVE: description, CVSS, EPSS, KEV flag, exploit/nuclei/msf flags",
103
+ "cve_cna": "CVE List v5 CNA record, stored beside (not replacing) NVD values",
104
+ "cve_cna_ref": "CNA reference URLs (CVE List), kept apart from NVD references",
105
+ "cve_cna_product": "CNA affected vendor/product pairs",
106
+ "cve_meta": "publication year vs CVE-ID year, and public-PoC counts",
107
+ "poc": "public GitHub PoC repositories (metadata only, never executed)",
108
+ "poc_orphan": "PoC CVEs that are absent from the local CVE index",
109
+ "cve_alias": "CVE -> GHSA/OSV alias mapping",
110
+ "source_state": "source URL/license/SHA-256, load time, record count, status",
111
+ "cve_cwe": "CVE -> CWE classification",
112
+ "cve_product": "CVE -> vendor/product candidates (from CPE)",
113
+ "cpe_match": "exact version ranges per CVE (use with `crowbar product --version`)",
114
+ "cve_ref": "reference URLs + tags",
115
+ "cve_exploit": "CVE -> Exploit-DB id",
116
+ "cve_nuclei": "CVE -> Nuclei template id",
117
+ "cve_msf": "CVE -> Metasploit module path (parsed from module sources)",
118
+ "kev": "CISA Known Exploited Vulnerabilities",
119
+ "exploit": "Exploit-DB index row",
120
+ "shellcode": "Exploit-DB shellcode row",
121
+ "nuclei": "Nuclei template metadata",
122
+ "msf": "Metasploit module metadata + CVE refs",
123
+ "attack": "MITRE ATT&CK technique (enterprise/mobile/ics)",
124
+ "cwe": "CWE definition",
125
+ "capec": "CAPEC attack pattern",
126
+ "model": "LLM catalog (context, price, capabilities)",
127
+ "ssvc": "CISA SSVC decision points per CVE",
128
+ "advisory": "OSV/GHSA advisories (ecosystem, package, aliases)",
129
+ "package_range": "OSV introduced/fixed version ranges",
130
+ "debian": "Debian tracker: package x release x CVE status + fixed version",
131
+ "os_advisory": "vendor OS advisories: Windows (MSRC) + Apple iOS/macOS",
132
+ "toolkit": "GTFOBins / LOLBAS / PayloadsAllTheThings entries",
133
+ "exploit_code_fts": "full-text index over Exploit-DB source code",
134
+ "toolkit_fts": "full-text index over toolkit entries",
135
+ "cve_fts": "full-text index over CVE descriptions + products",
136
+ "exploit_fts": "full-text index over Exploit-DB descriptions",
137
+ "nuclei_fts": "full-text index over Nuclei templates",
138
+ "model_fts": "full-text index over model names",
139
+ }
140
+
141
+
142
+ def group_of(dataset_name: str) -> str:
143
+ for prefix in ("nvd", "osv", "exploitdb", "attack", "metasploit", "cveorg", "poc"):
144
+ if dataset_name.startswith(prefix):
145
+ return {"metasploit": "metasploit"}.get(prefix, prefix)
146
+ if dataset_name in ("gtfobins", "lolbas", "payloads"):
147
+ return "toolkit"
148
+ if dataset_name in ("metasploit", "msf-source"):
149
+ return "metasploit"
150
+ if dataset_name in ("debian-tracker",):
151
+ return "debian"
152
+ if dataset_name in ("msrc", "apple"):
153
+ return "vendor"
154
+ return dataset_name
155
+
156
+
157
+ def describe(name: str) -> dict:
158
+ return GROUPS.get(group_of(name), {"path": "?", "tables": [], "commands": []})
159
+
160
+
161
+ def disk_state(dest: str) -> tuple[bool, int]:
162
+ p = paths.DATA / dest
163
+ if not p.exists():
164
+ return False, 0
165
+ if p.is_file():
166
+ return True, p.stat().st_size
167
+ total = 0
168
+ for f in p.rglob("*"):
169
+ if f.is_file():
170
+ try:
171
+ total += f.stat().st_size
172
+ except OSError:
173
+ pass
174
+ return True, total