arango-cve-processor 1.4.11__tar.gz → 1.4.14__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.
Files changed (65) hide show
  1. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/PKG-INFO +2 -1
  2. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/tools/cpe_db.py +19 -12
  3. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/tools/nvd.py +3 -3
  4. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/tools/retriever.py +10 -0
  5. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/pyproject.toml +2 -1
  6. arango_cve_processor-1.4.14/requirements.txt +130 -0
  7. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/tools/test_nvd.py +36 -3
  8. arango_cve_processor-1.4.11/requirements.txt +0 -27
  9. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/.env.example +0 -0
  10. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/.env.markdown +0 -0
  11. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/.github/workflows/create-release.yml +0 -0
  12. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/.github/workflows/run-tests.yml +0 -0
  13. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/.gitignore +0 -0
  14. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/LICENSE +0 -0
  15. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/README.md +0 -0
  16. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/__init__.py +0 -0
  17. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/__main__.py +0 -0
  18. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/config.py +0 -0
  19. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/managers/__init__.py +0 -0
  20. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/managers/base_manager.py +0 -0
  21. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/managers/cpe_match.py +0 -0
  22. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/managers/cve_attack.py +0 -0
  23. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/managers/cve_capec.py +0 -0
  24. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/managers/cve_cwe.py +0 -0
  25. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/managers/cve_kev.py +0 -0
  26. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/managers/cve_kev_vulncheck.py +0 -0
  27. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/tools/__init__.py +0 -0
  28. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/tools/cpe.py +0 -0
  29. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor/tools/utils.py +0 -0
  30. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/arango_cve_processor.py +0 -0
  31. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/docs/README.md +0 -0
  32. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/docs/arango_cve_processor-structure.jpg +0 -0
  33. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/docs/arango_cve_processor.png +0 -0
  34. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/docs/cpematch.md +0 -0
  35. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/docs/cve-attack.md +0 -0
  36. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/docs/cve-capec.md +0 -0
  37. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/docs/cve-cwe.md +0 -0
  38. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/docs/cve-epss.md +0 -0
  39. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/docs/cve-kev.md +0 -0
  40. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/docs/cve-vulncheck-kev.md +0 -0
  41. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/docs/vulmatch.png +0 -0
  42. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/NOTES.md +0 -0
  43. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/README.md +0 -0
  44. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/__init__.py +0 -0
  45. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/files/attack-enterprise-objects.json +0 -0
  46. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/files/base_cves.json +0 -0
  47. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/files/base_cves_update_1.json +0 -0
  48. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/files/base_cves_update_2.json +0 -0
  49. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/files/capec-objects.json +0 -0
  50. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/files/cves.json +0 -0
  51. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/files/cwe-objects.json +0 -0
  52. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/requirements.txt +0 -0
  53. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/tests.env +0 -0
  54. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/cli/test_main.py +0 -0
  55. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/conftest.py +0 -0
  56. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/managers/test_base.py +0 -0
  57. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/managers/test_cpematch.py +0 -0
  58. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/managers/test_cve_attack.py +0 -0
  59. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/managers/test_cve_capec.py +0 -0
  60. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/managers/test_cve_cwe.py +0 -0
  61. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/managers/test_cve_kev_cisa.py +0 -0
  62. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/managers/test_cve_kev_vulncheck.py +0 -0
  63. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/tools/test_cpe.py +0 -0
  64. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/tools/test_utils.py +0 -0
  65. {arango_cve_processor-1.4.11 → arango_cve_processor-1.4.14}/tests/unit/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arango_cve_processor
3
- Version: 1.4.11
3
+ Version: 1.4.14
4
4
  Summary: A small python script that enriches Vulnerability STIX Objects with other intel
5
5
  Project-URL: Homepage, https://github.com/muchdogesec/arango_cve_processor
6
6
  Project-URL: Issues, https://github.com/muchdogesec/arango_cve_processor/issues
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3
14
14
  Requires-Python: >=3.9
15
15
  Requires-Dist: arango-cve-processor
16
16
  Requires-Dist: jsonschema>=4.22.0; python_version >= '3.8'
17
+ Requires-Dist: pypdl
17
18
  Requires-Dist: python-arango>=7.9.1; python_version >= '3.8'
18
19
  Requires-Dist: requests>=2.32.4; python_version >= '3.7'
19
20
  Requires-Dist: stix2
