Skip to content

Commit 51b37ba

Browse files
Will Wangmeta-codesync[bot]
authored andcommitted
Add Validation Check 2/n: Add Filter Assertion on Writebackfilter
Summary: ## Summary Add an XCHECK assertion to prevent two WritebackFilters from being registered consecutively in `HTTPTransactionHandlerFilterSeries`. This is a defensive measure to prevent bugs like SEV S570156, where two `CacheRuleResponse` rules used back-to-back in a request handler caused response corruption. https://fb.workplace.com/groups/proxygendevelopers/permalink/3748394398801257/ Differential Revision: D89745261 fbshipit-source-id: a67c314b0e148cacc99bc32707ba117d4a25cb31
1 parent f88927b commit 51b37ba

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

third-party/proxygen/src/proxygen/lib/http/test/MockHTTPMessageFilter.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <gmock/gmock.h>
1212

13+
#include "proxygen/facebook/revproxy/caching/filter/FilterNames.h"
1314
#include <proxygen/lib/http/HTTPMessageFilters.h>
1415

1516
namespace proxygen {
@@ -111,4 +112,17 @@ class MockHTTPMessageFilter : public HTTPMessageFilter {
111112
std::shared_ptr<const HTTPHeaders> requestTrailersCopy_;
112113
};
113114

115+
// A mock filter that returns kWritebackFilterName for testing
116+
// the consecutive WritebackFilter check.
117+
class MockWritebackFilter : public HTTPMessageFilter {
118+
public:
119+
[[nodiscard]] std::string_view getFilterName() const noexcept override {
120+
return filter::kWritebackFilterName;
121+
}
122+
123+
[[noreturn]] std::unique_ptr<HTTPMessageFilter> clone() noexcept override {
124+
LOG(FATAL) << "clone() not implemented for MockWritebackFilter";
125+
}
126+
};
127+
114128
} // namespace proxygen

0 commit comments

Comments
 (0)