|
1 | | -const fs = require('fs'); |
2 | | -const util = require('util'); |
| 1 | +const fs = require("fs"); |
| 2 | +const util = require("util"); |
3 | 3 |
|
4 | 4 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
5 | 5 | const readFile = util.promisify(fs.readFile); |
6 | 6 |
|
7 | | -const { parse } = require('./parser'); |
| 7 | +const { parse } = require("./parser"); |
8 | 8 |
|
9 | | -test('ssh-scan parser parses errored result (no ssh server) to zero findings', async () => { |
| 9 | +test("ssh-scan parser parses errored result (no ssh server) to zero findings", async () => { |
10 | 10 | const hosts = JSON.parse( |
11 | | - await readFile(__dirname + '/__testFiles__/localhost.json', { |
12 | | - encoding: 'utf8', |
| 11 | + await readFile(__dirname + "/__testFiles__/localhost.json", { |
| 12 | + encoding: "utf8" |
13 | 13 | }) |
14 | 14 | ); |
15 | 15 |
|
16 | 16 | expect(await parse(hosts)).toEqual([]); |
17 | 17 | }); |
18 | 18 |
|
19 | | -test('ssh-scan parser parses a proper result to proper findings', async () => { |
| 19 | +test("ssh-scan parser parses a proper result to proper findings", async () => { |
20 | 20 | const hosts = JSON.parse( |
21 | | - await readFile(__dirname + '/__testFiles__/securecodebox.io.json', { |
22 | | - encoding: 'utf8', |
| 21 | + await readFile(__dirname + "/__testFiles__/securecodebox.io.json", { |
| 22 | + encoding: "utf8" |
23 | 23 | }) |
24 | 24 | ); |
25 | 25 |
|
@@ -84,14 +84,51 @@ test('ssh-scan parser parses a proper result to proper findings', async () => { |
84 | 84 | "reference": Object {}, |
85 | 85 | "severity": "INFORMATIONAL", |
86 | 86 | }, |
| 87 | + Object { |
| 88 | + "attributes": Object { |
| 89 | + "hostname": "securecodebox.io", |
| 90 | + "ip_address": "138.201.126.99", |
| 91 | + "payload": Array [ |
| 92 | + "diffie-hellman-group14-sha1", |
| 93 | + ], |
| 94 | + }, |
| 95 | + "category": "SSH Policy Violation", |
| 96 | + "description": "Deprecated / discouraged SSH key algorithms are used", |
| 97 | + "hint": "Remove these key exchange algorithms: diffie-hellman-group14-sha1", |
| 98 | + "location": "securecodebox.io", |
| 99 | + "name": "Insecure SSH Key Algorithms", |
| 100 | + "osi_layer": "NETWORK", |
| 101 | + "reference": Object {}, |
| 102 | + "severity": "MEDIUM", |
| 103 | + }, |
| 104 | + Object { |
| 105 | + "attributes": Object { |
| 106 | + "hostname": "securecodebox.io", |
| 107 | + "ip_address": "138.201.126.99", |
| 108 | + "payload": Array [ |
| 109 | + "umac-64-etm@openssh.com", |
| 110 | + "hmac-sha1-etm@openssh.com", |
| 111 | + "umac-64@openssh.com", |
| 112 | + "hmac-sha1", |
| 113 | + ], |
| 114 | + }, |
| 115 | + "category": "SSH Policy Violation", |
| 116 | + "description": "Deprecated / discouraged SSH MAC algorithms are used", |
| 117 | + "hint": "Remove these MAC algorithms: umac-64-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, hmac-sha1", |
| 118 | + "location": "securecodebox.io", |
| 119 | + "name": "Insecure SSH MAC Algorithms", |
| 120 | + "osi_layer": "NETWORK", |
| 121 | + "reference": Object {}, |
| 122 | + "severity": "MEDIUM", |
| 123 | + }, |
87 | 124 | ] |
88 | 125 | `); |
89 | 126 | }); |
90 | 127 |
|
91 | | -test('ssh-scan parser parses a result without a hostname into proper findings', async () => { |
| 128 | +test("ssh-scan parser parses a result without a hostname into proper findings", async () => { |
92 | 129 | const hosts = JSON.parse( |
93 | | - await readFile(__dirname + '/__testFiles__/192.168.42.42.json', { |
94 | | - encoding: 'utf8', |
| 130 | + await readFile(__dirname + "/__testFiles__/192.168.42.42.json", { |
| 131 | + encoding: "utf8" |
95 | 132 | }) |
96 | 133 | ); |
97 | 134 |
|
@@ -157,6 +194,60 @@ test('ssh-scan parser parses a result without a hostname into proper findings', |
157 | 194 | "reference": Object {}, |
158 | 195 | "severity": "INFORMATIONAL", |
159 | 196 | }, |
| 197 | + Object { |
| 198 | + "attributes": Object { |
| 199 | + "hostname": null, |
| 200 | + "ip_address": "192.168.42.42", |
| 201 | + "payload": Array [ |
| 202 | + "diffie-hellman-group14-sha1", |
| 203 | + ], |
| 204 | + }, |
| 205 | + "category": "SSH Policy Violation", |
| 206 | + "description": "Deprecated / discouraged SSH key algorithms are used", |
| 207 | + "hint": "Remove these key exchange algorithms: diffie-hellman-group14-sha1", |
| 208 | + "location": "192.168.42.42", |
| 209 | + "name": "Insecure SSH Key Algorithms", |
| 210 | + "osi_layer": "NETWORK", |
| 211 | + "reference": Object {}, |
| 212 | + "severity": "MEDIUM", |
| 213 | + }, |
| 214 | + Object { |
| 215 | + "attributes": Object { |
| 216 | + "hostname": null, |
| 217 | + "ip_address": "192.168.42.42", |
| 218 | + "payload": Array [ |
| 219 | + "umac-64-etm@openssh.com", |
| 220 | + "hmac-sha1-etm@openssh.com", |
| 221 | + "umac-64@openssh.com", |
| 222 | + "hmac-sha1", |
| 223 | + ], |
| 224 | + }, |
| 225 | + "category": "SSH Policy Violation", |
| 226 | + "description": "Deprecated / discouraged SSH MAC algorithms are used", |
| 227 | + "hint": "Remove these MAC algorithms: umac-64-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, hmac-sha1", |
| 228 | + "location": "192.168.42.42", |
| 229 | + "name": "Insecure SSH MAC Algorithms", |
| 230 | + "osi_layer": "NETWORK", |
| 231 | + "reference": Object {}, |
| 232 | + "severity": "MEDIUM", |
| 233 | + }, |
| 234 | + Object { |
| 235 | + "attributes": Object { |
| 236 | + "hostname": null, |
| 237 | + "ip_address": "192.168.42.42", |
| 238 | + "payload": Array [ |
| 239 | + "password", |
| 240 | + ], |
| 241 | + }, |
| 242 | + "category": "SSH Policy Violation", |
| 243 | + "description": "Discouraged SSH authentication methods are used", |
| 244 | + "hint": "Remove these authentication methods: password", |
| 245 | + "location": "192.168.42.42", |
| 246 | + "name": "Discouraged SSH authentication methods", |
| 247 | + "osi_layer": "NETWORK", |
| 248 | + "reference": Object {}, |
| 249 | + "severity": "MEDIUM", |
| 250 | + }, |
160 | 251 | ] |
161 | 252 | `); |
162 | 253 | }); |
0 commit comments