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

Function test_sql_injection_patterns

src/session/db_handler.rs:2905–2923  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2903
2904 #[test]
2905 fn test_sql_injection_patterns() {
2906 let db_path = "/tmp/test_injection.db";
2907 let _ = std::fs::remove_file(db_path); // Clean up
2908 let handler = DbHandler::new(db_path).unwrap();
2909
2910 // Test common SQL injection patterns should be rejected
2911 let injection_attempts = [
2912 "SELECT * FROM users WHERE id = 1 OR 1=1",
2913 "SELECT * FROM users\"; DROP TABLE users; --",
2914 "SELECT * FROM users WHERE name = \"test\" OR \"1\"=\"1\"",
2915 "EXEC(\"DROP TABLE users\")",
2916 "SELECT * FROM users WHERE id = 1 AND 1=1",
2917 ];
2918
2919 for injection in &injection_attempts {
2920 let result = handler.validate_sql_security(injection);
2921 assert!(result.is_err(), "Should reject injection: {}", injection);
2922 }
2923 }
2924
2925 #[test]
2926 fn test_sql_injection_resistance_edge_cases() {

Callers

nothing calls this directly

Calls 1

validate_sql_securityMethod · 0.80

Tested by

no test coverage detected