forked from secureCodeBox/secureCodeBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnmap.test.js
More file actions
84 lines (73 loc) · 1.93 KB
/
nmap.test.js
File metadata and controls
84 lines (73 loc) · 1.93 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const { startSecurityTest, Time } = require('./sdk');
test(
'finds open 3000 port of juiceshop',
async () => {
const securityTest = await startSecurityTest({
context: 'JuiceShopPortScan',
metaData: {},
name: 'nmap',
target: {
name: 'JuiceShop Container',
location: 'juice-shop',
attributes: {
NMAP_PARAMETER: '-Pn',
},
},
});
const { report } = securityTest;
const findings = report.findings.map(
({ description, category, name, osi_layer, severity }) => ({
description,
category,
name,
osi_layer,
severity,
})
);
expect(findings).toContainEqual({
description: 'Port 3000 is open using tcp protocol.',
category: 'Open Port',
name: 'ppp',
osi_layer: 'NETWORK',
severity: 'INFORMATIONAL',
});
expect(findings.length).toBe(1);
},
1 * Time.Minute
);
test(
'finds 3 open ports of bodgeit',
async () => {
const securityTest = await startSecurityTest({
context: 'BodgeItPortScan',
metaData: {},
name: 'nmap',
target: {
name: 'BodgeIt Container',
location: 'bodgeit',
attributes: {
NMAP_PARAMETER: '-Pn',
},
},
});
const { report } = securityTest;
const [finding1, finding2, finding3, ...otherFindings] = report.findings;
expect(finding1).toMatchObject({
description: 'Port 8009 is open using tcp protocol.',
category: 'Open Port',
severity: 'INFORMATIONAL',
});
expect(finding2).toMatchObject({
description: 'Port 8080 is open using tcp protocol.',
category: 'Open Port',
severity: 'INFORMATIONAL',
});
expect(finding3).toMatchObject({
description: 'Port 8443 is open using tcp protocol.',
category: 'Open Port',
severity: 'INFORMATIONAL',
});
expect(otherFindings).toEqual([]);
},
1 * Time.Minute
);