Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit f8fa59a

Browse files
committed
api, common, db4s: Sanitise further log messages
1 parent 40313cd commit f8fa59a

File tree

5 files changed

+79
-69
lines changed

5 files changed

+79
-69
lines changed

api/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ func collectInfoAndOpen(w http.ResponseWriter, r *http.Request) (sdb *sqlite.Con
242242
if id == "" {
243243
// The requested database wasn't found, or the user doesn't have permission to access it
244244
err = fmt.Errorf("Requested database not found")
245-
log.Printf("Requested database not found. Owner: '%s%s%s'", dbOwner, dbFolder, dbName)
245+
log.Printf("Requested database not found. Owner: '%s%s%s'", com.SanitiseLogString(dbOwner),
246+
com.SanitiseLogString(dbFolder), com.SanitiseLogString(dbName))
246247
httpStatus = http.StatusNotFound
247248
return
248249
}

common/cert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func GenerateClientCert(userName string) (_ []byte, err error) {
113113
return
114114
}
115115

116-
log.Printf("New client cert generated for user '%s'", userName)
116+
log.Printf("New client cert generated for user '%s'", SanitiseLogString(userName))
117117

118118
return buf.Bytes(), nil
119119
}

common/diff.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ func Diff(ownerA string, folderA string, nameA string, commitA string, ownerB st
9090
if idA == "" {
9191
// The requested database wasn't found, or the user doesn't have permission to access it
9292
err = fmt.Errorf("Requested database not found")
93-
log.Printf("Requested database not found: '%s%s%s'", ownerA, folderA, nameA)
93+
log.Printf("Requested database not found: '%s%s%s'", SanitiseLogString(ownerA),
94+
SanitiseLogString(folderA), SanitiseLogString(nameA))
9495
return Diffs{}, err
9596
}
9697
if idB == "" {
9798
// The requested database wasn't found, or the user doesn't have permission to access it
9899
err = fmt.Errorf("Requested database not found")
99-
log.Printf("Requested database not found: '%s%s%s'", ownerB, folderB, nameB)
100+
log.Printf("Requested database not found: '%s%s%s'", SanitiseLogString(ownerB),
101+
SanitiseLogString(folderB), SanitiseLogString(nameB))
100102
return Diffs{}, err
101103
}
102104

0 commit comments

Comments
 (0)