You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(examples): any text reaches the mongo stock filter as a sku (CodeQL go/sql-injection) #255
CodeQL (go/sql-injection) flags the MongoDB stock datastores: the sku from the request goes straight into the filter.
alert 9 and 10: examples/stock/internal/pkg/datastore/stock/mongodb/datastore.go (new in the 1.7.0 release PR release: 1.7.0 #254)
alert 5: docs/site/example/shop/internal/pkg/datastore/stock/mongodb/datastore.go (already on main)
In Go the sku is a string, so Mongo never reads it as an operator: no real injection. Still, the example app takes any text as a sku ($gt, spaces, empty) and sends it to the datastore.
Intended behavior:
examples/stock: a sku outside [a-z0-9-] (1 to 64 chars) is rejected as Bad Request / InvalidArgument at every door, before any datastore.
both mongodb datastores match the sku with an explicit $eq.
the three alerts are dismissed as false positive, pointing to this issue.
Merged in #258 (935ea02): RED first in examples/stock/cmd/api/main_test.go (400/InvalidArgument/tool error for $gt, upper case, space, 65 chars; the app answered 201/200/404), then entity.ValidSKU in the creator/finder/reserver services and $eq in both mongo datastores (README + site too). go test ./... green in examples/stock and the site shop; TestAPIMongo green on mongo:7. Next: dismiss CodeQL alerts 5, 9, 10 as false positive.
Activity
Merge pull request #258 from xgodev/bugfix/255-sku-filter
jpfaria commentedon Oct 20, 2026
Merged in #258 (935ea02): RED first in examples/stock/cmd/api/main_test.go (400/InvalidArgument/tool error for
$gt, upper case, space, 65 chars; the app answered 201/200/404), thenentity.ValidSKUin the creator/finder/reserver services and$eqin both mongo datastores (README + site too). go test ./... green in examples/stock and the site shop; TestAPIMongo green on mongo:7. Next: dismiss CodeQL alerts 5, 9, 10 as false positive.