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

Function TestIsSystemTable

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

Source from the content-addressed store, hash-verified

605}
606
607func TestIsSystemTable(t *testing.T) {
608 scanner := NewScanner()
609
610 // Test cases for system table detection
611 tests := []struct {
612 tableName string
613 isSystem bool
614 desc string
615 }{
616 // Exact matches
617 {"information_schema", true, "exact information_schema"},
618 {"INFORMATION_SCHEMA", true, "case-insensitive information_schema"},
619 {"pg_catalog", true, "exact pg_catalog"},
620 {"sys", true, "exact sys"},
621
622 // Prefix matches
623 {"information_schema.tables", true, "information_schema prefix"},
624 {"mysql.user", true, "mysql prefix"},
625 {"pg_class", true, "pg_ prefix"},
626 {"sys.tables", true, "sys. prefix"},
627 {"sqlite_master", true, "sqlite_ prefix"},
628 {"master.dbo.sysobjects", true, "SQL Server master.dbo prefix"},
629
630 // False positives that should NOT match
631 {"users", false, "regular table"},
632 {"mysystem", false, "table starting with 'my' should not match mysql"},
633 {"system_logs", false, "table containing 'system' should not match"},
634 {"postgresql_data", false, "table containing 'postgresql' should not match"},
635 {"syslog", false, "table starting with 'sys' (no dot) should not match"},
636 {"customer_info", false, "table with 'info' should not match information_schema"},
637 }
638
639 for _, tc := range tests {
640 t.Run(tc.desc, func(t *testing.T) {
641 result := scanner.isSystemTable(tc.tableName)
642 if result != tc.isSystem {
643 t.Errorf("isSystemTable(%q) = %v, want %v", tc.tableName, result, tc.isSystem)
644 }
645 })
646 }
647}
648
649func TestShouldInclude_UnknownSeverity(t *testing.T) {
650 scanner := NewScanner()

Callers

nothing calls this directly

Calls 4

isSystemTableMethod · 0.95
NewScannerFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected