Skip to content

Commit

Permalink
Mask password in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gamagoat committed Nov 12, 2024
1 parent 53323cb commit 70cf658
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,18 @@ func Run(debugLevel, host, port, password string, banner ...string) (err error)

func (s *server) start() (err error) {
log.SetLevel(s.debugLevel)
log.Debugf("starting with password '%s'", s.password)

// Mask our password in logs
maskedPassword := ""
if len(s.password) > 2 {
maskedPassword = fmt.Sprintf("%c***%c", s.password[0], s.password[len(s.password)-1])
} else {
// TODO: enforce a minimum password length?
maskedPassword = s.password
}

log.Debugf("starting with password '%s'", maskedPassword)

s.rooms.Lock()
s.rooms.rooms = make(map[string]roomInfo)
s.rooms.Unlock()
Expand Down

0 comments on commit 70cf658

Please sign in to comment.