dkatchr 0.3.0__tar.gz → 0.3.2__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 (66) hide show
  1. {dkatchr-0.3.0 → dkatchr-0.3.2}/PKG-INFO +13 -1
  2. {dkatchr-0.3.0 → dkatchr-0.3.2}/README.md +6 -0
  3. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/__init__.py +1 -1
  4. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/nvd.py +22 -14
  5. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr.egg-info/PKG-INFO +13 -1
  6. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr.egg-info/SOURCES.txt +2 -1
  7. {dkatchr-0.3.0 → dkatchr-0.3.2}/pyproject.toml +9 -1
  8. dkatchr-0.3.2/tests/test_nvd_client.py +66 -0
  9. {dkatchr-0.3.0 → dkatchr-0.3.2}/LICENSE +0 -0
  10. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/__main__.py +0 -0
  11. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/cli/__init__.py +0 -0
  12. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/cli/args.py +0 -0
  13. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/cli/dry_run.py +0 -0
  14. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/cli/main.py +0 -0
  15. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/cli/run.py +0 -0
  16. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/__init__.py +0 -0
  17. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/epss.py +0 -0
  18. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/exploitdb.py +0 -0
  19. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/github.py +0 -0
  20. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/kev.py +0 -0
  21. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/metasploit.py +0 -0
  22. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/osv.py +0 -0
  23. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/ratelimit.py +0 -0
  24. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/registry_meta.py +0 -0
  25. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/resolvers/__init__.py +0 -0
  26. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/resolvers/_base.py +0 -0
  27. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/resolvers/crates.py +0 -0
  28. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/resolvers/maven.py +0 -0
  29. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/resolvers/nuget.py +0 -0
  30. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/resolvers/packagist.py +0 -0
  31. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/resolvers/pypi.py +0 -0
  32. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/resolvers/rubygems.py +0 -0
  33. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/clients/top_packages.py +0 -0
  34. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/config.py +0 -0
  35. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/core/__init__.py +0 -0
  36. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/core/attribution.py +0 -0
  37. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/core/confusion.py +0 -0
  38. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/core/inventory.py +0 -0
  39. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/core/osv_enrichment.py +0 -0
  40. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/core/reachability.py +0 -0
  41. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/core/rules.py +0 -0
  42. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/core/scanner.py +0 -0
  43. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/core/typosquat.py +0 -0
  44. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/logger.py +0 -0
  45. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/output/__init__.py +0 -0
  46. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/output/csv_writer.py +0 -0
  47. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/output/schema.py +0 -0
  48. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/parsers/__init__.py +0 -0
  49. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/parsers/_common.py +0 -0
  50. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/parsers/cargo.py +0 -0
  51. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/parsers/composer.py +0 -0
  52. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/parsers/go.py +0 -0
  53. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/parsers/maven.py +0 -0
  54. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/parsers/npm.py +0 -0
  55. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/parsers/nuget.py +0 -0
  56. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/parsers/pypi.py +0 -0
  57. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/parsers/ruby.py +0 -0
  58. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/storage/__init__.py +0 -0
  59. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/storage/attribution_cache.py +0 -0
  60. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/storage/inventory_cache.py +0 -0
  61. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr/storage/reachability_cache.py +0 -0
  62. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr.egg-info/dependency_links.txt +0 -0
  63. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr.egg-info/entry_points.txt +0 -0
  64. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr.egg-info/requires.txt +0 -0
  65. {dkatchr-0.3.0 → dkatchr-0.3.2}/dkatchr.egg-info/top_level.txt +0 -0
  66. {dkatchr-0.3.0 → dkatchr-0.3.2}/setup.cfg +0 -0
@@ -1,7 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dkatchr
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Multi-ecosystem GitHub dependency scanner with OSV enrichment
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: Programming Language :: Python :: 3.10
7
+ Classifier: Programming Language :: Python :: 3.11
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Programming Language :: Python :: 3.13
10
+ Classifier: License :: OSI Approved :: MIT License
5
11
  Requires-Python: >=3.10
