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

Commit 760a745

Browse files
committed
Add securityContext to parsers and hooks
1 parent 1c597ed commit 760a745

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

hook-sdk/nodejs/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ RUN npm ci --production
55

66
FROM node:12-alpine
77
ARG NODE_ENV
8-
RUN addgroup -S app && adduser app -S -G app
8+
RUN addgroup --system --gid 1001 app && adduser app --system --uid 1001 --ingroup app
99
WORKDIR /home/app/hook-wrapper/
1010
COPY --from=build --chown=app:app /home/app/node_modules/ ./node_modules/
1111
COPY --chown=app:app ./hook-wrapper.js ./hook-wrapper.js
12-
USER app
12+
USER 1001
1313
ENV NODE_ENV ${NODE_ENV:-production}
1414
ENTRYPOINT ["node", "/home/app/hook-wrapper/hook-wrapper.js"]

operator/controllers/execution/scans/hook_reconciler.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ func (r *ScanReconciler) createJobForHook(hook *executionv1.ScanCompletionHook,
362362
labels["experimental.securecodebox.io/hook-name"] = hook.Name
363363

364364
var backOffLimit int32 = 3
365+
truePointer := true
366+
falsePointer := false
365367
job := &batch.Job{
366368
ObjectMeta: metav1.ObjectMeta{
367369
Annotations: make(map[string]string),
@@ -399,6 +401,15 @@ func (r *ScanReconciler) createJobForHook(hook *executionv1.ScanCompletionHook,
399401
corev1.ResourceMemory: resource.MustParse("200Mi"),
400402
},
401403
},
404+
SecurityContext: &corev1.SecurityContext{
405+
RunAsNonRoot: &truePointer,
406+
AllowPrivilegeEscalation: &falsePointer,
407+
ReadOnlyRootFilesystem: &truePointer,
408+
Privileged: &falsePointer,
409+
Capabilities: &corev1.Capabilities{
410+
Drop: []corev1.Capability{"all"},
411+
},
412+
},
402413
},
403414
},
404415
},

operator/controllers/execution/scans/parse_reconciler.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
8080
labels["experimental.securecodebox.io/job-type"] = "parser"
8181
automountServiceAccountToken := true
8282
var backOffLimit int32 = 3
83+
truePointer := true
84+
falsePointer := false
8385
job := &batch.Job{
8486
ObjectMeta: metav1.ObjectMeta{
8587
Annotations: make(map[string]string),
@@ -133,6 +135,15 @@ func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
133135
corev1.ResourceMemory: resource.MustParse("200Mi"),
134136
},
135137
},
138+
SecurityContext: &corev1.SecurityContext{
139+
RunAsNonRoot: &truePointer,
140+
AllowPrivilegeEscalation: &falsePointer,
141+
ReadOnlyRootFilesystem: &truePointer,
142+
Privileged: &falsePointer,
143+
Capabilities: &corev1.Capabilities{
144+
Drop: []corev1.Capability{"all"},
145+
},
146+
},
136147
},
137148
},
138149
AutomountServiceAccountToken: &automountServiceAccountToken,

parser-sdk/nodejs/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ RUN npm ci --production
55

66
FROM node:12-alpine
77
ARG NODE_ENV
8-
RUN addgroup -S app && adduser app -S -G app
8+
RUN addgroup --system --gid 1001 app && adduser app --system --uid 1001 --ingroup app
99
WORKDIR /home/app/parser-wrapper/
1010
COPY --from=build --chown=app:app /home/app/node_modules/ ./node_modules/
1111
COPY --chown=app:app ./parser-wrapper.js ./parser-wrapper.js
12-
USER app
12+
USER 1001
1313
ENV NODE_ENV ${NODE_ENV:-production}
1414
ENTRYPOINT ["node", "/home/app/parser-wrapper/parser-wrapper.js"]

0 commit comments

Comments
 (0)