Skip to content

Commit

Permalink
Merge pull request #13877 from spowelljr/filterOutEnvs
Browse files Browse the repository at this point in the history
Don't write logs that contain environment variables
  • Loading branch information
spowelljr authored Mar 29, 2022
2 parents 76aefce + 9549bef commit 43c11c7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/minikube/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 43c11c7

Please sign in to comment.