commit 1fceda6
delthas
·
2025-02-18 15:51:27 +0000 UTC
parent 2bb35a8
Censor passwords in debug logs Fixes: https://todo.sr.ht/~delthas/senpai/176
1 files changed,
+14,
-1
M
app.go
M
app.go
+14,
-1
1@@ -482,10 +482,23 @@ func (app *App) debugOutputMessages(netID string, out chan<- irc.Message) chan<-
2 debugOut := make(chan irc.Message, cap(out))
3 go func() {
4 for msg := range debugOut {
5+ const placeholder = "<removed>"
6+ d := msg
7+ if msg.Command == "PASS" && len(d.Params) >= 1 {
8+ d.Params = append([]string{placeholder}, d.Params[1:]...)
9+ } else if msg.Command == "OPER" && len(d.Params) >= 2 {
10+ d.Params = append([]string{d.Params[0], placeholder}, d.Params[2:]...)
11+ } else if msg.Command == "AUTHENTICATE" && len(d.Params) >= 1 {
12+ switch d.Params[0] {
13+ case "*", "PLAIN":
14+ default:
15+ d.Params = append([]string{placeholder}, d.Params[1:]...)
16+ }
17+ }
18 app.queueStatusLine(netID, ui.Line{
19 At: time.Now(),
20 Head: "OUT --",
21- Body: ui.PlainString(msg.String()),
22+ Body: ui.PlainString(d.String()),
23 })
24 out <- msg
25 }