diff --git a/README.md b/README.md index 76ae6fb..99f0d1e 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,14 @@ valk-guard-example/ Workflow install target is configured as: ```text -github.com/valkdb/valk-guard/cmd/valk-guard@latest +github.com/valkdb/valk-guard/cmd/valk-guard.0.0-20260304065917-b9d9468a4ea3@latest ``` Rationale: -- This repository is a demo showcase; tracking latest keeps examples aligned with current built-in behavior. -- If you need strict reproducibility, pin a fixed tag in workflow `VALK_GUARD_INSTALL_REF`. +- This repository is a demo showcase, but CI is pinned to a known-good valk-guard build to keep output shape stable. +- Pinning avoids format drift that can break downstream tooling steps (for example: `Convert to reviewdog format`). +- When upgrading, bump `VALK_GUARD_INSTALL_REF` intentionally and verify the full workflow output. ## Creating Demo PRs (one rule at a time) diff --git a/demo/violations/dist2-vg004-006/README.md b/demo/violations/dist2-vg004-006/README.md new file mode 100644 index 0000000..91a130f --- /dev/null +++ b/demo/violations/dist2-vg004-006/README.md @@ -0,0 +1,15 @@ +# Dist 2: VG004-VG006 + +This demo bundle intentionally triggers: + +- VG004 (unbounded select) +- VG005 (LIKE with leading wildcard) +- VG006 (`SELECT ... FOR UPDATE` without `WHERE`) + +Coverage in this bundle: + +- SQL files +- Go `database/sql` +- Goqu +- Python ORM +- Python non-ORM (`session.execute(text(...))`) diff --git a/demo/violations/dist2-vg004-006/go/goqu_queries.go b/demo/violations/dist2-vg004-006/go/goqu_queries.go new file mode 100644 index 0000000..da871f5 --- /dev/null +++ b/demo/violations/dist2-vg004-006/go/goqu_queries.go @@ -0,0 +1,9 @@ +package demo + +import goqulib "github.com/doug-martin/goqu/v9" + +func GoquViolations() { + _ = goqulib.L("SELECT id, email FROM users WHERE active = true") + _ = goqulib.L("SELECT id FROM users WHERE email LIKE '%@example.com' LIMIT 1") + _ = goqulib.L("SELECT id FROM users FOR UPDATE") +} diff --git a/demo/violations/dist2-vg004-006/go/std_queries.go b/demo/violations/dist2-vg004-006/go/std_queries.go new file mode 100644 index 0000000..1175117 --- /dev/null +++ b/demo/violations/dist2-vg004-006/go/std_queries.go @@ -0,0 +1,13 @@ +package demo + +import ( + "context" + "database/sql" +) + +func StdViolations(db *sql.DB) { + ctx := context.Background() + _, _ = db.QueryContext(ctx, "SELECT id, email FROM users WHERE active = true") + _, _ = db.QueryContext(ctx, "SELECT id FROM users WHERE email LIKE '%@example.com' LIMIT 1") + _, _ = db.QueryContext(ctx, "SELECT id FROM users FOR UPDATE") +} diff --git a/demo/violations/dist2-vg004-006/python/orm_queries.py b/demo/violations/dist2-vg004-006/python/orm_queries.py new file mode 100644 index 0000000..0c8d48f --- /dev/null +++ b/demo/violations/dist2-vg004-006/python/orm_queries.py @@ -0,0 +1,16 @@ +from sqlalchemy import text +from sqlalchemy.orm import Session + +from models import User + + +def orm_unbounded_select(session: Session): + return session.query(User.id, User.email).filter(User.active.is_(True)).all() + + +def orm_like_leading_wildcard(session: Session): + return session.query(User.id).filter(User.email.like("%@example.com")).limit(1).all() + + +def orm_select_for_update_no_where(session: Session): + return session.execute(text("SELECT id FROM users FOR UPDATE")).all() diff --git a/demo/violations/dist2-vg004-006/python/raw_queries.py b/demo/violations/dist2-vg004-006/python/raw_queries.py new file mode 100644 index 0000000..0512224 --- /dev/null +++ b/demo/violations/dist2-vg004-006/python/raw_queries.py @@ -0,0 +1,16 @@ +from sqlalchemy import text +from sqlalchemy.orm import Session + + +def raw_unbounded_select(session: Session): + return session.execute(text("SELECT id, email FROM users WHERE active = true")).all() + + +def raw_like_leading_wildcard(session: Session): + return session.execute( + text("SELECT id FROM users WHERE email LIKE '%@example.com' LIMIT 1") + ).all() + + +def raw_select_for_update_no_where(session: Session): + return session.execute(text("SELECT id FROM users FOR UPDATE")).all() diff --git a/demo/violations/dist2-vg004-006/sql/vg004_unbounded_select.sql b/demo/violations/dist2-vg004-006/sql/vg004_unbounded_select.sql new file mode 100644 index 0000000..ad8e219 --- /dev/null +++ b/demo/violations/dist2-vg004-006/sql/vg004_unbounded_select.sql @@ -0,0 +1 @@ +SELECT id, email FROM users WHERE active = true; diff --git a/demo/violations/dist2-vg004-006/sql/vg005_like_leading_wildcard.sql b/demo/violations/dist2-vg004-006/sql/vg005_like_leading_wildcard.sql new file mode 100644 index 0000000..01bef22 --- /dev/null +++ b/demo/violations/dist2-vg004-006/sql/vg005_like_leading_wildcard.sql @@ -0,0 +1 @@ +SELECT id FROM users WHERE email LIKE '%@example.com' LIMIT 1; diff --git a/demo/violations/dist2-vg004-006/sql/vg006_select_for_update_no_where.sql b/demo/violations/dist2-vg004-006/sql/vg006_select_for_update_no_where.sql new file mode 100644 index 0000000..23f8188 --- /dev/null +++ b/demo/violations/dist2-vg004-006/sql/vg006_select_for_update_no_where.sql @@ -0,0 +1 @@ +SELECT id FROM users FOR UPDATE;