bugcrowd-vrt 1.17.0

Rust client for Bugcrowd's Vulnerability Rating Taxonomy
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# bugcrowd-vrt

A comprehensive Rust library for working with the [Bugcrowd Vulnerability Rating Taxonomy (VRT)](https://bugcrowd.com/vulnerability-rating-taxonomy), including CWE mappings and CVSS v3 scoring.

[![Crates.io](https://img.shields.io/crates/v/bugcrowd-vrt.svg)](https://crates.io/crates/bugcrowd-vrt)
[![Documentation](https://docs.rs/bugcrowd-vrt/badge.svg)](https://docs.rs/bugcrowd-vrt)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Features

- **VRT Taxonomy** - Type-safe deserialization of Bugcrowd's vulnerability taxonomy
- **CWE Mapping** - Map VRT categories to Common Weakness Enumeration (CWE) identifiers
- **CVSS v3** - Get CVSS v3 vectors and scores for vulnerabilities
- **Smart Categorization** - Automatically categorize vulnerability findings
- **Zero Dependencies** (core) - Minimal footprint with optional features
- **Well Tested** - 50+ tests covering edge cases and integrations

## Quick Start

Add to your `Cargo.toml`:

```toml
[dependencies]
bugcrowd-vrt = "1.17"
```

### Basic Usage

```rust
use bugcrowd_vrt::{load_vrt_from_file, VulnerabilityCategorizer};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load the VRT taxonomy
    let vrt = load_vrt_from_file("vrt.json")?;

    println!("Loaded {} vulnerability categories", vrt.len());

    // Find a specific vulnerability
    if let Some(node) = vrt[0].find_by_id("sql_injection") {
        println!("Found: {} (Priority: P{})",
            node.name,
            node.priority.unwrap_or(5)
        );
    }

    Ok(())
}
```

### Scanner Integration

Perfect for vulnerability scanners - automatically categorize findings:

```rust
use bugcrowd_vrt::{
    VulnerabilityCategorizer,
    load_vrt_from_file,
    load_cwe_mapping_from_file,
    load_cvss_v3_mapping_from_file,
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load all mappings
    let vrt = load_vrt_from_file("vrt.json")?;
    let cwe = load_cwe_mapping_from_file("cwe.mappings.json")?;
    let cvss = load_cvss_v3_mapping_from_file("cvss_v3.json")?;

    let categorizer = VulnerabilityCategorizer::with_all_mappings(
        vrt, cwe, cvss
    );

    // Automatically categorize a finding
    let finding = categorizer
        .categorize_by_description("SQL injection in login form")
        .expect("Should categorize");

    println!("VRT: {}", finding.vrt_name);
    println!("Priority: P{}", finding.priority.unwrap_or(5));
    println!("CWEs: {:?}", finding.cwes);
    println!("CVSS: {:?}", finding.cvss_vector);

    Ok(())
}
```

**Output:**
```
VRT: SQL Injection
Priority: P1
CWEs: ["CWE-89"]
CVSS: Some("AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N")
```

## Use Cases

### 1. Vulnerability Scanners

Categorize security findings with industry-standard taxonomies:

```rust
// Your scanner finds a vulnerability
let scanner_output = "Reflected XSS in search parameter";

// Automatically categorize it
if let Some(finding) = categorizer.categorize_by_description(scanner_output) {
    report_vulnerability(
        finding.vrt_name,
        finding.priority.unwrap_or(5),
        finding.cwes,
        finding.cvss_vector,
    );
}
```

### 2. Security Reporting

Generate standardized vulnerability reports:

```rust
// Export to JSON
let report = serde_json::json!({
    "vulnerability": finding.vrt_name,
    "vrt_id": finding.vrt_id,
    "priority": finding.priority,
    "category_path": finding.category_path,
    "cwe": finding.cwes,
    "cvss_v3": finding.cvss_vector,
});
```

### 3. Bug Bounty Platforms

Validate and categorize bug bounty submissions:

```rust
// Search for matching categories
let matches = categorizer.search_by_name("injection");
println!("Found {} injection-related categories", matches.len());

// Get details for each
for vrt_id in matches {
    if let Some(cat) = categorizer.categorize_by_id(&vrt_id) {
        println!("  - {} (P{})", cat.vrt_name, cat.priority.unwrap_or(5));
    }
}
```

## API Overview

### VRT Taxonomy

```rust
use bugcrowd_vrt::{load_vrt_from_file, VrtNode};

let taxonomy = load_vrt_from_file("vrt.json")?;

// Navigate the hierarchy
for category in &taxonomy {
    println!("Category: {}", category.name);

    for subcategory in &category.children {
        println!("  Subcategory: {}", subcategory.name);

        // Get all variants (leaf nodes)
        let variants = subcategory.variants();
        println!("    {} variants", variants.len());
    }
}

// Find by ID
if let Some(node) = taxonomy[0].find_by_id("sql_injection") {
    println!("Priority: P{}", node.priority.unwrap_or(5));
}
```

### CWE Mapping

```rust
use bugcrowd_vrt::load_cwe_mapping_from_file;

let cwe_mapping = load_cwe_mapping_from_file("cwe.mappings.json")?;

// Lookup CWE IDs for a VRT entry
if let Some(cwes) = cwe_mapping.lookup_cwe("sql_injection") {
    for cwe in cwes {
        println!("CWE: {}", cwe); // "CWE-89"
    }
}

// Get statistics
let stats = cwe_mapping.statistics();
println!("Coverage: {}/{} nodes mapped",
    stats.nodes_with_mappings,
    stats.total_nodes
);
```

### CVSS v3 Vectors

```rust
use bugcrowd_vrt::{load_cvss_v3_mapping_from_file, CvssV3Vector};
use std::str::FromStr;

let cvss_mapping = load_cvss_v3_mapping_from_file("cvss_v3.json")?;

// Get CVSS vector for a vulnerability
if let Some(vector) = cvss_mapping.lookup_cvss("sql_injection") {
    println!("CVSS: {}", vector);
    println!("Attack Vector: {:?}", vector.attack_vector);
    println!("Confidentiality: {:?}", vector.confidentiality);

    if vector.is_critical() {
        println!("⚠️  CRITICAL severity!");
    }
}

// Parse CVSS vectors
let vector = CvssV3Vector::from_str(
    "AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
)?;
assert!(vector.is_critical());
```

### Vulnerability Categorization

```rust
use bugcrowd_vrt::VulnerabilityCategorizer;

let categorizer = VulnerabilityCategorizer::with_all_mappings(vrt, cwe, cvss);

// Method 1: Automatic categorization by description
let finding = categorizer.categorize_by_description(
    "Server-Side Request Forgery in API endpoint"
)?;

// Method 2: Direct lookup by VRT ID
let finding = categorizer.categorize_by_id("ssrf")?;

// Method 3: Search and select
let matches = categorizer.search_by_name("request forgery");
let finding = categorizer.categorize_by_id(&matches[0])?;

// Access all data
println!("VRT ID: {}", finding.vrt_id);
println!("Name: {}", finding.vrt_name);
println!("Path: {}", finding.category_path.join(" > "));
println!("Priority: P{}", finding.priority.unwrap_or(5));
println!("CWEs: {}", finding.cwes.join(", "));
println!("CVSS: {}", finding.cvss_vector.unwrap_or_default());
```

## Examples

Run the included examples:

```bash
# Load and explore VRT taxonomy
cargo run --example load_vrt

# Explore CWE mappings
cargo run --example cwe_mapping

# Explore CVSS v3 mappings
cargo run --example cvss_v3_mapping

# Complete scanner integration example
cargo run --example scanner_integration
```

## Data Files

You'll need the VRT data files (included in the repo):

- `vrt.json` - Bugcrowd VRT taxonomy (287 vulnerability variants)
- `cwe.mappings.json` - VRT to CWE mappings (117 unique CWEs)
- `cvss_v3.json` - VRT to CVSS v3 mappings (252 entries)

Download the latest from [Bugcrowd's VRT repository](https://github.com/bugcrowd/vulnerability-rating-taxonomy).

## Documentation

- **[Scanner Integration Guide]SCANNER_INTEGRATION.md** - Complete guide for vulnerability scanner integration
- **[API Documentation]https://docs.rs/bugcrowd-vrt** - Full API reference
- **[Examples Directory]examples/** - Working code examples

## Type Safety

All types are fully documented and use Rust's type system for safety:

```rust
pub struct VrtNode {
    pub id: String,
    pub name: String,
    pub node_type: VrtNodeType,  // Category | Subcategory | Variant
    pub children: Vec<VrtNode>,
    pub priority: Option<u8>,     // 1-5 for variants
}

pub struct CategorizedFinding {
    pub vrt_id: String,
    pub vrt_name: String,
    pub priority: Option<u8>,
    pub category_path: Vec<String>,
    pub cwes: Vec<String>,
    pub cvss_vector: Option<String>,
}

pub struct CvssV3Vector {
    pub attack_vector: AttackVector,
    pub attack_complexity: AttackComplexity,
    pub privileges_required: PrivilegesRequired,
    pub user_interaction: UserInteraction,
    pub scope: Scope,
    pub confidentiality: Impact,
    pub integrity: Impact,
    pub availability: Impact,
}
```

## Performance

- **Loading VRT data**: ~50ms (one-time at startup)
- **Categorization by ID**: O(1) - instant lookup
- **Categorization by description**: ~1ms (keyword matching)
- **Search operations**: ~5ms (full taxonomy scan)

Suitable for high-throughput scanners processing thousands of findings.

## Testing

Comprehensive test coverage with 50+ tests:

```bash
# Run all tests
cargo test

# Run specific test suites
cargo test vrt_tests
cargo test cwe_mapping_tests
cargo test cvss_v3_tests
cargo test edge_cases_tests
cargo test categorization

# Run with output
cargo test -- --nocapture
```

Test categories:
- ✅ VRT taxonomy parsing and navigation
- ✅ CWE mapping and lookups
- ✅ CVSS v3 parsing and validation
- ✅ Edge cases (empty data, invalid formats, deep nesting)
- ✅ Categorization accuracy
- ✅ Integration examples

## Project Structure

```
bugcrowd-vrt/
├── src/
│   ├── lib.rs              # Main library exports
│   ├── types.rs            # VRT taxonomy types
│   ├── cwe_mapping.rs      # CWE mapping types
│   ├── cvss_v3.rs          # CVSS v3 types and parsing
│   └── categorization.rs   # Vulnerability categorization
├── tests/
│   ├── vrt_tests.rs
│   ├── types_tests.rs
│   ├── cwe_mapping_tests.rs
│   ├── cvss_v3_tests.rs
│   └── edge_cases_tests.rs
├── examples/
│   ├── load_vrt.rs
│   ├── cwe_mapping.rs
│   ├── cvss_v3_mapping.rs
│   └── scanner_integration.rs
├── vrt.json                # VRT taxonomy data
├── cwe.mappings.json       # CWE mappings
├── cvss_v3.json            # CVSS v3 mappings
└── SCANNER_INTEGRATION.md  # Integration guide
```

## Contributing

Contributions welcome! Please:

1. Add tests for new features
2. Update documentation
3. Follow existing code style
4. Run `cargo fmt` and `cargo clippy`

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Acknowledgments

- [Bugcrowd]https://bugcrowd.com for the VRT taxonomy
- [MITRE]https://cwe.mitre.org for CWE
- [FIRST]https://www.first.org/cvss/ for CVSS

## Related Projects

- [Bugcrowd VRT]https://github.com/bugcrowd/vulnerability-rating-taxonomy - Official VRT repository
- [CVSS Calculator]https://www.first.org/cvss/calculator/3.1 - Official CVSS v3.1 calculator

## Support

- 📖 [Documentation]https://docs.rs/bugcrowd-vrt
- 💬 [Issues]https://github.com/akses0/bugcrowd-vrt/issues
- 📧 Contact: [trapdoorsec.com]https://trapdoorsec.com

---

Made with ❤️ for the security community