Skip to content

fix(webservices): patch SQL injection and improve reliability#12

Open
MrMichou wants to merge 3 commits intocropalato:mainfrom
MrMichou:security-and-improvements
Open

fix(webservices): patch SQL injection and improve reliability#12
MrMichou wants to merge 3 commits intocropalato:mainfrom
MrMichou:security-and-improvements

Conversation

@MrMichou
Copy link
Copy Markdown

@MrMichou MrMichou commented Mar 8, 2026

Summary

  • Security: Fix critical SQL injection in updateMergeStatus() by replacing fmt.Sprintf with parameterized queries ($1, $2)
  • Security: Fix CORS wildcard "*" origin — now uses configured CorsOrigin value
  • Reliability: Add DB connection pooling (shared *sqlx.DB in Service struct), replace all log.Fatal() with proper error returns, add graceful shutdown with signal handling (SIGINT/SIGTERM)
  • Maintenance: Remove github.com/pkg/errors dependency (use fmt.Errorf with %w), update Go to 1.25, update all dependencies, upgrade Dockerfile base to debian12

Test plan

  • go build ./... passes
  • go test ./... passes
  • go vet ./... clean
  • Verify parameterized SQL queries work against a real PostgreSQL instance
  • Verify graceful shutdown: send SIGTERM and confirm clean exit with DB pool closure
  • Verify CORS header uses configured origin instead of wildcard

🤖 Generated with Claude Code

mnicolet-ludia and others added 3 commits March 7, 2026 22:07
…bility

Replace string-interpolated SQL queries with parameterized queries ($1, $2)
to prevent SQL injection in updateMergeStatus(). Add DB connection pooling,
replace log.Fatal() with proper error returns, fix CORS wildcard origin,
add graceful shutdown, remove pkg/errors dependency, and update Go/deps
to latest versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…DB logic

Cover SQL parameterized queries, CORS headers, token validation,
error handling (no more log.Fatal crashes), GitLab API mocking,
and approval rule enforcement logic using sqlmock and httptest.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify SQL parameterized queries, DB updates through full webhook flow,
CORS headers, token validation, ReinforceAllMrRule, and SQL injection
prevention against a real PostgreSQL 16 instance. Docker build also
tested successfully.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants