From f1b1098b221539291c214e17e263e7d014a9761f Mon Sep 17 00:00:00 2001 From: Zvonimir Pavlinovic Date: Wed, 3 Apr 2024 14:55:14 +0000 Subject: [PATCH] internal/sarif,internal/scan,internal/traces: clean up tests And some redundant code. Change-Id: I37483214c11ed4865698279f4c287e9d75af613b Reviewed-on: https://go-review.googlesource.com/c/vuln/+/576095 Run-TryBot: Zvonimir Pavlinovic LUCI-TryBot-Result: Go LUCI TryBot-Result: Gopher Robot Reviewed-by: Maceo Thompson --- internal/sarif/handler.go | 6 ------ internal/scan/template_test.go | 8 ++++---- internal/traces/traces_test.go | 14 +++++++------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/internal/sarif/handler.go b/internal/sarif/handler.go index 9043fc1..0010165 100644 --- a/internal/sarif/handler.go +++ b/internal/sarif/handler.go @@ -294,12 +294,6 @@ func stack(f *govulncheck.Finding) Stack { }) } - vuln := trace[0] - vulnSym := vuln.Function - if vuln.Receiver != "" { - vulnSym = vuln.Receiver + "." + vulnSym - } - vulnSym = vuln.Package + "." + vulnSym return Stack{ Frames: frames, Message: Description{Text: fmt.Sprintf("A call stack for vulnerable function %s", symbol(trace[0]))}, diff --git a/internal/scan/template_test.go b/internal/scan/template_test.go index 9faa36e..fd255dd 100644 --- a/internal/scan/template_test.go +++ b/internal/scan/template_test.go @@ -32,7 +32,7 @@ func TestCompactTrace(t *testing.T) { { []*govulncheck.Frame{ {Module: "vuln", Function: "V"}, - {Module: "interm", Function: "I"}, + {Module: "interim", Function: "I"}, {Module: "user", Function: "U"}, {Module: "user", Function: "W"}, }, @@ -42,9 +42,9 @@ func TestCompactTrace(t *testing.T) { []*govulncheck.Frame{ {Module: "vuln", Function: "V"}, {Module: "x", Function: "X"}, - {Module: "interm", Function: "K"}, - {Module: "interm", Function: "J"}, - {Module: "interm", Function: "I"}, + {Module: "interim", Function: "K"}, + {Module: "interim", Function: "J"}, + {Module: "interim", Function: "I"}, {Module: "user", Function: "U"}, {Module: "user", Function: "W"}, }, diff --git a/internal/traces/traces_test.go b/internal/traces/traces_test.go index 876429a..bd36338 100644 --- a/internal/traces/traces_test.go +++ b/internal/traces/traces_test.go @@ -49,13 +49,13 @@ func TestCompact(t *testing.T) { { []*govulncheck.Frame{ {Module: "vuln", Function: "V"}, - {Module: "interm", Function: "I"}, + {Module: "interim", Function: "I"}, {Module: "user", Function: "U"}, {Module: "user", Function: "W"}, }, []*govulncheck.Frame{ {Module: "vuln", Function: "V"}, - {Module: "interm", Function: "I"}, + {Module: "interim", Function: "I"}, {Module: "user", Function: "U"}, }, }, @@ -63,16 +63,16 @@ func TestCompact(t *testing.T) { []*govulncheck.Frame{ {Module: "vuln", Function: "V"}, {Module: "x", Function: "X"}, - {Module: "interm", Function: "K"}, - {Module: "interm", Function: "J"}, - {Module: "interm", Function: "I"}, + {Module: "interim", Function: "K"}, + {Module: "interim", Function: "J"}, + {Module: "interim", Function: "I"}, {Module: "user", Function: "U"}, {Module: "user", Function: "W"}, }, []*govulncheck.Frame{ {Module: "vuln", Function: "V"}, - {Module: "interm", Function: "J"}, - {Module: "interm", Function: "I"}, + {Module: "interim", Function: "J"}, + {Module: "interim", Function: "I"}, {Module: "user", Function: "U"}, }, },