forked from secureCodeBox/secureCodeBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
235 lines (206 loc) · 8.74 KB
/
Taskfile.yaml
File metadata and controls
235 lines (206 loc) · 8.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# SPDX-FileCopyrightText: the secureCodeBox authors
#
# SPDX-License-Identifier: Apache-2.0
version: "3.48.0"
env:
IMG_NS: securecodebox
IMG_TAG:
sh: 'echo "sha-$(git rev-parse --short HEAD)"'
vars:
SCANNERS_DIR: '{{ .TASKFILE_DIR }}/scanners'
HOOKS_DIR: '{{ .TASKFILE_DIR }}/hooks'
DEMO_TARGETS_DIR: '{{ .TASKFILE_DIR }}/demo-targets'
OPERATOR_DIR: '{{ .TASKFILE_DIR }}/operator'
PARSER_SDK_DIR: '{{ .TASKFILE_DIR }}/parser-sdk/nodejs'
HOOK_SDK_DIR: '{{ .TASKFILE_DIR }}/hook-sdk/nodejs'
AUTO_DISCOVERY_DIR: '{{ .TASKFILE_DIR }}/auto-discovery'
HELM_DOCS_DIR: '{{ .TASKFILE_DIR }}/.helm-docs'
TEMPLATES_DIR: '{{ .TASKFILE_DIR }}/.templates'
BIN_DIR: '{{ .TASKFILE_DIR }}/bin'
tasks:
create-kind-cluster:
run: once
cmds:
- 'echo "Starting kind cluster for testing environment"'
- kind create cluster --name testing-env
status:
- kind get clusters | grep -q testing-env
build-operator-image:
run: once
cmds:
- 'echo "Building operator image with tag ${IMG_TAG}"'
- docker build -t ${IMG_NS}/operator:${IMG_TAG} {{ .TASKFILE_DIR }}/operator
status:
- docker images | grep -q "${IMG_NS}/operator:${IMG_TAG}"
build-lurker-image:
run: once
cmds:
- 'echo "Building lurker image with tag ${IMG_TAG}"'
- docker build -t ${IMG_NS}/lurker:${IMG_TAG} {{ .TASKFILE_DIR }}/lurker
status:
- docker images | grep -q "${IMG_NS}/lurker:${IMG_TAG}"
load-operator-image:
run: once
deps: [build-operator-image]
cmds:
- kind load docker-image ${IMG_NS}/operator:${IMG_TAG} --name testing-env
status:
- kind get images --name testing-env | grep -q "${IMG_NS}/operator:${IMG_TAG}"
load-lurker-image:
run: once
deps: [build-lurker-image]
cmds:
- kind load docker-image ${IMG_NS}/lurker:${IMG_TAG} --name testing-env
status:
- kind get images --name testing-env | grep -q "${IMG_NS}/lurker:${IMG_TAG}"
deploy-operator:
run: once
deps: [load-operator-image, load-lurker-image]
cmds:
- 'echo "Deploying secureCodeBox operator to the testing environment"'
- kubectl config use-context kind-testing-env
- kubectl create namespace integration-tests || true
- |
helm -n securecodebox-system upgrade --create-namespace --install securecodebox-operator {{ .TASKFILE_DIR }}/operator --wait \
--set="image.repository=docker.io/${IMG_NS}/operator" \
--set="image.tag=${IMG_TAG}" \
--set="image.pullPolicy=IfNotPresent" \
--set="lurker.image.repository=docker.io/${IMG_NS}/lurker" \
--set="lurker.image.tag=${IMG_TAG}" \
--set="lurker.image.pullPolicy=IfNotPresent"
status:
- kubectl get deployment -n securecodebox-system securecodebox-controller-manager | grep -q "1/1"
build-parser-sdk-image:
run: once
cmds:
- 'echo "Building parser-sdk images with tag ${IMG_TAG}"'
- docker build -t securecodebox/parser-sdk-nodejs:${IMG_TAG} {{ .TASKFILE_DIR }}/parser-sdk/nodejs
status:
- docker images | grep -q "securecodebox/parser-sdk-nodejs:${IMG_TAG}"
build-hook-sdk-image:
run: once
cmds:
- 'echo "Building hook-sdk images with tag ${IMG_TAG}"'
- docker build -t securecodebox/hook-sdk-nodejs:${IMG_TAG} {{ .TASKFILE_DIR }}/hook-sdk/nodejs
status:
- docker images | grep -q "securecodebox/hook-sdk-nodejs:${IMG_TAG}"
prepare-testing-env:
desc: "Prepare the testing environment by running all required tasks"
cmds:
- task: create-kind-cluster
- task: deploy-operator
cleanup-testing-env:
desc: "Cleanup the testing environment by deleting the kind cluster"
cmds:
- 'echo "Cleaning up testing environment"'
- kind delete cluster --name testing-env
minio-port-forward:
desc: "Port forward the MinIO service to access it locally"
cmds:
- 'echo "Port forwarding MinIO service to localhost:9001"'
- 'echo "You can access MinIO at http://localhost:9001"'
- 'echo "Use the credentials from the secureCodeBox operator to log in:"'
- 'echo "Access Key: $(kubectl get secret -n securecodebox-system securecodebox-operator-minio -o jsonpath="{.data.root-user}" | base64 --decode)"'
- 'echo "Secret Key: $(kubectl get secret -n securecodebox-system securecodebox-operator-minio -o jsonpath="{.data.root-password}" | base64 --decode)"'
- 'echo "Press Ctrl+C to stop port forwarding"'
- kubectl port-forward -n securecodebox-system svc/securecodebox-operator-minio 9001:9001
interactive: true
test:helm:all:
desc: "Run helm unit tests for all charts in the project"
preconditions:
- msg: "Helm unittest plugin is not installed. Install it from https://github.com/helm-unittest/helm-unittest/"
sh: "helm plugin list | grep -q 'unittest' || false"
vars:
CHARTS:
sh: find {{ .TASKFILE_DIR }} -name "Chart.yaml" -exec dirname {} \;
cmds:
- for: { var: CHARTS }
cmd: helm unittest "{{ .ITEM }}"
npm-ci-all:
desc: "Install all NPM dependencies across the project"
cmds:
- 'echo "Installing all NPM dependencies"'
- '{{ .BIN_DIR }}/npm-ci-all.sh'
npm-test-all:
desc: "Run all Jest based test suites"
cmds:
- npm test -- --ci --colors --coverage --testPathIgnorePatterns /integration-tests/
readme:
desc: "Generate README.md based on Chart.yaml and template"
cmds:
- '{{ .BIN_DIR }}/generate-helm-docs.sh --readme {{ .TASKFILE_DIR }} {{ .HELM_DOCS_DIR }}'
hook-docs:
desc: "Generate documentation for all hooks"
vars:
CHARTS:
sh: find {{ .HOOKS_DIR }} -maxdepth 2 -name "Chart.yaml"
cmds:
- for: { var: CHARTS }
cmd: '{{ .BIN_DIR }}/generate-helm-docs.sh --hook "{{ .ITEM }}" "{{ .HELM_DOCS_DIR }}"'
scanner-docs:
desc: "Generate documentation for all scanners"
vars:
CHARTS:
sh: find {{ .SCANNERS_DIR }} -maxdepth 2 -name "Chart.yaml"
cmds:
- for: { var: CHARTS }
cmd: '{{ .BIN_DIR }}/generate-helm-docs.sh --scanner "{{ .ITEM }}" "{{ .HELM_DOCS_DIR }}"'
operator-docs:
desc: "Generate documentation for the operator"
cmds:
- '{{ .BIN_DIR }}/generate-helm-docs.sh --operator "{{ .OPERATOR_DIR }}/Chart.yaml" "{{ .HELM_DOCS_DIR }}"'
auto-discovery-docs:
desc: "Generate documentation for auto-discovery components"
cmds:
- '{{ .BIN_DIR }}/generate-helm-docs.sh --operator "{{ .AUTO_DISCOVERY_DIR }}/cloud-aws/Chart.yaml" "{{ .HELM_DOCS_DIR }}"'
- '{{ .BIN_DIR }}/generate-helm-docs.sh --operator "{{ .AUTO_DISCOVERY_DIR }}/kubernetes/Chart.yaml" "{{ .HELM_DOCS_DIR }}"'
demo-target-docs:
desc: "Generate documentation for demo targets"
vars:
CHARTS:
sh: find {{ .DEMO_TARGETS_DIR }} -maxdepth 2 -name "Chart.yaml"
cmds:
- for: { var: CHARTS }
cmd: '{{ .BIN_DIR }}/generate-helm-docs.sh --demo-target "{{ .ITEM }}" "{{ .HELM_DOCS_DIR }}"'
docs:
desc: "Generate all documentation"
cmds:
- task: readme
- task: hook-docs
- task: scanner-docs
- task: operator-docs
- task: auto-discovery-docs
- task: demo-target-docs
create-new-scanner:
desc: "Create a new scanner from template (use -- NAME=scanner-name)"
preconditions:
- msg: "Scanner name not defined, please provide via: task create-new-scanner -- NAME=NEW-SCANNER"
sh: '[ -n "{{ .NAME }}" ]'
cmds:
- rm -rf "{{ .SCANNERS_DIR }}/{{ .NAME }}"
- cp -r "{{ .TEMPLATES_DIR }}/new-scanner/" "{{ .SCANNERS_DIR }}/{{ .NAME }}"
- |
find "{{ .SCANNERS_DIR }}/{{ .NAME }}" -type f ! -name tmp \
-exec sed -n "s/new-scanner/{{ .NAME }}/g;w {{ .SCANNERS_DIR }}/{{ .NAME }}/tmp" {} \; \
-exec mv "{{ .SCANNERS_DIR }}/{{ .NAME }}/tmp" {} \;
- mv "{{ .SCANNERS_DIR }}/{{ .NAME }}/templates/new-scanner-parse-definition.yaml" "{{ .SCANNERS_DIR }}/{{ .NAME }}/templates/{{ .NAME }}-parse-definition.yaml"
- mv "{{ .SCANNERS_DIR }}/{{ .NAME }}/templates/new-scanner-scan-type.yaml" "{{ .SCANNERS_DIR }}/{{ .NAME }}/templates/{{ .NAME }}-scan-type.yaml"
lint:
desc: "Lint only changed files with respect to main branch"
cmds:
- npx mega-linter-runner
- 'echo "The generated reports can be found under ./report/linters_logs/"'
lintfix:
desc: "Lint only changed files with respect to main branch and apply automatic fixes"
cmds:
- npx mega-linter-runner --fix
- 'echo "The generated reports can be found under ./report/linters_logs/"'
lintall:
desc: "Lint complete repo"
cmds:
- npx mega-linter-runner --env VALIDATE_ALL_CODEBASE=true
- 'echo "The generated reports can be found under ./report/linters_logs/"'
scbctl:
desc: "Build scbctl CLI tool"
cmds:
- cd scbctl && go build -o scbctl main.go