Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
test: fix the NodeSWG test
Browse files Browse the repository at this point in the history
isolate each server url in a different local repo according to its url
  • Loading branch information
temsa committed Jul 27, 2018
1 parent b07d5df commit 3a05ae4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions vulnfetcher/nodeswg/nodeswg.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nodeswg

import (
"encoding/base64"
"encoding/json"
"io"
"log"
Expand Down Expand Up @@ -39,8 +40,12 @@ func New(URL string) *Fetcher {

// Fetch builds the database from nodeswg on github
func (n *Fetcher) Fetch() error {
destFilePath := path.Join(os.TempDir(), "nodeswg.zip")
unzipFolder := path.Join(os.TempDir(), "nodeswg")
tmpDir := path.Join(os.TempDir(), base64.StdEncoding.EncodeToString([]byte(n.DatabaseURL)))
os.Mkdir(tmpDir, os.ModePerm)

log.Print("Temporary directory for NodeSWG Database <", n.DatabaseURL, ">:\n", tmpDir)
destFilePath := path.Join(tmpDir, "nodeswg.zip")
unzipFolder := path.Join(tmpDir, "nodeswg")
vulnFolder := path.Join(unzipFolder, "security-wg-master", "vuln", "npm")

os.Mkdir(unzipFolder, os.ModePerm)
Expand Down
2 changes: 1 addition & 1 deletion vulnfetcher/nodeswg/nodeswg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestTestExistingPackage(t *testing.T) {
assert.Equal(t, "Arbitrary JavaScript Execution", vulnerabilities[0].Title, "Title")
assert.True(t, strings.HasPrefix(vulnerabilities[0].Description, "A vulnerability exists in bassmaster"), "Description")
assert.Equal(t, "<=1.5.1", vulnerabilities[0].Versions, "Version")
assert.True(t, strings.HasPrefix(vulnerabilities[0].References, "- https://www.npmjs.org/package/bassmaster"))
assert.True(t, strings.HasPrefix(vulnerabilities[0].References, "https://www.npmjs.org/package/bassmaster"))
}

func TestTestExistingPackageWithFixedVersion(t *testing.T) {
Expand Down
Binary file modified vulnfetcher/nodeswg/test_data/test-data.zip
Binary file not shown.

0 comments on commit 3a05ae4

Please sign in to comment.