From d504b67b4ef3f45d4f622fa18ded94391cba58b3 Mon Sep 17 00:00:00 2001 From: David Moore Date: Mon, 11 Nov 2024 12:34:19 +1100 Subject: [PATCH] fix: skip blacklisted env vars --- pkg/project/batch.go | 16 ++++++++++++++++ pkg/project/service.go | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/pkg/project/batch.go b/pkg/project/batch.go index dcb99f078..9b149577e 100644 --- a/pkg/project/batch.go +++ b/pkg/project/batch.go @@ -199,6 +199,22 @@ func (s *Batch) RunContainer(stop <-chan bool, updates chan<- ServiceRunUpdate, } for k, v := range runtimeOptions.envVars { + // detect blacklisted env vars set by nitric in env vars + _, isBlacklisted := lo.Find(env, func(e string) bool { + return strings.HasPrefix(e, k) + }) + + if isBlacklisted { + updates <- ServiceRunUpdate{ + ServiceName: s.Name, + Label: s.GetFilePath(), + Message: fmt.Sprintf("Skipping blacklisted env var: %s", k), + Status: ServiceRunStatus_Running, + } + + continue + } + env = append(env, k+"="+v) } diff --git a/pkg/project/service.go b/pkg/project/service.go index b956ea911..c572c2696 100644 --- a/pkg/project/service.go +++ b/pkg/project/service.go @@ -370,6 +370,22 @@ func (s *Service) RunContainer(stop <-chan bool, updates chan<- ServiceRunUpdate } for k, v := range runtimeOptions.envVars { + // detect blacklisted env vars set by nitric in env vars + _, isBlacklisted := lo.Find(env, func(e string) bool { + return strings.HasPrefix(e, k) + }) + + if isBlacklisted { + updates <- ServiceRunUpdate{ + ServiceName: s.Name, + Label: s.GetFilePath(), + Message: fmt.Sprintf("Skipping blacklisted env var: %s", k), + Status: ServiceRunStatus_Running, + } + + continue + } + env = append(env, k+"="+v) }