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

Function TestScan_UpdateWithTautology

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

Source from the content-addressed store, hash-verified

284}
285
286func TestScan_UpdateWithTautology(t *testing.T) {
287 scanner := NewScanner()
288
289 // UPDATE users SET admin=1 WHERE 1=1
290 updateStmt := &ast.UpdateStatement{
291 TableName: "users",
292 Assignments: []ast.UpdateExpression{
293 {Column: &ast.Identifier{Name: "admin"}, Value: &ast.LiteralValue{Value: "1", Type: "INTEGER"}},
294 },
295 Where: &ast.BinaryExpression{
296 Left: &ast.LiteralValue{Value: "1", Type: "INTEGER"},
297 Operator: "=",
298 Right: &ast.LiteralValue{Value: "1", Type: "INTEGER"},
299 },
300 }
301
302 tree := &ast.AST{Statements: []ast.Statement{updateStmt}}
303 result := scanner.Scan(tree)
304
305 if result.CriticalCount == 0 {
306 t.Error("expected critical finding for UPDATE with 1=1 tautology")
307 }
308}
309
310func TestScan_DeleteWithTautology(t *testing.T) {
311 scanner := NewScanner()

Callers

nothing calls this directly

Calls 3

ScanMethod · 0.95
NewScannerFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected