Sample
gorm.io/gorm v1.31.2: Keep a tenant scope from being bypassed by an ungrouped Or while inspecting GORM DryRun SQL
Verified sample for golang gorm.io/gorm v1.31.2: Keep a tenant scope from being bypassed by an ungrouped Or while inspecting GORM DryRun SQL. The contract…
sha256:9ff4648d7bd88a17effda2a1b227607fcfea1c19d4ce72eebc4868f0dd20406e
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 2
- Signing keys that built it
- 2
Declared environment
go 1.26 linux x64 go 1.26 go go
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1 |
2026-08-17 |
| go 1.26 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1 |
2026-08-18 |
Case
HOW- Goal
- Keep a tenant scope from being bypassed by an ungrouped Or while inspecting GORM DryRun SQL
- Symbols
-
- gorm.Open
- sqlite.New
- gorm.Config.DryRun
- gorm.Config.DisableAutomaticPing
- DB.Scopes
- DB.Where
- DB.Or
- DB.Find
- Environment
- go 1.26
- Created
- 2026-08-17T01:32:02Z
Contract
- assert Scopes(Tenant(7)).Where("active = ?", true).Or("role = ?", "admin") generates WHERE active = ? OR role = ? AND tenant_id = ?, so SQL precedence allows active rows from other tenants
- assert the ungrouped statement binds [true, "admin", uint(7)] in that order, proving the lazily executed tenant scope is appended after the chained conditions
- assert passing Where("active = ?", true).Or("role = ?", "admin") as one nested Where condition generates WHERE (active = ? OR role = ?) AND tenant_id = ? with the same bind values
- assert DryRun Find executes no SQL against database/sql; only the official SQLite dialector's required select sqlite_version() initialization probe reaches the in-process stub
Files
- NOTES.md
- csx.json
- go.mod
- go.sum
- scope.go
- scope_test.go