diff options
Diffstat (limited to 'grasp-audit/src/result.rs')
| -rw-r--r-- | grasp-audit/src/result.rs | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/grasp-audit/src/result.rs b/grasp-audit/src/result.rs index 0de16ae..f296633 100644 --- a/grasp-audit/src/result.rs +++ b/grasp-audit/src/result.rs | |||
| @@ -38,7 +38,9 @@ fn parse_spec_lines(spec_ref: &str) -> Vec<u32> { | |||
| 38 | if line_part.contains('-') { | 38 | if line_part.contains('-') { |
| 39 | let range_parts: Vec<&str> = line_part.split('-').collect(); | 39 | let range_parts: Vec<&str> = line_part.split('-').collect(); |
| 40 | if range_parts.len() == 2 { | 40 | if range_parts.len() == 2 { |
| 41 | if let (Ok(start), Ok(end)) = (range_parts[0].parse::<u32>(), range_parts[1].parse::<u32>()) { | 41 | if let (Ok(start), Ok(end)) = |
| 42 | (range_parts[0].parse::<u32>(), range_parts[1].parse::<u32>()) | ||
| 43 | { | ||
| 42 | return (start..=end).collect(); | 44 | return (start..=end).collect(); |
| 43 | } | 45 | } |
| 44 | } | 46 | } |
| @@ -162,10 +164,19 @@ impl AuditResult { | |||
| 162 | /// Print a detailed report aligned to GRASP-01 specification | 164 | /// Print a detailed report aligned to GRASP-01 specification |
| 163 | pub fn print_report(&self) { | 165 | pub fn print_report(&self) { |
| 164 | println!(); | 166 | println!(); |
| 165 | println!("{}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{}", BOLD, RESET); | 167 | println!( |
| 168 | "{}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{}", | ||
| 169 | BOLD, RESET | ||
| 170 | ); | ||
| 166 | println!("{}GRASP-01 Compliance Report{}", BOLD, RESET); | 171 | println!("{}GRASP-01 Compliance Report{}", BOLD, RESET); |
| 167 | println!("Source: github.com/nostr-protocol/grasp (commit: {})", GRASP_COMMIT_ID); | 172 | println!( |
| 168 | println!("{}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{}", BOLD, RESET); | 173 | "Source: github.com/nostr-protocol/grasp (commit: {})", |
| 174 | GRASP_COMMIT_ID | ||
| 175 | ); | ||
| 176 | println!( | ||
| 177 | "{}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{}", | ||
| 178 | BOLD, RESET | ||
| 179 | ); | ||
| 169 | 180 | ||
| 170 | // Build a map of spec line -> tests that cover it | 181 | // Build a map of spec line -> tests that cover it |
| 171 | let mut tests_by_line: BTreeMap<u32, Vec<&TestResult>> = BTreeMap::new(); | 182 | let mut tests_by_line: BTreeMap<u32, Vec<&TestResult>> = BTreeMap::new(); |
| @@ -185,7 +196,10 @@ impl AuditResult { | |||
| 185 | println!(); | 196 | println!(); |
| 186 | println!("{}{}## {}{}", CYAN, BOLD, section, RESET); | 197 | println!("{}{}## {}{}", CYAN, BOLD, section, RESET); |
| 187 | 198 | ||
| 188 | for req in GRASP_01_REQUIREMENTS.iter().filter(|r| r.section == section) { | 199 | for req in GRASP_01_REQUIREMENTS |
| 200 | .iter() | ||
| 201 | .filter(|r| r.section == section) | ||
| 202 | { | ||
| 189 | println!(); | 203 | println!(); |
| 190 | // Print spec requirement in blue | 204 | // Print spec requirement in blue |
| 191 | println!("{}📘 Line {}: {}{}", BLUE, req.line, req.text, RESET); | 205 | println!("{}📘 Line {}: {}{}", BLUE, req.line, req.text, RESET); |
| @@ -218,7 +232,10 @@ impl AuditResult { | |||
| 218 | } | 232 | } |
| 219 | 233 | ||
| 220 | println!(); | 234 | println!(); |
| 221 | println!("{}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{}", BOLD, RESET); | 235 | println!( |
| 236 | "{}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{}", | ||
| 237 | BOLD, RESET | ||
| 238 | ); | ||
| 222 | 239 | ||
| 223 | // Summary statistics | 240 | // Summary statistics |
| 224 | let passed = self.passed_count(); | 241 | let passed = self.passed_count(); |
| @@ -252,7 +269,10 @@ impl AuditResult { | |||
| 252 | "{}Test results: {}/{} tests passed ({:.1}%){}", | 269 | "{}Test results: {}/{} tests passed ({:.1}%){}", |
| 253 | summary_color, passed, total_tests, pass_rate, RESET | 270 | summary_color, passed, total_tests, pass_rate, RESET |
| 254 | ); | 271 | ); |
| 255 | println!("{}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{}", BOLD, RESET); | 272 | println!( |
| 273 | "{}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{}", | ||
| 274 | BOLD, RESET | ||
| 275 | ); | ||
| 256 | println!(); | 276 | println!(); |
| 257 | } | 277 | } |
| 258 | 278 | ||
| @@ -313,7 +333,10 @@ mod tests { | |||
| 313 | #[test] | 333 | #[test] |
| 314 | fn test_parse_spec_lines_range() { | 334 | fn test_parse_spec_lines_range() { |
| 315 | assert_eq!(parse_spec_lines("GRASP-01:nostr-relay:7-9"), vec![7, 8, 9]); | 335 | assert_eq!(parse_spec_lines("GRASP-01:nostr-relay:7-9"), vec![7, 8, 9]); |
| 316 | assert_eq!(parse_spec_lines("GRASP-01:cors:44-47"), vec![44, 45, 46, 47]); | 336 | assert_eq!( |
| 337 | parse_spec_lines("GRASP-01:cors:44-47"), | ||
| 338 | vec![44, 45, 46, 47] | ||
| 339 | ); | ||
| 317 | } | 340 | } |
| 318 | 341 | ||
| 319 | #[test] | 342 | #[test] |
| @@ -327,4 +350,4 @@ mod tests { | |||
| 327 | assert_eq!(parse_spec_lines("GRASP-01:invalid"), Vec::<u32>::new()); | 350 | assert_eq!(parse_spec_lines("GRASP-01:invalid"), Vec::<u32>::new()); |
| 328 | assert_eq!(parse_spec_lines("GRASP-01:test:abc"), Vec::<u32>::new()); | 351 | assert_eq!(parse_spec_lines("GRASP-01:test:abc"), Vec::<u32>::new()); |
| 329 | } | 352 | } |
| 330 | } \ No newline at end of file | 353 | } |