From 123f6f5a4f602156ed29b771f1a7432b69101d90 Mon Sep 17 00:00:00 2001 From: Clay Gerrard Date: Thu, 13 Sep 2018 16:42:49 -0500 Subject: [PATCH] Allow EC to ignore invalid request ETag ... as long as the correct ETag is sent in the footers. This would be relevant to encryption except our middleware pops the client provided plaintext ETag before passing the request onto the proxy app. Change-Id: Ie60d1723a0d610e8dab0fd70a3a768c38ce12a85 --- swift/proxy/controllers/obj.py | 14 ++++---------- test/unit/proxy/controllers/test_obj.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index 5c6948c242..bdd044eac5 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -2643,19 +2643,13 @@ class ECObjectController(BaseObjectController): self.app.logger.increment('client_disconnects') raise HTTPClientDisconnect(request=req) - computed_etag = (etag_hasher.hexdigest() - if etag_hasher else None) - received_etag = req.headers.get( - 'etag', '').strip('"') - if (computed_etag and received_etag and - computed_etag != received_etag): - raise HTTPUnprocessableEntity(request=req) - send_chunk('') # flush out any buffered data + computed_etag = (etag_hasher.hexdigest() + if etag_hasher else None) footers = self._get_footers(req) - received_etag = footers.get( - 'etag', '').strip('"') + received_etag = footers.get('etag', req.headers.get( + 'etag', '')).strip('"') if (computed_etag and received_etag and computed_etag != received_etag): raise HTTPUnprocessableEntity(request=req) diff --git a/test/unit/proxy/controllers/test_obj.py b/test/unit/proxy/controllers/test_obj.py index 78b2e95aa8..25dbc44b64 100644 --- a/test/unit/proxy/controllers/test_obj.py +++ b/test/unit/proxy/controllers/test_obj.py @@ -4349,6 +4349,17 @@ class TestECObjControllerMimePutter(BaseObjectControllerMixin, for conn in conns: self.assertTrue(conn.closed) + # make the footers callback send the correct etag + footers_callback = make_footers_callback(test_body) + env = {'swift.callback.update_footers': footers_callback} + headers = {'Etag': 'bad etag'} + req = swift.common.swob.Request.blank( + '/v1/a/c/o', method='PUT', headers=headers, environ=env, + body=test_body) + with set_http_connect(*codes, expect_headers=self.expect_headers): + resp = req.get_response(self.app) + self.assertEqual(201, resp.status_int) + # make the footers callback send a bad Etag footer footers_callback = make_footers_callback('not the test body') env = {'swift.callback.update_footers': footers_callback}