Skip to content

Commit

Permalink
Stringmatcher: rename StringMatcherImplWithContext
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Greenway <[email protected]>
  • Loading branch information
ggreenway committed Mar 22, 2024
1 parent b68af06 commit 1403fa0
Show file tree
Hide file tree
Showing 29 changed files with 101 additions and 143 deletions.
2 changes: 1 addition & 1 deletion contrib/generic_proxy/filters/network/source/match.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ REGISTER_FACTORY(PropertyMatchDataInputFactory, Matcher::DataInputFactory<Reques

REGISTER_FACTORY(RequestMatchDataInputFactory, Matcher::DataInputFactory<Request>);

using StringMatcherImpl = Matchers::StringMatcherImplWithContext<StringMatcherProto>;
using StringMatcherImpl = Matchers::StringMatcherImpl<StringMatcherProto>;

RequestMatchInputMatcher::RequestMatchInputMatcher(
const RequestMatcherProto& proto_config, Server::Configuration::CommonFactoryContext& context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RouteEntryImpl : public RouteEntry,
private:
bool headersMatch(const Http::HeaderMap& headers) const;

const Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher> topic_name_;
const Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher> topic_name_;
const std::string cluster_name_;
const std::vector<Http::HeaderUtility::HeaderDataPtr> config_headers_;
Envoy::Router::MetadataMatchCriteriaConstPtr metadata_match_criteria_;
Expand Down
6 changes: 2 additions & 4 deletions source/common/common/matchers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ ValueMatcher::create(const envoy::type::matcher::v3::ValueMatcher& v,
case envoy::type::matcher::v3::ValueMatcher::MatchPatternCase::kDoubleMatch:
return std::make_shared<const DoubleMatcher>(v.double_match());
case envoy::type::matcher::v3::ValueMatcher::MatchPatternCase::kStringMatch:
return std::make_shared<
const StringMatcherImplWithContext<std::decay_t<decltype(v.string_match())>>>(
return std::make_shared<const StringMatcherImpl<std::decay_t<decltype(v.string_match())>>>(
v.string_match(), context);
case envoy::type::matcher::v3::ValueMatcher::MatchPatternCase::kBoolMatch:
return std::make_shared<const BoolMatcher>(v.bool_match());
Expand Down Expand Up @@ -128,8 +127,7 @@ StringMatcherPtr valueMatcherFromProto(const envoy::type::matcher::v3::FilterSta
Server::Configuration::CommonFactoryContext& context) {
switch (matcher.matcher_case()) {
case envoy::type::matcher::v3::FilterStateMatcher::MatcherCase::kStringMatch:
return std::make_unique<
const StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
return std::make_unique<const StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
matcher.string_match(), context);
break;
default:
Expand Down
10 changes: 5 additions & 5 deletions source/common/common/matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ StringMatcherPtr getExtensionStringMatcher(const ::xds::core::v3::TypedExtension
Server::Configuration::CommonFactoryContext& context);

template <class StringMatcherType = envoy::type::matcher::v3::StringMatcher>
class StringMatcherImplWithContext : public ValueMatcher, public StringMatcher {
class StringMatcherImpl : public ValueMatcher, public StringMatcher {
public:
explicit StringMatcherImplWithContext(const StringMatcherType& matcher,
Server::Configuration::CommonFactoryContext& context)
explicit StringMatcherImpl(const StringMatcherType& matcher,
Server::Configuration::CommonFactoryContext& context)
: matcher_(matcher) {
if (matcher.match_pattern_case() == StringMatcherType::MatchPatternCase::kSafeRegex) {
if (matcher.ignore_case()) {
Expand Down Expand Up @@ -263,12 +263,12 @@ class PathMatcher : public StringMatcher {
Server::Configuration::CommonFactoryContext& context);

bool match(const absl::string_view path) const override;
const StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>& matcher() const {
const StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>& matcher() const {
return matcher_;
}

private:
const StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher> matcher_;
const StringMatcherImpl<envoy::type::matcher::v3::StringMatcher> matcher_;
};

} // namespace Matchers
Expand Down
6 changes: 3 additions & 3 deletions source/common/http/header_utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ HeaderUtility::HeaderData::HeaderData(const envoy::config::route::v3::HeaderMatc
break;
case envoy::config::route::v3::HeaderMatcher::HeaderMatchSpecifierCase::kStringMatch:
header_match_type_ = HeaderMatchType::StringMatch;
string_match_ = std::make_unique<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
config.string_match(), factory_context);
string_match_ =
std::make_unique<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
config.string_match(), factory_context);
break;
case envoy::config::route::v3::HeaderMatcher::HeaderMatchSpecifierCase::
HEADER_MATCH_SPECIFIER_NOT_SET:
Expand Down
2 changes: 1 addition & 1 deletion source/common/matcher/value_input_matcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class StringInputMatcher : public InputMatcher, Logger::Loggable<Logger::Id::mat
}

private:
const Matchers::StringMatcherImplWithContext<StringMatcherType> matcher_;
const Matchers::StringMatcherImpl<StringMatcherType> matcher_;
};

} // namespace Matcher
Expand Down
3 changes: 1 addition & 2 deletions source/common/router/config_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ template <class ProtoType> class CorsPolicyImplBase : public CorsPolicy {
max_age_(config.max_age()) {
for (const auto& string_match : config.allow_origin_string_match()) {
allow_origins_.push_back(
std::make_unique<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
std::make_unique<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
string_match, factory_context));
}
if (config.has_allow_credentials()) {
Expand Down
4 changes: 2 additions & 2 deletions source/common/router/config_utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ namespace Envoy {
namespace Router {
namespace {

absl::optional<Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>
absl::optional<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>
maybeCreateStringMatcher(const envoy::config::route::v3::QueryParameterMatcher& config,
Server::Configuration::CommonFactoryContext& context) {
switch (config.query_parameter_match_specifier_case()) {
case envoy::config::route::v3::QueryParameterMatcher::QueryParameterMatchSpecifierCase::
kStringMatch:
return Matchers::StringMatcherImplWithContext(config.string_match(), context);
return Matchers::StringMatcherImpl(config.string_match(), context);
case envoy::config::route::v3::QueryParameterMatcher::QueryParameterMatchSpecifierCase::
kPresentMatch:
return absl::nullopt;
Expand Down
3 changes: 1 addition & 2 deletions source/common/router/config_utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class ConfigUtility {

private:
const std::string name_;
const absl::optional<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>
const absl::optional<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>
matcher_;
};

Expand Down
7 changes: 3 additions & 4 deletions source/common/stats/histogram_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@ HistogramSettingsImpl::HistogramSettingsImpl(const envoy::config::metrics::v3::S
for (const auto& matcher : config.histogram_bucket_settings()) {
std::vector<double> buckets{matcher.buckets().begin(), matcher.buckets().end()};
std::sort(buckets.begin(), buckets.end());
configs.emplace_back(
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>(
matcher.match(), context),
std::move(buckets));
configs.emplace_back(Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>(
matcher.match(), context),
std::move(buckets));
}

return configs;
Expand Down
5 changes: 2 additions & 3 deletions source/common/stats/histogram_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ class HistogramSettingsImpl : public HistogramSettings {
static ConstSupportedBuckets& defaultBuckets();

private:
using Config =
std::pair<Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>,
ConstSupportedBuckets>;
using Config = std::pair<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>,
ConstSupportedBuckets>;
const std::vector<Config> configs_{};
};

Expand Down
4 changes: 2 additions & 2 deletions source/common/stats/stats_matcher_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ StatsMatcherImpl::StatsMatcherImpl(const envoy::config::metrics::v3::StatsConfig
case envoy::config::metrics::v3::StatsMatcher::StatsMatcherCase::kInclusionList:
// If we have an inclusion list, we are being default-exclusive.
for (const auto& stats_matcher : config.stats_matcher().inclusion_list().patterns()) {
matchers_.push_back(Matchers::StringMatcherImplWithContext(stats_matcher, context));
matchers_.push_back(Matchers::StringMatcherImpl(stats_matcher, context));
optimizeLastMatcher();
}
is_inclusive_ = false;
break;
case envoy::config::metrics::v3::StatsMatcher::StatsMatcherCase::kExclusionList:
// If we have an exclusion list, we are being default-inclusive.
for (const auto& stats_matcher : config.stats_matcher().exclusion_list().patterns()) {
matchers_.push_back(Matchers::StringMatcherImplWithContext(stats_matcher, context));
matchers_.push_back(Matchers::StringMatcherImpl(stats_matcher, context));
optimizeLastMatcher();
}
FALLTHRU;
Expand Down
3 changes: 1 addition & 2 deletions source/common/stats/stats_matcher_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class StatsMatcherImpl : public StatsMatcher {
OptRef<SymbolTable> symbol_table_;
std::unique_ptr<StatNamePool> stat_name_pool_;

std::vector<Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>
matchers_;
std::vector<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>> matchers_;
std::vector<StatName> prefixes_;
};

Expand Down
2 changes: 1 addition & 1 deletion source/common/tls/cert_validator/san_matcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class StringSanMatcher : public SanMatcher {

private:
const int general_name_type_;
const Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher> matcher_;
const Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher> matcher_;
};

SanMatcherPtr createStringSanMatcher(
Expand Down
6 changes: 2 additions & 4 deletions source/extensions/common/aws/signer_base_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ class SignerBaseImpl : public Signer, public Logger::Loggable<Logger::Id::aws> {
short_date_formatter_(std::string(SignatureConstants::ShortDateFormat)) {
for (const auto& matcher : matcher_config) {
excluded_header_matchers_.emplace_back(
std::make_unique<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
std::make_unique<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
matcher, context));
}
}
Expand Down Expand Up @@ -139,8 +138,7 @@ class SignerBaseImpl : public Signer, public Logger::Loggable<Logger::Id::aws> {
envoy::type::matcher::v3::StringMatcher m;
m.set_exact(header);
matcher_ptrs.emplace_back(
std::make_unique<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
std::make_unique<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
m, context));
}
return matcher_ptrs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ CheckRequestUtils::toRequestMatchers(const envoy::type::matcher::v3::ListStringM
envoy::type::matcher::v3::StringMatcher matcher;
matcher.set_exact(key.get());
matchers.push_back(
std::make_unique<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
std::make_unique<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
matcher, context));
}
}
Expand All @@ -275,8 +274,7 @@ CheckRequestUtils::createStringMatchers(const envoy::type::matcher::v3::ListStri
std::vector<Matchers::StringMatcherPtr> matchers;
for (const auto& matcher : list.patterns()) {
matchers.push_back(
std::make_unique<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
std::make_unique<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
matcher, context));
}
return matchers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ ClientConfig::toClientMatchers(const envoy::type::matcher::v3::ListStringMatcher
envoy::type::matcher::v3::StringMatcher matcher;
matcher.set_exact(Http::Headers::get().Host.get());
matchers.push_back(
std::make_unique<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
std::make_unique<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
matcher, context));

return std::make_shared<NotHeaderKeyMatcher>(std::move(matchers));
Expand All @@ -169,8 +168,7 @@ ClientConfig::toClientMatchers(const envoy::type::matcher::v3::ListStringMatcher
envoy::type::matcher::v3::StringMatcher matcher;
matcher.set_exact(key.get());
matchers.push_back(
std::make_unique<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
std::make_unique<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
matcher, context));
}

Expand Down
12 changes: 6 additions & 6 deletions source/extensions/filters/common/rbac/matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@ class AuthenticatedMatcher : public Matcher {
AuthenticatedMatcher(const envoy::config::rbac::v3::Principal::Authenticated& auth,
Server::Configuration::CommonFactoryContext& context)
: matcher_(auth.has_principal_name()
? absl::make_optional<Matchers::StringMatcherImplWithContext<
envoy::type::matcher::v3::StringMatcher>>(auth.principal_name(), context)
? absl::make_optional<
Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
auth.principal_name(), context)
: absl::nullopt) {}

bool matches(const Network::Connection& connection, const Envoy::Http::RequestHeaderMap& headers,
const StreamInfo::StreamInfo&) const override;

private:
const absl::optional<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>
const absl::optional<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>
matcher_;
};

Expand Down Expand Up @@ -274,11 +274,11 @@ class FilterStateMatcher : public Matcher {
*/
class RequestedServerNameMatcher
: public Matcher,
Envoy::Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher> {
Envoy::Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher> {
public:
RequestedServerNameMatcher(const envoy::type::matcher::v3::StringMatcher& requested_server_name,
Server::Configuration::CommonFactoryContext& context)
: Envoy::Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>(
: Envoy::Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>(
requested_server_name, context) {}

bool matches(const Network::Connection& connection, const Envoy::Http::RequestHeaderMap& headers,
Expand Down
3 changes: 1 addition & 2 deletions source/extensions/filters/http/cache/cache_headers_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ VaryAllowList::VaryAllowList(

for (const auto& rule : allow_list) {
allow_list_.emplace_back(
std::make_unique<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
std::make_unique<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
rule, context));
}
}
Expand Down
3 changes: 1 addition & 2 deletions source/extensions/filters/http/csrf/csrf_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class CsrfPolicy : public Router::RouteSpecificFilterConfig {
: policy_(policy), runtime_(context.runtime()) {
for (const auto& additional_origin : policy.additional_origins()) {
additional_origins_.emplace_back(
std::make_unique<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
std::make_unique<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
additional_origin, context));
}
}
Expand Down
3 changes: 1 addition & 2 deletions source/extensions/filters/http/ext_proc/matching_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ initHeaderMatchers(const envoy::type::matcher::v3::ListStringMatcher& header_lis
std::vector<Matchers::StringMatcherPtr> header_matchers;
for (const auto& matcher : header_list.patterns()) {
header_matchers.push_back(
std::make_unique<
Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>(
std::make_unique<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>(
matcher, context));
}
return header_matchers;
Expand Down
3 changes: 1 addition & 2 deletions source/extensions/filters/http/jwt_authn/jwks_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ class JwksDataImpl : public JwksCache::JwksData, public Logger::Loggable<Logger:
ThreadLocal::TypedSlot<ThreadLocalCache> tls_;
// async fetcher
JwksAsyncFetcherPtr async_fetcher_;
absl::optional<Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>
sub_matcher_;
absl::optional<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>> sub_matcher_;
absl::optional<absl::Duration> max_exp_;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ class MethodRouteEntryImpl : public RouteEntryImplBase {
uint64_t random_value) const override;

private:
const Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>
method_name_;
const Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher> method_name_;
std::shared_ptr<ParameterRouteEntryImpl> parameter_route_;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class HttpHealthCheckerImpl : public HealthCheckerImplBase {
PayloadMatcher::MatchSegments receive_bytes_;
const envoy::config::core::v3::RequestMethod method_;
uint64_t response_buffer_size_;
absl::optional<Matchers::StringMatcherImplWithContext<envoy::type::matcher::v3::StringMatcher>>
absl::optional<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>
service_name_matcher_;
Router::HeaderParserPtr request_headers_parser_;
const HttpStatusChecker http_status_checker_;
Expand Down
Loading

0 comments on commit 1403fa0

Please sign in to comment.