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

Commit fb8a9f1

Browse files
J12934jorgestiganigthknight
committed
WIP
Co-authored-by: Jorge Estigarribia <jorgestiga@hotmail.com> Co-authored-by: Yannik Fuhrmeister <12710254+fuhrmeistery@users.noreply.github.com>
1 parent 1b6b08b commit fb8a9f1

File tree

7 files changed

+83
-6
lines changed

7 files changed

+83
-6
lines changed

operator/apis/execution/v1/scan_types.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ type ScanStatus struct {
4545
RawResultFile string `json:"rawResultFile,omitempty"`
4646

4747
Findings FindingStats `json:"findings,omitempty"`
48+
49+
ReadAndWriteHookStatus []HookStatus `json:"readAndWriteHookStatus,omitempty"`
50+
}
51+
52+
// HookState Describes the State of a Hook on a Scan
53+
type HookState string
54+
55+
const (
56+
Pending HookState = "Pending"
57+
InProgress HookState = "InProgress"
58+
Completed HookState = "Completed"
59+
60+
// Cancelled HookState = "Cancelled"
61+
// Failed HookState = "Failed"
62+
)
63+
64+
type HookStatus struct {
65+
HookName string `json:"hookName"`
66+
State HookState `json:"state"`
67+
JobName string `json:"jobName"`
4868
}
4969

5070
// FindingStats contains the general stats about the results of the scan

operator/config/crd/bases/execution.experimental.securecodebox.io_scans.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ spec:
113113
description: RawResultType determines which kind of ParseDefinition
114114
will be used to turn the raw results of the scanner into findings
115115
type: string
116+
readAndWriteHookStatus:
117+
items:
118+
properties:
119+
hookName:
120+
type: string
121+
jobName:
122+
type: string
123+
state:
124+
type: string
125+
required:
126+
- hookName
127+
- jobName
128+
- state
129+
type: object
130+
type: array
116131
state:
117132
type: string
118133
type: object

operator/config/samples/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
FROM alpine
2-
CMD [sleep, 5s]
2+
ENTRYPOINT [sleep, 5s]

operator/config/samples/execution_v1_persistenceprovider.yaml renamed to operator/config/samples/execution_v1_readonlyhook.yaml

File renamed without changes.
Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
1-
apiVersion: "execution.experimental.securecodebox.io/v1"
1+
apiVersion: execution.experimental.securecodebox.io/v1
22
kind: Scan
33
metadata:
4-
name: "nmap-localhost"
4+
finalizers:
5+
- s3.storage.experimental.securecodebox.io
6+
name: nmap-localhost
7+
namespace: default
58
spec:
6-
scanType: "nmap"
79
parameters:
8-
- "-Pn"
10+
- -Pn
911
- localhost
12+
scanType: nmap
13+
status:
14+
state: Errored
15+
errorDescription: At least one ReadOnlyHook failed, check the hooks kubernetes jobs related to the scan for more details.
16+
findings:
17+
categories:
18+
Host: 1
19+
count: 1
20+
severities:
21+
informational: 1
22+
rawResultFile: nmap-results.xml
23+
rawResultType: nmap-xml
24+
readAndWriteHookStatus:
25+
- hookName: luy-metadata
26+
state: Completed
27+
jobName: luy-metadata-123123
28+
- hookName: finding-priority
29+
state: Error
30+
jobName: finding-priority-123123
31+
error: "Job failed"
32+
- hookName: hook-3
33+
state: Pending

operator/controllers/execution/scan_controller.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,23 @@ func (r *ScanReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
113113
case "Parsing":
114114
err = r.checkIfParsingIsCompleted(&scan)
115115
case "ParseCompleted":
116+
// Hook status erstellen
117+
// List all ReadAndWrite Hook -> Hook Status an Scan hängen
118+
// Scan State auf ReadAndWriteHookProcessing setzen
119+
case "ReadAndWriteHookProcessing":
120+
// Hook Status Array durchgegen
121+
122+
// hook := First Array entry which is not Completed.
123+
124+
// if hook == "Pending" => create Job
125+
// if hook == "InProgress" =>
126+
// if job == "Completed" => hook = "Completed"
127+
// (if job == "Failed" => hook = "Failed" => scan = "Failed")
128+
129+
// hook = nil => scan = "ReadAndWriteHookCompleted"
130+
131+
// Scan Status auf ReadAndWriteHookCompleted setzen
132+
case "ReadAndWriteHookCompleted":
116133
err = r.startReadOnlyHooks(&scan)
117134
case "ReadOnlyHookProcessing":
118135
err = r.checkIfReadOnlyHookIsCompleted(&scan)

persistence/persistence-elastic/templates/persistence-provider.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
apiVersion: "execution.experimental.securecodebox.io/v1"
2-
kind: PersistenceProvider
2+
kind: ScanCompletionHook
33
metadata:
44
name: {{ include "persistence-elastic.fullname" . }}
55
labels:
66
type: Structured
77
spec:
8+
type: ReadOnly
89
image: "scbexperimental/persistence-elastic:latest"
910
{{- if .Values.image.digest }}
1011
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}@{{ .Values.image.digest }}"

0 commit comments

Comments
 (0)