Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't write logs that contain environment variables #13877

Merged
merged 1 commit into from
Mar 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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