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

Function TestScan_TimeBasedFunction

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

Source from the content-addressed store, hash-verified

174}
175
176func TestScan_TimeBasedFunction(t *testing.T) {
177 scanner := NewScanner()
178
179 // Create AST with SLEEP function call
180 selectStmt := &ast.SelectStatement{
181 Columns: []ast.Expression{
182 &ast.FunctionCall{
183 Name: "SLEEP",
184 Arguments: []ast.Expression{&ast.LiteralValue{Value: "5", Type: "INTEGER"}},
185 },
186 },
187 }
188
189 tree := &ast.AST{Statements: []ast.Statement{selectStmt}}
190 result := scanner.Scan(tree)
191
192 if result.HighCount == 0 {
193 t.Error("expected at least one high severity finding for SLEEP function")
194 }
195
196 found := false
197 for _, f := range result.Findings {
198 if f.Pattern == PatternTimeBased {
199 found = true
200 break
201 }
202 }
203 if !found {
204 t.Error("expected TIME_BASED pattern to be detected")
205 }
206}
207
208func TestScan_DangerousFunction_LoadFile(t *testing.T) {
209 scanner := NewScanner()

Callers

nothing calls this directly

Calls 3

ScanMethod · 0.95
NewScannerFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected