-
Notifications
You must be signed in to change notification settings - Fork 0
demo: suppression showcase (inline + global) with verification #6
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Suppression Showcase | ||
|
|
||
| This demo shows suppression at two levels: | ||
|
|
||
| 1. Query-level inline suppression | ||
| - Rule-specific: `valk-guard:disable VG001` | ||
| - Statement-wide: `valk-guard:disable` | ||
|
|
||
| 2. Global suppression via config | ||
| - `demo/suppressions/config/global_disable_vg001.yaml` disables `VG001` globally. | ||
|
|
||
| ## Files | ||
|
|
||
| - `inline/sql_inline.sql` | ||
| - `inline/go_inline.go` | ||
| - `inline/python_inline.py` | ||
|
|
||
| ## Verification | ||
|
|
||
| From repo root: | ||
|
|
||
| ```bash | ||
| # Baseline config: query-level suppressions apply, unsuppressed VG001 remains. | ||
| valk-guard scan demo/suppressions/inline --config .valk-guard.yaml --format json | ||
|
|
||
| # Global config: VG001 disabled globally, so inline folder returns zero findings. | ||
| valk-guard scan demo/suppressions/inline --config demo/suppressions/config/global_disable_vg001.yaml --format json | ||
| ``` | ||
|
|
||
| Expected behavior: | ||
|
|
||
| - Baseline config: only unsuppressed `VG001` findings remain. | ||
| - Global config: `VG001` findings are suppressed globally; result is empty. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| rules: | ||
| VG001: | ||
| enabled: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package suppressions | ||
|
|
||
| import ( | ||
| "context" | ||
| "database/sql" | ||
| ) | ||
|
|
||
| func GoInlineSuppression(db *sql.DB) { | ||
| ctx := context.Background() | ||
|
|
||
| // valk-guard:disable VG001 | ||
| _, _ = db.QueryContext(ctx, "SELECT * FROM users LIMIT 1") | ||
|
|
||
| _, _ = db.QueryContext(ctx, "SELECT * FROM users LIMIT 1") | ||
|
|
||
| // valk-guard:disable | ||
| _, _ = db.ExecContext(ctx, "DELETE FROM orders") | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| from sqlalchemy import text | ||
| from sqlalchemy.orm import Session | ||
|
|
||
|
|
||
| def python_inline_suppression(session: Session): | ||
| # valk-guard:disable VG001 | ||
| session.execute(text("SELECT * FROM users LIMIT 1")).all() | ||
|
|
||
| session.execute(text("SELECT * FROM users LIMIT 1")).all() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| # valk-guard:disable | ||
| session.execute(text("UPDATE users SET active = false")) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| -- valk-guard:disable VG001 | ||
| SELECT * FROM users LIMIT 1; | ||
|
|
||
| SELECT * FROM users LIMIT 1; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| -- valk-guard:disable | ||
| UPDATE users SET active = false; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VG001: avoid SELECT *; project only required columns | Query:
SELECT * FROM users LIMIT 1