@@ -6,8 +6,9 @@ import sqlite3
6
6
  import os
7
7
  import tempfile
8
8
  import logging
9
+ from pathlib import Path
9
10
 
10
- import requests
11
+ from pypdl import Pypdl
11
12
 
12
13
  from arango_cve_processor.tools.nvd import fetch_nvd_api
13
14
 
@@ -38,18 +39,24 @@ class SwidTitleDB:
38
39
  cls._class_db = SwidTitleDB()
39
40
  return cls._class_db
40
41
 
42
+
41
43
  def _download_zip(self):
42
- logging.info("downloading cpe dictionary")
43
- retry_count = 0
44
- while retry_count < 5:
45
- try:
46
- resp = requests.get(self.archive_url)
47
- resp.raise_for_status()
48
- return io.BytesIO(resp.content)
49
- except requests.RequestException as e:
50
- logging.warning(f"Failed to download cpe dictionary: {e}")
51
- retry_count += 1
52
- raise RuntimeError("Failed to download cpe dictionary after 5 attempts")
44
+ logging.info("Downloading CPE dictionary")
45
+
46
+ with tempfile.TemporaryDirectory() as tmpdir:
47
+ output = Path(tmpdir) / "cpe.zip"
48
+
49
+ dl = Pypdl()
50
+ result = dl.start(
51
+ url=self.archive_url,
52
+ file_path=str(output),
53
+ retries=5,
54
+ block=True,
55
+ )
56
+ if not result or not output.exists():
57
+ raise RuntimeError("Failed to download CPE dictionary after 5 attempts")
58
+
59
+ return io.BytesIO(output.read_bytes())
53
60
 
54
61
  def _create_db(self):
55
62
  self.cur = self.conn.cursor()
@@ -9,13 +9,13 @@ RATE_LIMIT_WINDOW = 30
9
9
  RATE_LIMIT_MAX_SLEEP = 10*60 #10 minutes
10
10
 
11
11
 
12
- def fetch_nvd_api(url, query: dict):
12
+ def fetch_nvd_api(url, query: dict, api_key=None):
13
13
  total_results = math.inf
14
14
  start_index = 0
15
15
  query.update(startIndex=0)
16
+ api_key = api_key or os.environ.get("NVD_API_KEY")
16
17
 
17
18
  session = requests.Session()
18
- api_key = os.environ.get("NVD_API_KEY")
19
19
  requests_per_window = 5
20
20
  if api_key:
21
21
  session.headers = {"apiKey": api_key}
@@ -38,7 +38,7 @@ def fetch_nvd_api(url, query: dict):
38
38
  logging.warning("Got response status code %d.", response.status_code)
39
39
  raise requests.ConnectionError
40
40
 
41
- except requests.ConnectionError as ex:
41
+ except requests.RequestException as ex:
42
42
  logging.warning(
43
43
  "Got ConnectionError. Backing off for %d seconds.", backoff_time
44
44
  )
@@ -2,6 +2,8 @@ import logging
2
2
  from urllib.parse import urljoin
3
3
  import os
4
4
  import requests
5
+ from requests.adapters import HTTPAdapter
6
+ from urllib3.util import Retry
5
7
 
6
8
 
7
9
  class STIXObjectRetriever:
@@ -44,6 +46,14 @@ class STIXObjectRetriever:
44
46
  "API-KEY": self.api_key,
45
47
  }
46
48
  )
49
+ retries = Retry(
50
+ total=3,
51
+ backoff_factor=1,
52
+ status_forcelist=[500],
53
+ allowed_methods=["GET"],
54
+ )
55
+ s.mount("https://", HTTPAdapter(max_retries=retries))
56
+ s.mount("http://", HTTPAdapter(max_retries=retries))
47
57
  data = []
48
58
  page = 1
49
59
  logging.info("fetching from: %s", endpoint)
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "arango_cve_processor"
7
- version = "1.4.11"
7
+ version = "1.4.14"
8
8
  authors = [
9
9
  { name = "dogesec" }
10
10
  ]
@@ -28,6 +28,7 @@ dependencies = [
28
28
  "arango-cve-processor",
29
29
  "stix2arango",
30
30
  "stix2extensions>=2.0.1",
31
+ "pypdl",
31
32
  ]
32
33
 
33
34
  [project.urls]
@@ -0,0 +1,130 @@
1
+ #
2
+ # This file is autogenerated by pip-compile with Python 3.13
3
+ # by the following command:
4
+ #
5
+ # pip-compile --output-file=requirements.txt pyproject.toml
6
+ #
7
+ aiofiles==25.1.0
8
+ # via pypdl
9
+ aiohappyeyeballs==2.6.2
10
+ # via aiohttp
11
+ aiohttp==3.14.1
12
+ # via pypdl
13
+ aiosignal==1.4.0
14
+ # via aiohttp
15
+ annotated-types==0.7.0
16
+ # via pydantic
17
+ antlr4-python3-runtime==4.9.3
18
+ # via stix2-patterns
19
+ arango-cve-processor==1.4.11
20
+ # via arango_cve_processor (pyproject.toml)
21
+ attrs==23.2.0
22
+ # via
23
+ # aiohttp
24
+ # jsonschema
25
+ # referencing
26
+ certifi==2024.7.4
27
+ # via requests
28
+ charset-normalizer==3.3.2
29
+ # via requests
30
+ frozenlist==1.8.0
31
+ # via
32
+ # aiohttp
33
+ # aiosignal
34
+ idna==3.15
35
+ # via
36
+ # requests
37
+ # yarl
38
+ ijson==3.5.0
39
+ # via stix2arango
40
+ jsonschema==4.22.0 ; python_version >= "3.8"
41
+ # via
42
+ # arango-cve-processor
43
+ # arango_cve_processor (pyproject.toml)
44
+ # stix2arango
45
+ jsonschema-specifications==2023.12.1
46
+ # via jsonschema
47
+ multidict==6.7.1
48
+ # via
49
+ # aiohttp
50
+ # yarl
51
+ packaging==24.0
52
+ # via python-arango
53
+ propcache==0.5.2
54
+ # via
55
+ # aiohttp
56
+ # yarl
57
+ pydantic==2.13.4
58
+ # via stix2extensions
59
+ pydantic-core==2.46.4
60
+ # via pydantic
61
+ pyjwt==2.13.0
62
+ # via python-arango
63
+ pypdl==1.5.7
64
+ # via arango_cve_processor (pyproject.toml)
65
+ python-arango==8.3.3 ; python_version >= "3.8"
66
+ # via
67
+ # arango-cve-processor
68
+ # arango_cve_processor (pyproject.toml)
69
+ # stix2arango
70
+ python-dotenv==1.2.2
71
+ # via stix2arango
72
+ pytz==2024.1
73
+ # via stix2
74
+ referencing==0.35.1
75
+ # via
76
+ # jsonschema
77
+ # jsonschema-specifications
78
+ requests==2.33.0 ; python_version >= "3.7"
79
+ # via
80
+ # arango-cve-processor
81
+ # arango_cve_processor (pyproject.toml)
82
+ # python-arango
83
+ # requests-toolbelt
84
+ # stix2
85
+ # stix2arango
86
+ # stix2extensions
87
+ requests-toolbelt==1.0.0
88
+ # via python-arango
89
+ rpds-py==0.18.1
90
+ # via
91
+ # jsonschema
92
+ # referencing
93
+ simplejson==3.19.2
94
+ # via stix2
95
+ six==1.16.0
96
+ # via stix2-patterns
97
+ stix2==3.0.1
98
+ # via
99
+ # arango-cve-processor
100
+ # arango_cve_processor (pyproject.toml)
101
+ # stix2arango
102
+ # stix2extensions
103
+ stix2-patterns==2.0.0
104
+ # via stix2
105
+ stix2arango==1.1.2
106
+ # via
107
+ # arango-cve-processor
108
+ # arango_cve_processor (pyproject.toml)
109
+ stix2extensions==2.3.3
110
+ # via
111
+ # arango-cve-processor
112
+ # arango_cve_processor (pyproject.toml)
113
+ tqdm==4.66.4 ; python_version >= "3.7"
114
+ # via
115
+ # arango-cve-processor
116
+ # arango_cve_processor (pyproject.toml)
117
+ # stix2arango
118
+ typing-extensions==4.15.0
119
+ # via
120
+ # pydantic
121
+ # pydantic-core
122
+ # typing-inspection
123
+ typing-inspection==0.4.2
124
+ # via pydantic
125
+ urllib3==2.7.0
126
+ # via
127
+ # python-arango
128
+ # requests
129
+ yarl==1.24.2
130
+ # via aiohttp
@@ -1,6 +1,6 @@
1
-
2
1
  from unittest.mock import MagicMock, patch
