Skip to content

feat: Go third-party QueryType classes + GORM SQLi & Gin SSRF rules - #644

Merged
shivasurya merged 1 commit into
mainfrom
shiva/pr-04-golang-thirdparty
Apr 7, 2026
Merged

shivasurya merged 1 commit into
mainfrom
shiva/pr-04-golang-thirdparty

Conversation

@shivasurya

Copy link
Copy Markdown
Owner

Summary

  • Adds 15 new QueryType classes in python-sdk/codepathfinder/go_rule.py for popular Go frameworks: GORM, Gin, Echo, Fiber, gRPC, pgx, sqlx, go-redis, MongoDB, golang-jwt, Gorilla Mux, Resty, Chi, Viper, YAML v3
  • Adds two example security rules demonstrating type-constrained detection:
    • rules/golang/gorm_sqli_taint.py — GORM SQL injection (CWE-89) with Gin/Echo/net-http sources
    • rules/golang/gin_ssrf.py — SSRF (CWE-918) via Resty HTTP client with Gin/net-http sources
  • Adds 27 tests in test_go_thirdparty_querytypes.py covering FQN correctness, multi-FQN types, MethodMatcher IR output, negative matching, and a no-duplicate-FQN invariant

Why

Rule authors can now write type-constrained matchers like GoGormDB.method("Raw", "Exec") instead of fragile calls("*Raw"). This eliminates false positives from unrelated Raw() calls on non-GORM types, and enables cross-framework taint tracking:

flows(
    from_sources=[GoGinContext.method("Query")],
    to_sinks=[GoGormDB.method("Raw")],
)

Dependencies

Stacked on PR-03 (shiva/pr-03-golang-thirdparty): package-level var resolution + StdlibLoader embed fix.

Test plan

  • cd python-sdk && python3 -m pytest tests/test_go_thirdparty_querytypes.py -v — 27 new tests pass
  • cd python-sdk && python3 -m pytest tests/ -v — 408 total tests, zero regressions
  • python3 -c "from codepathfinder.go_rule import GoGormDB, GoGinContext" — imports work
  • CI green on all checks

🤖 Generated with Claude Code

@shivasurya shivasurya added enhancement New feature or request python labels Apr 5, 2026
@shivasurya shivasurya self-assigned this Apr 5, 2026
@safedep

safedep Bot commented Apr 5, 2026 •

Copy link
Copy Markdown

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

View complete scan results →

This report is generated by SafeDep Github App

@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown

Code Pathfinder Security Scan

Pass Critical High Medium Low Info

No security issues detected.

Metric Value
Files Scanned 4
Rules 205

Powered by Code Pathfinder

@codecov

codecov Bot commented Apr 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.24%. Comparing base (81346a6) to head (19785a8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #644   +/-   ##
=======================================
  Coverage   84.24%   84.24%           
=======================================
  Files         162      162           
  Lines       23358    23358           
=======================================
  Hits        19677    19677           
  Misses       2941     2941           
  Partials      740      740           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

shivasurya commented Apr 7, 2026 •

Copy link
Copy Markdown
Owner Author

Merge activity

  • Apr 7, 8:35 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 7, 8:41 PM UTC: Graphite rebased this pull request as part of a merge.
  • Apr 7, 8:41 PM UTC: @shivasurya merged this pull request with Graphite.

@shivasurya
shivasurya changed the base branch from shiva/pr-03-golang-thirdparty to graphite-base/644 April 7, 2026 20:38
@shivasurya
shivasurya changed the base branch from graphite-base/644 to main April 7, 2026 20:39
Add 15 new QueryType classes for popular Go frameworks (GORM, Gin, Echo,
Fiber, gRPC, pgx, sqlx, go-redis, MongoDB, JWT, Gorilla Mux, Resty, Chi,
Viper, YAML) to python-sdk/codepathfinder/go_rule.py.

Add example security rules:
- rules/golang/gorm_sqli_taint.py: GORM SQL injection via Gin/Echo/net/http sources
- rules/golang/gin_ssrf.py: SSRF via Resty HTTP client with Gin/net/http sources

Add 27 tests in test_go_thirdparty_querytypes.py covering FQN correctness,
multi-FQN types, MethodMatcher IR, negative matching, and no-duplicate-FQN invariant.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shivasurya
shivasurya force-pushed the shiva/pr-04-golang-thirdparty branch from 61d181d to 19785a8 Compare April 7, 2026 20:40
@shivasurya
shivasurya merged commit ca99cdd into main Apr 7, 2026
5 checks passed
@shivasurya
shivasurya deleted the shiva/pr-04-golang-thirdparty branch April 7, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant