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

Commit 2186f9c

Browse files
committed
Added ownerReference to all subsequent scan created by the nmap-subsequent-scans hook. Now it ist possible to delete the primary scan and all subsequent scans will be deleted too.
1 parent c43da41 commit 2186f9c

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

hooks/nmap-subsequent-scans/hook.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async function handle({ scan, getFindings }) {
6767
*/
6868
async function startZAPBaselineScan({ parentScan, hostname, port }) {
6969
console.log(
70-
" --> starting subsequent ZAP Scan for host: " + hostname + ":" + port
70+
" --> Starting async subsequent ZAP Scan for host: " + hostname + ":" + port
7171
);
7272

7373
await startSubsequentSecureCodeBoxScan({
@@ -85,7 +85,7 @@ async function startZAPBaselineScan({ parentScan, hostname, port }) {
8585
*/
8686
async function startSSHScan({ parentScan, hostname, port }) {
8787
console.log(
88-
" --> starting subsequent SSH Scan for host: " + hostname + ":" + port
88+
" --> Starting async subsequent SSH Scan for host: " + hostname + ":" + port
8989
);
9090

9191
await startSubsequentSecureCodeBoxScan({
@@ -103,7 +103,7 @@ async function startSSHScan({ parentScan, hostname, port }) {
103103
*/
104104
async function startNiktoScan({ parentScan, hostname, port }) {
105105
console.log(
106-
" --> starting subsequent Nikto Scan for host: " + hostname + ":" + port
106+
" --> Starting async subsequent Nikto Scan for host: " + hostname + ":" + port
107107
);
108108

109109
await startSubsequentSecureCodeBoxScan({
@@ -121,7 +121,7 @@ async function startNiktoScan({ parentScan, hostname, port }) {
121121
*/
122122
async function startSSLyzeScan({ parentScan, hostname, port }) {
123123
console.log(
124-
" --> starting subsequent SSLyze Scan for host: " + hostname + ":" + port
124+
" --> Starting async subsequent SSLyze Scan for host: " + hostname + ":" + port
125125
);
126126

127127
await startSubsequentSecureCodeBoxScan({

hooks/nmap-subsequent-scans/scan-helpers.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ async function startSubsequentSecureCodeBoxScan({
2020
labels: {
2121
...parentScan.metadata.labels,
2222
},
23+
annotations: {
24+
'securecodebox.io/hook': 'nmap-subsequent-scans',
25+
'securecodebox.io/parent-scan': parentScan.metadata.name,
26+
},
27+
...(await getOwnerReference(parentScan)),
2328
},
2429
spec: {
2530
scanType,
2631
parameters,
2732
},
2833
};
2934

35+
3036
try {
3137
// Starting another subsequent sslyze scan based on the nmap results
3238
// found at: https://github.com/kubernetes-client/javascript/blob/79736b9a608c18d818de61a6b44503a08ea3a78f/src/gen/api/customObjectsApi.ts#L209
@@ -44,4 +50,19 @@ async function startSubsequentSecureCodeBoxScan({
4450
}
4551
}
4652

53+
async function getOwnerReference(parentScan) {
54+
return {
55+
ownerReferences: [
56+
{
57+
apiVersion: 'execution.experimental.securecodebox.io/v1',
58+
blockOwnerDeletion: true,
59+
controller: true,
60+
kind: 'Scan',
61+
name: parentScan.metadata.name,
62+
uid: parentScan.metadata.uid,
63+
},
64+
],
65+
};
66+
}
67+
4768
module.exports.startSubsequentSecureCodeBoxScan = startSubsequentSecureCodeBoxScan;

0 commit comments

Comments
 (0)