MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestScanSQL_TimeBasedPatterns

Function TestScanSQL_TimeBasedPatterns

pkg/sql/security/scanner_test.go:361–385  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

359}
360
361func TestScanSQL_TimeBasedPatterns(t *testing.T) {
362 scanner := NewScanner()
363
364 testCases := []string{
365 "SELECT * FROM users WHERE id = 1 AND SLEEP(5)",
366 "SELECT * FROM users; WAITFOR DELAY '0:0:5'",
367 "SELECT pg_sleep(10)",
368 "SELECT BENCHMARK(1000000, MD5('test'))",
369 }
370
371 for _, sql := range testCases {
372 result := scanner.ScanSQL(sql)
373 hasTimeBased := false
374 for _, f := range result.Findings {
375 if f.Pattern == PatternTimeBased {
376 hasTimeBased = true
377 break
378 }
379 }
380
381 if !hasTimeBased {
382 t.Errorf("expected time-based pattern in: %s", sql)
383 }
384 }
385}
386
387func TestScanSQL_OutOfBandPatterns(t *testing.T) {
388 scanner := NewScanner()

Callers

nothing calls this directly

Calls 3

ScanSQLMethod · 0.95
NewScannerFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected