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

Commit c220959

Browse files
authored
Merge pull request #2 from secureCodeBox/hooks
Hooks Concept Implementation
2 parents 4f0a0dd + cd4af69 commit c220959

File tree

310 files changed

+55052
-890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

310 files changed

+55052
-890
lines changed

.github/workflows/ci.yaml

Lines changed: 88 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
run: ls
1111
- name: "Install npm dependencies in all parser sub projects"
1212
run: |
13-
for dir in integrations/*/parser/
13+
for dir in scanner/*/parser/
1414
do
1515
cd $dir
1616
if [ -f package.json ] && [ -f package-lock.json ]; then
@@ -20,9 +20,9 @@ jobs:
2020
# cd back
2121
cd -
2222
done
23-
- name: "Install npm dependencies in all persistence sub projects"
23+
- name: "Install npm dependencies in all hook sub projects"
2424
run: |
25-
for dir in persistence/*/
25+
for dir in hooks/*/
2626
do
2727
cd $dir
2828
if [ -f package.json ] && [ -f package-lock.json ]; then
@@ -35,7 +35,10 @@ jobs:
3535
- name: "Install npm test dependencies"
3636
run: |
3737
npm ci
38-
cd integrations/
38+
cd scanner/
39+
npm ci
40+
cd -
41+
cd hooks/
3942
npm ci
4043
- name: "Run tests"
4144
run: |
@@ -106,7 +109,7 @@ jobs:
106109
username: ${{ secrets.DOCKER_USERNAME }}
107110
password: ${{ secrets.DOCKER_PASSWORD }}
108111
repository: scbexperimental/parser-amass
109-
path: ./integrations/amass/parser/
112+
path: ./scanner/amass/parser/
110113
tag_with_ref: true
111114
tag_with_sha: true
112115
- uses: docker/build-push-action@v1
@@ -115,7 +118,7 @@ jobs:
115118
username: ${{ secrets.DOCKER_USERNAME }}
116119
password: ${{ secrets.DOCKER_PASSWORD }}
117120
repository: scbexperimental/parser-kube-hunter
118-
path: ./integrations/kube-hunter/parser/
121+
path: ./scanner/kube-hunter/parser/
119122
tag_with_ref: true
120123
tag_with_sha: true
121124
- uses: docker/build-push-action@v1
@@ -124,7 +127,7 @@ jobs:
124127
username: ${{ secrets.DOCKER_USERNAME }}
125128
password: ${{ secrets.DOCKER_PASSWORD }}
126129
repository: scbexperimental/parser-nikto
127-
path: ./integrations/nikto/parser/
130+
path: ./scanner/nikto/parser/
128131
tag_with_ref: true
129132
tag_with_sha: true
130133
- uses: docker/build-push-action@v1
@@ -133,7 +136,7 @@ jobs:
133136
username: ${{ secrets.DOCKER_USERNAME }}
134137
password: ${{ secrets.DOCKER_PASSWORD }}
135138
repository: scbexperimental/parser-nmap
136-
path: ./integrations/nmap/parser/
139+
path: ./scanner/nmap/parser/
137140
tag_with_ref: true
138141
tag_with_sha: true
139142
- uses: docker/build-push-action@v1
@@ -142,7 +145,7 @@ jobs:
142145
username: ${{ secrets.DOCKER_USERNAME }}
143146
password: ${{ secrets.DOCKER_PASSWORD }}
144147
repository: scbexperimental/parser-ssh-scan
145-
path: ./integrations/ssh_scan/parser/
148+
path: ./scanner/ssh_scan/parser/
146149
tag_with_ref: true
147150
tag_with_sha: true
148151
- uses: docker/build-push-action@v1
@@ -151,7 +154,16 @@ jobs:
151154
username: ${{ secrets.DOCKER_USERNAME }}
152155
password: ${{ secrets.DOCKER_PASSWORD }}
153156
repository: scbexperimental/parser-sslyze
154-
path: ./integrations/sslyze/parser/
157+
path: ./scanner/sslyze/parser/
158+
tag_with_ref: true
159+
tag_with_sha: true
160+
- uses: docker/build-push-action@v1
161+
name: "Build & Push test-scan Parser Image"
162+
with:
163+
username: ${{ secrets.DOCKER_USERNAME }}
164+
password: ${{ secrets.DOCKER_PASSWORD }}
165+
repository: scbexperimental/parser-test-scan
166+
path: ./scanner/test-scan/parser/
155167
tag_with_ref: true
156168
tag_with_sha: true
157169
- uses: docker/build-push-action@v1
@@ -160,7 +172,7 @@ jobs:
160172
username: ${{ secrets.DOCKER_USERNAME }}
161173
password: ${{ secrets.DOCKER_PASSWORD }}
162174
repository: scbexperimental/parser-trivy
163-
path: ./integrations/trivy/parser/
175+
path: ./scanner/trivy/parser/
164176
tag_with_ref: true
165177
tag_with_sha: true
166178
- uses: docker/build-push-action@v1
@@ -169,40 +181,65 @@ jobs:
169181
username: ${{ secrets.DOCKER_USERNAME }}
170182
password: ${{ secrets.DOCKER_PASSWORD }}
171183
repository: scbexperimental/parser-zap
172-
path: ./integrations/zap/parser/
184+
path: ./scanner/zap/parser/
173185
tag_with_ref: true
174186
tag_with_sha: true
175-
persistenceImages:
176-
name: "Build / PersistenceProviders"
187+
hookImages:
188+
name: "Build / Hooks"
177189
runs-on: ubuntu-latest
178190
steps:
179191
- uses: actions/checkout@master
180192
# SDK
181193
- uses: docker/build-push-action@v1
182-
name: "Build & Push Persistence SDK"
194+
name: "Build & Push Hook SDK"
183195
with:
184196
username: ${{ secrets.DOCKER_USERNAME }}
185197
password: ${{ secrets.DOCKER_PASSWORD }}
186-
repository: scbexperimental/persistence-sdk-nodejs
187-
path: ./persistence-sdk/nodejs/
198+
repository: scbexperimental/hook-sdk-nodejs
199+
path: ./hook-sdk/nodejs/
188200
tag_with_ref: true
189201
# Actual PersistenceProviders
190202
- uses: docker/build-push-action@v1
191-
name: "Build & Push Elastic PersistenceProvider Image"
203+
name: "Build & Push Elastic PersistenceProvider Hook Image"
192204
with:
193205
username: ${{ secrets.DOCKER_USERNAME }}
194206
password: ${{ secrets.DOCKER_PASSWORD }}
195207
repository: scbexperimental/persistence-elastic
196-
path: ./persistence/persistence-elastic/
208+
path: ./hooks/persistence-elastic/
197209
tag_with_ref: true
198210
- uses: docker/build-push-action@v1
199211
name: "Build & Push Elastic PersistenceProvider Dashboard Importer Image"
200212
with:
201213
username: ${{ secrets.DOCKER_USERNAME }}
202214
password: ${{ secrets.DOCKER_PASSWORD }}
203215
repository: scbexperimental/persistence-elastic-dashboard-importer
204-
path: ./persistence/persistence-elastic/dashboardImporter/
216+
path: ./hooks/persistence-elastic/dashboardImporter/
217+
tag_with_ref: true
218+
- uses: docker/build-push-action@v1
219+
name: "Build & Push GenericWebhook Hook Image"
220+
with:
221+
username: ${{ secrets.DOCKER_USERNAME }}
222+
password: ${{ secrets.DOCKER_PASSWORD }}
223+
repository: scbexperimental/generic-webhook
224+
path: ./hooks/generic-webhook/
225+
tag_with_ref: true
226+
- uses: docker/build-push-action@v1
227+
name: "Build & Push ImperativeSubsequentScans Hook Image"
228+
with:
229+
username: ${{ secrets.DOCKER_USERNAME }}
230+
password: ${{ secrets.DOCKER_PASSWORD }}
231+
repository: scbexperimental/hook-imperative-subsequent-scans
232+
path: ./hooks/imperative-subsequent-scans/
205233
tag_with_ref: true
234+
- uses: docker/build-push-action@v1
235+
name: "Build & Push UpdateField Hook Image"
236+
with:
237+
username: ${{ secrets.DOCKER_USERNAME }}
238+
password: ${{ secrets.DOCKER_PASSWORD }}
239+
repository: scbexperimental/update-field
240+
path: ./hooks/update-field/
241+
tag_with_ref: true
242+
tag_with_sha: true
206243
scannerImages:
207244
# Note we only build images for scanner that don't provider official public container images
208245
name: "Build / Scanner"
@@ -215,7 +252,7 @@ jobs:
215252
username: ${{ secrets.DOCKER_USERNAME }}
216253
password: ${{ secrets.DOCKER_PASSWORD }}
217254
repository: scbexperimental/nmap
218-
path: ./integrations/nmap/scanner/
255+
path: ./scanner/nmap/scanner/
219256
# Note: not prefixed with a "v" as this seems to match nmap versioning standards
220257
tags: "7.80,7.80-1,latest"
221258
- uses: docker/build-push-action@v1
@@ -224,14 +261,23 @@ jobs:
224261
username: ${{ secrets.DOCKER_USERNAME }}
225262
password: ${{ secrets.DOCKER_PASSWORD }}
226263
repository: scbexperimental/kube-hunter
227-
path: ./integrations/kube-hunter/scanner/
264+
path: ./scanner/kube-hunter/scanner/
228265
# Note: not prefixed with a "v" as this matches the aquasec/kube-hunter tags
229266
tags: "0.3.0,latest"
267+
- uses: docker/build-push-action@v1
268+
name: "Build & Push test-scan Scanner Image"
269+
with:
270+
username: ${{ secrets.DOCKER_USERNAME }}
271+
password: ${{ secrets.DOCKER_PASSWORD }}
272+
repository: scbexperimental/test-scan
273+
path: ./scanner/test-scan/scanner/
274+
# Note: not prefixed with a "v" as this seems to match nmap versioning standards
275+
tags: "latest"
230276
integrationTests:
231277
name: "Test / Integration / k8s ${{ matrix.k8sVersion }}"
232278
needs:
233279
- scannerImages
234-
- persistenceImages
280+
- hookImages
235281
- parserImages
236282
- operator
237283
- lurcher
@@ -276,23 +322,37 @@ jobs:
276322
cd tests/integration/
277323
npm ci
278324
# This steps should include Integration tests which are not related to a Specific Scanner
279-
- name: "Generic Integration Tests"
325+
- name: "Throws NoScanDefiniton Error Integration Tests"
280326
run: |
281327
cd tests/integration/
282328
npx jest --ci --color no-scan-definition-error
329+
- name: "Hooks Integration Tests"
330+
run: |
331+
helm -n integration-tests install update-category ./hooks/update-field/ \
332+
--set="image.tag=sha-$(git rev-parse --short HEAD)" \
333+
--set="attribute.name=category" \
334+
--set="attribute.value=fancy-category"
335+
helm -n integration-tests install update-severity ./hooks/update-field/ \
336+
--set="image.tag=sha-$(git rev-parse --short HEAD)" \
337+
--set="attribute.name=severity" \
338+
--set="attribute.value=high"
339+
helm -n integration-tests install test-scan ./scanner/test-scan/ --set="parserImage.tag=sha-$(git rev-parse --short HEAD)"
340+
cd tests/integration/
341+
npx jest --ci --color read-write-hook
342+
helm -n integration-tests uninstall test-scan update-category update-severity
283343
- name: "nmap Integration Tests"
284344
run: |
285-
helm -n integration-tests install nmap ./integrations/nmap/ --set="parserImage.tag=sha-$(git rev-parse --short HEAD)"
345+
helm -n integration-tests install nmap ./scanner/nmap/ --set="parserImage.tag=sha-$(git rev-parse --short HEAD)"
286346
cd tests/integration/
287347
npx jest --ci --color nmap
288348
- name: "kube-hunter Integration Tests"
289349
run: |
290-
helm -n integration-tests install kube-hunter ./integrations/kube-hunter/ --set="parserImage.tag=sha-$(git rev-parse --short HEAD)"
350+
helm -n integration-tests install kube-hunter ./scanner/kube-hunter/ --set="parserImage.tag=sha-$(git rev-parse --short HEAD)"
291351
cd tests/integration/
292352
npx jest --ci --color kube-hunter
293353
- name: "ssh-scan Integration Tests"
294354
run: |
295-
helm -n integration-tests install ssh-scan ./integrations/ssh_scan/ --set="parserImage.tag=sha-$(git rev-parse --short HEAD)"
355+
helm -n integration-tests install ssh-scan ./scanner/ssh_scan/ --set="parserImage.tag=sha-$(git rev-parse --short HEAD)"
296356
# Install dummy-ssh app
297357
helm -n demo-apps install dummy-ssh ./demo-apps/dummy-ssh/ --wait
298358
cd tests/integration/
@@ -304,6 +364,7 @@ jobs:
304364
kubectl -n integration-tests get jobs -o wide
305365
kubectl -n integration-tests get pods -o wide
306366
- name: "Inspect Operator"
367+
if: failure()
307368
run: |
308369
echo "Deployment in namespace 'securecodebox-system'"
309370
kubectl -n securecodebox-system get deployments

