From f2b7df7e02bf19bae036b5f17a59e699557ede75 Mon Sep 17 00:00:00 2001 From: Alon Girmonsky <1990761+alongir@users.noreply.github.com> Date: Fri, 19 Jan 2024 16:51:33 -0800 Subject: [PATCH] Global Filter, escaping doublequotes in strings (#1484) * Global filter quote change Global filter uses a single quote as opposed to double quote. This limits the use of `'` inside the string as it can not be escaped. When using double quote ("), single quote can be used and double quote can be escaped as part of a string. An example for a Global Filter string: "redact(\"request.headers.Authorization\", \"request.headers['X-Aws-Ec2-Metadata-Token']\")" * support escaping double quotes in the global filter string --- helm-chart/templates/12-config-map.yaml | 2 +- helm-chart/templates/_helpers.tpl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/helm-chart/templates/12-config-map.yaml b/helm-chart/templates/12-config-map.yaml index 70c838974..b0f8e57c1 100644 --- a/helm-chart/templates/12-config-map.yaml +++ b/helm-chart/templates/12-config-map.yaml @@ -16,5 +16,5 @@ data: AUTH_APPROVED_TENANTS: '{{ gt (len .Values.tap.auth.approvedTenants) 0 | ternary (join "," .Values.tap.auth.approvedTenants) "" }}' TELEMETRY_DISABLED: '{{ not .Values.tap.telemetry.enabled | ternary "true" "" }}' REPLAY_DISABLED: '{{ .Values.tap.replayDisabled | ternary "true" "" }}' - GLOBAL_FILTER: '{{ .Values.tap.globalFilter }}' + GLOBAL_FILTER: {{ include "kubeshark.escapeDoubleQuotes" .Values.tap.globalFilter | quote }} TRAFFIC_SAMPLE_RATE: '{{ .Values.tap.trafficSampleRate }}' diff --git a/helm-chart/templates/_helpers.tpl b/helm-chart/templates/_helpers.tpl index 16b1014a9..ab5151662 100644 --- a/helm-chart/templates/_helpers.tpl +++ b/helm-chart/templates/_helpers.tpl @@ -48,3 +48,11 @@ Create the name of the service account to use {{- define "kubeshark.serviceAccountName" -}} {{- printf "%s-service-account" .Release.Name }} {{- end }} + +{{/* +Escape double quotes in a string +*/}} +{{- define "kubeshark.escapeDoubleQuotes" -}} + {{- regexReplaceAll "\"" . "\"" -}} +{{- end -}} +