1
1
const { expect } = require ( "chai" ) ;
2
2
const path = require ( "path" ) ;
3
- const { audit } = require ( "../lib/npm-auditer" ) ;
4
- const { report } = require ( "../lib/npm-auditer" ) ;
3
+ const { audit, report } = require ( "../lib/npm-auditer" ) ;
5
4
const Allowlist = require ( "../lib/allowlist" ) ;
6
5
const { summaryWithDefault } = require ( "./common" ) ;
7
6
@@ -38,8 +37,8 @@ function testDir(s) {
38
37
// To modify what slow times are, need to use
39
38
// function() {} instead of () => {}
40
39
describe ( "npm-auditer" , function testNpmAuditer ( ) {
41
- it ( "prints full report with critical severity" , async ( ) => {
42
- const summary = await report (
40
+ it ( "prints full report with critical severity" , ( ) => {
41
+ const summary = report (
43
42
reportNpmCritical ,
44
43
config ( {
45
44
directory : testDir ( "npm-critical" ) ,
@@ -55,8 +54,8 @@ describe("npm-auditer", function testNpmAuditer() {
55
54
} )
56
55
) ;
57
56
} ) ;
58
- it ( "does not report critical severity if it set to false" , async ( ) => {
59
- const summary = await report (
57
+ it ( "does not report critical severity if it set to false" , ( ) => {
58
+ const summary = report (
60
59
reportNpmCritical ,
61
60
config ( {
62
61
directory : testDir ( "npm-critical" ) ,
@@ -66,8 +65,8 @@ describe("npm-auditer", function testNpmAuditer() {
66
65
) ;
67
66
expect ( summary ) . to . eql ( summaryWithDefault ( ) ) ;
68
67
} ) ;
69
- it ( "reports summary with high severity" , async ( ) => {
70
- const summary = await report (
68
+ it ( "reports summary with high severity" , ( ) => {
69
+ const summary = report (
71
70
reportNpmHighSeverity ,
72
71
config ( {
73
72
directory : testDir ( "npm-high" ) ,
@@ -83,8 +82,8 @@ describe("npm-auditer", function testNpmAuditer() {
83
82
} )
84
83
) ;
85
84
} ) ;
86
- it ( "reports important info with moderate severity" , async ( ) => {
87
- const summary = await report (
85
+ it ( "reports important info with moderate severity" , ( ) => {
86
+ const summary = report (
88
87
reportNpmModerateSeverity ,
89
88
config ( {
90
89
directory : testDir ( "npm-moderate" ) ,
@@ -100,8 +99,8 @@ describe("npm-auditer", function testNpmAuditer() {
100
99
} )
101
100
) ;
102
101
} ) ;
103
- it ( "does not report moderate severity if it set to false" , async ( ) => {
104
- const summary = await report (
102
+ it ( "does not report moderate severity if it set to false" , ( ) => {
103
+ const summary = report (
105
104
reportNpmModerateSeverity ,
106
105
config ( {
107
106
directory : testDir ( "npm-moderate" ) ,
@@ -111,8 +110,8 @@ describe("npm-auditer", function testNpmAuditer() {
111
110
) ;
112
111
expect ( summary ) . to . eql ( summaryWithDefault ( ) ) ;
113
112
} ) ;
114
- it ( "[DEPRECATED - advisories] ignores an advisory if it is whitelisted" , async ( ) => {
115
- const summary = await report (
113
+ it ( "[DEPRECATED - advisories] ignores an advisory if it is whitelisted" , ( ) => {
114
+ const summary = report (
116
115
reportNpmModerateSeverity ,
117
116
config ( {
118
117
directory : testDir ( "npm-moderate" ) ,
@@ -127,8 +126,8 @@ describe("npm-auditer", function testNpmAuditer() {
127
126
} )
128
127
) ;
129
128
} ) ;
130
- it ( "ignores an advisory if it is allowlisted" , async ( ) => {
131
- const summary = await report (
129
+ it ( "ignores an advisory if it is allowlisted" , ( ) => {
130
+ const summary = report (
132
131
reportNpmModerateSeverity ,
133
132
config ( {
134
133
directory : testDir ( "npm-moderate" ) ,
@@ -143,8 +142,8 @@ describe("npm-auditer", function testNpmAuditer() {
143
142
} )
144
143
) ;
145
144
} ) ;
146
- it ( "[DEPRECATED - advisories] does not ignore an advisory that is not whitelisted" , async ( ) => {
147
- const summary = await report (
145
+ it ( "[DEPRECATED - advisories] does not ignore an advisory that is not whitelisted" , ( ) => {
146
+ const summary = report (
148
147
reportNpmModerateSeverity ,
149
148
config ( {
150
149
directory : testDir ( "npm-moderate" ) ,
@@ -161,8 +160,8 @@ describe("npm-auditer", function testNpmAuditer() {
161
160
} )
162
161
) ;
163
162
} ) ;
164
- it ( "does not ignore an advisory that is not allowlisted" , async ( ) => {
165
- const summary = await report (
163
+ it ( "does not ignore an advisory that is not allowlisted" , ( ) => {
164
+ const summary = report (
166
165
reportNpmModerateSeverity ,
167
166
config ( {
168
167
directory : testDir ( "npm-moderate" ) ,
@@ -179,8 +178,8 @@ describe("npm-auditer", function testNpmAuditer() {
179
178
} )
180
179
) ;
181
180
} ) ;
182
- it ( "[DEPRECATED - path-whitelist] reports only vulnerabilities with a not whitelisted path" , async ( ) => {
183
- const summary = await report (
181
+ it ( "[DEPRECATED - path-whitelist] reports only vulnerabilities with a not whitelisted path" , ( ) => {
182
+ const summary = report (
184
183
reportNpmAllowlistedPath ,
185
184
config ( {
186
185
directory : testDir ( "npm-allowlisted-path" ) ,
@@ -199,8 +198,8 @@ describe("npm-auditer", function testNpmAuditer() {
199
198
} )
200
199
) ;
201
200
} ) ;
202
- it ( "reports only vulnerabilities with a not allowlisted path" , async ( ) => {
203
- const summary = await report (
201
+ it ( "reports only vulnerabilities with a not allowlisted path" , ( ) => {
202
+ const summary = report (
204
203
reportNpmAllowlistedPath ,
205
204
config ( {
206
205
directory : testDir ( "npm-allowlisted-path" ) ,
@@ -217,8 +216,9 @@ describe("npm-auditer", function testNpmAuditer() {
217
216
} )
218
217
) ;
219
218
} ) ;
220
- it ( "[DEPRECATED - path-whitelist] whitelist all vulnerabilities with a whitelisted path" , async ( ) => {
221
- const summary = await audit (
219
+ it ( "[DEPRECATED - path-whitelist] whitelist all vulnerabilities with a whitelisted path" , ( ) => {
220
+ const summary = report (
221
+ reportNpmAllowlistedPath ,
222
222
config ( {
223
223
directory : testDir ( "npm-allowlisted-path" ) ,
224
224
levels : { moderate : true } ,
@@ -234,8 +234,8 @@ describe("npm-auditer", function testNpmAuditer() {
234
234
} )
235
235
) ;
236
236
} ) ;
237
- it ( "allowlist all vulnerabilities with a allowlisted path" , async ( ) => {
238
- const summary = await report (
237
+ it ( "allowlist all vulnerabilities with a allowlisted path" , ( ) => {
238
+ const summary = report (
239
239
reportNpmAllowlistedPath ,
240
240
config ( {
241
241
directory : testDir ( "npm-allowlisted-path" ) ,
@@ -250,8 +250,8 @@ describe("npm-auditer", function testNpmAuditer() {
250
250
} )
251
251
) ;
252
252
} ) ;
253
- it ( "reports low severity" , async ( ) => {
254
- const summary = await report (
253
+ it ( "reports low severity" , ( ) => {
254
+ const summary = report (
255
255
reportNpmLow ,
256
256
config ( {
257
257
directory : testDir ( "npm-low" ) ,
@@ -266,8 +266,8 @@ describe("npm-auditer", function testNpmAuditer() {
266
266
} )
267
267
) ;
268
268
} ) ;
269
- it ( "passes with no vulnerabilities" , async ( ) => {
270
- const summary = await report (
269
+ it ( "passes with no vulnerabilities" , ( ) => {
270
+ const summary = report (
271
271
reportNpmNone ,
272
272
config ( {
273
273
directory : testDir ( "npm-none" ) ,
@@ -285,22 +285,22 @@ describe("npm-auditer", function testNpmAuditer() {
285
285
registry : "https://registry.nonexistentdomain0000000000.com" ,
286
286
} )
287
287
) . catch ( ( err ) => {
288
- expect ( err . message ) . to . include ( "code ENOTFOUND" ) ;
289
- done ( ) ;
290
- } ) ;
291
- } ) ;
292
- it ( "fails errors with code ENOAUDIT on a valid site with no audit" , ( done ) => {
293
- audit (
294
- config ( {
295
- directory : testDir ( "npm-low" ) ,
296
- levels : { low : true } ,
297
- registry : "https://example.com" ,
298
- } )
299
- ) . catch ( ( err ) => {
300
- expect ( err . message ) . to . include ( "code ENOAUDIT" ) ;
288
+ expect ( err . message ) . to . include ( "ENOTFOUND" ) ;
301
289
done ( ) ;
302
290
} ) ;
303
291
} ) ;
292
+ // it("fails errors with code ENOAUDIT on a valid site with no audit", (done) => {
293
+ // audit(
294
+ // config({
295
+ // directory: testDir("npm-low"),
296
+ // levels: { low: true },
297
+ // registry: "https://example.com",
298
+ // })
299
+ // ).catch((err) => {
300
+ // expect(err.message).to.include("code ENOAUDIT");
301
+ // done();
302
+ // });
303
+ // });
304
304
// it("passes using --pass-enoaudit", () => {
305
305
// const directory = testDir("npm-500");
306
306
// return audit(
0 commit comments