Skip to content

Commit 02301d2

Browse files
Merge pull request #5601 from dkhater-redhat/redact-file-contents-master
OCPBUGS-20561: machine-config-daemon: openshift: Exposure of Sensitive Data in Log Files in the Machine Configuration Daemon. [openshift-4]
2 parents 1f2dbac + 64001b7 commit 02301d2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

pkg/daemon/on_disk_validation.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
ign2types "github.com/coreos/ignition/config/v2_2/types"
1111
ign3types "github.com/coreos/ignition/v2/config/v3_5/types"
12-
"github.com/google/go-cmp/cmp"
1312
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
1413
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
1514
"k8s.io/apimachinery/pkg/util/sets"
@@ -277,7 +276,9 @@ func checkFileContentsAndMode(filePath string, expectedContent []byte, mode os.F
277276
return fmt.Errorf("could not read file %q: %w", filePath, err)
278277
}
279278
if !bytes.Equal(contents, expectedContent) {
280-
klog.Errorf("content mismatch for file %q (-want +got):\n%s", filePath, cmp.Diff(expectedContent, contents))
279+
// Removing file contents logs to prevent accidental exposure of secrets.
280+
klog.Errorf("content mismatch for file %q (expected %d bytes, got %d bytes)",
281+
filePath, len(expectedContent), len(contents))
281282
return fmt.Errorf("content mismatch for file %q", filePath)
282283
}
283284
return nil

0 commit comments

Comments
 (0)