Skip to content

Commit 2d879d2

Browse files
committed
Add example to _filter_json_for_vulnerabilities
1 parent 1254a73 commit 2d879d2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

exasol/toolbox/nox/_dependencies.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,21 @@ def name_tuple(cls) -> tuple:
237237
class Audit:
238238
@staticmethod
239239
def _filter_json_for_vulnerabilities(audit_json_bytes: bytes) -> dict:
240-
"""filters json for only packages with vulnerabilities"""
240+
"""Filters json for only packages with vulnerabilities
241+
242+
Examples:
243+
>>> audit_json_dict = {"dependencies": [
244+
... {"name": "alabaster", "version": "0.7.16", "vulns": []},
245+
... {"name": "cryptography", "version": "43.0.3", "vulns":
246+
... [{"id": "GHSA-79v4-65xg-pq4g", "fix_versions": ["44.0.1"],
247+
... "aliases": ["CVE-2024-12797"],
248+
... "description": "pyca/cryptography\'s wheels..."}]}]}
249+
>>> audit_json = json.dumps(audit_json_dict).encode()
250+
>>> Audit._filter_json_for_vulnerabilities(audit_json)
251+
{"dependencies": [{"name": "cryptography", "version": "43.0.3", "vulns":
252+
[{"id": "GHSA-79v4-65xg-pq4g", "fix_versions": ["44.0.1"], "aliases":
253+
["CVE-2024-12797"], "description": "pyca/cryptography\'s wheels..."}]}]}
254+
"""
241255
audit_dict = json.loads(audit_json_bytes.decode("utf-8"))
242256
return {
243257
"dependencies": [

0 commit comments

Comments
 (0)