6
12
  Description-Content-Type: text/markdown
7
13
  License-File: LICENSE
@@ -22,6 +28,12 @@ Dynamic: license-file
22
28
  </picture>
23
29
  </p>
24
30
 
31
+ <p align="center">
32
+ <a href="https://pypi.org/project/dkatchr/"><img alt="PyPI" src="https://img.shields.io/pypi/v/dkatchr"></a>
33
+ <a href="https://pypi.org/project/dkatchr/"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/dkatchr"></a>
34
+ <a href="https://github.com/dkatchr/dkatchr-core/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/pypi/l/dkatchr"></a>
35
+ </p>
36
+
25
37
  # dKatchr
26
38
 
27
39
  Multi-ecosystem Software Composition Analysis (SCA) scanner for GitHub. Point it at one or more GitHub orgs (or a specific list of repos), and it discovers every dependency manifest across 8 package ecosystems, enriches findings against multiple vulnerability intelligence sources, and flags supply-chain risks that plain CVE scanning misses - dependency confusion, typosquatting, and unauthenticated internal-name exposure.
@@ -6,6 +6,12 @@
6
6
  </picture>
7
7
  </p>
8
8
 
9
+ <p align="center">
10
+ <a href="https://pypi.org/project/dkatchr/"><img alt="PyPI" src="https://img.shields.io/pypi/v/dkatchr"></a>
11
+ <a href="https://pypi.org/project/dkatchr/"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/dkatchr"></a>
12
+ <a href="https://github.com/dkatchr/dkatchr-core/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/pypi/l/dkatchr"></a>
13
+ </p>
14
+
9
15
  # dKatchr
10
16
 
11
17
  Multi-ecosystem Software Composition Analysis (SCA) scanner for GitHub. Point it at one or more GitHub orgs (or a specific list of repos), and it discovers every dependency manifest across 8 package ecosystems, enriches findings against multiple vulnerability intelligence sources, and flags supply-chain risks that plain CVE scanning misses - dependency confusion, typosquatting, and unauthenticated internal-name exposure.
@@ -1,3 +1,3 @@
1
1
  """dKatchr — multi-ecosystem GitHub dependency scanner with OSV enrichment."""
2
2
 
3
- __version__ = "0.3.0"
3
+ __version__ = "0.3.2"
@@ -4,8 +4,16 @@ NVDClient — HTTP wrapper + per-CVE file cache for the NVD 2.0 CVE API.
4
4
  Same role as osv.py (network client + cache), used by the credential-risk
5
5
  classification pass when OSV carries no usable CWE data: it fetches a single
6
6
  CVE record so we can read its CWE weaknesses. Vuln records are effectively
7
- immutable, so the cache is permanent per CVE — including a "not found"
8
- sentinel so we never re-query a CVE NVD doesn't know about.
7
+ immutable, so the cache is permanent per CVE. A CVE NVD doesn't know about
8
+ comes back as HTTP 200 with zero results, and that empty record is cached like
9
+ any other.
10
+
11
+ The API key goes in the `apiKey` request HEADER — NVD's documented mechanism.
12
+ Up to 0.3.1 it was sent as an `?apiKey=` query parameter, which NVD rejects
13
+ with HTTP 404; the client then cached a permanent "not found" sentinel, so with
14
+ a key configured EVERY lookup silently failed. A 404 is therefore never cached
15
+ now, and legacy {"not_found": true} sentinels are treated as cache misses and
16
+ re-fetched (they can only have come from that bug).
9
17
 
10
18
  This module does NOT decide credential risk or parse weaknesses — it only
11
19
  returns the raw NVD JSON (or None). Classification logic lives in
@@ -68,34 +76,34 @@ class NVDClient:
68
76
  def get_cve(self, cve_id: str, max_retries: int = 4) -> dict | None:
69
77
  """Return the raw NVD 2.0 record for `cve_id`, or None.
70
78
 
71
- Cache-first: a hit returns immediately with no HTTP call. A cached
72
- {"not_found": true} sentinel returns None without re-querying. On a
73
- live 404 we write that sentinel. Any other error logs and returns
74
- None — this never raises, so a flaky NVD never aborts a scan.
79
+ Cache-first: a hit returns immediately with no HTTP call. A legacy
80
+ {"not_found": true} sentinel (written by <=0.3.1 on a rejected-key
81
+ 404) is ignored and re-fetched. HTTP errors log and return None
82
+ without caching — this never raises, so a flaky NVD never aborts a
83
+ scan.
75
84
  """
76
85
  path = self._cve_path(cve_id)
77
86
  cached = self._read_cache(path)
78
- if cached is not None:
79
- if cached.get("not_found"):
80
- return None
87
+ if cached is not None and not cached.get("not_found"):
81
88
  return cached
82
89
 
83
90
  params = {"cveId": cve_id}
84
- if self.api_key:
85
- params["apiKey"] = self.api_key
91
+ headers = {"apiKey": self.api_key} if self.api_key else {}
86
92
 
87
93
  for attempt in range(max_retries):
88
94
  self.limiter.acquire()
89
95
  try:
90
- resp = requests.get(NVD_BASE_URL, params=params, timeout=30)
96
+ resp = requests.get(NVD_BASE_URL, params=params, headers=headers, timeout=30)
91
97
  except requests.RequestException as e:
92
98
  wait = 2 ** attempt
93
99
  log(f"[!] NVD GET {cve_id} network error: {e} — retrying in {wait}s")
94
100
  time.sleep(wait)
95
101
  continue
96
102
  if resp.status_code == 404:
97
- # CVE not in NVD — cache a sentinel so we never ask again.
98
- self._write_cache(path, {"not_found": True})
103
+ # NOT "CVE unknown" (that is a 200 with zero results) — NVD
104
+ # returns 404 for a rejected request, e.g. a bad API key.
105
+ # Never cached, so a later fix/retry can succeed.
106
+ log(f"[!] NVD GET {cve_id} 404 — request rejected (check NVD_API_KEY); not cached")
99
107
  return None
100
108
  if resp.status_code == 429:
101
109
  retry_after = resp.headers.get("Retry-After")
@@ -1,7 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dkatchr
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Multi-ecosystem GitHub dependency scanner with OSV enrichment
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: Programming Language :: Python :: 3.10
7
+ Classifier: Programming Language :: Python :: 3.11
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Programming Language :: Python :: 3.13
10
+ Classifier: License :: OSI Approved :: MIT License
5
11
  Requires-Python: >=3.10
6
12
  Description-Content-Type: text/markdown
7
13
  License-File: LICENSE
@@ -22,6 +28,12 @@ Dynamic: license-file
22
28
  </picture>
23
29
  </p>
24
30
 
31
+ <p align="center">
32
+ <a href="https://pypi.org/project/dkatchr/"><img alt="PyPI" src="https://img.shields.io/pypi/v/dkatchr"></a>
33
+ <a href="https://pypi.org/project/dkatchr/"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/dkatchr"></a>
34
+ <a href="https://github.com/dkatchr/dkatchr-core/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/pypi/l/dkatchr"></a>
35
+ </p>
36
+
25
37
  # dKatchr
26
38
 
27
39
  Multi-ecosystem Software Composition Analysis (SCA) scanner for GitHub. Point it at one or more GitHub orgs (or a specific list of repos), and it discovers every dependency manifest across 8 package ecosystems, enriches findings against multiple vulnerability intelligence sources, and flags supply-chain risks that plain CVE scanning misses - dependency confusion, typosquatting, and unauthenticated internal-name exposure.
@@ -60,4 +60,5 @@ dkatchr/parsers/ruby.py
60
60
  dkatchr/storage/__init__.py
61
61
  dkatchr/storage/attribution_cache.py
62
62
  dkatchr/storage/inventory_cache.py
63
- dkatchr/storage/reachability_cache.py
63
+ dkatchr/storage/reachability_cache.py
64
+ tests/test_nvd_client.py
@@ -4,10 +4,18 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dkatchr"
7
- version = "0.3.0"
7
+ version = "0.3.2"
8
8
  description = "Multi-ecosystem GitHub dependency scanner with OSV enrichment"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
+ classifiers = [
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3.10",
14
+ "Programming Language :: Python :: 3.11",
15
+ "Programming Language :: Python :: 3.12",
16
+ "Programming Language :: Python :: 3.13",
17
+ "License :: OSI Approved :: MIT License",
18
+ ]
11
19
  dependencies = [
12
20
  "requests>=2.28.0",
13
21
  "tqdm>=4.65.0",
@@ -0,0 +1,66 @@
1
+ """NVDClient: API key travels as the `apiKey` header, never a query param, and
2
+ a 404 (a rejected request — NVD answers unknown CVEs with 200 + zero results)
3
+ is never cached as a permanent "not found"."""
4
+
5
+ import json
6
+
7
+ from dkatchr.clients import nvd as nvd_mod
8
+ from dkatchr.clients.nvd import NVDClient
9
+
10
+
11
+ class _Resp:
12
+ def __init__(self, status, payload=None):
13
+ self.status_code = status
14
+ self._payload = payload or {}
15
+ self.text = json.dumps(self._payload)
16
+ self.headers = {}
17
+
18
+ def json(self):
19
+ return self._payload
20
+
21
+
22
+ def _client(tmp_path, monkeypatch, responses, calls, api_key="k-123"):
23
+ def fake_get(url, params=None, headers=None, timeout=None):
24
+ calls.append({"params": dict(params or {}), "headers": dict(headers or {})})
25
+ return responses.pop(0)
26
+ monkeypatch.setattr(nvd_mod.requests, "get", fake_get)
27
+ c = NVDClient(cache_dir=str(tmp_path), api_key=api_key)
28
+ c.limiter.acquire = lambda *a, **k: None
29
+ return c
30
+
31
+
32
+ def test_api_key_sent_as_header_not_query_param(tmp_path, monkeypatch):
33
+ calls = []
34
+ rec = {"totalResults": 1, "vulnerabilities": [{"cve": {"id": "CVE-2021-44228"}}]}
35
+ c = _client(tmp_path, monkeypatch, [_Resp(200, rec)], calls)
36
+ assert c.get_cve("CVE-2021-44228") == rec
37
+ assert calls[0]["headers"] == {"apiKey": "k-123"}
38
+ assert "apiKey" not in calls[0]["params"]
39
+
40
+
41
+ def test_no_key_sends_no_header(tmp_path, monkeypatch):
42
+ calls = []
43
+ c = _client(tmp_path, monkeypatch, [_Resp(200, {"totalResults": 0, "vulnerabilities": []})],
44
+ calls, api_key=None)
45
+ c.get_cve("CVE-2099-0001")
46
+ assert calls[0]["headers"] == {}
47
+
48
+
49
+ def test_404_is_not_cached(tmp_path, monkeypatch):
50
+ calls = []
51
+ rec = {"totalResults": 1, "vulnerabilities": [{"cve": {"id": "CVE-2020-1"}}]}
52
+ c = _client(tmp_path, monkeypatch, [_Resp(404), _Resp(200, rec)], calls)
53
+ assert c.get_cve("CVE-2020-1") is None
54
+ assert c.get_cve("CVE-2020-1") == rec # retried, not a cached "not found"
55
+ assert len(calls) == 2
56
+
57
+
58
+ def test_legacy_not_found_sentinel_is_refetched(tmp_path, monkeypatch):
59
+ calls = []
60
+ rec = {"totalResults": 1, "vulnerabilities": [{"cve": {"id": "CVE-2020-2"}}]}
61
+ c = _client(tmp_path, monkeypatch, [_Resp(200, rec)], calls)
62
+ with open(c._cve_path("CVE-2020-2"), "w") as fh:
63
+ json.dump({"not_found": True}, fh)
64
+ assert c.get_cve("CVE-2020-2") == rec
65
+ assert c.get_cve("CVE-2020-2") == rec # now a real cache hit
66
+ assert len(calls) == 1
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes