npq 3.13.5 → 3.15.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/README.md +29 -2
- package/bin/npq-hero.js +9 -0
- package/bin/npq.js +8 -0
- package/lib/cli.js +15 -7
- package/lib/marshalls/snyk.marshall.js +11 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,9 +37,11 @@ npq install express
|
|
|
37
37
|
* Package has a LICENSE file
|
|
38
38
|
* Package has pre/post install scripts
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
**IMPORTANT**: npq by default uses an auto-continue mode when warnings are detected (no errors), waiting 15 seconds before proceeding with the installation. You can disable this behavior via the `--disable-auto-continue` CLI flag or the `NPQ_DISABLE_AUTO_CONTINUE=true` environment variable to enforce a strict review and security hardened installs. See [the auto-continue documentation](docs/feature/auto-continue.md) for more details.
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
When npq completes its signal checks it hands over the actual package install job to the package manager (npm by default, or as specified via the `NPQ_PKG_MGR` environment variable).
|
|
43
|
+
|
|
44
|
+
**DISCLAIMER**: there's no guaranteed absolute safety; a malicious or vulnerable package could still exist that has no security vulnerabilities publicly disclosed and passes npq's checks.
|
|
43
45
|
|
|
44
46
|
## Demo
|
|
45
47
|
|
|
@@ -165,6 +167,31 @@ npq install express --dry-run
|
|
|
165
167
|
npq install express --plain
|
|
166
168
|
```
|
|
167
169
|
|
|
170
|
+
### Disable auto-continue countdown
|
|
171
|
+
|
|
172
|
+
By default, when npq detects only warnings (no errors), it automatically proceeds with installation after a 15-second countdown. To disable this behavior and always require explicit confirmation:
|
|
173
|
+
|
|
174
|
+
**Using the CLI flag:**
|
|
175
|
+
|
|
176
|
+
```sh
|
|
177
|
+
npq install express --disable-auto-continue
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Using the environment variable:**
|
|
181
|
+
|
|
182
|
+
```sh
|
|
183
|
+
export NPQ_DISABLE_AUTO_CONTINUE=true
|
|
184
|
+
npq install express
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Or set it permanently in your shell profile (`.bashrc`, `.zshrc`, etc.):
|
|
188
|
+
|
|
189
|
+
```sh
|
|
190
|
+
export NPQ_DISABLE_AUTO_CONTINUE=true
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
When auto-continue is disabled, npq will always prompt for explicit confirmation before proceeding with installation, even when only warnings are detected.
|
|
194
|
+
|
|
168
195
|
## Learn Node.js Security
|
|
169
196
|
|
|
170
197
|
<div align="center">
|
package/bin/npq-hero.js
CHANGED
|
@@ -14,6 +14,7 @@ const { Spinner } = require('../lib/helpers/cliSpinner')
|
|
|
14
14
|
const { promiseThrottleHelper } = require('../lib/helpers/promiseThrottler')
|
|
15
15
|
|
|
16
16
|
const PACKAGE_MANAGER_TOOL = process.env.NPQ_PKG_MGR
|
|
17
|
+
const DISABLE_AUTO_CONTINUE = process.env.NPQ_DISABLE_AUTO_CONTINUE === 'true'
|
|
17
18
|
|
|
18
19
|
const cliArgs = CliParser.parseArgsMinimal()
|
|
19
20
|
|
|
@@ -80,6 +81,14 @@ marshall
|
|
|
80
81
|
} else {
|
|
81
82
|
if (result && result.countWarnings > 0) {
|
|
82
83
|
console.log()
|
|
84
|
+
// Check if auto-continue is disabled via environment variable
|
|
85
|
+
if (DISABLE_AUTO_CONTINUE) {
|
|
86
|
+
return cliPrompt.prompt({
|
|
87
|
+
name: 'install',
|
|
88
|
+
message: 'Continue install ?',
|
|
89
|
+
default: false
|
|
90
|
+
})
|
|
91
|
+
}
|
|
83
92
|
return cliPrompt.autoContinue({
|
|
84
93
|
name: 'install',
|
|
85
94
|
message: 'Auto-continue with install in... ',
|
package/bin/npq.js
CHANGED
|
@@ -106,6 +106,14 @@ Promise.resolve()
|
|
|
106
106
|
} else {
|
|
107
107
|
if (result && result.countWarnings > 0) {
|
|
108
108
|
console.log()
|
|
109
|
+
// Check if auto-continue is disabled via CLI flag or environment variable
|
|
110
|
+
if (cliArgs.disableAutoContinue) {
|
|
111
|
+
return cliPrompt.prompt({
|
|
112
|
+
name: 'install',
|
|
113
|
+
message: 'Continue install ?',
|
|
114
|
+
default: false
|
|
115
|
+
})
|
|
116
|
+
}
|
|
109
117
|
return cliPrompt.autoContinue({
|
|
110
118
|
name: 'install',
|
|
111
119
|
message: 'Auto-continue with install in... ',
|
package/lib/cli.js
CHANGED
|
@@ -67,6 +67,7 @@ class CliParser {
|
|
|
67
67
|
plain: { type: 'boolean' },
|
|
68
68
|
packageManager: { type: 'string' },
|
|
69
69
|
pkgMgr: { type: 'string' },
|
|
70
|
+
'disable-auto-continue': { type: 'boolean' },
|
|
70
71
|
help: { type: 'boolean', short: 'h' },
|
|
71
72
|
version: { type: 'boolean', short: 'v' }
|
|
72
73
|
}
|
|
@@ -87,12 +88,17 @@ Commands:
|
|
|
87
88
|
install [package...] install a package
|
|
88
89
|
|
|
89
90
|
Options:
|
|
90
|
-
--dry-run
|
|
91
|
-
--plain
|
|
92
|
-
--packageManager
|
|
93
|
-
--pkgMgr
|
|
94
|
-
|
|
95
|
-
-
|
|
91
|
+
--dry-run Run checks only, don't install
|
|
92
|
+
--plain Force non-rich text output
|
|
93
|
+
--packageManager Package Manager to use (default: npm)
|
|
94
|
+
--pkgMgr Alias for packageManager
|
|
95
|
+
--disable-auto-continue Disable auto-continue countdown, always prompt
|
|
96
|
+
-h, --help Show help
|
|
97
|
+
-v, --version Show version
|
|
98
|
+
|
|
99
|
+
Environment Variables:
|
|
100
|
+
NPQ_PKG_MGR Package manager to use (default: npm)
|
|
101
|
+
NPQ_DISABLE_AUTO_CONTINUE Set to 'true' to disable auto-continue
|
|
96
102
|
|
|
97
103
|
Examples:
|
|
98
104
|
npq install express
|
|
@@ -114,7 +120,9 @@ curated by Liran Tal at https://github.com/lirantal/npq`)
|
|
|
114
120
|
packages: normalizedPackages,
|
|
115
121
|
packageManager: values.packageManager || values.pkgMgr || process.env.NPQ_PKG_MGR || 'npm',
|
|
116
122
|
dryRun: values['dry-run'] || false,
|
|
117
|
-
plain: values.plain || false
|
|
123
|
+
plain: values.plain || false,
|
|
124
|
+
disableAutoContinue:
|
|
125
|
+
values['disable-auto-continue'] || process.env.NPQ_DISABLE_AUTO_CONTINUE === 'true'
|
|
118
126
|
}
|
|
119
127
|
}
|
|
120
128
|
|
|
@@ -7,10 +7,7 @@ const BaseMarshall = require('./baseMarshall')
|
|
|
7
7
|
const { marshallCategories } = require('./constants')
|
|
8
8
|
|
|
9
9
|
const MARSHALL_NAME = 'snyk'
|
|
10
|
-
const SNYK_API_URL = 'https://snyk.io/api/v1/vuln/npm'
|
|
11
|
-
|
|
12
10
|
const SNYK_PACKAGE_PAGE = 'https://snyk.io/vuln/npm:'
|
|
13
|
-
const SNYK_API_TOKEN = process.env.SNYK_TOKEN
|
|
14
11
|
const SNYK_CONFIG_FILE = '.config/configstore/snyk.json'
|
|
15
12
|
|
|
16
13
|
class Marshall extends BaseMarshall {
|
|
@@ -20,6 +17,11 @@ class Marshall extends BaseMarshall {
|
|
|
20
17
|
this.categoryId = marshallCategories.SupplyChainSecurity.id
|
|
21
18
|
|
|
22
19
|
this.snykApiToken = this.getSnykToken()
|
|
20
|
+
this.snykApiUrl = this.getSnykApiUrl()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getSnykApiUrl() {
|
|
24
|
+
return process.env.SNYK_API_URL || process.env.SNYK_API || 'https://snyk.io/api/v1/vuln/npm'
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
title() {
|
|
@@ -119,7 +121,7 @@ class Marshall extends BaseMarshall {
|
|
|
119
121
|
return this.getOsvVulnerabilityInfo({ packageName, packageVersion })
|
|
120
122
|
}
|
|
121
123
|
|
|
122
|
-
const url = `${
|
|
124
|
+
const url = `${this.snykApiUrl}/${encodeURIComponent(packageName + '@' + packageVersion)}`
|
|
123
125
|
|
|
124
126
|
return fetch(url, {
|
|
125
127
|
headers: {
|
|
@@ -150,8 +152,11 @@ class Marshall extends BaseMarshall {
|
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
getSnykToken() {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
// Check for SNYK_API_TOKEN first, then fall back to SNYK_TOKEN
|
|
156
|
+
const snykApiToken = process.env.SNYK_API_TOKEN || process.env.SNYK_TOKEN
|
|
157
|
+
|
|
158
|
+
if (snykApiToken) {
|
|
159
|
+
return snykApiToken
|
|
155
160
|
}
|
|
156
161
|
|
|
157
162
|
const snykConfigPath = path.join(os.homedir(), SNYK_CONFIG_FILE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npq",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"description": "marshall your npm/npm package installs with high quality and class 🎖",
|
|
5
5
|
"bin": {
|
|
6
6
|
"npq": "./bin/npq.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"fastest-levenshtein": "^1.0.16",
|
|
47
47
|
"npm-package-arg": "^13.0.0",
|
|
48
|
-
"semver": "^7.7.
|
|
48
|
+
"semver": "^7.7.3",
|
|
49
49
|
"sigstore": "^3.1.0",
|
|
50
50
|
"ssri": "^12.0.0"
|
|
51
51
|
},
|