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

Function TestScanSQL_CommentPatterns

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

Source from the content-addressed store, hash-verified

329}
330
331func TestScanSQL_CommentPatterns(t *testing.T) {
332 scanner := NewScanner()
333
334 testCases := []struct {
335 sql string
336 shouldFind bool
337 description string
338 }{
339 {"SELECT * FROM users WHERE id = 1 --", true, "single-line comment at end"},
340 {"SELECT * FROM users WHERE id = '1'--", true, "comment after quote"},
341 {"SELECT * FROM users /* WHERE id = 1 */", true, "block comment"},
342 {"SELECT * FROM users", false, "no comments"},
343 }
344
345 for _, tc := range testCases {
346 result := scanner.ScanSQL(tc.sql)
347 hasCommentFinding := false
348 for _, f := range result.Findings {
349 if f.Pattern == PatternComment {
350 hasCommentFinding = true
351 break
352 }
353 }
354
355 if tc.shouldFind && !hasCommentFinding {
356 t.Errorf("expected comment pattern in: %s", tc.description)
357 }
358 }
359}
360
361func TestScanSQL_TimeBasedPatterns(t *testing.T) {
362 scanner := NewScanner()

Callers

nothing calls this directly

Calls 3

ScanSQLMethod · 0.95
NewScannerFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected