-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add PostgreSQL parser and reporting capabilities #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cb040cb
feat: add PostgreSQL parser and reporting capabilities
KARTIKrocks 909d07e
Update .github/workflows/ci.yml
KARTIKrocks b38719e
Update .github/workflows/codeql.yml
KARTIKrocks b5f7fa9
fix: disable credential persistence for checkout actions in CI workflows
KARTIKrocks 5c7ab7a
Update cmd/sqlguard/scan.go
KARTIKrocks 95b90ed
Update reporter/json.go
KARTIKrocks f313107
fix: correct comment typo in skipSingleQuoted function
KARTIKrocks c51e319
fix: add missing import for fmt in JSONReporter
KARTIKrocks d203993
feat: enhance reporting capabilities and improve documentation
KARTIKrocks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| --- | ||
| name: Bug report | ||
| about: Report incorrect behavior, a false positive/negative, or a crash | ||
| title: "" | ||
| labels: bug | ||
| assignees: "" | ||
| --- | ||
|
|
||
| **Do not file security vulnerabilities here** — see [SECURITY.md](../../SECURITY.md). | ||
|
|
||
| ## What happened | ||
|
|
||
| A clear description of the bug. | ||
|
|
||
| ## Expected behavior | ||
|
|
||
| What you expected instead. For a false positive/negative, say which **rule** | ||
| (e.g. `select-star`) fired or failed to fire. | ||
|
|
||
| ## Reproduction | ||
|
|
||
| The SQL or Go snippet, and how it was issued: | ||
|
|
||
| ```sql | ||
| -- query (redacted is fine) | ||
| ``` | ||
|
|
||
| ```go | ||
| // minimal repro | ||
| ``` | ||
|
|
||
| ## Environment | ||
|
|
||
| - sqlguard version / commit: | ||
| - Affected module(s) (root, `integrations/<name>`, `parsers/<name>`): | ||
| - Parser in use (default fallback / pgparser / mysqlparser): | ||
| - Entry surface (runtime middleware / CLI `scan` / CLI `explain` / integration): | ||
| - Go version: | ||
| - Database + dialect (if relevant): | ||
|
|
||
| ## Additional context | ||
|
|
||
| Logs (redaction-safe), config (`.sqlguard.yml`), or anything else useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| blank_issues_enabled: false | ||
| contact_links: | ||
| - name: Security vulnerability | ||
| url: https://github.com/KARTIKrocks/sqlguard/security/advisories/new | ||
| about: Report security issues privately — please do not open a public issue. | ||
| - name: Question / discussion | ||
| url: https://github.com/KARTIKrocks/sqlguard/discussions | ||
| about: Ask usage questions or discuss ideas here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| name: Feature request | ||
| about: Suggest a new rule, integration, or capability | ||
| title: "" | ||
| labels: enhancement | ||
| assignees: "" | ||
| --- | ||
|
|
||
| ## Problem | ||
|
|
||
| What are you trying to catch or do that sqlguard can't today? | ||
|
|
||
| ## Proposed solution | ||
|
|
||
| What you'd like to see. If you're proposing a **new detection rule**, include: | ||
|
|
||
| - the SQL anti-pattern it should flag, | ||
| - example queries that should and should **not** trigger it, | ||
| - a suggested severity (info / warning / critical), | ||
| - any tunable (and its default). | ||
|
|
||
| If you're proposing a **new integration**, name the ORM/driver and its | ||
| hook/seam. | ||
|
|
||
| ## Alternatives considered | ||
|
|
||
| Other approaches, workarounds, or existing rules/config that almost fit. | ||
|
|
||
| ## Additional context | ||
|
|
||
| Anything else — links, prior art, willingness to send a PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| ## Summary | ||
|
|
||
| What does this PR change, and why? | ||
|
|
||
| Closes #<!-- issue number, if any --> | ||
|
|
||
| ## Type of change | ||
|
|
||
| - [ ] Bug fix | ||
| - [ ] New detection rule | ||
| - [ ] New integration / parser | ||
| - [ ] Feature / enhancement | ||
| - [ ] Docs only | ||
| - [ ] Refactor / chore | ||
|
|
||
| ## Checklist | ||
|
|
||
| - [ ] `make ci` passes (fmt-check, vet, lint, test-race) across all modules | ||
| - [ ] Added/updated tests (and, where practical, a failure-mode check) | ||
| - [ ] Updated docs as needed (`README.md`, `CLAUDE.md`, `.sqlguard.example.yml`) | ||
| - [ ] Added an entry under `## [Unreleased]` in `CHANGELOG.md` | ||
| - [ ] No new third-party deps in `analyzer` / `middleware` / `reporter` | ||
| - [ ] Findings stay redaction-safe (no raw literals leak into a `Result`) | ||
|
|
||
| ## Notes for reviewers | ||
|
|
||
| Anything reviewers should focus on — tricky areas, trade-offs, follow-ups. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| version: 2 | ||
|
|
||
| updates: | ||
| - package-ecosystem: gomod | ||
| directory: / | ||
| schedule: | ||
| interval: weekly | ||
| groups: | ||
| go-dependencies: | ||
| patterns: | ||
| - "*" | ||
|
|
||
| - package-ecosystem: gomod | ||
| directory: /integrations/gormguard | ||
| schedule: | ||
| interval: weekly | ||
|
|
||
| - package-ecosystem: gomod | ||
| directory: /integrations/sqlxguard | ||
| schedule: | ||
| interval: weekly | ||
|
|
||
| - package-ecosystem: gomod | ||
| directory: /integrations/pgxguard | ||
| schedule: | ||
| interval: weekly | ||
|
|
||
| - package-ecosystem: gomod | ||
| directory: /integrations/bunguard | ||
| schedule: | ||
| interval: weekly | ||
|
|
||
| - package-ecosystem: gomod | ||
| directory: /integrations/xormguard | ||
| schedule: | ||
| interval: weekly | ||
|
|
||
| - package-ecosystem: gomod | ||
| directory: /integrations/entguard | ||
| schedule: | ||
| interval: weekly | ||
|
|
||
| - package-ecosystem: gomod | ||
| directory: /parsers/pgparser | ||
| schedule: | ||
| interval: weekly | ||
|
|
||
| - package-ecosystem: gomod | ||
| directory: /parsers/mysqlparser | ||
| schedule: | ||
| interval: weekly | ||
|
|
||
| - package-ecosystem: github-actions | ||
| directory: / | ||
| schedule: | ||
| interval: weekly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| go-version: ["1.26"] | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-go@v6 | ||
| with: | ||
| go-version: ${{ matrix.go-version }} | ||
|
|
||
| - name: Run tests | ||
| run: go test ./... -count=1 -race | ||
|
|
||
| - name: Test integrations (gormguard) | ||
| run: cd integrations/gormguard && go test ./... -count=1 -race | ||
|
|
||
| - name: Test integrations (sqlxguard) | ||
| run: cd integrations/sqlxguard && go test ./... -count=1 -race | ||
|
|
||
| - name: Test integrations (pgxguard) | ||
| run: cd integrations/pgxguard && go test ./... -count=1 -race | ||
|
|
||
| - name: Test integrations (bunguard) | ||
| run: cd integrations/bunguard && go test ./... -count=1 -race | ||
|
|
||
| - name: Test integrations (xormguard) | ||
| run: cd integrations/xormguard && go test ./... -count=1 -race | ||
|
|
||
| - name: Test integrations (entguard) | ||
| run: cd integrations/entguard && go test ./... -count=1 -race | ||
|
|
||
| - name: Test parsers (pgparser) | ||
| run: cd parsers/pgparser && go test ./... -count=1 -race | ||
|
|
||
| - name: Test parsers (mysqlparser) | ||
| run: cd parsers/mysqlparser && go test ./... -count=1 -race | ||
|
|
||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-go@v6 | ||
| with: | ||
| go-version: "1.26" | ||
|
|
||
| - uses: golangci/golangci-lint-action@v9 | ||
| with: | ||
| version: v2.11 | ||
| args: --timeout=5m | ||
|
|
||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-go@v6 | ||
| with: | ||
| go-version: "1.26" | ||
|
|
||
| - name: Build CLI | ||
| run: go build -o bin/sqlguard ./cmd/sqlguard | ||
|
|
||
| coverage: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-go@v6 | ||
| with: | ||
| go-version: "1.26" | ||
|
|
||
| # `make coverage` runs every module and merges into a single coverage.out | ||
| # (root go test does not reach the satellite modules). | ||
| - name: Generate merged coverage | ||
| run: make coverage | ||
|
|
||
| - name: Upload to Codecov | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| files: ./coverage.out | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| fail_ci_if_error: false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: CodeQL | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| schedule: | ||
| # Weekly re-scan so newly published CodeQL queries flag old code too. | ||
| - cron: "0 6 * * 1" | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.event_name != 'schedule' }} | ||
|
|
||
| permissions: | ||
| # CodeQL requires security-events: write to upload SARIF results | ||
| security-events: write | ||
| contents: read | ||
|
KARTIKrocks marked this conversation as resolved.
|
||
|
|
||
| jobs: | ||
| analyze: | ||
| name: Analyze (Go) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version: "1.26" | ||
|
|
||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@v4 | ||
| with: | ||
| languages: go | ||
| # Build the modules ourselves (below) so the tracer sees all nine. | ||
| build-mode: manual | ||
| queries: security-extended | ||
|
|
||
| # Each integration/parser carries its own go.mod (heavy deps kept opt-in), | ||
| # so `go build ./...` from root does NOT reach them. Build every module | ||
| # under the CodeQL tracer so all nine are analyzed — same MODULES loop the | ||
| # Makefile uses; a satellite must not silently skip scanning. | ||
| - name: Build all modules | ||
| run: | | ||
| set -e | ||
| for mod in . \ | ||
| ./integrations/gormguard ./integrations/sqlxguard \ | ||
| ./integrations/pgxguard ./integrations/bunguard \ | ||
| ./integrations/xormguard ./integrations/entguard \ | ||
| ./parsers/pgparser ./parsers/mysqlparser; do | ||
| echo "==> Building $mod" | ||
| (cd "$mod" && go build ./...) | ||
| done | ||
|
|
||
| - name: Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@v4 | ||
| with: | ||
| category: "/language:go" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.