check-package-lock 1.12.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +10 -0
- package/.github/workflows/ci.yml +7 -5
- package/.github/workflows/scorecard.yml +5 -1
- package/README.md +42 -46
- package/eslint.config.js +15 -17
- package/index.js +46 -68
- package/package.json +10 -11
- package/test/index.js +52 -56
package/.github/workflows/ci.yml
CHANGED
|
@@ -7,15 +7,16 @@ concurrency:
|
|
|
7
7
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
8
8
|
cancel-in-progress: true
|
|
9
9
|
|
|
10
|
-
permissions:
|
|
11
|
-
contents: read
|
|
12
|
-
security-events: write
|
|
10
|
+
permissions: {}
|
|
13
11
|
|
|
14
12
|
jobs:
|
|
15
13
|
build:
|
|
16
14
|
name: Build and Test
|
|
17
15
|
runs-on: ubuntu-latest
|
|
18
16
|
environment: Development
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
security-events: write # to report vulnerabilities
|
|
19
20
|
|
|
20
21
|
steps:
|
|
21
22
|
- name: Harden Runner
|
|
@@ -81,15 +82,16 @@ jobs:
|
|
|
81
82
|
run: ./node_modules/.bin/eslint '*.js' 'test/*.js'
|
|
82
83
|
|
|
83
84
|
- name: Run tests with coverage
|
|
84
|
-
run: ./node_modules/.bin/
|
|
85
|
+
run: ./node_modules/.bin/c8 ./node_modules/.bin/mocha
|
|
85
86
|
|
|
86
87
|
- name: Generate coverage report
|
|
87
|
-
run: ./node_modules/.bin/
|
|
88
|
+
run: ./node_modules/.bin/c8 report --reporter=lcov
|
|
88
89
|
|
|
89
90
|
- name: Upload coverage to Codecov
|
|
90
91
|
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
|
|
91
92
|
# https://github.com/codecov/codecov-action/releases
|
|
92
93
|
with:
|
|
94
|
+
files: coverage/lcov.info
|
|
93
95
|
fail_ci_if_error: true
|
|
94
96
|
env:
|
|
95
97
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -10,8 +10,12 @@ on:
|
|
|
10
10
|
push:
|
|
11
11
|
branches: [ "main" ]
|
|
12
12
|
|
|
13
|
+
concurrency:
|
|
14
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
15
|
+
cancel-in-progress: true
|
|
16
|
+
|
|
13
17
|
# Declare default permissions as read only.
|
|
14
|
-
permissions:
|
|
18
|
+
permissions: {}
|
|
15
19
|
|
|
16
20
|
jobs:
|
|
17
21
|
analysis:
|
package/README.md
CHANGED
|
@@ -1,46 +1,42 @@
|
|
|
1
|
-
# check-package-lock
|
|
2
|
-
Checks the package-lock.json file for http:// links
|
|
3
|
-
|
|
4
|
-
## What does it do?
|
|
5
|
-
check-package-lock can check if the package-lock.json file contain insecure http:// links
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
To check the package-lock.json file in the current folder:
|
|
9
|
-
```
|
|
10
|
-
npm install -g check-package-lock
|
|
11
|
-
check-package-lock
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
To check the package-lock.json file in another folder:
|
|
15
|
-
```
|
|
16
|
-
npm install -g check-package-lock
|
|
17
|
-
check-package-lock --folder 'nodefolder'
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Exit codes
|
|
21
|
-
```
|
|
22
|
-
0 = No errors
|
|
23
|
-
1 = Errors were founds in the package-lock.json files
|
|
24
|
-
2 = package-lock.json was not found
|
|
25
|
-
3 = Folder specified does not exists
|
|
26
|
-
4 = Folder specified is not a folder
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## CI - Continuous Integration
|
|
30
|
-
check-package-lock can be used in CI environments to check your package-lock.json file before merging a pull request
|
|
31
|
-
|
|
32
|
-
## Badges
|
|
33
|
-
|
|
34
|
-
[](https://www.codefactor.io/repository/github/gemal/node-check-package-lock)
|
|
45
|
-
|
|
46
|
-
[](https://deepscan.io/dashboard#view=project&tid=14204&pid=17307&bid=392368)
|
|
1
|
+
# check-package-lock
|
|
2
|
+
Checks the package-lock.json file for http:// links
|
|
3
|
+
|
|
4
|
+
## What does it do?
|
|
5
|
+
check-package-lock can check if the package-lock.json file contain insecure http:// links
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
To check the package-lock.json file in the current folder:
|
|
9
|
+
```
|
|
10
|
+
npm install -g check-package-lock
|
|
11
|
+
check-package-lock
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
To check the package-lock.json file in another folder:
|
|
15
|
+
```
|
|
16
|
+
npm install -g check-package-lock
|
|
17
|
+
check-package-lock --folder 'nodefolder'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Exit codes
|
|
21
|
+
```
|
|
22
|
+
0 = No errors
|
|
23
|
+
1 = Errors were founds in the package-lock.json files
|
|
24
|
+
2 = package-lock.json was not found
|
|
25
|
+
3 = Folder specified does not exists
|
|
26
|
+
4 = Folder specified is not a folder
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## CI - Continuous Integration
|
|
30
|
+
check-package-lock can be used in CI environments to check your package-lock.json file before merging a pull request
|
|
31
|
+
|
|
32
|
+
## Badges
|
|
33
|
+
|
|
34
|
+
[](https://codecov.io/gh/gemal/node-check-package-lock)
|
|
35
|
+
|
|
36
|
+
[](https://github.styleci.io/repos/183420925)
|
|
37
|
+
|
|
38
|
+
[](https://snyk.io/test/github/gemal/node-check-package-lock)
|
|
39
|
+
|
|
40
|
+
[](https://www.codefactor.io/repository/github/gemal/node-check-package-lock)
|
|
41
|
+
|
|
42
|
+
[](https://deepscan.io/dashboard#view=project&tid=14204&pid=17307&bid=392368)
|
package/eslint.config.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import globals from "globals";
|
|
2
|
-
import js from "@eslint/js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
js.configs.recommended,
|
|
17
|
-
];
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import js from "@eslint/js";
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
{
|
|
6
|
+
languageOptions: {
|
|
7
|
+
globals: {
|
|
8
|
+
...globals.node,
|
|
9
|
+
describe: "readonly",
|
|
10
|
+
it: "readonly",
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
js.configs.recommended,
|
|
15
|
+
];
|
package/index.js
CHANGED
|
@@ -1,68 +1,46 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} else {
|
|
39
|
-
console.log(
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.
|
|
46
|
-
|
|
47
|
-
.option('-f, --folder <folder>', 'Folder with package-lock.json file')
|
|
48
|
-
.parse(process.argv);
|
|
49
|
-
|
|
50
|
-
const options = program.opts();
|
|
51
|
-
if (options.folder) {
|
|
52
|
-
if (fs.existsSync(options.folder)) {
|
|
53
|
-
const stats = fs.statSync(options.folder);
|
|
54
|
-
if (stats.isDirectory()) {
|
|
55
|
-
const err = checkFolder();
|
|
56
|
-
process.exitCode = err;
|
|
57
|
-
} else {
|
|
58
|
-
console.log('Oops! Folder is not a real folder: ' + options.folder);
|
|
59
|
-
process.exitCode = 4;
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
console.log('Oops! Folder does not exist: ' + options.folder);
|
|
63
|
-
process.exitCode = 3;
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
const err = checkFolder();
|
|
67
|
-
process.exitCode = err;
|
|
68
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { program } from 'commander';
|
|
6
|
+
|
|
7
|
+
function checkFolder(folder) {
|
|
8
|
+
const packPath = folder ? path.join(folder, 'package-lock.json') : 'package-lock.json';
|
|
9
|
+
if (!fs.existsSync(packPath)) {
|
|
10
|
+
console.log(`${packPath} does not exist`);
|
|
11
|
+
return 2;
|
|
12
|
+
}
|
|
13
|
+
const filecontent = fs.readFileSync(packPath, { encoding: 'utf-8' });
|
|
14
|
+
if (/"http:\/\/registry\.npmjs\.org[/"']/.test(filecontent)) {
|
|
15
|
+
console.log(`${packPath} is NOT OK. It contains references to http://registry.npmjs.org`);
|
|
16
|
+
console.log('In order to fix this do:');
|
|
17
|
+
console.log('- Delete the package-lock.json file');
|
|
18
|
+
console.log('- Delete the node_modules folder');
|
|
19
|
+
console.log('- Run <npm cache clean --force>');
|
|
20
|
+
console.log('- Run <npm install>');
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
console.log(`${packPath} is OK`);
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
program
|
|
28
|
+
.version(JSON.parse(fs.readFileSync(path.join(import.meta.dirname, 'package.json'))).version)
|
|
29
|
+
.description('Checks the package-lock.json file for http:// links')
|
|
30
|
+
.option('-f, --folder <folder>', 'Folder with package-lock.json file')
|
|
31
|
+
.parse(process.argv);
|
|
32
|
+
|
|
33
|
+
const options = program.opts();
|
|
34
|
+
if (options.folder) {
|
|
35
|
+
if (!fs.existsSync(options.folder)) {
|
|
36
|
+
console.log(`Oops! Folder does not exist: ${options.folder}`);
|
|
37
|
+
process.exitCode = 3;
|
|
38
|
+
} else if (!fs.statSync(options.folder).isDirectory()) {
|
|
39
|
+
console.log(`Oops! Folder is not a real folder: ${options.folder}`);
|
|
40
|
+
process.exitCode = 4;
|
|
41
|
+
} else {
|
|
42
|
+
process.exitCode = checkFolder(options.folder);
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
process.exitCode = checkFolder();
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "check-package-lock",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "Checks the package-lock.json file for insecure http:// links",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"url": "https://github.com/gemal/node-check-package-lock.git"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "mocha"
|
|
11
|
+
"test": "mocha",
|
|
12
|
+
"eslint": "eslint *.js test/*.js"
|
|
12
13
|
},
|
|
13
14
|
"type": "module",
|
|
14
15
|
"author": "Henrik Gemal <henrik@gemal.dk> (https://gemal.dk/)",
|
|
@@ -31,16 +32,14 @@
|
|
|
31
32
|
],
|
|
32
33
|
"homepage": "https://github.com/gemal/node-check-package-lock",
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"commander": "^
|
|
35
|
+
"commander": "^15.0.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@eslint/js": "^
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"eslint": "^
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"mocha": "^10.0.0",
|
|
44
|
-
"nyc": "^17.1.0"
|
|
38
|
+
"@eslint/js": "^10.0.1",
|
|
39
|
+
"c8": "^11.0.0",
|
|
40
|
+
"chai": "^6.2.2",
|
|
41
|
+
"eslint": "^10.5.0",
|
|
42
|
+
"globals": "^17.6.0",
|
|
43
|
+
"mocha": "^11.7.6"
|
|
45
44
|
}
|
|
46
45
|
}
|
package/test/index.js
CHANGED
|
@@ -1,56 +1,52 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { exec } from
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
it('should exit
|
|
26
|
-
runTest(['--folder', 'test/
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should exit 0 having no problems', function(done) {
|
|
30
|
-
runTest(['--folder', 'test/test2'], 0, /package-lock.json is OK/, done);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should exit 0 having no problems
|
|
34
|
-
runTest([
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should exit
|
|
38
|
-
runTest([],
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should exit
|
|
42
|
-
runTest(['--folder', 'test
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should exit
|
|
46
|
-
runTest(['--folder', '
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should exit
|
|
50
|
-
runTest(['--folder', '
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should exit 4 if folder is not a folder', function(done) {
|
|
54
|
-
runTest(['--folder', 'test/index.js'], 4, /Oops! Folder is not a real folder: test\/index.js\n/, done);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { exec } from 'node:child_process';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
|
|
8
|
+
describe('index.js', function() {
|
|
9
|
+
this.timeout(8000);
|
|
10
|
+
|
|
11
|
+
function runTest(args, expectedExitCode, expectedOutput, done) {
|
|
12
|
+
const command = `node ${path.join(__dirname, '../index.js')} ${args.join(' ')}`;
|
|
13
|
+
exec(command, { cwd: path.join(__dirname, '../') }, (error, stdout) => {
|
|
14
|
+
const exitCode = error ? error.code : 0;
|
|
15
|
+
expect(exitCode).to.equal(expectedExitCode);
|
|
16
|
+
expect(stdout).to.match(expectedOutput);
|
|
17
|
+
done();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
it('should exit 1 having problems in test1', function(done) {
|
|
22
|
+
runTest(['--folder', 'test/test1'], 1, /package-lock.json is NOT OK/, done);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should exit 0 having no problems', function(done) {
|
|
26
|
+
runTest(['--folder', 'test/test2'], 0, /package-lock.json is OK/, done);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should exit 0 having no problems with slash', function(done) {
|
|
30
|
+
runTest(['--folder', 'test/test2/'], 0, /package-lock.json is OK/, done);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should exit 0 having no problems without folder', function(done) {
|
|
34
|
+
runTest([], 0, /package-lock.json is OK/, done);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should exit 1 having problems in test3', function(done) {
|
|
38
|
+
runTest(['--folder', 'test/test3'], 1, /package-lock.json is NOT OK/, done);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should exit 2 having problems with no file', function(done) {
|
|
42
|
+
runTest(['--folder', 'test'], 2, /package-lock.json does not exist/, done);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should exit 3 if folder does not exist', function(done) {
|
|
46
|
+
runTest(['--folder', '404'], 3, /Oops! Folder does not exist: 404/, done);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should exit 4 if folder is not a folder', function(done) {
|
|
50
|
+
runTest(['--folder', 'test/index.js'], 4, /Oops! Folder is not a real folder: test\/index.js/, done);
|
|
51
|
+
});
|
|
52
|
+
});
|