MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_fuzz_performance_degradation

Function test_fuzz_performance_degradation

tests/protocol_fuzzing_test.rs:132–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130
131#[tokio::test]
132async 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

Callers

nothing calls this directly

Calls 3

parse_message_safelyFunction · 0.85
rate_limit_exceededFunction · 0.85

Tested by

no test coverage detected