Skip to content

Commit 3d0e55a

Browse files
committed
Removed the check for lockfile version 3 since it's now supported by Veracode SCA
1 parent f65739f commit 3d0e55a

File tree

3 files changed

+0
-75
lines changed

3 files changed

+0
-75
lines changed

main.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818

1919
var doesSCAFileExist bool = false
2020
var doesMapFileExist bool = false
21-
var usesLockfileVersion3 bool = false
2221

2322
func main() {
2423
// parse all the command line flags
@@ -123,12 +122,6 @@ func checkForPotentialSmells(source string) {
123122
if strings.HasSuffix(path, ".map") {
124123
doesMapFileExist = true
125124
}
126-
127-
// currently (as of Feb 2023), Veracode SCA does not support the new lockfile format version 3 of NPM. Thus, we look for this here
128-
// and notify if version 3 is found
129-
if strings.HasSuffix(path, "package-lock.json") && !usesLockfileVersion3 {
130-
usesLockfileVersion3 = UsesLockfileVersion3(path)
131-
}
132125
}
133126
}
134127

@@ -148,14 +141,6 @@ func checkForPotentialSmells(source string) {
148141
log.Warn("\tThe 1st party code contains `.map` files outside of `/build`, `/dist` or `/public` (which indicates minified JavaScript)...")
149142
log.Warn("\tPlease pass a directory to this tool that contains the unminified/unbundled/unconcatenated JavaScript (or TypeScript)")
150143
}
151-
152-
if usesLockfileVersion3 {
153-
log.Error("Veracode SCA does currently not support Lockfile Version 3. This means you will not get SCA results unless you" +
154-
" downgrade your `package-lock.json` to version 2!")
155-
log.Error("To achieve this, please run `npm install --lockfile 2`")
156-
} else {
157-
log.Info("The `package-lock.json` uses a supported lockfile version (version 3 is currently not supported)")
158-
}
159144
}
160145

161146
func zipSource(source string, target string, testsPath string) error {

main_test.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"reflect"
77
"regexp"
88
"sort"
9-
"strconv"
109

1110
"testing"
1211

@@ -221,49 +220,6 @@ func TestZipSourceWithAngularSample(t *testing.T) {
221220
log.Info("---------- Finished Test: TestZipSourceWithAngularSample ----------\n\n")
222221
}
223222

224-
// Unit test for `UsesLockfileVersion3()` with a lock file that uses version 3 (`./sample-projects/lockfile-v3-test/package-lock.json`)
225-
func TestUsesLockfileVersion3(t *testing.T) {
226-
expected := true
227-
pathToLockFile := "." + string(os.PathSeparator) + "sample-projects" + string(os.PathSeparator) + "lockfile-v3-test" +
228-
string(os.PathSeparator) + "package-lock.json"
229-
usesLockFileV3 := UsesLockfileVersion3(pathToLockFile)
230-
231-
if !usesLockFileV3 {
232-
t.Error("Test failed!")
233-
t.Errorf("Got: %v", strconv.FormatBool(usesLockFileV3))
234-
t.Errorf("Expected: %v", strconv.FormatBool(expected))
235-
}
236-
}
237-
238-
// Unit test for `UsesLockfileVersion3()` with a lock file that does not use version 3 (`./sample-projects/sample-node-project/package-lock.json`)
239-
func TestDoesNotUseLockfileVersion3(t *testing.T) {
240-
expected := false
241-
pathToLockFile := "." + string(os.PathSeparator) + "sample-projects" + string(os.PathSeparator) + "sample-node-project" +
242-
string(os.PathSeparator) + "package-lock.json"
243-
usesLockFileV3 := UsesLockfileVersion3(pathToLockFile)
244-
245-
if usesLockFileV3 {
246-
t.Error("Test failed!")
247-
t.Errorf("Got: %v", strconv.FormatBool(usesLockFileV3))
248-
t.Errorf("Expected: %v", strconv.FormatBool(expected))
249-
}
250-
}
251-
252-
// Integration test for the logic to identify lockfile version 3 with `./sample-projects/lockfile-v3-test`
253-
func TestLockfileV3Integrationtest(t *testing.T) {
254-
sourcePath := "." + string(os.PathSeparator) + "sample-projects" + string(os.PathSeparator) + "lockfile-v3-test"
255-
256-
// generate the zip file and return a list of all its file names
257-
checkForPotentialSmells(sourcePath)
258-
259-
// check if the global `usesLockfileVersion3` is true
260-
if !usesLockfileVersion3 {
261-
t.Error("Test failed! It uses lockfile version 3 but this is not identified")
262-
t.Errorf("Got: %v", strconv.FormatBool(usesLockfileVersion3))
263-
t.Errorf("Expected: %v", strconv.FormatBool(true))
264-
}
265-
}
266-
267223
func generateZipAndReturnItsFiles(sourcePath string, targetPath string, testsPath string) []string {
268224
// generate the zip file, and omit all non-required files
269225
if err := zipSource(sourcePath, targetPath, testsPath); err != nil {

utils.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"encoding/json"
54
"os"
65
"strings"
76

@@ -429,18 +428,3 @@ func IsMiscNotRequiredFile(path string) bool {
429428

430429
return false
431430
}
432-
433-
func UsesLockfileVersion3(path string) bool {
434-
log.Info("Looking at the `package-lock.json` file to identify the lockfile version")
435-
436-
packageLockFile, err := os.ReadFile(path)
437-
if err != nil {
438-
log.Error(err)
439-
}
440-
441-
// parsing the lockfile to JSON and check if version 3 is used
442-
var lockfile map[string]interface{}
443-
json.Unmarshal([]byte(packageLockFile), &lockfile)
444-
445-
return lockfile["lockfileVersion"].(float64) == 3
446-
}

0 commit comments

Comments
 (0)