Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(chart): warn about a TLS-less ingress when NODE_ENV is unset

Yudhi Armyndharis46f99ae7bd37
diff --git a/charts/openwa/templates/NOTES.txt b/charts/openwa/templates/NOTES.txt
index 9a898a58f..3d4e2ad44 100644
--- a/charts/openwa/templates/NOTES.txt
+++ b/charts/openwa/templates/NOTES.txt
@@ -18,7 +18,9 @@ OpenWA has been installed as release "{{ .Release.Name }}".
Or via the ingress host: http{{ if .Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.host }}
{{- $env := .Values.env | default dict }}
{{- $csp := toString (get $env "CSP_UPGRADE_INSECURE_REQUESTS") }}
-{{- $upgrade := or (eq $csp "true") (and (ne $csp "false") (eq (toString (get $env "NODE_ENV")) "production")) }}
+{{- /* An absent NODE_ENV leaves the image's NODE_ENV=production in effect; an empty one overrides it. */}}
+{{- $nodeEnv := ternary (toString (get $env "NODE_ENV")) "production" (hasKey $env "NODE_ENV") }}
+{{- $upgrade := or (eq $csp "true") (and (ne $csp "false") (eq $nodeEnv "production")) }}
{{- if and (not .Values.ingress.tls) $upgrade }}
WARNING: this ingress has no TLS, but the app tells browsers to upgrade insecure requests, so
diff --git a/scripts/check-chart-behaviour.mjs b/scripts/check-chart-behaviour.mjs
index f31ebbd47..94c99cdc3 100644
--- a/scripts/check-chart-behaviour.mjs
+++ b/scripts/check-chart-behaviour.mjs
@@ -293,6 +293,10 @@ const check = (id, ok, detail) => results.push({ id, ok, detail });
// `--set` parses this one as a YAML boolean rather than a string.
['CSP upgrade off as a boolean', false, ['--set', 'ingress.enabled=true', '--set', 'env.CSP_UPGRADE_INSECURE_REQUESTS=false']],
['ingress with TLS', false, ['--set', 'ingress.enabled=true', ...tls]],
+ // A null drops the key from the ConfigMap, so the image's NODE_ENV=production applies.
+ ['NODE_ENV removed', true, ['--set', 'ingress.enabled=true', '--set', 'env.NODE_ENV=null']],
+ // An empty value reaches the container and overrides the image default.
+ ['NODE_ENV empty', false, ['--set', 'ingress.enabled=true', '--set-string', 'env.NODE_ENV=']],
['no ingress', false, []],
];
const wrong = cases.filter(([, want, args]) => warns(notes(...args)) !== want).map(([name, want]) => `${name} (expected ${want ? 'a' : 'no'} warning)`);