Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
15 changes: 15 additions & 0 deletions demo/violations/dist1-vg001-003/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Dist 1: VG001-VG003

This demo bundle intentionally triggers:

- VG001 (`SELECT *`)
- VG002 (`UPDATE` without `WHERE`)
- VG003 (`DELETE` without `WHERE`)

Coverage in this bundle:

- SQL files
- Go `database/sql`
- Goqu
- Python ORM
- Python non-ORM (`session.execute(text(...))`)
9 changes: 9 additions & 0 deletions demo/violations/dist1-vg001-003/go/goqu_queries.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package demo

import goqulib "github.com/doug-martin/goqu/v9"

func GoquViolations() {
_ = goqulib.L("SELECT * FROM users LIMIT 1")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [valk-guard] reported by reviewdog 🐶
VG001: avoid SELECT *; project only required columns | Query: SELECT * FROM users LIMIT 1

_ = goqulib.L("UPDATE users SET active = false")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [valk-guard] reported by reviewdog 🐶
VG002: UPDATE without WHERE may affect all rows; add a WHERE clause | Query: UPDATE users SET active = false

_ = goqulib.L("DELETE FROM orders")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [valk-guard] reported by reviewdog 🐶
VG003: DELETE without WHERE may affect all rows; add a WHERE clause | Query: DELETE FROM orders

}
13 changes: 13 additions & 0 deletions demo/violations/dist1-vg001-003/go/std_queries.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package demo

import (
"context"
"database/sql"
)

func StdViolations(db *sql.DB) {
ctx := context.Background()
_, _ = db.QueryContext(ctx, "SELECT * FROM users LIMIT 1")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [valk-guard] reported by reviewdog 🐶
VG001: avoid SELECT *; project only required columns | Query: SELECT * FROM users LIMIT 1

_, _ = db.ExecContext(ctx, "UPDATE users SET active = false")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [valk-guard] reported by reviewdog 🐶
VG002: UPDATE without WHERE may affect all rows; add a WHERE clause | Query: UPDATE users SET active = false

_, _ = db.ExecContext(ctx, "DELETE FROM orders")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [valk-guard] reported by reviewdog 🐶
VG003: DELETE without WHERE may affect all rows; add a WHERE clause | Query: DELETE FROM orders

}
15 changes: 15 additions & 0 deletions demo/violations/dist1-vg001-003/python/orm_queries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from sqlalchemy.orm import Session

from models import Order, User


def orm_recent_user(session: Session):
return session.query(User.id, User.email).filter(User.active.is_(True)).limit(1).all()


def orm_update_without_where(session: Session):
return session.query(User).update({"active": False})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [valk-guard] reported by reviewdog 🐶
VG002: UPDATE without WHERE may affect all rows; add a WHERE clause | Origin: SQLAlchemy query builder | Query: UPDATE "User" SET synthetic_col = 1



def orm_delete_without_where(session: Session):
return session.query(Order).delete()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [valk-guard] reported by reviewdog 🐶
VG003: DELETE without WHERE may affect all rows; add a WHERE clause | Origin: SQLAlchemy query builder | Query: DELETE FROM "Order"

14 changes: 14 additions & 0 deletions demo/violations/dist1-vg001-003/python/raw_queries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from sqlalchemy import text
from sqlalchemy.orm import Session


def raw_select_star(session: Session):
return session.execute(text("SELECT * FROM users LIMIT 1")).first()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [valk-guard] reported by reviewdog 🐶
VG001: avoid SELECT *; project only required columns | Query: SELECT * FROM users LIMIT 1



def raw_update_without_where(session: Session):
return session.execute(text("UPDATE users SET active = false"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [valk-guard] reported by reviewdog 🐶
VG002: UPDATE without WHERE may affect all rows; add a WHERE clause | Query: UPDATE users SET active = false



def raw_delete_without_where(session: Session):
return session.execute(text("DELETE FROM orders"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [valk-guard] reported by reviewdog 🐶
VG003: DELETE without WHERE may affect all rows; add a WHERE clause | Query: DELETE FROM orders

1 change: 1 addition & 0 deletions demo/violations/dist1-vg001-003/sql/vg001_select_star.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM users LIMIT 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [valk-guard] reported by reviewdog 🐶
VG001: avoid SELECT *; project only required columns | Query: SELECT * FROM users LIMIT 1

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE users SET active = false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [valk-guard] reported by reviewdog 🐶
VG002: UPDATE without WHERE may affect all rows; add a WHERE clause | Query: UPDATE users SET active = false

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM orders;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [valk-guard] reported by reviewdog 🐶
VG003: DELETE without WHERE may affect all rows; add a WHERE clause | Query: DELETE FROM orders