3
2
 
3
+ import pytest
4
4
  import requests
5
5
 
6
6
  from arango_cve_processor.tools.nvd import RATE_LIMIT_WINDOW, fetch_nvd_api
@@ -36,7 +36,7 @@ def test_fetch_nvd_success():
36
36
  make_mock_response(start_index=1),
37
37
  ]
38
38
 
39
- results = list(fetch_nvd_api('', {}))
39
+ results = list(fetch_nvd_api("", {}))
40
40
 
41
41
  assert len(results) == 2 # 2 pages
42
42
  assert all(isinstance(group, dict) for group in results)
@@ -53,7 +53,7 @@ def test_fetch_nvd_with_backoff():
53
53
  make_mock_response(start_index=1),
54
54
  ]
55
55
 
56
- results = list(fetch_nvd_api('', {}))
56
+ results = list(fetch_nvd_api("", {}))
57
57
 
58
58
  assert len(results) == 2
59
59
  assert mock_sleep.call_count >= 2 # One for backoff, one for pagination
@@ -61,3 +61,36 @@ def test_fetch_nvd_with_backoff():
61
61
  # first_sleep_duration = RATE_LIMIT_WINDOW / 2
62
62
  # second_sleep_duration = RATE_LIMIT_WINDOW / cpematch_manager.requests_per_window
63
63
  assert mock_sleep.call_count == 2
64
+
65
+
66
+ @pytest.mark.parametrize(
67
+ "api_key,api_key_env,expected",
68
+ [
69
+ [None, None, None],
70
+ ["arg", None, "arg"],
71
+ ["arg", "env", "arg"],
72
+ [None, "env", "env"],
73
+ ],
74
+ )
75
+ def test_fetch_nvd_uses_api_key(api_key, api_key_env, expected, monkeypatch):
76
+ monkeypatch.delenv("NVD_API_KEY", raising=False)
77
+ if api_key_env:
78
+ monkeypatch.setenv("NVD_API_KEY", api_key_env)
79
+
80
+ patched_session = requests.Session()
81
+ monkeypatch.setattr(requests, "Session", MagicMock(return_value=patched_session))
82
+ monkeypatch.setattr(
83
+ patched_session,
84
+ "get",
85
+ MagicMock(
86
+ side_effect=[
87
+ make_mock_response(start_index=0),
88
+ make_mock_response(start_index=1),
89
+ ]
90
+ ),
91
+ )
92
+ with patch("time.sleep") as mock_sleep:
93
+
94
+ # Simulate a connection error first, then success
95
+ results = list(fetch_nvd_api("", {}, api_key=api_key))
96
+ assert patched_session.headers.get("apiKey") == expected
@@ -1,27 +0,0 @@
1
- -i https://pypi.org/simple
2
- antlr4-python3-runtime==4.9.3
3
- attrs==23.2.0; python_version >= '3.7'
4
- certifi==2024.7.4; python_version >= '3.6'
5
- charset-normalizer==3.3.2; python_full_version >= '3.7.0'
6
- idna==3.7; python_version >= '3.5'
7
- importlib-metadata==7.1.0; python_version >= '3.8'
8
- jsonschema==4.22.0; python_version >= '3.8'
9
- jsonschema-specifications==2023.12.1; python_version >= '3.8'
10
- packaging==24.0; python_version >= '3.7'
11
- pyjwt==2.12.0; python_version >= '3.7'
12
- python-arango>=7.9.1; python_version >= '3.8'
13
- python-dotenv==1.0.1; python_version >= '3.8'
14
- pytz==2024.1
15
- referencing==0.35.1; python_version >= '3.8'
16
- requests==2.32.4; python_version >= '3.7'
17
- requests-toolbelt==1.0.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
18
- rpds-py==0.18.1; python_version >= '3.8'
19
- setuptools==78.1.1; python_version >= '3.8'
20
- simplejson==3.19.2; python_version >= '2.5' and python_version not in '3.0, 3.1, 3.2, 3.3'
21
- six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
22
- stix2==3.0.1; python_version >= '3.6'
23
- stix2-patterns==2.0.0; python_version >= '3.6'
24
- tqdm==4.66.4; python_version >= '3.7'
25
- urllib3==2.6.3; python_version >= '3.8'
26
- zipp==3.19.1; python_version >= '3.8'
27
- stix2arango==1.1.2