elf 0.1.0__tar.gz

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.
elf-0.1.0/.gitignore ADDED
@@ -0,0 +1,163 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
163
+ .DS_Store
elf-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 TypeError
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
elf-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,344 @@
1
+ Metadata-Version: 2.4
2
+ Name: elf
3
+ Version: 0.1.0
4
+ Summary: A Python library for integrating and analyzing vulnerability data to enhance vulnerability management and prioritization.
5
+ Project-URL: Homepage, https://github.com/TypeError/elf
6
+ Project-URL: Documentation, https://github.com/TypeError/elf/
7
+ Project-URL: Repository, https://github.com/TypeError/elf
8
+ Project-URL: Issue-Tracker, https://github.com/TypeError/elf/issues
9
+ Author-email: cak <cak@typeerror.com>
10
+ License: MIT License
11
+
12
+ Copyright (c) 2024 TypeError
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENSE
32
+ Keywords: CISA KEV,FIRST EPSS,NIST NVD,cybersecurity,vulnerability management
33
+ Classifier: Development Status :: 3 - Alpha
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Programming Language :: Python :: 3.10
37
+ Classifier: Topic :: Security
38
+ Requires-Python: >=3.10
39
+ Requires-Dist: httpx>=0.28.0
40
+ Requires-Dist: pydantic>=2.10.2
41
+ Description-Content-Type: text/markdown
42
+
43
+ <div align="center">
44
+
45
+ # ELF (Exposure Lookup Framework)
46
+
47
+ **Bringing together vulnerability intelligence from multiple sources into a single, harmonious API.**
48
+
49
+ [![PyPI Version](https://img.shields.io/pypi/v/elf.svg)](https://pypi.org/project/elf/)
50
+ [![Python Versions](https://img.shields.io/pypi/pyversions/elf.svg)](https://pypi.org/project/elf/)
51
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
52
+ [![Downloads](https://pepy.tech/badge/elf)](https://pepy.tech/project/elf)
53
+ [![License](https://img.shields.io/pypi/l/elf.svg)](https://github.com/TypeError/elf/blob/main/LICENSE)
54
+ [![GitHub Stars](https://img.shields.io/github/stars/TypeError/elf.svg)](https://github.com/TypeError/elf/stargazers)
55
+
56
+ </div>
57
+
58
+ ---
59
+
60
+ **ELF** (Exposure Lookup Framework) is a modern Python library that streamlines the **aggregation**, **parsing**, and **analysis** of vulnerability data from multiple trusted sources, including:
61
+
62
+ - **[CISA KEV](#cisa-kev)** – Authoritative catalog of actively exploited vulnerabilities
63
+ - **[FIRST EPSS](#first-epss)** – Predictive scoring system to gauge exploitation likelihood
64
+ - **[NIST NVD](#nist-nvd)** – Comprehensive CVE database maintained by the National Institute of Standards and Technology
65
+
66
+ **Supported Python Versions**: 3.10 and above
67
+
68
+ ELF helps you:
69
+
70
+ - Effortlessly query and consolidate vulnerability information
71
+ - Apply advanced filters, searches, and scoring systems
72
+ - Validate structured data using Pydantic models
73
+ - Integrate insights into dashboards, CI/CD pipelines, and data-driven security workflows
74
+
75
+ All with a clean, Pythonic, **async-first** interface. If you’re new to asynchronous programming in Python, check out the [asyncio documentation](https://docs.python.org/3/library/asyncio.html).
76
+
77
+ ---
78
+
79
+ ## Table of Contents
80
+
81
+ - [Features](#features)
82
+ - [Installation](#installation)
83
+ - [Supported Data Sources](#supported-data-sources)
84
+ - [CISA KEV](#cisa-kev)
85
+ - [FIRST EPSS](#first-epss)
86
+ - [NIST NVD](#nist-nvd)
87
+ - [Usage](#usage)
88
+ - [CISA KEV Examples](#cisa-kev-examples)
89
+ - [FIRST EPSS Examples](#first-epss-examples)
90
+ - [NIST NVD Examples](#nist-nvd-examples)
91
+ - [Attribution and Usage Guidelines](#attribution-and-usage-guidelines)
92
+ - [Special Thanks to Solos](#special-thanks-to-solos)
93
+ - [Contributing](#contributing)
94
+ - [License](#license)
95
+
96
+ ---
97
+
98
+ ## Features
99
+
100
+ - ✅ **Query vulnerability data from multiple sources**
101
+
102
+ - **CISA KEV**: Known Exploited Vulnerabilities catalog
103
+ - **FIRST EPSS**: Exploit Prediction Scoring System for prioritization
104
+ - **NIST NVD**: National Vulnerability Database for comprehensive CVE details
105
+
106
+ - 🔍 **Advanced filtering and searching**
107
+
108
+ - Filter by date, CVE IDs, scores, severity, and more
109
+
110
+ - 🛠️ **Pydantic-based data validation**
111
+
112
+ - Robust validation for structured data handling
113
+
114
+ - 📈 **Pagination and bulk data fetching**
115
+
116
+ - Efficiently process large datasets
117
+
118
+ - 🚀 **Integration-ready**
119
+ - Seamlessly integrate into dashboards, CI/CD pipelines, or analytics workflows
120
+
121
+ ---
122
+
123
+ ## Installation
124
+
125
+ ### Using `pip`
126
+
127
+ ```bash
128
+ pip install elf
129
+ ```
130
+
131
+ ### Using `uv`
132
+
133
+ If you use [uv](https://docs.astral.sh/uv/) for package management:
134
+
135
+ ```bash
136
+ uv add elf
137
+ ```
138
+
139
+ ---
140
+
141
+ ## Supported Data Sources
142
+
143
+ ### CISA KEV
144
+
145
+ The [CISA Known Exploited Vulnerabilities (KEV)](https://www.cisa.gov/known-exploited-vulnerabilities-catalog) catalog provides an authoritative list of vulnerabilities actively exploited in the wild. ELF enables seamless programmatic access to these datasets.
146
+
147
+ ### FIRST EPSS
148
+
149
+ The [Exploit Prediction Scoring System (EPSS)](https://www.first.org/epss) predicts the likelihood of a CVE being exploited. ELF offers interfaces for JSON and CSV retrievals, along with time-series data.
150
+
151
+ ### NIST NVD
152
+
153
+ The [National Vulnerability Database (NVD)](https://nvd.nist.gov/) from NIST is among the most comprehensive CVE data sources. ELF integrates with NVD for CVE details, search functionality, and change history.
154
+
155
+ ---
156
+
157
+ ## Usage
158
+
159
+ ### CISA KEV Examples
160
+
161
+ ```python
162
+ import asyncio
163
+ from elf import CisaKevApiClient
164
+
165
+ # Fetch all vulnerabilities in JSON format
166
+ async def fetch_all_vulnerabilities():
167
+ async with CisaKevApiClient() as client:
168
+ kev_data = await client.get_kev_json()
169
+ print(f"Catalog Title: {kev_data.catalog_version}")
170
+ print(f"Total Vulnerabilities: {kev_data.count}")
171
+
172
+ # Fetch vulnerabilities as raw CSV
173
+ async def fetch_vulnerabilities_csv():
174
+ async with CisaKevApiClient() as client:
175
+ kev_csv = await client.get_kev_csv()
176
+ with open("kev_data.csv", "wb") as file:
177
+ file.write(kev_csv)
178
+ print("CSV data saved as kev_data.csv")
179
+
180
+ # Fetch paginated data
181
+ async def fetch_paginated_vulnerabilities():
182
+ async with CisaKevApiClient() as client:
183
+ async for chunk in client.get_kev_json_paginated(chunk_size=500):
184
+ print(f"Fetched {len(chunk.vulnerabilities)} vulnerabilities in this chunk.")
185
+
186
+ # Run examples
187
+ async def main():
188
+ await fetch_all_vulnerabilities()
189
+ await fetch_vulnerabilities_csv()
190
+ await fetch_paginated_vulnerabilities()
191
+
192
+ asyncio.run(main())
193
+ ```
194
+
195
+ ---
196
+
197
+ ### FIRST EPSS Examples
198
+
199
+ ```python
200
+ import asyncio
201
+ from elf import FirstEpssApiClient, FirstEpssOrderOption
202
+
203
+ # Retrieve EPSS scores for specific CVEs
204
+ async def fetch_epss_scores():
205
+ async with FirstEpssApiClient() as client:
206
+ scores = await client.get_scores_json(["CVE-2023-1234", "CVE-2023-5678"])
207
+ for score in scores.data:
208
+ print(f"CVE: {score.cve}, Score: {score.epss}, Percentile: {score.percentile}")
209
+
210
+ # Download full EPSS CSV for a specific date
211
+ async def download_full_csv():
212
+ async with FirstEpssApiClient() as client:
213
+ csv_data = await client.download_and_decompress_full_csv_for_date("2023-12-01")
214
+ with open("epss_data.csv", "w") as file:
215
+ file.write(csv_data)
216
+ print("Decompressed CSV saved as epss_data.csv")
217
+
218
+ # Fetch the highest EPSS scores
219
+ async def fetch_highest_epss_scores():
220
+ async with FirstEpssApiClient() as client:
221
+ response = await client.get_cves(order=FirstEpssOrderOption.EPSS_DESC, limit=5)
222
+ print("Top 5 CVEs with the highest EPSS scores:")
223
+ for item in response.data:
224
+ print(f"CVE: {item.cve}, EPSS: {item.epss}, Percentile: {item.percentile}")
225
+
226
+ # Paginate EPSS data
227
+ async def fetch_paginated_epss_scores():
228
+ async with FirstEpssApiClient() as client:
229
+ async for page in client.get_scores_paginated_json(limit_per_request=100, max_records=500):
230
+ for record in page.data:
231
+ print(f"CVE: {record.cve}, Score: {record.epss}")
232
+
233
+ # Run examples
234
+ async def main():
235
+ await fetch_epss_scores()
236
+ await download_full_csv()
237
+ await fetch_highest_epss_scores()
238
+ await fetch_paginated_epss_scores()
239
+
240
+ asyncio.run(main())
241
+ ```
242
+
243
+ ---
244
+
245
+ ### NIST NVD Examples
246
+
247
+ ```python
248
+ import asyncio
249
+ import os
250
+ from datetime import datetime
251
+
252
+ from elf.core.exceptions import ApiClientError
253
+ from elf.sources.nist_nvd.client import NistNvdApiClient
254
+
255
+ NIST_NVD_API_KEY = os.getenv("NIST_NVD_API_KEY")
256
+
257
+
258
+ # Fetch details for a specific CVE
259
+ async def fetch_cve_details():
260
+ async with NistNvdApiClient(api_key=NIST_NVD_API_KEY) as client:
261
+ cve_data = await client.get_cve("CVE-2021-34527")
262
+ print(f"CVE ID: {cve_data.vulnerabilities[0].cve.id}")
263
+ print(f"Description: {cve_data.vulnerabilities[0].cve.descriptions[0].value}")
264
+
265
+
266
+ # Search CVEs with filters
267
+ async def search_cves():
268
+ try:
269
+ async with NistNvdApiClient(api_key=NIST_NVD_API_KEY) as client:
270
+ async for page in client.search_cves(
271
+ cpe_name="cpe:2.3:o:microsoft:windows:-:*:*:*:*:*:*:*",
272
+ cvss_v3_severity="HIGH",
273
+ pub_start_date=datetime(2016, 3, 1),
274
+ pub_end_date=datetime(2016, 3, 12),
275
+ ):
276
+ if not page.vulnerabilities:
277
+ print("No vulnerabilities found for this query.")
278
+ return
279
+ for vuln in page.vulnerabilities:
280
+ print(f"CVE ID: {vuln.cve.id}, Published: {vuln.cve.published}")
281
+ except ApiClientError as e:
282
+ print(f"Error during CVE search: {e}")
283
+
284
+
285
+ # Retrieve CVE change history
286
+ async def fetch_cve_history():
287
+ try:
288
+ async with NistNvdApiClient(api_key=NIST_NVD_API_KEY) as client:
289
+ async for page in client.get_cve_history_paginated(
290
+ cve_id="CVE-2021-34527",
291
+ change_start_date=datetime(2023, 1, 1),
292
+ change_end_date=datetime(2023, 6, 1),
293
+ ):
294
+ if not page.cve_changes:
295
+ print("No changes found for this CVE.")
296
+ return
297
+ print(page.cve_changes)
298
+ except ApiClientError as e:
299
+ print(f"Error during CVE history fetch: {e}")
300
+
301
+
302
+ # Run examples
303
+ async def main():
304
+ await fetch_cve_details()
305
+ await search_cves()
306
+ await fetch_cve_history()
307
+
308
+
309
+ asyncio.run(main())
310
+ ```
311
+
312
+ ---
313
+
314
+ ## Attribution and Usage Guidelines
315
+
316
+ ### CISA KEV
317
+
318
+ Data provided under the [Creative Commons 0 1.0 License (CC0)](https://www.cisa.gov/sites/default/files/licenses/kev/license.txt).
319
+
320
+ ### FIRST EPSS
321
+
322
+ Usage must adhere to the [FIRST EPSS Usage Guidelines](https://www.first.org/epss/user-guide).
323
+
324
+ ### NIST NVD
325
+
326
+ Data usage is governed by the [NIST Terms of Use](https://nvd.nist.gov/developers/terms-of-use).
327
+
328
+ ---
329
+
330
+ ## Special Thanks to Solos
331
+
332
+ Special thanks to [Solos](https://github.com/solos) for donating the `elf` package name on PyPI.
333
+
334
+ ---
335
+
336
+ ## Contributing
337
+
338
+ Contributions are welcome! Please [open an issue](https://github.com/TypeError/elf/issues) or submit a [pull request](https://github.com/TypeError/elf/pulls) for new features or bug fixes.
339
+
340
+ ---
341
+
342
+ ## License
343
+
344
+ This project is licensed under the [MIT License](LICENSE).