fsouza / fake-gcs-server

Google Cloud Storage emulator & testing library.
https://pkg.go.dev/github.com/fsouza/fake-gcs-server/fakestorage?tab=doc
BSD 2-Clause "Simplified" License
1.07k stars 210 forks source link

Delete object doesn't check conditions #1282

Open yvrhdn opened 1 year ago

yvrhdn commented 1 year ago

Hi, thanks for this project, it's been really helpful for us!

I noticed that conditions are not checked when you delete an object. When we create or update objects conditions work as expected.

I'm sending a request with an invalid version 123:

DELETE /storage/v1/b/tempo/o/overrides%2Fsingle-tenant%2Foverrides.json?alt=json&ifGenerationMatch=123&prettyPrint=false

This request should fail but it succeeds with a 200 and deletes the object.


Digging through the code it seems storageFS.DeleteObject does not pass in conditions: https://github.com/fsouza/fake-gcs-server/blob/4f6952135e326fadb87a3d090a24b9d4b2e219aa/internal/backend/fs.go#L379-L391

Would the solution be as simple as passing in the Conditions and checking them like you do in CreateObject? https://github.com/fsouza/fake-gcs-server/blob/4f6952135e326fadb87a3d090a24b9d4b2e219aa/internal/backend/fs.go#L199

noamshvacher commented 4 months ago

@fsouza Hi, are there any updates on that?