Skip to content

Commit d6f2a33

Browse files
committed
clean: Address codacy comments
1 parent 76f19a4 commit d6f2a33

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

internal/tool/malicious_packages_scanner.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"golang.org/x/mod/semver"
1515
)
1616

17+
// MaliciousPackagesIndexPath is the default path to the malicious package index.
1718
const MaliciousPackagesIndexPath = "/dist/cache/codacy-trivy/openssf-malicious-packages-index.json.gz"
1819

1920
// maliciousPackage represents a shallow representation of an Open Source Vulnerability (OSV).
@@ -120,7 +121,7 @@ func NewMaliciousPackagesScanner(indexPath string) (*MaliciousPackagesScanner, e
120121
return &MaliciousPackagesScanner{index: index}, nil
121122
}
122123

123-
// Scans the given Trivy report for malicious packages.
124+
// Scan scans the given Trivy report for malicious packages.
124125
func (s MaliciousPackagesScanner) Scan(report ptypes.Report, toolExecution codacy.ToolExecution) []codacy.Result {
125126
maliciousPackagesEnabled := lo.SomeBy(*toolExecution.Patterns, func(p codacy.Pattern) bool {
126127
return p.ID == ruleIDMaliciousPackages

internal/tool/tool_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ func TestNew(t *testing.T) {
3232
// Create an empty temporary file for the malicious packages index
3333
maliciousPackageIndexFileName := "malicious-package.json.gz"
3434

35-
f, err := os.Create(maliciousPackageIndexFileName)
35+
tmpDir := t.TempDir()
36+
f, err := os.CreateTemp(tmpDir, maliciousPackageIndexFileName)
3637
if err != nil {
3738
assert.FailNow(t, "Failed to create malicious package index", err.Error())
3839
}
39-
defer os.Remove(f.Name())
40+
defer os.RemoveAll(tmpDir)
4041
defer f.Close()
4142

4243
gz := gzip.NewWriter(f)

0 commit comments

Comments
 (0)