Skip to content

Commit 9dc37de

Browse files
committed
Add env vars obfuscation to pod recording
1 parent 8a806b7 commit 9dc37de

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

pkg/gatherers/clusterconfig/operators_pods_and_events.go

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/openshift/insights-operator/pkg/record"
2323
"github.com/openshift/insights-operator/pkg/recorder"
2424
"github.com/openshift/insights-operator/pkg/utils"
25+
"github.com/openshift/insights-operator/pkg/utils/anonymize"
2526
"github.com/openshift/insights-operator/pkg/utils/check"
2627
"github.com/openshift/insights-operator/pkg/utils/marshal"
2728
)
@@ -217,6 +218,8 @@ func gatherPodsAndTheirContainersLogs(ctx context.Context,
217218
for _, pod := range pods {
218219
// if pod is not healthy then record its definition and try to get previous log
219220
if !check.IsHealthyPod(pod, time.Now()) {
221+
anonymize.SensitiveEnvVars(pod.Spec.Containers)
222+
220223
records = append(records, record.Record{
221224
Name: fmt.Sprintf("config/pod/%s/%s", pod.Namespace, pod.Name),
222225
Item: record.ResourceMarshaller{Resource: pod},

pkg/gatherers/clusterconfig/version.go

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func getClusterVersion(ctx context.Context,
7878
}
7979
for i := range pods.Items {
8080
pod := &pods.Items[i]
81+
anonymize.SensitiveEnvVars(pod.Spec.Containers)
8182

8283
// TODO: shift after IsHealthyPod
8384
records = append(records, record.Record{

pkg/gatherers/conditional/gather_pod_definition.go

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/openshift/insights-operator/pkg/gatherers"
1313
"github.com/openshift/insights-operator/pkg/record"
14+
"github.com/openshift/insights-operator/pkg/utils/anonymize"
1415
)
1516

1617
// BuildGatherPodDefinition collects pod definition from pods that are firing one of the configured alerts.
@@ -76,6 +77,7 @@ func (g *Gatherer) gatherPodDefinition(
7677
errs = append(errs, err)
7778
continue
7879
}
80+
anonymize.SensitiveEnvVars(pod.Spec.Containers)
7981

8082
records = append(records, record.Record{
8183
Name: fmt.Sprintf(

0 commit comments

Comments
 (0)