Browse Source

cmd/stcrashreceiver: Sanitize failure report fingerprints (#7840)

Simon Frei 4 years ago
parent
commit
1ae5ac7d0b
2 changed files with 11 additions and 5 deletions
  1. 2 1
      cmd/stcrashreceiver/main.go
  2. 9 4
      cmd/stcrashreceiver/sentry.go

+ 2 - 1
cmd/stcrashreceiver/main.go

@@ -89,7 +89,8 @@ func handleFailureFn(dsn string) func(w http.ResponseWriter, req *http.Request)
 			pkt.Extra = raven.Extra{
 				"count": r.Count,
 			}
-			pkt.Fingerprint = []string{r.Description}
+			message := sanitizeMessageLDB(r.Description)
+			pkt.Fingerprint = []string{message}
 
 			if err := sendReport(dsn, pkt, userIDFor(req)); err != nil {
 				log.Println("Failed to send failure report:", err)

+ 9 - 4
cmd/stcrashreceiver/sentry.go

@@ -143,15 +143,20 @@ var (
 	ldbPathRe        = regexp.MustCompile(`(open|write|read) .+[\\/].+[\\/]index[^\\/]+[\\/][^\\/]+: `)
 )
 
-func crashReportFingerprint(message string) []string {
-	// Do not fingerprint on the stack in case of db corruption or fatal
-	// db io error - where it occurs doesn't matter.
-	orig := message
+func sanitizeMessageLDB(message string) string {
 	message = ldbPosRe.ReplaceAllString(message, "${1}x)")
 	message = ldbFileRe.ReplaceAllString(message, "${1}x${3}")
 	message = ldbChecksumRe.ReplaceAllString(message, "${1}X${3}X")
 	message = ldbInternalKeyRe.ReplaceAllString(message, "${1}x${2}x")
 	message = ldbPathRe.ReplaceAllString(message, "$1 x: ")
+	return message
+}
+
+func crashReportFingerprint(message string) []string {
+	// Do not fingerprint on the stack in case of db corruption or fatal
+	// db io error - where it occurs doesn't matter.
+	orig := message
+	message = sanitizeMessageLDB(message)
 	if message != orig {
 		return []string{message}
 	}