Skip to content

Commit 520389e

Browse files
authored
tap: factor out the TAP filter matcher for later reuse in other filters (#12429)
This is the 1st PR for #11832 that factors out the TAP filter matcher to prepare for reuse in other filters. Signed-off-by: Yangmin Zhu <[email protected]>
1 parent 0d74a8b commit 520389e

File tree

37 files changed

+756
-122
lines changed

37 files changed

+756
-122
lines changed

CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ extensions/filters/common/original_src @snowp @klarose
8080
/*/extensions/filters/common/expr @kyessenov @yangminzhu @lizan
8181
# webassembly common extension
8282
/*/extensions/common/wasm @jplevyak @PiotrSikora @lizan
83+
# common matcher
84+
/*/extensions/common/matcher @mattklein123 @yangminzhu
8385
# common crypto extension
8486
/*/extensions/common/crypto @lizan @PiotrSikora @bdecoste
8587
/*/extensions/common/proxy_protocol @alyssawilk @wez470

api/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ proto_library(
130130
"//envoy/config/accesslog/v3:pkg",
131131
"//envoy/config/bootstrap/v3:pkg",
132132
"//envoy/config/cluster/v3:pkg",
133+
"//envoy/config/common/matcher/v3:pkg",
133134
"//envoy/config/core/v3:pkg",
134135
"//envoy/config/endpoint/v3:pkg",
135136
"//envoy/config/filter/thrift/router/v2alpha1:pkg",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# DO NOT EDIT. This file is generated by tools/proto_sync.py.
2+
3+
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")
4+
5+
licenses(["notice"]) # Apache 2
6+
7+
api_proto_package(
8+
deps = [
9+
"//envoy/config/route/v3:pkg",
10+
"@com_github_cncf_udpa//udpa/annotations:pkg",
11+
],
12+
)
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
syntax = "proto3";
2+
3+
package envoy.config.common.matcher.v3;
4+
5+
import "envoy/config/route/v3/route_components.proto";
6+
7+
import "udpa/annotations/migrate.proto";
8+
import "udpa/annotations/status.proto";
9+
import "udpa/annotations/versioning.proto";
10+
import "validate/validate.proto";
11+
12+
option java_package = "io.envoyproxy.envoy.config.common.matcher.v3";
13+
option java_outer_classname = "MatcherProto";
14+
option java_multiple_files = true;
15+
option (udpa.annotations.file_status).package_version_status = ACTIVE;
16+
17+
// [#protodoc-title: Unified Matcher API]
18+
19+
// Match configuration. This is a recursive structure which allows complex nested match
20+
// configurations to be built using various logical operators.
21+
// [#next-free-field: 11]
22+
message MatchPredicate {
23+
// A set of match configurations used for logical operations.
24+
message MatchSet {
25+
// The list of rules that make up the set.
26+
repeated MatchPredicate rules = 1 [(validate.rules).repeated = {min_items: 2}];
27+
}
28+
29+
oneof rule {
30+
option (validate.required) = true;
31+
32+
// A set that describes a logical OR. If any member of the set matches, the match configuration
33+
// matches.
34+
MatchSet or_match = 1;
35+
36+
// A set that describes a logical AND. If all members of the set match, the match configuration
37+
// matches.
38+
MatchSet and_match = 2;
39+
40+
// A negation match. The match configuration will match if the negated match condition matches.
41+
MatchPredicate not_match = 3;
42+
43+
// The match configuration will always match.
44+
bool any_match = 4 [(validate.rules).bool = {const: true}];
45+
46+
// HTTP request headers match configuration.
47+
HttpHeadersMatch http_request_headers_match = 5;
48+
49+
// HTTP request trailers match configuration.
50+
HttpHeadersMatch http_request_trailers_match = 6;
51+
52+
// HTTP response headers match configuration.
53+
HttpHeadersMatch http_response_headers_match = 7;
54+
55+
// HTTP response trailers match configuration.
56+
HttpHeadersMatch http_response_trailers_match = 8;
57+
58+
// HTTP request generic body match configuration.
59+
HttpGenericBodyMatch http_request_generic_body_match = 9;
60+
61+
// HTTP response generic body match configuration.
62+
HttpGenericBodyMatch http_response_generic_body_match = 10;
63+
}
64+
}
65+
66+
// HTTP headers match configuration.
67+
message HttpHeadersMatch {
68+
// HTTP headers to match.
69+
repeated route.v3.HeaderMatcher headers = 1;
70+
}
71+
72+
// HTTP generic body match configuration.
73+
// List of text strings and hex strings to be located in HTTP body.
74+
// All specified strings must be found in the HTTP body for positive match.
75+
// The search may be limited to specified number of bytes from the body start.
76+
//
77+
// .. attention::
78+
//
79+
// Searching for patterns in HTTP body is potentially cpu intensive. For each specified pattern, http body is scanned byte by byte to find a match.
80+
// If multiple patterns are specified, the process is repeated for each pattern. If location of a pattern is known, ``bytes_limit`` should be specified
81+
// to scan only part of the http body.
82+
message HttpGenericBodyMatch {
83+
message GenericTextMatch {
84+
oneof rule {
85+
option (validate.required) = true;
86+
87+
// Text string to be located in HTTP body.
88+
string string_match = 1;
89+
90+
// Sequence of bytes to be located in HTTP body.
91+
bytes binary_match = 2;
92+
}
93+
}
94+
95+
// Limits search to specified number of bytes - default zero (no limit - match entire captured buffer).
96+
uint32 bytes_limit = 1;
97+
98+
// List of patterns to match.
99+
repeated GenericTextMatch patterns = 2 [(validate.rules).repeated = {min_items: 1}];
100+
}

api/envoy/config/common/matcher/v4alpha/BUILD

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/envoy/config/common/matcher/v4alpha/matcher.proto

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/envoy/config/tap/v3/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ licenses(["notice"]) # Apache 2
66

77
api_proto_package(
88
deps = [
9+
"//envoy/config/common/matcher/v3:pkg",
910
"//envoy/config/core/v3:pkg",
1011
"//envoy/config/route/v3:pkg",
1112
"//envoy/service/tap/v2alpha:pkg",

api/envoy/config/tap/v3/common.proto

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ syntax = "proto3";
22

33
package envoy.config.tap.v3;
44

5+
import "envoy/config/common/matcher/v3/matcher.proto";
56
import "envoy/config/core/v3/base.proto";
67
import "envoy/config/core/v3/grpc_service.proto";
78
import "envoy/config/route/v3/route_components.proto";
@@ -28,7 +29,17 @@ message TapConfig {
2829

2930
// The match configuration. If the configuration matches the data source being tapped, a tap will
3031
// occur, with the result written to the configured output.
31-
MatchPredicate match_config = 1 [(validate.rules).message = {required: true}];
32+
// Exactly one of :ref:`match <envoy_api_field_config.tap.v3.TapConfig.match>` and
33+
// :ref:`match_config <envoy_api_field_config.tap.v3.TapConfig.match_config>` must be set. If both
34+
// are set, the :ref:`match <envoy_api_field_config.tap.v3.TapConfig.match>` will be used.
35+
MatchPredicate match_config = 1 [deprecated = true];
36+
37+
// The match configuration. If the configuration matches the data source being tapped, a tap will
38+
// occur, with the result written to the configured output.
39+
// Exactly one of :ref:`match <envoy_api_field_config.tap.v3.TapConfig.match>` and
40+
// :ref:`match_config <envoy_api_field_config.tap.v3.TapConfig.match_config>` must be set. If both
41+
// are set, the :ref:`match <envoy_api_field_config.tap.v3.TapConfig.match>` will be used.
42+
common.matcher.v3.MatchPredicate match = 4;
3243

3344
// The tap output configuration. If a match configuration matches a data source being tapped,
3445
// a tap will occur and the data will be written to the configured output.

api/envoy/config/tap/v4alpha/BUILD

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/envoy/config/tap/v4alpha/common.proto

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)