Represents gin.Context, the primary request/response carrier in the Gin HTTP framework. All user-input accessors (Query, Param, PostForm, etc.) are taint sources. Output methods (JSON, String, Redirect) are sinks for XSS and open-redirect rules.
.Query().DefaultQuery().Param().PostForm().GetHeader().ShouldBindJSON().Cookie().JSON().Redirect()from codepathfinder.go_rule import GoGinContext, GoGormDB, GoStrconv
from codepathfinder import flows
from codepathfinder.presets import PropagationPresets
from codepathfinder.go_decorators import go_rule
@go_rule(
id="GO-GORM-SQLI-001",
severity="CRITICAL",
cwe="CWE-89",
owasp="A03:2021",
message="User input flows into GORM Raw()/Exec(). Use parameterized queries.",
)
def detect_gorm_sqli():
return flows(
from_sources=[
GoGinContext.method("Query", "Param", "PostForm", "ShouldBindJSON"),
],
to_sinks=[
GoGormDB.method("Raw", "Exec"),
],
sanitized_by=[
GoStrconv.method("Atoi", "ParseInt", "ParseFloat"),
],
propagates_through=PropagationPresets.standard(),
scope="global",
)
pathfinder scan --ruleset custom/security --project ..Query()SourceQuery(key string) string
Returns URL query parameter value for the given key. Empty string if missing.
return.DefaultQuery()SourceDefaultQuery(key, defaultValue string) string
Returns URL query parameter value, or defaultValue if the key is absent.
return.Param()SourceParam(key string) string
Returns URL path parameter (e.g. /user/:id). Always non-empty if route matched.
return.PostForm()SourcePostForm(key string) string
Returns POST form value for the given key from application/x-www-form-urlencoded body.
return.GetHeader()SourceGetHeader(key string) string
Returns HTTP request header value. User-controlled for headers like X-Forwarded-For.
return.ShouldBindJSON()SourceShouldBindJSON(obj any) error
Deserializes JSON request body into obj. obj becomes tainted after binding.
0.Cookie()SourceCookie(name string) (string, error)
Returns the named cookie value. Cookies are user-controlled.
return| FQN | Field | |
|---|---|---|
| github.com/gin-gonic/gin.Context | fqns[0] | |
| *.Context | patterns |
Wrong FQN → 0 findings. Verify with: change fqns to garbage → must produce 0 results.
require github.com/gin-gonic/gin v1.9.1
from codepathfinder.go_rule import GoGinContext