Skip to content

Commit ce16f7c

Browse files
more precise match exprs [skip ci]
- see https://cloud.google.com/armor/docs/rules-language-reference Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
1 parent d01b223 commit ce16f7c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cluster/pulumi/infra/src/cloudArmor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ function addThrottleAndBanRules(
132132
if (throttleAcrossAllEndpointsAllIps.maxRequestsBeforeHttp429 > 0) {
133133
const ruleName = `throttle-all-endpoints-all-ips-${confEntryHead}`;
134134

135-
// Build the expression for path and hostname matching
136-
const pathExpr = `request.path.matches('${endpoint.path}')`;
137-
const hostExpr = `request.headers['host'].matches('${endpoint.hostname}')`;
138-
const matchExpr = `${pathExpr} && ${hostExpr}`;
135+
// Build the expression for path and hostname matching
136+
const pathExpr = `request.path.startsWith(R"${pathPrefix}")`;
137+
const hostExpr = `request.headers['host'].matches(R"^${_.escapeRegExp(hostname)}(:[0-9]+)?$")`;
138+
const matchExpr = `${pathExpr} && ${hostExpr}`;
139139

140140
new gcp.compute.SecurityPolicyRule(
141141
ruleName,

0 commit comments

Comments
 (0)