Skip to content

Commit 9d59d8b

Browse files
authored
Merge pull request #240 from aojea/alpha-hardening
Alpha/beta hardening: security, storage, Helm, and test fixes
2 parents 3c8c269 + e8a7708 commit 9d59d8b

26 files changed

Lines changed: 488 additions & 30 deletions

‎.github/workflows/deploy.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ on:
88
- 'v*.*.*'
99
workflow_dispatch:
1010

11+
# Serialize deploys per-environment so a burst of pushes (e.g. several
12+
# dependabot PRs merging back-to-back) can't run concurrently against the
13+
# same GKE namespace and race on shared resources (e.g. the dns-sync-rollout
14+
# job name). Keeps only the latest queued run per environment; never cancels
15+
# one already in progress.
16+
concurrency:
17+
group: deploy-${{ github.ref_type == 'tag' && 'hub' || 'bananas' }}
18+
cancel-in-progress: false
19+
1120
env:
1221
REGISTRY: ghcr.io
1322

‎Dockerfile.nano-init‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ RUN gcc -shared -fPIC -ldl -o libinterceptor.so cmd/nano-init/interceptor/interc
99
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o nano-init ./cmd/nano-init
1010

1111
# Stage 2: Final
12-
FROM gcr.io/distroless/base:latest
13-
COPY --from=builder /app/nano-init /
14-
COPY --from=builder /app/libinterceptor.so /opt/sam/libinterceptor.so
12+
FROM gcr.io/distroless/base:nonroot
13+
COPY --from=builder --chown=nonroot:nonroot /app/nano-init /
14+
COPY --from=builder --chown=nonroot:nonroot /app/libinterceptor.so /opt/sam/libinterceptor.so
15+
USER nonroot:nonroot
1516
ENTRYPOINT ["/nano-init"]

‎Dockerfile.sam-box‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ COPY . .
77
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o sam-box ./cmd/sam-box
88

99
# Stage 2: Final
10-
FROM gcr.io/distroless/static:latest
11-
COPY --from=builder /app/sam-box /
10+
FROM gcr.io/distroless/static:nonroot
11+
COPY --from=builder --chown=nonroot:nonroot /app/sam-box /
12+
USER nonroot:nonroot
1213
ENTRYPOINT ["/sam-box"]

‎Dockerfile.sam-console‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ RUN go mod download
77
COPY . .
88
RUN CGO_ENABLED=0 go build -o /bin/sam-console ./cmd/sam-console
99

10-
FROM gcr.io/distroless/static-debian12
10+
FROM gcr.io/distroless/static-debian12:nonroot
1111

1212
WORKDIR /app
13-
COPY --from=builder /bin/sam-console /usr/local/bin/sam-console
14-
COPY cmd/sam-console/public /app/public
13+
COPY --from=builder --chown=nonroot:nonroot /bin/sam-console /usr/local/bin/sam-console
14+
COPY --chown=nonroot:nonroot cmd/sam-console/public /app/public
1515

16+
USER nonroot:nonroot
1617
EXPOSE 8081
1718
ENTRYPOINT ["/usr/local/bin/sam-console"]

‎Dockerfile.sam-control-plane‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ COPY go.mod go.sum ./
55
RUN go mod download
66
COPY . .
77
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o sam-control-plane ./cmd/sam-control-plane
8+
# Pre-create the sqlite data dir owned by the nonroot UID so that a fresh
9+
# named/anonymous volume mounted over it inherits writable ownership instead
10+
# of defaulting to root.
11+
RUN mkdir -p /data-seed && chown 65532:65532 /data-seed
812

913
# Stage 2: Final
10-
FROM gcr.io/distroless/static:latest
11-
COPY --from=builder /app/sam-control-plane /
14+
FROM gcr.io/distroless/static:nonroot
15+
WORKDIR /tmp
16+
COPY --from=builder --chown=nonroot:nonroot /app/sam-control-plane /
17+
COPY --from=builder --chown=nonroot:nonroot /data-seed /data
18+
USER nonroot:nonroot
1219
ENTRYPOINT ["/sam-control-plane"]

‎Dockerfile.sam-node‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ COPY go.mod go.sum ./
55
RUN go mod download
66
COPY . .
77
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o sam-node ./cmd/sam-node
8+
# Pre-create the default data dir owned by the nonroot UID so that a fresh
9+
# named/anonymous volume mounted over it inherits writable ownership instead
10+
# of defaulting to root.
11+
RUN mkdir -p /data-seed && chown 65532:65532 /data-seed
812

913
# Stage 2: Final
10-
FROM gcr.io/distroless/static:latest
11-
COPY --from=builder /app/sam-node /
14+
FROM gcr.io/distroless/static:nonroot
15+
WORKDIR /tmp
16+
COPY --from=builder --chown=nonroot:nonroot /app/sam-node /
17+
COPY --from=builder --chown=nonroot:nonroot /data-seed /data
18+
USER nonroot:nonroot
1219
ENTRYPOINT ["/sam-node"]

‎Dockerfile.sam-router‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ COPY go.mod go.sum ./
55
RUN go mod download
66
COPY . .
77
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o sam-router ./cmd/sam-router
8+
# Pre-create the keys/data dir owned by the nonroot UID so that a fresh
9+
# named/anonymous volume mounted over it inherits writable ownership instead
10+
# of defaulting to root.
11+
RUN mkdir -p /data-seed && chown 65532:65532 /data-seed
812

913
# Stage 2: Final
10-
FROM gcr.io/distroless/static:latest
11-
COPY --from=builder /app/sam-router /
14+
FROM gcr.io/distroless/static:nonroot
15+
WORKDIR /tmp
16+
COPY --from=builder --chown=nonroot:nonroot /app/sam-router /
17+
COPY --from=builder --chown=nonroot:nonroot /data-seed /data
18+
USER nonroot:nonroot
1219
ENTRYPOINT ["/sam-router"]

‎charts/sam-mesh/templates/console-deployment.yaml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ spec:
4242
- containerPort: 8081
4343
name: http
4444
protocol: TCP
45+
readinessProbe:
46+
httpGet:
47+
path: /info
48+
port: http
49+
periodSeconds: 5
50+
livenessProbe:
51+
httpGet:
52+
path: /info
53+
port: http
54+
periodSeconds: 15
55+
resources:
56+
{{- toYaml .Values.console.resources | nindent 10 }}
4557
args:
4658
- "--hub=http://{{ include "sam-mesh.fullname" . }}-control-plane:{{ .Values.controlPlane.service.port }}"
4759
- "--bind-addr=:8081"

‎charts/sam-mesh/templates/control-plane-deployment.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ spec:
4646
path: /info
4747
port: http
4848
periodSeconds: 15
49+
resources:
50+
{{- toYaml .Values.controlPlane.resources | nindent 10 }}
4951
args:
5052
- "--bind-address=0.0.0.0:8080"
5153
{{- if eq .Values.database.type "postgres" }}

‎charts/sam-mesh/templates/db-statefulset.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ spec:
3434
- containerPort: 5432
3535
name: postgres
3636
protocol: TCP
37+
resources:
38+
{{- toYaml .Values.database.postgres.resources | nindent 10 }}
3739
volumeMounts:
3840
- name: db-data
3941
mountPath: /var/lib/postgresql/data

0 commit comments

Comments
 (0)