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

Method scanFunctionCall

pkg/sql/security/scanner.go:919–976  ·  view source on GitHub ↗

scanFunctionCall checks for dangerous function usage.

(fn *ast.FunctionCall, result *ScanResult)

Source from the content-addressed store, hash-verified

917
918// scanFunctionCall checks for dangerous function usage.
919func (s *Scanner) scanFunctionCall(fn *ast.FunctionCall, result *ScanResult) {
920 if fn == nil {
921 return
922 }
923
924 funcName := strings.ToUpper(fn.Name)
925
926 // Time-based blind injection functions
927 timeBasedFuncs := map[string]bool{
928 "SLEEP": true,
929 "PG_SLEEP": true,
930 "BENCHMARK": true,
931 "WAITFOR": true,
932 }
933
934 if timeBasedFuncs[funcName] {
935 finding := Finding{
936 Severity: SeverityHigh,
937 Pattern: PatternTimeBased,
938 Description: "Time-based blind injection function detected: " + fn.Name,
939 Risk: "Time-based blind SQL injection, DoS",
940 Suggestion: "Block or restrict time delay functions",
941 }
942 if s.shouldInclude(finding.Severity) {
943 result.Findings = append(result.Findings, finding)
944 }
945 }
946
947 // Out-of-band / dangerous functions
948 dangerousFuncs := map[string]string{
949 "LOAD_FILE": "File system access",
950 "LOAD DATA": "File system access",
951 "XP_CMDSHELL": "Command execution",
952 "SP_OACREATE": "OLE automation",
953 "UTL_HTTP": "Network access",
954 "DBMS_LDAP": "LDAP access",
955 "EXEC": "Dynamic SQL execution",
956 "SP_EXECUTESQL": "Dynamic SQL execution",
957 }
958
959 if risk, found := dangerousFuncs[funcName]; found {
960 finding := Finding{
961 Severity: SeverityCritical,
962 Pattern: PatternOutOfBand,
963 Description: "Dangerous function detected: " + fn.Name,
964 Risk: risk,
965 Suggestion: "Block dangerous functions or use allowlist",
966 }
967 if s.shouldInclude(finding.Severity) {
968 result.Findings = append(result.Findings, finding)
969 }
970 }
971
972 // Recursively check function arguments
973 for _, arg := range fn.Arguments {
974 s.scanExpressionForDangerousFunctions(arg, result)
975 }
976}

Callers 2

scanExpressionMethod · 0.95

Calls 2

shouldIncludeMethod · 0.95

Tested by

no test coverage detected