()
| 130 | |
| 131 | #[tokio::test] |
| 132 | async fn test_fuzz_performance_degradation() { |
| 133 | let malicious_inputs = generate_performance_attack_inputs(); |
| 134 | |
| 135 | for input in malicious_inputs { |
| 136 | let start = std::time::Instant::now(); |
| 137 | |
| 138 | // Use timeout to prevent DoS attacks via slow parsing |
| 139 | let result = timeout(Duration::from_millis(100), parse_message_safely(&input)).await; |
| 140 | |
| 141 | let elapsed = start.elapsed(); |
| 142 | |
| 143 | match result { |
| 144 | Ok(_) => { |
| 145 | // Parsing should complete within reasonable time |
| 146 | assert!(elapsed < Duration::from_millis(100)); |
| 147 | } |
| 148 | Err(_) => { |
| 149 | // Timeout is acceptable - prevents DoS |
| 150 | events::rate_limit_exceeded(None, "protocol-parser-timeout", 1); |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | // Helper functions for safe parsing with error handling |
| 157 |
nothing calls this directly
no test coverage detected