Beispiel
Show that casting user-supplied `:lock_version` can redefine the optimistic-lock filter before `Repo` write-time checks, even without a database.
sha256:1e2a19ac37ba6adfa3f491b086bfc7d9a193727d9a750b88d8379b12a21249fb
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Ausführungsbelege
Deklarierte Umgebung und signierte Prüfläufe werden getrennt dargestellt.
BeleggrundlageSignierter Vertrag bestanden
Verifizierungsbelege1
VerifizierungsstufeL3_CONTRACT_PASS
Deklarierte Umgebung
- Ausführungskontext
- elixir
- Betriebssystem
- linux
- Architektur
- x64
- Runtime
- elixir
- Sprache
- elixir
- Paketmanager
- mix
Umgebungen der Verifizierungsläufe
- Ausführungskontext
- elixir 1
- Betriebssystem
- linux alpine · musl
- Architektur
- x64
- Runtime
- elixir 1
- Sprache
- elixir
- Paketmanager
- mix
- Ausführung
- container · docker
CONTAINER_RUN · compile:PASS · contract:PASS · load:PASS · resolve:PASS · hex@1 · 2026-08-17
Fall
- Ziel
- Show that casting user-supplied `:lock_version` can redefine the optimistic-lock filter before `Repo` write-time checks, even without a database. HOW
- Pakete
-
ecto 3.14.1
- Umgebung
- elixir
- Erstellt
- 2026-08-17T04:43:50Z
Häufige Annahme
A competent Ecto user expects `optimistic_lock/2` to protect updates using the row's current stored `:lock_version`, and that unsafely cast `:lock_version` params cannot influence the value used in the conflict check.
So hat der Autor des Samples festgehalten, was eine Entwicklerin oder ein Modell hier erwarten würde. Der Vertrag darunter ist das, was tatsächlich lief.
Contract
- When `:lock_version` is not cast, `optimistic_lock/2` keeps the filter at the struct value, but once `:lock_version` is allowed in `cast/3`, `optimistic_lock/2` switches the filter to that user-supplied value, so checks can run against a client-controlled token.
- After `optimistic_lock/2`, a casted `:lock_version` value is still bumped in place, so `get_change/3` and `apply_changes/1` reflect an incremented counter even though no Repo is involved.
Dateien
- NOTES.md
- csx.json
- mix.exs
- mix.lock
- test/contract.exs
Quellartefakt herunterladen (tar.gz)
Ursprungs-Seeder
csx-seed
Verifizierungsbelege
- elixir 1 · linux alpine/x64 · docker · CONTAINER_RUN · compile:PASS · contract:PASS · load:PASS · resolve:PASS · hex@1 · 2026-08-17 · ed25519:d91480838ac982c9