-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest.js
More file actions
41 lines (36 loc) · 1.72 KB
/
Copy pathtest.js
File metadata and controls
41 lines (36 loc) · 1.72 KB
1
2
3
4
5
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
39
40
41
const assert = require('assert')
const { isNodeVulnerable } = require('./index')
async function t () {
// of course, this test is fragile
assert.ok(await isNodeVulnerable('20.5.0'))
assert.ok(await isNodeVulnerable('20.0.0'))
assert.ok(await isNodeVulnerable('19.0.0'))
assert.ok(await isNodeVulnerable('18.0.0'))
assert.ok(await isNodeVulnerable('14.0.0'))
assert.ok(await isNodeVulnerable('16.0.0'))
assert.ok(await isNodeVulnerable('19.6.0'))
assert.ok(await isNodeVulnerable('18.14.0'))
assert.ok(await isNodeVulnerable('16.19.0'))
assert.ok(await isNodeVulnerable('20.8.0'))
assert.ok(await isNodeVulnerable('20.11.0'))
assert.ok(await isNodeVulnerable('23.6.0'))
assert.ok(await isNodeVulnerable('24.0.1'))
assert.rejects(() => isNodeVulnerable('999'), /Could not fetch version information/)
assert.rejects(() => isNodeVulnerable('Unobtanium'), /Could not fetch version information/) // i.e. not found
// EOL
assert.ok(await isNodeVulnerable('21.0.0'))
assert.ok(await isNodeVulnerable('19.0.0'))
assert.ok(await isNodeVulnerable('16.0.0'))
assert.ok(await isNodeVulnerable('17.0.0'))
assert.ok(await isNodeVulnerable('15.0.0'))
assert.ok(await isNodeVulnerable('13.0.0'))
assert.ok(await isNodeVulnerable('12.0.0'))
assert.ok(await isNodeVulnerable('v0.12.18'))
// Platform specific
assert.ok(await isNodeVulnerable('22.4.0', 'win32'))
assert.ok(await isNodeVulnerable('19.0.0', 'linux'))
assert.ok(await isNodeVulnerable('18.0.0', 'win32'))
assert.ok(await isNodeVulnerable('14.0.0', 'android'))
assert.rejects(() => isNodeVulnerable('20.0.0', 'non-valid-platform'), /platform non-valid-platform is not valid. Please use aix,darwin,freebsd,linux,openbsd,sunos,win32,android/)
}
t()