Skip to content

Commit 85fb453

Browse files
committed
add filename in view
1 parent 3c69012 commit 85fb453

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

cmd/view.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ func printFileReport(file entity.File, webSvc webapi.Service) {
5757
// File identification.
5858
fmt.Println(headerStyle.Render("Identification"))
5959
printKV("SHA256", file.SHA256)
60+
if name := submissionFilename(file.Submissions); name != "" {
61+
printKV("Filename", name)
62+
}
6063
if !file.IsArchive {
6164
printKV("MD5", file.MD5)
6265
printKV("SHA1", file.SHA1)
@@ -324,3 +327,14 @@ func formatTimestamp(ts int64) string {
324327
t := time.Unix(ts, 0)
325328
return t.Format("2006-01-02 15:04:05 UTC")
326329
}
330+
331+
// submissionFilename returns the first submission filename that does not look
332+
// like a bare hash (MD5/SHA1/SHA256), or empty string if none is found.
333+
func submissionFilename(submissions []entity.Submission) string {
334+
for _, s := range submissions {
335+
if s.Filename != "" && !looksLikeHash(s.Filename) {
336+
return s.Filename
337+
}
338+
}
339+
return ""
340+
}

0 commit comments

Comments
 (0)