This repository was archived by the owner on Mar 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 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 {
199199 if err := m .conn .ReadJSON (msg ); err != nil {
200200 return err
201201 }
202- logrus .Tracef ("Read build message %s" , msg )
202+ logrus .Tracef ("Read build message %s" , redact ( msg ) )
203203 if m .handler != nil {
204204 if err := m .handler (msg ); err != nil {
205205 return err
@@ -229,8 +229,26 @@ func (m *WebsocketMessages) Recv() (<-chan *Message, func()) {
229229}
230230
231231func (m * WebsocketMessages ) Send (msg * Message ) error {
232- logrus .Tracef ("Send build message %s" , msg )
232+ logrus .Tracef ("Send build message %s" , redact ( msg ) )
233233 m .lock .Lock ()
234234 defer m .lock .Unlock ()
235235 return m .conn .WriteJSON (msg )
236236}
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