Skip to content

Commit

Permalink
internal/sarif,internal/scan,internal/traces: clean up tests
Browse files Browse the repository at this point in the history
And some redundant code.

Change-Id: I37483214c11ed4865698279f4c287e9d75af613b
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/576095
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
  • Loading branch information
zpavlinovic committed Apr 3, 2024
1 parent 33791bc commit f1b1098
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
6 changes: 0 additions & 6 deletions internal/sarif/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]))},
Expand Down
8 changes: 4 additions & 4 deletions internal/scan/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
Expand All @@ -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"},
},
Expand Down
14 changes: 7 additions & 7 deletions internal/traces/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,30 @@ 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"},
},
},
{
[]*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"},
},
},
Expand Down

0 comments on commit f1b1098

Please sign in to comment.