fix: Remove debug syscall; Tighten perms; Strip spaces in label

This commit is contained in:
Mike Greenberg 2021-09-27 17:54:43 -04:00
parent 574b5c03dc
commit c3faadf749

View File

@ -8,7 +8,7 @@ import (
"runtime/debug" "runtime/debug"
"runtime/pprof" "runtime/pprof"
"strconv" "strconv"
"syscall" "strings"
"time" "time"
"github.com/icza/backscanner" "github.com/icza/backscanner"
@ -58,8 +58,7 @@ func GeneratePanicReport(persistPath, repoPath, label string) {
} }
} }
syscall.Umask(0) err := os.MkdirAll(reportPath, 0644)
err := os.MkdirAll(reportPath, 0755)
if err != nil { if err != nil {
panicLog.Error(err.Error()) panicLog.Error(err.Error())
return return
@ -157,11 +156,7 @@ func writeJournalTail(tailLen int, repoPath, file string) {
} }
break break
} }
if _, err := f.Write(line); err != nil { if _, err := f.Write(append(line, "\n"...)); err != nil {
panicLog.Error(err.Error())
break
}
if _, err := f.Write([]byte("\n")); err != nil {
panicLog.Error(err.Error()) panicLog.Error(err.Error())
break break
} }
@ -179,5 +174,6 @@ func getLatestJournalFilePath(repoPath string) (string, error) {
} }
func generateReportName(label string) string { func generateReportName(label string) string {
return fmt.Sprintf("report_%s_%s", label, time.Now().Format("2006-01-02T150405Z0700")) label = strings.ReplaceAll(label, " ", "")
return fmt.Sprintf("report_%s_%s", label, time.Now().Format("2006-01-02T150405"))
} }