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
pub use ;
pub use ;
pub use ;
pub use ;
use fs;
use io;
use Path;
/// Loads and deserializes a VRT taxonomy from a JSON file
///
/// # Arguments
/// * `path` - Path to the VRT JSON file
///
/// # Errors
/// Returns an error if the file cannot be read or the JSON is invalid
///
/// # Example
/// ```no_run
/// use bugcrowd_vrt::load_vrt_from_file;
///
/// let taxonomy = load_vrt_from_file("vrt.json").expect("Failed to load VRT");
/// println!("Loaded {} categories", taxonomy.len());
/// ```
/// Deserializes a VRT taxonomy from a JSON string
///
/// # Arguments
/// * `json` - JSON string containing the VRT data
///
/// # Errors
/// Returns an error if the JSON is invalid
///
/// # Example
/// ```
/// use bugcrowd_vrt::load_vrt_from_str;
///
/// let json = r#"[{"id": "test", "name": "Test", "type": "category", "children": []}]"#;
/// let taxonomy = load_vrt_from_str(json).expect("Failed to parse VRT");
/// assert_eq!(taxonomy.len(), 1);
/// ```
/// Deserializes a VRT taxonomy from a reader
///
/// # Arguments
/// * `reader` - Any type implementing `io::Read` containing JSON data
///
/// # Errors
/// Returns an error if reading fails or the JSON is invalid
/// Loads and deserializes a CWE mapping from a JSON file
///
/// # Arguments
/// * `path` - Path to the CWE mapping JSON file
///
/// # Errors
/// Returns an error if the file cannot be read or the JSON is invalid
///
/// # Example
/// ```no_run
/// use bugcrowd_vrt::load_cwe_mapping_from_file;
///
/// let mapping = load_cwe_mapping_from_file("cwe.mappings.json")
/// .expect("Failed to load CWE mapping");
/// println!("Loaded {} root nodes", mapping.content.len());
/// ```
/// Deserializes a CWE mapping from a JSON string
///
/// # Arguments
/// * `json` - JSON string containing the CWE mapping data
///
/// # Errors
/// Returns an error if the JSON is invalid
///
/// # Example
/// ```
/// use bugcrowd_vrt::load_cwe_mapping_from_str;
///
/// let json = r#"{
/// "metadata": {"default": null},
/// "content": [
/// {"id": "xss", "cwe": ["CWE-79"]}
/// ]
/// }"#;
/// let mapping = load_cwe_mapping_from_str(json).expect("Failed to parse");
/// assert_eq!(mapping.content.len(), 1);
/// ```
/// Deserializes a CWE mapping from a reader
///
/// # Arguments
/// * `reader` - Any type implementing `io::Read` containing JSON data
///
/// # Errors
/// Returns an error if reading fails or the JSON is invalid
/// Loads and deserializes a CVSS v3 mapping from a JSON file
///
/// # Arguments
/// * `path` - Path to the CVSS v3 mapping JSON file
///
/// # Errors
/// Returns an error if the file cannot be read or the JSON is invalid
///
/// # Example
/// ```no_run
/// use bugcrowd_vrt::load_cvss_v3_mapping_from_file;
///
/// let mapping = load_cvss_v3_mapping_from_file("cvss_v3.json")
/// .expect("Failed to load CVSS v3 mapping");
/// println!("Loaded {} root nodes", mapping.content.len());
/// ```
/// Deserializes a CVSS v3 mapping from a JSON string
///
/// # Arguments
/// * `json` - JSON string containing the CVSS v3 mapping data
///
/// # Errors
/// Returns an error if the JSON is invalid
///
/// # Example
/// ```
/// use bugcrowd_vrt::load_cvss_v3_mapping_from_str;
///
/// let json = r#"{
/// "metadata": {"default": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N"},
/// "content": [
/// {"id": "xss", "cvss_v3": "AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"}
/// ]
/// }"#;
/// let mapping = load_cvss_v3_mapping_from_str(json).expect("Failed to parse");
/// assert_eq!(mapping.content.len(), 1);
/// ```
/// Deserializes a CVSS v3 mapping from a reader
///
/// # Arguments
/// * `reader` - Any type implementing `io::Read` containing JSON data
///
/// # Errors
/// Returns an error if reading fails or the JSON is invalid