Skip to content

demo: C# EF Core VG001-VG003#10

Open
eitamring wants to merge 1 commit into
mainfrom
demo/csharp-vg001-003
Open

demo: C# EF Core VG001-VG003#10
eitamring wants to merge 1 commit into
mainfrom
demo/csharp-vg001-003

Conversation

@eitamring
Copy link
Copy Markdown
Contributor

Purpose

This PR adds a C# EF Core demo branch that mirrors the existing SQL/Go/Python rule-triggering PRs.

Expected Findings In This PR

  • VG001 (select-star): expected on SELECT * FROM users LIMIT 1.
  • VG002 (missing-where-update): expected on UPDATE users SET active = false.
  • VG003 (missing-where-delete): expected on DELETE FROM orders.

These are intentional violations to prove C# scanner and inline review comment behavior.

Workflow Updates

  • Bump VALK_GUARD_INSTALL_REF to v0.1.5, which includes the C# scanner stdout-noise fix.
  • Add actions/setup-dotnet so the C# scanner can run in CI.
  • Include **/*.cs in changed-file detection.

Local Verification

PATH=/tmp/valk-dotnet-bin:$PATH go run github.com/valkdb/valk-guard/cmd/valk-guard@v0.1.5 scan demo/violations/csharp-vg001-003/csharp/efcore_queries.cs --config .valk-guard.yaml --format rdjsonl

Result: exactly 3 diagnostics: VG001, VG002, and VG003.

{
public void RawSqlViolations(DbContext db)
{
db.Database.ExecuteSqlRaw("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

public void RawSqlViolations(DbContext db)
{
db.Database.ExecuteSqlRaw("SELECT * FROM users LIMIT 1");
db.Database.ExecuteSqlRaw("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.Database.ExecuteSqlRaw("SELECT * FROM users LIMIT 1");
db.Database.ExecuteSqlRaw("UPDATE users SET active = false");
db.Database.ExecuteSqlRaw("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

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.

1 participant