From 9549bef5048542a32cac4043466b30dad8d0fc08 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Tue, 29 Mar 2022 11:09:11 -0700 Subject: [PATCH] don't write logs that contain environment variables --- cmd/minikube/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/minikube/main.go b/cmd/minikube/main.go index 496ec6e9fd13..6f12f844b034 100644 --- a/cmd/minikube/main.go +++ b/cmd/minikube/main.go @@ -60,6 +60,8 @@ var ( // unexpected errors from libmachine to the user. machineLogErrorRe = regexp.MustCompile(`VirtualizationException`) machineLogWarningRe = regexp.MustCompile(`(?i)warning`) + // This regex is to filter out logs that contain environment variables which could contain sensitive information + machineLogEnvironmentRe = regexp.MustCompile(`&exec\.Cmd`) ) func main() { @@ -122,7 +124,9 @@ type machineLogBridge struct{} // Write passes machine driver logs to klog func (lb machineLogBridge) Write(b []byte) (n int, err error) { - if machineLogErrorRe.Match(b) { + if machineLogEnvironmentRe.Match(b) { + return len(b), nil + } else if machineLogErrorRe.Match(b) { klog.Errorf("libmachine: %s", b) } else if machineLogWarningRe.Match(b) { klog.Warningf("libmachine: %s", b)