Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit b1eb1b1

Browse files
committed
Add debbuging when a scan times out
1 parent 1118125 commit b1eb1b1

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

tests/integration/helpers.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ async function deleteScan(name) {
2121
);
2222
}
2323

24+
async function getScan(name) {
25+
const { body: scan } = await k8sCRDApi.getNamespacedCustomObjectStatus(
26+
"execution.experimental.securecodebox.io",
27+
"v1",
28+
namespace,
29+
"scans",
30+
name
31+
);
32+
return scan
33+
}
34+
2435
/**
2536
*
2637
* @param {string} name name of the scan. Actual name will be sufixed with a random number to avoid conflicts
@@ -54,22 +65,18 @@ async function scan(name, scanType, parameters = [], timeout = 180) {
5465

5566
for (let i = 0; i < timeout; i++) {
5667
await sleep(1);
57-
58-
const { body } = await k8sCRDApi.getNamespacedCustomObjectStatus(
59-
"execution.experimental.securecodebox.io",
60-
"v1",
61-
namespace,
62-
"scans",
63-
actualName
64-
);
65-
66-
const scanStatus = body.status;
67-
68-
if (scanStatus && scanStatus.state === "Done") {
68+
const { status } = await getScan(actualName);
69+
70+
if (status && status.state === "Done") {
6971
await deleteScan(actualName);
70-
return scanStatus.findings;
72+
return status.findings;
7173
}
7274
}
75+
76+
console.error("Scan Timed out!")
77+
const scan = await getScan(actualName);
78+
console.log("Last Scan State:")
79+
console.dir(scan)
7380

7481
throw new Error("timed out while waiting for scan results");
7582
}

tests/integration/nmap.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ test(
2121
}
2222
`);
2323
},
24-
3 * 60 * 1000
24+
5 * 60 * 1000
2525
);

0 commit comments

Comments
 (0)