Skip to content

Commit 746599d

Browse files
cursoragentscript3r
andcommitted
feat: Add MV-CBOM generation and PQC analysis
This commit introduces the Minimal Viable Cryptographic Bill of Materials (MV-CBOM) generation feature. It includes new crates for parsing certificates, analyzing dependencies, detecting algorithms, and parsing Cargo.toml files. The CLI is updated to support the `--cbom` flag for generating MV-CBOM JSON output. This enables Post-Quantum Cryptography (PQC) readiness assessment by identifying vulnerable algorithms and their usage. New test cases are added to validate the MV-CBOM generation for various cryptographic scenarios. Co-authored-by: script3r <[email protected]>
1 parent f1cec94 commit 746599d

File tree

26 files changed

+3028
-9
lines changed

26 files changed

+3028
-9
lines changed

Cargo.lock

Lines changed: 452 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ members = [
1212
"crates/detector-objc",
1313
"crates/detector-kotlin",
1414
"crates/detector-erlang",
15+
"crates/cbom-generator",
1516
"crates/cli",
1617
]
1718
resolver = "2"
@@ -42,4 +43,9 @@ globset = "0.4"
4243
crossbeam-channel = "0.5"
4344
walkdir = "2"
4445
num_cpus = "1"
46+
uuid = { version = "1", features = ["v4", "serde"] }
47+
x509-parser = "0.15"
48+
der-parser = "9"
49+
chrono = { version = "0.4", features = ["serde"] }
50+
tempfile = "3"
4551

README.md

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@
66

77
Fast, low-false-positive static scanner that finds third-party cryptographic libraries and call sites across 11 programming languages: Go, Java, C, C++, Rust, Python, PHP, Swift, Objective-C, Kotlin, and Erlang.
88

9+
**NEW**: Now generates **Minimal Viable Cryptographic Bill of Materials (MV-CBOM)** for Post-Quantum Cryptography (PQC) readiness assessment.
10+
911
### Install & Run
1012

1113
```bash
1214
cargo build --release
1315
./target/release/cipherscope .
1416
```
1517

18+
Generate MV-CBOM (Cryptographic Bill of Materials):
19+
20+
```bash
21+
./target/release/cipherscope . --cbom
22+
```
23+
1624
JSONL and SARIF:
1725

1826
```bash
@@ -21,6 +29,7 @@ JSONL and SARIF:
2129
```
2230

2331
Key flags:
32+
- `--cbom`: generate MV-CBOM (Minimal Viable Cryptographic Bill of Materials)
2433
- `--threads N`: set thread pool size
2534
- `--max-file-size MB`: skip large files (default 2)
2635
- `--patterns PATH`: specify patterns file (default: `patterns.toml`)
@@ -32,7 +41,47 @@ Key flags:
3241

3342
### Output
3443

35-
Pretty table to stdout (default) and optional JSONL/SARIF.
44+
Pretty table to stdout (default), optional JSONL/SARIF, and **MV-CBOM** for PQC readiness assessment.
45+
46+
#### MV-CBOM (Minimal Viable Cryptographic Bill of Materials)
47+
48+
CipherScope can generate a comprehensive cryptographic inventory in JSON format that follows the MV-CBOM specification. This enables:
49+
50+
- **Post-Quantum Cryptography (PQC) Risk Assessment**: Identifies algorithms vulnerable to quantum attacks (NIST Quantum Security Level 0)
51+
- **Crypto-Agility Planning**: Provides detailed algorithm parameters and usage patterns
52+
- **Supply Chain Security**: Maps dependencies between components and cryptographic assets
53+
54+
The MV-CBOM includes:
55+
- **Cryptographic Assets**: Algorithms, certificates, and related crypto material with NIST security levels
56+
- **Dependency Relationships**: Distinguishes between "uses" (actively called) vs "implements" (available but unused)
57+
- **Parameter Extraction**: Key sizes, curves, and other algorithm-specific parameters
58+
59+
Example MV-CBOM snippet:
60+
```json
61+
{
62+
"bomFormat": "MV-CBOM",
63+
"specVersion": "1.0",
64+
"cryptoAssets": [
65+
{
66+
"bom-ref": "uuid-1234",
67+
"assetType": "algorithm",
68+
"name": "RSA",
69+
"assetProperties": {
70+
"primitive": "signature",
71+
"parameterSet": {"keySize": 2048},
72+
"nistQuantumSecurityLevel": 0
73+
}
74+
}
75+
],
76+
"dependencies": [
77+
{
78+
"ref": "main-component",
79+
"dependsOn": ["uuid-1234"],
80+
"dependencyType": "uses"
81+
}
82+
]
83+
}
84+
```
3685

