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

Method detectCommentPatterns

pkg/sql/security/scanner.go:996–1014  ·  view source on GitHub ↗

detectCommentPatterns checks raw SQL for comment-based injection.

(sql string, result *ScanResult)

Source from the content-addressed store, hash-verified

994
995// detectCommentPatterns checks raw SQL for comment-based injection.
996func (s *Scanner) detectCommentPatterns(sql string, result *ScanResult) {
997 // Ensure patterns are initialized
998 commentPatternsOnce.Do(initCommentPatterns)
999
1000 for _, p := range commentPatterns {
1001 if safeRegexMatch(p.re, sql) {
1002 finding := Finding{
1003 Severity: p.severity,
1004 Pattern: PatternComment,
1005 Description: p.description,
1006 Risk: "SQL injection via comment-based bypass",
1007 Suggestion: "Sanitize input to remove SQL comments",
1008 }
1009 if s.shouldInclude(finding.Severity) {
1010 result.Findings = append(result.Findings, finding)
1011 }
1012 }
1013 }
1014}
1015
1016// detectTautologyInSQL checks raw SQL for tautology patterns (e.g. OR 1=1, 'a'='a').
1017// Because Go's RE2 engine does not support backreferences, equality of the two sides

Callers 1

ScanSQLMethod · 0.95

Calls 2

shouldIncludeMethod · 0.95
safeRegexMatchFunction · 0.85

Tested by

no test coverage detected