cbomly 0.2.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.
- cbomly/__init__.py +3 -0
- cbomly/__main__.py +5 -0
- cbomly/algorithms.py +218 -0
- cbomly/cbom.py +216 -0
- cbomly/cbom_names.py +35 -0
- cbomly/cli.py +191 -0
- cbomly/detect/__init__.py +1 -0
- cbomly/detect/deps.py +81 -0
- cbomly/detect/keys.py +319 -0
- cbomly/detect/services.py +69 -0
- cbomly/detect/source.py +358 -0
- cbomly/findings.py +29 -0
- cbomly/inventory.py +150 -0
- cbomly/packs/au.toml +45 -0
- cbomly/packs/baseline.toml +110 -0
- cbomly/packs/ca.toml +61 -0
- cbomly/packs/eu.toml +117 -0
- cbomly/packs/india.toml +102 -0
- cbomly/packs/jp.toml +44 -0
- cbomly/packs/pci-dss.toml +55 -0
- cbomly/packs/sg.toml +45 -0
- cbomly/packs/uk.toml +47 -0
- cbomly/packs/us-cnsa2.toml +97 -0
- cbomly/packs/us-fda.toml +63 -0
- cbomly/packs/us.toml +145 -0
- cbomly/report.py +188 -0
- cbomly/rules.py +235 -0
- cbomly/sbom.py +54 -0
- cbomly/scanner.py +77 -0
- cbomly/upload.py +96 -0
- cbomly-0.2.0.dist-info/METADATA +202 -0
- cbomly-0.2.0.dist-info/RECORD +37 -0
- cbomly-0.2.0.dist-info/WHEEL +5 -0
- cbomly-0.2.0.dist-info/entry_points.txt +2 -0
- cbomly-0.2.0.dist-info/licenses/LICENSE +202 -0
- cbomly-0.2.0.dist-info/licenses/NOTICE +4 -0
- cbomly-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# US national security systems rule pack: NSA CNSA 2.0 and CNSSP 15.
|
|
2
|
+
#
|
|
3
|
+
# REVIEW STATUS: draft (checked 2026-11-29). The per-category years and the 2027 acquisition gate
|
|
4
|
+
# come from secondary summaries of the NSA advisory and CNSSP 15. Check them against the NSA
|
|
5
|
+
# documents before a paid report quotes them.
|
|
6
|
+
|
|
7
|
+
[pack]
|
|
8
|
+
id = "us-cnsa2"
|
|
9
|
+
name = "US national security systems: NSA CNSA 2.0"
|
|
10
|
+
version = "2026.11-draft"
|
|
11
|
+
jurisdiction = "US"
|
|
12
|
+
extends = ["us"]
|
|
13
|
+
review_status = "draft"
|
|
14
|
+
summary = "For vendors whose products go into US national security systems (defence, intelligence, their contractors)."
|
|
15
|
+
|
|
16
|
+
[references.cnsa2]
|
|
17
|
+
title = "Commercial National Security Algorithm Suite 2.0 (CNSA 2.0) advisory and FAQ"
|
|
18
|
+
issuer = "NSA"
|
|
19
|
+
date = "2022-09-07"
|
|
20
|
+
url = "https://www.nsa.gov/Cybersecurity/Post-Quantum-Cybersecurity-Resources/"
|
|
21
|
+
status = "mandatory for national security systems. Algorithms: ML-KEM-1024, ML-DSA-87, LMS or XMSS (firmware signing), AES-256, SHA-384 or SHA-512. Exclusive use: software and firmware signing and networking equipment by 2030; browsers, servers, cloud, operating systems and niche equipment by 2033; custom and legacy updated or replaced by 2033."
|
|
22
|
+
|
|
23
|
+
[references.cnssp-15]
|
|
24
|
+
title = "CNSSP 15: Use of Public Standards for Secure Information Sharing (2024 update)"
|
|
25
|
+
issuer = "Committee on National Security Systems"
|
|
26
|
+
date = "2024-12"
|
|
27
|
+
url = "https://www.cnss.gov/CNSS/issuances/Policies.cfm"
|
|
28
|
+
status = "mandatory for national security systems. UNVERIFIED (secondary source): new acquisitions must be CNSA 2.0 compliant from 2027-01-01; equipment that cannot support it phased out by 2030-12-31."
|
|
29
|
+
|
|
30
|
+
[[rules]]
|
|
31
|
+
id = "CNSA-001"
|
|
32
|
+
title = "Quantum-vulnerable signatures (CNSA 2.0 only, from 2030 for software and firmware signing)"
|
|
33
|
+
severity = "high"
|
|
34
|
+
match = { quantum = ["vulnerable"], primitive = ["signature"] }
|
|
35
|
+
message = "CNSA 2.0 asks for software and firmware signing to prefer CNSA 2.0 algorithms from 2025 and use them exclusively by 2030. New national security system acquisitions must be CNSA 2.0 compliant from 1 January 2027."
|
|
36
|
+
action = "Sign releases and firmware with LMS or XMSS (or ML-DSA-87 where stateful hashes do not fit)."
|
|
37
|
+
references = ["cnsa2", "cnssp-15"]
|
|
38
|
+
due = "2030 (software and firmware signing)"
|
|
39
|
+
|
|
40
|
+
[[rules]]
|
|
41
|
+
id = "CNSA-002"
|
|
42
|
+
title = "Quantum-vulnerable key exchange (CNSA 2.0 requires ML-KEM-1024)"
|
|
43
|
+
severity = "high"
|
|
44
|
+
match = { quantum = ["vulnerable"], primitive = ["key-agree", "pke"] }
|
|
45
|
+
message = "CNSA 2.0 key establishment is ML-KEM-1024. Networking equipment must use it exclusively by 2030; web browsers, servers, cloud services and operating systems by 2033."
|
|
46
|
+
action = "Move key exchange to ML-KEM-1024. Hybrid modes are a transition step only."
|
|
47
|
+
references = ["cnsa2"]
|
|
48
|
+
due = "2030 (networking), 2033 (browsers, servers, cloud, OS)"
|
|
49
|
+
|
|
50
|
+
[[rules]]
|
|
51
|
+
id = "CNSA-003"
|
|
52
|
+
title = "AES-128 is below the CNSA 2.0 requirement"
|
|
53
|
+
severity = "medium"
|
|
54
|
+
match = { algorithm = ["aes-128"] }
|
|
55
|
+
message = "CNSA 2.0 allows only AES-256 for symmetric encryption."
|
|
56
|
+
action = "Use AES-256."
|
|
57
|
+
references = ["cnsa2"]
|
|
58
|
+
due = "2030"
|
|
59
|
+
|
|
60
|
+
[[rules]]
|
|
61
|
+
id = "CNSA-004"
|
|
62
|
+
title = "SHA-256 is below the CNSA 2.0 requirement"
|
|
63
|
+
severity = "low"
|
|
64
|
+
match = { algorithm = ["sha256"] }
|
|
65
|
+
message = "CNSA 2.0 hashing is SHA-384 or SHA-512."
|
|
66
|
+
action = "Use SHA-384 or SHA-512 where the hash protects national security data."
|
|
67
|
+
references = ["cnsa2"]
|
|
68
|
+
due = "2030"
|
|
69
|
+
|
|
70
|
+
[[rules]]
|
|
71
|
+
id = "CNSA-005"
|
|
72
|
+
title = "SLH-DSA is not part of CNSA 2.0"
|
|
73
|
+
severity = "medium"
|
|
74
|
+
match = { algorithm = ["slh-dsa"] }
|
|
75
|
+
message = "SLH-DSA is a NIST standard but is not approved for national security systems under CNSA 2.0."
|
|
76
|
+
action = "Use ML-DSA-87, or LMS or XMSS for firmware signing."
|
|
77
|
+
references = ["cnsa2"]
|
|
78
|
+
|
|
79
|
+
[[rules]]
|
|
80
|
+
id = "CNSA-006"
|
|
81
|
+
title = "Post-quantum algorithm found: confirm the CNSA 2.0 parameter set"
|
|
82
|
+
severity = "info"
|
|
83
|
+
positive = true
|
|
84
|
+
match = { algorithm = ["ml-kem", "ml-dsa", "hybrid-kem"] }
|
|
85
|
+
message = "CNSA 2.0 requires the highest parameter sets: ML-KEM-1024 and ML-DSA-87. The scanner does not always see the parameter set."
|
|
86
|
+
action = "Check that these use ML-KEM-1024 and ML-DSA-87, not ML-KEM-768 or ML-DSA-65."
|
|
87
|
+
references = ["cnsa2"]
|
|
88
|
+
|
|
89
|
+
[[rules]]
|
|
90
|
+
id = "CNSA-007"
|
|
91
|
+
title = "Stateful hash-based signatures in use"
|
|
92
|
+
severity = "info"
|
|
93
|
+
positive = true
|
|
94
|
+
match = { algorithm = ["lms"] }
|
|
95
|
+
message = "LMS (and XMSS) are the CNSA 2.0 choice for software and firmware signing."
|
|
96
|
+
action = "Keep. Make sure signing state is managed so a one-time key is never reused."
|
|
97
|
+
references = ["cnsa2"]
|
cbomly/packs/us-fda.toml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# US medical devices rule pack: FD&C Act section 524B and FDA premarket cybersecurity guidance.
|
|
2
|
+
#
|
|
3
|
+
# REVIEW STATUS: draft (checked 2026-11-29). The statute and guidance dates are from the Federal
|
|
4
|
+
# Register. The SBOM field expectations below are our summary; check the guidance text.
|
|
5
|
+
|
|
6
|
+
[pack]
|
|
7
|
+
id = "us-fda"
|
|
8
|
+
name = "US medical devices: FD&C Act section 524B and FDA premarket cybersecurity guidance"
|
|
9
|
+
version = "2026.11-draft"
|
|
10
|
+
jurisdiction = "US"
|
|
11
|
+
extends = ["baseline"]
|
|
12
|
+
review_status = "draft"
|
|
13
|
+
summary = "For makers of software and connected medical devices (\"cyber devices\") sold in the US, and their software suppliers."
|
|
14
|
+
|
|
15
|
+
[references.fdca-524b]
|
|
16
|
+
title = "FD&C Act section 524B: Ensuring cybersecurity of devices (added by section 3305 of the Food and Drug Omnibus Reform Act of 2022)"
|
|
17
|
+
issuer = "US Congress"
|
|
18
|
+
date = "2022-12-29"
|
|
19
|
+
url = "https://www.govinfo.gov/content/pkg/FR-2025-06-27/html/2025-11669.htm"
|
|
20
|
+
status = "statute: premarket submissions for cyber devices must include an SBOM covering commercial, open-source and off-the-shelf components"
|
|
21
|
+
|
|
22
|
+
[references.fda-premarket-cyber]
|
|
23
|
+
title = "Cybersecurity in Medical Devices: Quality System Considerations and Content of Premarket Submissions"
|
|
24
|
+
issuer = "US FDA"
|
|
25
|
+
date = "2025-06-27"
|
|
26
|
+
url = "https://www.fda.gov/media/119933/download"
|
|
27
|
+
status = "final guidance (supersedes 2023-09-27 version); revised again in early 2026 to align with QMSR (secondary source)"
|
|
28
|
+
|
|
29
|
+
[[checks]]
|
|
30
|
+
id = "FDA-SBOM-001"
|
|
31
|
+
title = "Software bill of materials (SBOM) produced"
|
|
32
|
+
severity = "critical"
|
|
33
|
+
type = "sbom-present"
|
|
34
|
+
references = ["fdca-524b", "fda-premarket-cyber"]
|
|
35
|
+
message = "Section 524B requires an SBOM in every premarket submission for a cyber device. FDA can refuse to accept a submission without one."
|
|
36
|
+
|
|
37
|
+
[[checks]]
|
|
38
|
+
id = "FDA-SBOM-002"
|
|
39
|
+
title = "SBOM component data"
|
|
40
|
+
severity = "medium"
|
|
41
|
+
type = "sbom-fields"
|
|
42
|
+
fields = ["name", "version", "supplier", "unique-id"]
|
|
43
|
+
min_coverage = 0.9
|
|
44
|
+
references = ["fda-premarket-cyber"]
|
|
45
|
+
message = "FDA's guidance expects each component to be identifiable, and adds support level, end-of-support date and known vulnerabilities, which you fill in."
|
|
46
|
+
|
|
47
|
+
[[checks]]
|
|
48
|
+
id = "FDA-SBOM-003"
|
|
49
|
+
title = "Dependency relationships recorded"
|
|
50
|
+
severity = "low"
|
|
51
|
+
type = "dependencies-present"
|
|
52
|
+
references = ["fda-premarket-cyber"]
|
|
53
|
+
message = "FDA reviewers use the dependency tree to judge the impact of a vulnerable component."
|
|
54
|
+
|
|
55
|
+
[[rules]]
|
|
56
|
+
id = "FDA-PQC-001"
|
|
57
|
+
title = "Quantum-vulnerable crypto in a long-lived device"
|
|
58
|
+
severity = "medium"
|
|
59
|
+
match = { quantum = ["vulnerable"] }
|
|
60
|
+
message = "FDA does not yet set post-quantum dates, but devices often stay in service 10 to 20 years, beyond NIST's 2035 cut-off for RSA and elliptic curves. Reviewers ask how cryptography will be updated over the device's life."
|
|
61
|
+
action = "Describe in your cybersecurity management plan how the device's crypto can be updated in the field, and plan ML-KEM and ML-DSA support."
|
|
62
|
+
references = ["fda-premarket-cyber"]
|
|
63
|
+
due = "Before 2035 for devices still in service"
|
cbomly/packs/us.toml
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# United States rule pack: federal civilian buyers (NIST, OMB, CISA, executive orders).
|
|
2
|
+
# For national security systems use us-cnsa2; for medical devices use us-fda.
|
|
3
|
+
#
|
|
4
|
+
# REVIEW STATUS: draft (checked 2026-11-29). Dates come from the primary documents where we
|
|
5
|
+
# could read them; anything taken only from secondary summaries says so in its reference.
|
|
6
|
+
|
|
7
|
+
[pack]
|
|
8
|
+
id = "us"
|
|
9
|
+
name = "United States: NIST IR 8547, the post-quantum executive orders, OMB and CISA, and EO 14028 SBOM"
|
|
10
|
+
version = "2026.11-draft"
|
|
11
|
+
jurisdiction = "US"
|
|
12
|
+
extends = ["baseline"]
|
|
13
|
+
review_status = "draft"
|
|
14
|
+
summary = "For software vendors selling to US federal agencies and their contractors."
|
|
15
|
+
|
|
16
|
+
[references.nist-ir-8547]
|
|
17
|
+
title = "NIST IR 8547: Transition to Post-Quantum Cryptography Standards"
|
|
18
|
+
issuer = "NIST"
|
|
19
|
+
date = "2026-10"
|
|
20
|
+
url = "https://nvlpubs.nist.gov/nistpubs/ir/2026/NIST.IR.8547.pdf"
|
|
21
|
+
status = "final guidance. Quantum-vulnerable public-key algorithms (RSA, ECDSA, EdDSA, DH, ECDH) are deprecated after 2030 and disallowed after 2035. The per-algorithm table was not re-checked line by line."
|
|
22
|
+
|
|
23
|
+
[references.eo-14412]
|
|
24
|
+
title = "Executive Order 14412 on post-quantum cryptography, with OMB memo M-26-15"
|
|
25
|
+
issuer = "The White House; OMB"
|
|
26
|
+
date = "2026-06-22"
|
|
27
|
+
url = "https://nvlpubs.nist.gov/nistpubs/ir/2026/NIST.IR.8547.pdf"
|
|
28
|
+
status = "binding on federal agencies. NIST IR 8547 confirms: most sensitive systems use PQC key establishment by 2030-12-31 and PQC signatures by 2031-12-31. UNVERIFIED (secondary summary only): CISA and NIST to publish minimum CBOM elements within 270 days; FAR rules for contractors proposed by 2030."
|
|
29
|
+
|
|
30
|
+
[references.eo-14306]
|
|
31
|
+
title = "Executive Order 14306: Sustaining Select Efforts to Strengthen the Nation's Cybersecurity (amends EO 14144)"
|
|
32
|
+
issuer = "The White House"
|
|
33
|
+
date = "2025-06-06"
|
|
34
|
+
url = "https://www.govinfo.gov/content/pkg/FR-2025-06-11/html/2025-10804.htm"
|
|
35
|
+
status = "binding on federal agencies. CISA keeps a list of product categories with PQC support; agencies must support TLS 1.3 or later by 2030-01-02."
|
|
36
|
+
|
|
37
|
+
[references.cisa-pqc-categories]
|
|
38
|
+
title = "Product categories for technologies that use post-quantum cryptography standards"
|
|
39
|
+
issuer = "CISA"
|
|
40
|
+
date = "2026-01-23"
|
|
41
|
+
url = "https://www.cisa.gov/resources-tools/resources/product-categories-technologies-use-post-quantum-cryptography-standards"
|
|
42
|
+
status = "federal buying guidance: in listed categories, buy only PQC-capable products"
|
|
43
|
+
|
|
44
|
+
[references.omb-m-23-02]
|
|
45
|
+
title = "OMB M-23-02: Migrating to Post-Quantum Cryptography"
|
|
46
|
+
issuer = "OMB"
|
|
47
|
+
date = "2022-11-18"
|
|
48
|
+
url = "https://bidenwhitehouse.archives.gov/omb/briefing-room/"
|
|
49
|
+
status = "agencies submit a cryptographic inventory every year (first due 2023-05-04). Reported as superseded in practice by M-26-15 (secondary source)."
|
|
50
|
+
|
|
51
|
+
[references.nsm-10]
|
|
52
|
+
title = "National Security Memorandum 10 on promoting US leadership in quantum computing while mitigating risks to vulnerable cryptographic systems"
|
|
53
|
+
issuer = "The White House"
|
|
54
|
+
date = "2022-05-04"
|
|
55
|
+
url = "https://bidenwhitehouse.archives.gov/briefing-room/"
|
|
56
|
+
status = "policy goal: mitigate quantum risk as much as feasible by 2035"
|
|
57
|
+
|
|
58
|
+
[references.qccpa]
|
|
59
|
+
title = "Quantum Computing Cybersecurity Preparedness Act (Public Law 117-260)"
|
|
60
|
+
issuer = "US Congress"
|
|
61
|
+
date = "2022-12-21"
|
|
62
|
+
url = "https://www.congress.gov/bill/117th-congress/house-bill/7535"
|
|
63
|
+
status = "statute: agencies inventory and migrate quantum-vulnerable cryptography under OMB guidance"
|
|
64
|
+
|
|
65
|
+
[references.eo-14028]
|
|
66
|
+
title = "Executive Order 14028: Improving the Nation's Cybersecurity (section 4, software supply chain and SBOM)"
|
|
67
|
+
issuer = "The White House"
|
|
68
|
+
date = "2021-05-12"
|
|
69
|
+
url = "https://www.federalregister.gov/documents/2021/05/17/2021-10460/improving-the-nations-cybersecurity"
|
|
70
|
+
status = "in force; agencies may ask suppliers for an SBOM (OMB M-22-18)"
|
|
71
|
+
|
|
72
|
+
[references.ntia-sbom-minimum]
|
|
73
|
+
title = "The Minimum Elements for a Software Bill of Materials (SBOM)"
|
|
74
|
+
issuer = "NTIA, US Department of Commerce"
|
|
75
|
+
date = "2021-07-12"
|
|
76
|
+
url = "https://www.ntia.gov/report/2021/minimum-elements-software-bill-materials-sbom"
|
|
77
|
+
status = "baseline definition. CISA consulted on an updated 2025 list; its final status was not confirmed."
|
|
78
|
+
|
|
79
|
+
# --- Crypto (CBOM) ------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
[[rules]]
|
|
82
|
+
id = "US-PQC-001"
|
|
83
|
+
title = "Quantum-vulnerable crypto: deprecated after 2030, disallowed after 2035"
|
|
84
|
+
severity = "high"
|
|
85
|
+
match = { quantum = ["vulnerable"] }
|
|
86
|
+
message = "NIST IR 8547 deprecates RSA, elliptic-curve and Diffie-Hellman after 2030 and disallows them after 2035. CISA's product category list tells agencies to buy only PQC-capable products in listed categories, and agencies already inventory their crypto every year."
|
|
87
|
+
action = "Keep this CBOM with each release and give federal customers a dated plan to move each item to ML-KEM, ML-DSA or SLH-DSA."
|
|
88
|
+
references = ["nist-ir-8547", "cisa-pqc-categories", "omb-m-23-02", "qccpa", "nsm-10"]
|
|
89
|
+
due = "Deprecated after 2030, disallowed after 2035"
|
|
90
|
+
|
|
91
|
+
[[rules]]
|
|
92
|
+
id = "US-PQC-002"
|
|
93
|
+
title = "Quantum-vulnerable key exchange (federal deadline 2030-12-31)"
|
|
94
|
+
severity = "high"
|
|
95
|
+
match = { quantum = ["vulnerable"], primitive = ["key-agree", "pke"] }
|
|
96
|
+
message = "Under EO 14412 and OMB M-26-15, the government's most sensitive systems must use post-quantum key establishment by 31 December 2030. EO 14306 separately requires TLS 1.3 or later by 2 January 2030."
|
|
97
|
+
action = "Support hybrid X25519MLKEM768 or ML-KEM in TLS 1.3, and use ML-KEM for stored-data key wrapping."
|
|
98
|
+
references = ["eo-14412", "eo-14306", "nist-ir-8547"]
|
|
99
|
+
due = "2030-12-31"
|
|
100
|
+
|
|
101
|
+
[[rules]]
|
|
102
|
+
id = "US-PQC-003"
|
|
103
|
+
title = "Quantum-vulnerable signatures (federal deadline 2031-12-31)"
|
|
104
|
+
severity = "high"
|
|
105
|
+
match = { quantum = ["vulnerable"], primitive = ["signature"] }
|
|
106
|
+
message = "Under EO 14412 and OMB M-26-15, the government's most sensitive systems must use post-quantum digital signatures by 31 December 2031."
|
|
107
|
+
action = "Add ML-DSA (or a hybrid classical + ML-DSA signature) for code signing, releases and signed documents."
|
|
108
|
+
references = ["eo-14412", "nist-ir-8547"]
|
|
109
|
+
due = "2031-12-31"
|
|
110
|
+
|
|
111
|
+
[[checks]]
|
|
112
|
+
id = "US-CBOM-001"
|
|
113
|
+
title = "Cryptographic inventory (CBOM) produced"
|
|
114
|
+
severity = "medium"
|
|
115
|
+
type = "crypto-inventory"
|
|
116
|
+
references = ["omb-m-23-02", "qccpa", "eo-14412"]
|
|
117
|
+
message = "Agencies must inventory their cryptography and need the same from their suppliers."
|
|
118
|
+
|
|
119
|
+
# --- Software list (SBOM) ----------------------------------------------
|
|
120
|
+
|
|
121
|
+
[[checks]]
|
|
122
|
+
id = "US-SBOM-001"
|
|
123
|
+
title = "Software bill of materials (SBOM) produced"
|
|
124
|
+
severity = "high"
|
|
125
|
+
type = "sbom-present"
|
|
126
|
+
references = ["eo-14028", "ntia-sbom-minimum"]
|
|
127
|
+
message = "EO 14028 made SBOMs part of federal software buying. Agencies can ask suppliers for one."
|
|
128
|
+
|
|
129
|
+
[[checks]]
|
|
130
|
+
id = "US-SBOM-002"
|
|
131
|
+
title = "NTIA minimum data fields"
|
|
132
|
+
severity = "medium"
|
|
133
|
+
type = "sbom-fields"
|
|
134
|
+
fields = ["name", "version", "supplier", "unique-id"]
|
|
135
|
+
min_coverage = 0.8
|
|
136
|
+
references = ["ntia-sbom-minimum"]
|
|
137
|
+
message = "The NTIA minimum elements are supplier, component name, version, other unique identifiers, dependency relationship, SBOM author and timestamp. This checks the ones a scanner can fill in per component."
|
|
138
|
+
|
|
139
|
+
[[checks]]
|
|
140
|
+
id = "US-SBOM-003"
|
|
141
|
+
title = "Dependency relationships recorded"
|
|
142
|
+
severity = "low"
|
|
143
|
+
type = "dependencies-present"
|
|
144
|
+
references = ["ntia-sbom-minimum"]
|
|
145
|
+
message = "Dependency relationships are one of the NTIA minimum elements."
|
cbomly/report.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""Human-readable summaries: a Markdown report and a short terminal view."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections import Counter, OrderedDict
|
|
6
|
+
|
|
7
|
+
from . import __version__, algorithms, inventory
|
|
8
|
+
from .cbom import display_name
|
|
9
|
+
from .findings import Finding
|
|
10
|
+
from .rules import SEVERITIES, Evaluation
|
|
11
|
+
|
|
12
|
+
MAX_LOCATIONS = 10
|
|
13
|
+
SEV_ICON = {"critical": "🔴", "high": "🟠", "medium": "🟡", "low": "🔵", "info": "⚪"}
|
|
14
|
+
STATUS_ICON = {"pass": "✅", "warn": "⚠️", "fail": "❌"}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _group(findings: list[Finding]) -> OrderedDict[str, list[Finding]]:
|
|
18
|
+
g: OrderedDict[str, list[Finding]] = OrderedDict()
|
|
19
|
+
for f in sorted(findings, key=lambda f: (display_name(f), f.file, f.line or 0)):
|
|
20
|
+
g.setdefault(display_name(f), []).append(f)
|
|
21
|
+
return g
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def quantum_counts(findings: list[Finding]) -> Counter:
|
|
25
|
+
seen = {display_name(f): algorithms.get(f.algorithm).quantum for f in findings}
|
|
26
|
+
return Counter(seen.values())
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _loc(f: Finding) -> str:
|
|
30
|
+
return f"`{f.file}:{f.line}`" if f.line else f"`{f.file}`"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def markdown(target: str, findings: list[Finding], ev: Evaluation, crypto_libs: list[dict],
|
|
34
|
+
sbom_components: int | None, notes: list[str], services: list[dict] | None = None) -> str:
|
|
35
|
+
inv = inventory.build(findings)
|
|
36
|
+
cnt = inventory.counts(inv)
|
|
37
|
+
q = quantum_counts(findings)
|
|
38
|
+
worst = ev.worst_severity()
|
|
39
|
+
pack_names = ", ".join(p.name for p in ev.packs)
|
|
40
|
+
lines = [
|
|
41
|
+
f"# Cbomly scan: {target}",
|
|
42
|
+
"",
|
|
43
|
+
f"Generated by cbomly {__version__}. Rule packs: {pack_names}.",
|
|
44
|
+
"",
|
|
45
|
+
"## Summary",
|
|
46
|
+
"",
|
|
47
|
+
f"- **Quantum-vulnerable algorithms:** {q.get('vulnerable', 0)} distinct (RSA, elliptic curves, DSA, Diffie-Hellman)",
|
|
48
|
+
f"- **Weakened by quantum:** {q.get('reduced', 0)}",
|
|
49
|
+
f"- **Already quantum-safe:** {q.get('resistant', 0)}",
|
|
50
|
+
(f"- **Inventory:** {cnt['algorithms']} algorithms, {cnt['certificates']} certificates, {cnt['keys']} keys, "
|
|
51
|
+
f"{cnt['protocols']} protocols"),
|
|
52
|
+
f"- **Places crypto was found:** {len(findings)} in {len({f.file for f in findings})} files",
|
|
53
|
+
f"- **Software components (SBOM):** {sbom_components if sbom_components is not None else 'not generated'}",
|
|
54
|
+
f"- **Most serious issue:** {worst or 'none'}",
|
|
55
|
+
"",
|
|
56
|
+
]
|
|
57
|
+
for n in notes:
|
|
58
|
+
lines += [f"> {n}", ""]
|
|
59
|
+
|
|
60
|
+
vulnerable = [f for f in findings if algorithms.get(f.algorithm).quantum == "vulnerable"]
|
|
61
|
+
lines += ["## Quantum-vulnerable crypto and where it is used", ""]
|
|
62
|
+
if not vulnerable:
|
|
63
|
+
lines += ["None found.", ""]
|
|
64
|
+
else:
|
|
65
|
+
lines += ["| Algorithm | Used for | Places | Replace with |", "|---|---|---|---|"]
|
|
66
|
+
for name, group in _group(vulnerable).items():
|
|
67
|
+
a = algorithms.get(group[0].algorithm)
|
|
68
|
+
funcs = ", ".join(sorted({f.function for f in group if f.function})) or "unknown"
|
|
69
|
+
lines.append(f"| {name} | {funcs} | {len(group)} | {a.replacement} |")
|
|
70
|
+
lines.append("")
|
|
71
|
+
for name, group in _group(vulnerable).items():
|
|
72
|
+
lines += [f"### {name}", "", algorithms.get(group[0].algorithm).note, ""]
|
|
73
|
+
for f in group[:MAX_LOCATIONS]:
|
|
74
|
+
conf = "" if f.confidence == "high" else f" _({f.confidence} confidence)_"
|
|
75
|
+
lines.append(f"- {_loc(f)} {('`' + f.snippet[:100] + '`') if f.snippet else ''}{conf}")
|
|
76
|
+
if len(group) > MAX_LOCATIONS:
|
|
77
|
+
lines.append(f"- …and {len(group) - MAX_LOCATIONS} more (see cbom.cdx.json)")
|
|
78
|
+
lines.append("")
|
|
79
|
+
|
|
80
|
+
lines += ["## Rule results", ""]
|
|
81
|
+
for sev in SEVERITIES:
|
|
82
|
+
for r in ev.rules:
|
|
83
|
+
if r.rule.get("severity", "info") != sev or not r.triggered:
|
|
84
|
+
continue
|
|
85
|
+
rule = r.rule
|
|
86
|
+
names = ", ".join(_group(r.findings).keys())
|
|
87
|
+
tag = "✅" if rule.get("positive") else SEV_ICON[sev]
|
|
88
|
+
lines += [f"### {tag} {rule['id']}: {rule['title']}", "",
|
|
89
|
+
f"**Severity:** {sev}" + (f" · **Due:** {rule['due']}" if rule.get("due") else ""), "",
|
|
90
|
+
rule.get("message", ""), "", f"**Found:** {names}", "",
|
|
91
|
+
f"**What to do:** {rule.get('action', '')}", ""]
|
|
92
|
+
refs = [ev.references[x]["title"] for x in rule.get("references", []) if x in ev.references]
|
|
93
|
+
if refs:
|
|
94
|
+
lines += ["**Source:** " + "; ".join(refs), ""]
|
|
95
|
+
passed = [r for r in ev.rules if not r.triggered]
|
|
96
|
+
if passed:
|
|
97
|
+
lines += ["Rules with no findings: " + ", ".join(f"{r.rule['id']}" for r in passed), ""]
|
|
98
|
+
|
|
99
|
+
if ev.checks:
|
|
100
|
+
lines += ["## Document checks", "", "| Check | Result | Detail |", "|---|---|---|"]
|
|
101
|
+
for c in ev.checks:
|
|
102
|
+
lines.append(f"| {c.check['id']}: {c.check['title']} | {STATUS_ICON[c.status]} {c.status} | {c.detail} |")
|
|
103
|
+
lines.append("")
|
|
104
|
+
|
|
105
|
+
if crypto_libs:
|
|
106
|
+
lines += ["## Crypto libraries in your dependencies", "", "| Library | Version | Post-quantum capable? |",
|
|
107
|
+
"|---|---|---|"]
|
|
108
|
+
for lib in crypto_libs:
|
|
109
|
+
pq = {True: "yes", False: f"no, upgrade to {lib['pqc_from']}+", None: "unknown"}[lib["pqc_ready"]]
|
|
110
|
+
lines.append(f"| {lib['library']} ({lib['component']}) | {lib['version'] or '?'} | {pq} |")
|
|
111
|
+
lines.append("")
|
|
112
|
+
|
|
113
|
+
lines += ["## Crypto inventory", "", "### Algorithms and protocols", "",
|
|
114
|
+
"| Algorithm | Type | Status | Used for | Places |", "|---|---|---|---|---|"]
|
|
115
|
+
for e in inv["algorithms"] + inv["protocols"]:
|
|
116
|
+
lines.append(f"| {e['name']} | {e['primitive']} | {inventory.STATUS_LABEL[e['status']]} | "
|
|
117
|
+
f"{', '.join(e['functions']) or '-'} | {len(e['places'])} |")
|
|
118
|
+
lines.append("")
|
|
119
|
+
if inv["certificates"]:
|
|
120
|
+
lines += ["### Certificates", "", "| Subject | Issuer | Public key | Signature | Valid until | Status | File |",
|
|
121
|
+
"|---|---|---|---|---|---|---|"]
|
|
122
|
+
for c in inv["certificates"]:
|
|
123
|
+
until = (c["not_after"] or "?")[:10] + (" (expired)" if c["expired"] else "")
|
|
124
|
+
issuer = "self-signed" if c["self_signed"] else (c["issuer"] or "?")
|
|
125
|
+
lines.append(f"| {c['subject'] or '?'} | {issuer} | {c['public_key'] or '?'} | {c['signature'] or '?'} | "
|
|
126
|
+
f"{until} | {inventory.STATUS_LABEL[c['status']]} | `{c['file']}` |")
|
|
127
|
+
lines.append("")
|
|
128
|
+
if inv["keys"]:
|
|
129
|
+
lines += ["### Keys", "", "| Key | Size or curve | Status | File |", "|---|---|---|---|"]
|
|
130
|
+
for k in inv["keys"]:
|
|
131
|
+
size = str(k["size"]) if k["size"] else (k["curve"] or "-")
|
|
132
|
+
flag = " ⚠️ private key in code" if k["type"] == "private-key" else ""
|
|
133
|
+
loc = f"{k['file']}:{k['line']}" if k["line"] else k["file"]
|
|
134
|
+
lines.append(f"| {k['name']} | {size} | {inventory.STATUS_LABEL[k['status']]}{flag} | `{loc}` |")
|
|
135
|
+
lines.append("")
|
|
136
|
+
vend = inventory.vendors(inv, crypto_libs, services or [])
|
|
137
|
+
if vend:
|
|
138
|
+
lines += ["## Vendors", "", ("Who supplies or controls your crypto: library makers, certificate issuers, "
|
|
139
|
+
"and key management, HSM or secret-store services found in the code."), "",
|
|
140
|
+
"| Vendor | What | Kind | Where |", "|---|---|---|---|"]
|
|
141
|
+
for v in vend:
|
|
142
|
+
where = ", ".join(f"`{w}`" for w in v["where"][:3]) + (" …" if len(v["where"]) > 3 else "")
|
|
143
|
+
lines.append(f"| {v['vendor']} | {v['what']} | {inventory.KIND_LABEL.get(v['kind'], v['kind'])} | {where} |")
|
|
144
|
+
lines.append("")
|
|
145
|
+
|
|
146
|
+
if ev.references:
|
|
147
|
+
lines += ["## References", ""]
|
|
148
|
+
for ref in ev.references.values():
|
|
149
|
+
lines.append(f"- **{ref.get('title')}**, {ref.get('issuer', '')}, {ref.get('date', '')}. {ref.get('status', '')}")
|
|
150
|
+
lines.append("")
|
|
151
|
+
drafts = [p.name for p in ev.packs if p.review_status != "stable"]
|
|
152
|
+
if drafts:
|
|
153
|
+
lines += [f"_Rule pack(s) marked draft: {', '.join(drafts)}. Requirement summaries are informational, not legal advice._", ""]
|
|
154
|
+
lines += [("_This is an automated, pattern-based scan. It can miss crypto (for example inside compiled binaries) "
|
|
155
|
+
"and can report false positives; items marked low or medium confidence deserve a quick look._"), ""]
|
|
156
|
+
return "\n".join(lines)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def terminal(findings: list[Finding], ev: Evaluation, out_dir: str, color: bool = True) -> str:
|
|
160
|
+
def c(code, s):
|
|
161
|
+
return f"\033[{code}m{s}\033[0m" if color else s
|
|
162
|
+
|
|
163
|
+
q = quantum_counts(findings)
|
|
164
|
+
out = ["", c("1", "Cbomly scan complete"), ""]
|
|
165
|
+
out.append(f" {c('31;1', str(q.get('vulnerable', 0)))} quantum-vulnerable algorithm(s) "
|
|
166
|
+
f"{c('33;1', str(q.get('reduced', 0)))} weakened {c('32;1', str(q.get('resistant', 0)))} quantum-safe")
|
|
167
|
+
cnt = inventory.counts(inventory.build(findings))
|
|
168
|
+
out.append(f" Inventory: {cnt['algorithms']} algorithms, {cnt['certificates']} certificates, {cnt['keys']} keys, "
|
|
169
|
+
f"{cnt['protocols']} protocols")
|
|
170
|
+
out.append(f" {len(findings)} crypto use(s) in {len({f.file for f in findings})} file(s)")
|
|
171
|
+
out.append("")
|
|
172
|
+
vulnerable = [f for f in findings if algorithms.get(f.algorithm).quantum == "vulnerable"]
|
|
173
|
+
for name, group in list(_group(vulnerable).items())[:12]:
|
|
174
|
+
first = group[0]
|
|
175
|
+
more = f" (+{len(group) - 1} more)" if len(group) > 1 else ""
|
|
176
|
+
out.append(f" {c('31', '●')} {name:<28} {first.file}:{first.line or '-'}{more}")
|
|
177
|
+
if vulnerable:
|
|
178
|
+
out.append("")
|
|
179
|
+
for sev in SEVERITIES:
|
|
180
|
+
for r in ev.rules:
|
|
181
|
+
if r.triggered and r.rule.get("severity") == sev and not r.rule.get("positive"):
|
|
182
|
+
out.append(f" [{sev.upper():8}] {r.rule['id']}: {r.rule['title']}")
|
|
183
|
+
for ch in ev.checks:
|
|
184
|
+
if ch.status != "pass":
|
|
185
|
+
out.append(f" [{ch.status.upper():8}] {ch.check['id']}: {ch.check['title']} ({ch.detail})")
|
|
186
|
+
out += ["", f" Reports written to {out_dir}/", " cbom.cdx.json CycloneDX 1.6 CBOM (software + crypto)",
|
|
187
|
+
" summary.md readable report", " findings.json raw findings", ""]
|
|
188
|
+
return "\n".join(out)
|