3786
Example table:
3887

@@ -108,7 +157,9 @@ CipherScope uses a **producer-consumer model** inspired by ripgrep to achieve ma
108157
- Efficient memory usage through batched processing
109158
- Progress reporting accuracy: 100% (matches `find` command results)
110159

111-
### Detector Architecture
160+
### Architecture
161+
162+
#### Detector Architecture
112163

113164
The scanner uses a modular detector architecture with dedicated crates for each language:
114165

@@ -126,6 +177,23 @@ The scanner uses a modular detector architecture with dedicated crates for each
126177

127178
Each detector implements the `Detector` trait and can be extended independently. To add support for a new language, create a new detector crate under `crates/` or extend the `patterns.toml` to cover additional libraries. See `crates/scanner-core/src/lib.rs` for the trait definition and pattern-driven detector implementation.
128179

180+
#### MV-CBOM Architecture
181+
182+
The MV-CBOM generation is implemented in the `cbom-generator` crate with modular components:
183+
184+
- **cbom-generator**: Main CBOM generation and JSON serialization
185+
- **certificate-parser**: X.509 certificate parsing and signature algorithm extraction
186+
- **algorithm-detector**: Deep static analysis for algorithm parameter extraction
187+
- **dependency-analyzer**: Intelligent "uses" vs "implements" relationship detection
188+
- **cargo-parser**: Rust project metadata and dependency analysis
189+
190+
The MV-CBOM pipeline:
191+
1. **Static Analysis**: Scanner finds cryptographic usage patterns
192+
2. **Algorithm Detection**: Extracts specific algorithms and parameters from findings
193+
3. **Certificate Parsing**: Discovers and analyzes X.509 certificates in the project
194+
4. **Dependency Analysis**: Correlates Cargo.toml dependencies with actual code usage
195+
5. **CBOM Generation**: Produces standards-compliant JSON with NIST security levels
196+
129197
### Tests & Benchmarks
130198

131199
Run unit tests and integration tests (fixtures):
@@ -134,6 +202,22 @@ Run unit tests and integration tests (fixtures):
134202
cargo test
135203
```
136204

205+
#### MV-CBOM Test Cases
206+
207+
The `test-cases/` directory contains comprehensive test scenarios for MV-CBOM validation:
208+
209+
- **test-case-1-rsa-uses**: RSA 2048-bit usage (PQC vulnerable, "uses" relationship)
210+
- **test-case-2-implements-vs-uses**: SHA2 "uses" vs P256 "implements" distinction
211+
- **test-case-3-certificate**: X.509 certificate parsing with signature algorithm detection
212+
- **test-case-4-pqc-safe**: Quantum-safe algorithms (AES-256, ChaCha20Poly1305, SHA-3, BLAKE3)
213+
214+
Run tests:
215+
```bash
216+
cd test-cases/test-case-1-rsa-uses
217+
../../target/release/cipherscope . --cbom --patterns ../../patterns.toml
218+
cat mv-cbom.json | jq '.cryptoAssets[] | select(.assetProperties.nistQuantumSecurityLevel == 0)'
219+
```
220+
137221
Benchmark scan throughput on test fixtures:
138222

139223
```bash

crates/cbom-generator/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "cbom-generator"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "Apache-2.0"
6+
7+
[dependencies]
8+
scanner-core = { path = "../scanner-core" }
9+
anyhow = { workspace = true }
10+
serde = { workspace = true }
11+
serde_json = { workspace = true }
12+
toml = { workspace = true }
13+
uuid = { workspace = true }
14+
x509-parser = { workspace = true }
15+
der-parser = { workspace = true }
16+
chrono = { workspace = true }
17+
regex = { workspace = true }
18+
walkdir = { workspace = true }
19+
20+
[dev-dependencies]
21+
tempfile = { workspace = true }
22+
23+
[lib]
24+
name = "cbom_generator"
25+
path = "src/lib.rs"

0 commit comments

Comments
 (0)