From 6df10584892e909d481aa5e126008254bf34fed1 Mon Sep 17 00:00:00 2001 From: Andrey Matveenko Date: Thu, 19 Dec 2024 20:53:31 +0300 Subject: [PATCH] Added filename length restriction for debug mode (-srd flag) --- pkg/output/output.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/output/output.go b/pkg/output/output.go index 84201c0d73..dbc0a21060 100644 --- a/pkg/output/output.go +++ b/pkg/output/output.go @@ -512,6 +512,13 @@ func sanitizeFileName(fileName string) string { } func (w *StandardWriter) WriteStoreDebugData(host, templateID, eventType string, data string) { if w.storeResponse { + if len(host) > 60 { + host = host[:57] + "..." + } + if len(templateID) > 100 { + templateID = templateID[:97] + "..." + } + filename := sanitizeFileName(fmt.Sprintf("%s_%s", host, templateID)) subFolder := filepath.Join(w.storeResponseDir, sanitizeFileName(eventType)) if !fileutil.FolderExists(subFolder) { @@ -526,7 +533,6 @@ func (w *StandardWriter) WriteStoreDebugData(host, templateID, eventType string, _, _ = f.WriteString(fmt.Sprintln(data)) f.Close() } - } // tryParseCause tries to parse the cause of given error