This repository was archived by the owner on Mar 16, 2024. It is now read-only.
File tree 1 file changed +20
-2
lines changed
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ func (m *WebsocketMessages) run(ctx context.Context) error {
199
199
if err := m .conn .ReadJSON (msg ); err != nil {
200
200
return err
201
201
}
202
- logrus .Tracef ("Read build message %s" , msg )
202
+ logrus .Tracef ("Read build message %s" , redact ( msg ) )
203
203
if m .handler != nil {
204
204
if err := m .handler (msg ); err != nil {
205
205
return err
@@ -229,8 +229,26 @@ func (m *WebsocketMessages) Recv() (<-chan *Message, func()) {
229
229
}
230
230
231
231
func (m * WebsocketMessages ) Send (msg * Message ) error {
232
- logrus .Tracef ("Send build message %s" , msg )
232
+ logrus .Tracef ("Send build message %s" , redact ( msg ) )
233
233
m .lock .Lock ()
234
234
defer m .lock .Unlock ()
235
235
return m .conn .WriteJSON (msg )
236
236
}
237
+
238
+ // redact returns a Message with all sensitive information redacted.
239
+ // Use this to prep a Message for logging.
240
+ func redact (msg * Message ) * Message {
241
+ if msg == nil {
242
+ return nil
243
+ }
244
+
245
+ redacted := * msg
246
+ if redacted .RegistryAuth != nil {
247
+ redacted .RegistryAuth = & apiv1.RegistryAuth {
248
+ Username : "REDACTED" ,
249
+ Password : "REDACTED" ,
250
+ }
251
+ }
252
+
253
+ return & redacted
254
+ }
You can’t perform that action at this time.
0 commit comments