README.md

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<img alt="secureCodeBox Logo" src="securecodebox-logo.svg" width="800px">
2+
<img alt="secureCodeBox Logo" src="./docs/resources/securecodebox-logo.svg" width="800px">
33
</p>
44

55
<p align="center">
@@ -20,7 +20,9 @@
2020
- [Purpose of this Project](#purpose-of-this-project)
2121
- [Quickstart](#quickstart)
2222
- [Prerequisites](#prerequisites)
23-
- [Deployment](#deployment)
23+
- [Deployment (based on Helm)](#deployment-based-on-helm)
24+
- [Examples](#examples)
25+
- [Access Services](#access-services)
2426
- [How does it work?](#how-does-it-work)
2527
- [Architecture](#architecture)
2628
- [License](#license)
@@ -56,38 +58,80 @@ There is a german article about [Security DevOps – Angreifern (immer) einen Sc
5658

5759
- kubernetes (last 4 mayor releases supported: `1.15`, `1.16`, `1.17` & `1.18`)
5860

59-
### Deployment
61+
### Deployment (based on Helm)
6062

6163
```bash
62-
# Deploy secureCodeBox Operator
64+
# Deploy the secureCodeBox Operator first
6365
kubectl create namespace securecodebox-system
6466
helm -n securecodebox-system install securecodebox-operator ./operator/
6567

66-
# Elasticsearch Persistence Provider Deployment
67-
helm install persistence-elastic ./persistence/persistence-elastic/
68+
# Deploy SCB scanner Charts for each security scanner you want to use (all optional)
69+
helm upgrade --install amass ./integrations/amass/
70+
helm upgrade --install kube-hunter ./integrations/kube-hunter/
71+
helm upgrade --install nikto ./integrations/nikto
72+
helm upgrade --install nmap ./integrations/nmap/
73+
helm upgrade --install ssh-scan ./integrations/ssh_scan/
74+
helm upgrade --install sslyze ./integrations/sslyze/
75+
helm upgrade --install trivy ./integrations/trivy/
76+
helm upgrade --install zap ./integrations/zap/
77+
helm upgrade --install wpscan ./integrations/wpscan/
78+
79+
# Optional Deploy some Demo Apps for scanning
80+
helm upgrade --install dummy-ssh ./demo-apps/dummy-ssh/
81+
82+
# Deploy secureCodeBox Hooks
83+
helm upgrade --install aah ./hooks/add-attributes/
84+
helm upgrade --install gwh ./hooks/generic-webhook/
85+
helm upgrade --install issh ./hooks/imperative-subsequent-scans/
86+
87+
## Persistence Provider: Elasticsearch
88+
helm upgrade --install elkh ./hooks/persistence-elastic/
89+
```
6890

69-
# Deploy definitions for the integrated scanners
70-
helm install amass ./integrations/amass/
71-
helm install kube-hunter ./integrations/kube-hunter/
72-
helm install nikto ./integrations/nikto
73-
helm install nmap ./integrations/nmap/
74-
helm install ssh-scan ./integrations/ssh_scan/
75-
helm install sslyze ./integrations/sslyze/
76-
helm install zap ./integrations/zap/
91+
### Examples
7792

93+
```bash
7894
# Now everything is installed. You can try deploying scans from the `operator/config/samples/` directory
95+
## Local Scan Examples
7996

97+
### E.g. localhost nmap scan
98+
kubectl apply -f operator/config/samples/execution_v1_scan/nmap_localhost.yaml
99+
kubectl apply -f operator/config/samples/execution_v1_scan/kube-hunter_in_cluster.yaml
100+
101+
## Public Scan Examples
80102
# E.g. www.securecodebox.io sslyze scan
103+
kubectl apply -f operator/config/samples/execution_v1_scan/nmap_securecodebox_io.yaml
104+
kubectl apply -f operator/config/samples/execution_v1_scan/amass_securecodebox_io.yaml
105+
kubectl apply -f operator/config/samples/execution_v1_scan/sslyze_securecodebox_io.yaml
106+
kubectl apply -f operator/config/samples/execution_v1_scan/nikto_securecodebox_io.yaml
107+
kubectl apply -f operator/config/samples/execution_v1_scan/ssh_iteratec_de.yaml
108+
kubectl apply -f operator/config/samples/execution_v1_scan/wpscan_nurdemteam_org.yaml
81109
kubectl apply -f operator/config/samples/execution_v1_scan/sslyze_securecodebox_io.yaml
110+
kubectl apply -f operator/config/samples/execution_v1_scan/trivy_mediawiki.yaml
111+
kubectl apply -f operator/config/samples/execution_v1_scan/trivy_juiceshop.yaml
112+
82113
# Then get the current State of the Scan by running:
83114
kubectl get scans
84115
```
85116

117+
### Access Services
118+
119+
* Minio UI:
120+
* AccessKey: `kubectl get secret securecodebox-operator-minio -n securecodebox-system -o=jsonpath='{.data.accesskey}' | base64 --decode; echo`
121+
* SecretKey: `kubectl get secret securecodebox-operator-minio -n securecodebox-system -o=jsonpath='{.data.secretkey}' | base64 --decode; echo`
122+
* Port Forward Minio UI: `kubectl port-forward -n securecodebox-system service/securecodebox-operator-minio 9000:9000`
123+
* Elastic / Kibana UI:
124+
* User: `elastic`
125+
* Password: `kubectl get secret scb-elasticsearch-es-elastic-user -n scb-analytics -o=jsonpath='{.data.elastic}' | base64 --decode; echo`
126+
* Port Forward Kibana: `kubectl port-forward -n default service/persistence-elastic-kibana 5601:5601`
127+
* Port Forward Elasticsearch: `kubectl port-forward -n default service/elasticsearch-master 9200:9200`
128+
129+
86130
## How does it work?
87131

88132
## Architecture
89133

90-
![secureCodeBox Architecture](scb-architecture.svg)
134+
![secureCodeBox Architecture](./docs/resources/scb-architecture.svg)
91135

92136
## License
93137

docs/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#

docs/_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
theme: jekyll-theme-minimal

0 commit comments

Comments
 (0)