Skip to content

Commit 56c68cc

Browse files
authored
FFM-12631 - Update golang & pushpin to resolve vulns (#413)
* fix: [FFM-12648] upgrade golang & pushpin version to resolve vulnerabilities (#412)
1 parent 8bffa34 commit 56c68cc

File tree

6 files changed

+38
-134
lines changed

6 files changed

+38
-134
lines changed

Dockerfile

Lines changed: 27 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
############################
22
# STEP 1 build executable binary
33
############################
4-
FROM golang:1.23.5 as builder
4+
FROM golang:1.23.12 as builder
55

66
WORKDIR /app
77

@@ -15,73 +15,42 @@ COPY . .
1515
# Generate Code and Build
1616
RUN make build
1717

18-
1918
############################
20-
# STEP 2 build pushpin 22.04 image - source https://github.com/fanout/docker-pushpin/blob/master/Dockerfile
21-
# TODO - this will rarely change - publish as an image we can consume
19+
# STEP 2: Grab CA certificates
2220
############################
23-
# Pull the base image
24-
FROM ubuntu:24.04 as pushpin
25-
26-
# Add private APT repository
27-
RUN \
28-
apt-get update && \
29-
apt-get install -y apt-transport-https software-properties-common && \
30-
echo deb https://fanout.jfrog.io/artifactory/debian fanout-jammy main \
31-
| tee /etc/apt/sources.list.d/fanout.list && \
32-
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys \
33-
7D0343148157C3DF
34-
35-
ENV PUSHPIN_VERSION 1.37.0-1~jammy
36-
37-
# Install Pushpin
38-
RUN \
39-
apt-get update && \
40-
apt-get install -y pushpin=$PUSHPIN_VERSION curl binutils
21+
FROM debian:bookworm-slim as certs
22+
RUN apt-get update && apt-get install -y ca-certificates
23+
RUN mkdir /tmp/certs && cp -r /etc/ssl/certs/* /tmp/certs
4124

42-
# Fix CVEs
43-
RUN \
44-
apt-get upgrade -y perl openssl nghttp2
45-
46-
# Required for the image to work on Centos7 with 3.10 kernel
47-
RUN \
48-
strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
25+
############################
26+
# STEP 3: Add relay proxy to base pushpin image
27+
############################
28+
FROM fanout/pushpin:1.41.0
4929

50-
# Cleanup
51-
RUN \
52-
apt-get clean && \
53-
rm -fr /var/lib/apt/lists/* && \
54-
rm -fr /tmp/*
30+
# Use root user for setup
31+
USER root
5532

56-
# Add entrypoint script
33+
# Copy entrypoint and binaries
5734
COPY docker-entrypoint.sh /usr/local/bin/
58-
# give permission to run entrypoint script
59-
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
60-
61-
# Define default entrypoint and command
62-
ENTRYPOINT ["docker-entrypoint.sh"]
63-
CMD ["pushpin", "--merge-output"]
64-
65-
66-
############################
67-
# STEP 3 add relay proxy build to pushpin image
68-
############################
69-
FROM pushpin
7035
COPY --from=builder /app/ff-proxy /app/ff-proxy
71-
COPY --from=builder ./app/config/pushpin /etc/pushpin
72-
COPY --from=builder ./app/start.sh /start.sh
36+
COPY --from=builder /app/config/pushpin /etc/pushpin
37+
COPY --from=builder /app/start.sh /start.sh
38+
39+
# Copy CA certificates
40+
COPY --from=certs /tmp/certs /etc/ssl/certs
7341

74-
RUN mkdir /log
75-
RUN mkdir /pushpin
76-
RUN mkdir /pushpin/run
77-
RUN mkdir /pushpin/log
78-
RUN chmod -R 0500 /app/ff-proxy /usr/lib/pushpin /etc/pushpin
79-
RUN chmod -R 0755 /log /pushpin /usr/lib/pushpin /etc/pushpin
80-
RUN chown -R 65534:65534 /app/ff-proxy /log /pushpin /usr/lib/pushpin /etc/pushpin
42+
# Prepare directories + set permissions in a single layer
43+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh \
44+
&& mkdir -p /log /pushpin/run /pushpin/log \
45+
&& chmod 0500 /app/ff-proxy \
46+
&& chmod -R 0755 /usr/lib/pushpin /etc/pushpin \
47+
&& chmod -R 0775 /log /pushpin \
48+
&& chown -R 65534:65534 /app/ff-proxy /log /pushpin /usr/lib/pushpin /etc/pushpin
8149

82-
# Setting this to 65534 which hould be the nodbody user
83-
USER 65534
50+
# Use nobody user for runtime
51+
USER 65534:65534
8452

8553
# Expose default port pushpin listens on
8654
EXPOSE 7000
55+
ENTRYPOINT ["docker-entrypoint.sh"]
8756
CMD ["./start.sh"]

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ check: lint format sec ## Runs linter, goimports and gosec
134134
PHONY+= lint
135135
lint: tools ## lint the golang code
136136
@echo "Linting $(1)"
137-
@golint ./...
137+
golint ./...
138138

139139
PHONY+= tools
140140
format: tools ## Format go code and error if any changes are made
@@ -159,17 +159,16 @@ sec: tools ## Run the security checks
159159
# Install golangci-lint
160160
$(GOBIN)/golangci-lint:
161161
@echo "🔘 Installing golangci-lint... (`date '+%H:%M:%S'`)"
162-
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin
162+
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.8
163163

164-
# Install golint to lint code
165164
$(GOBIN)/golint:
166165
@echo "🔘 Installing golint ... (`date '+%H:%M:%S'`)"
167166
@go install golang.org/x/lint/golint@latest
168167

169168
# Install goimports to format code
170169
$(GOBIN)/goimports:
171170
@echo "🔘 Installing goimports ... (`date '+%H:%M:%S'`)"
172-
@go install golang.org/x/tools/cmd/goimports@latest
171+
@go install golang.org/x/tools/cmd/goimports@v0.30.0
173172

174173
# Install gocov to parse code coverage
175174
$(GOBIN)/gocov:

config/pushpin/pushpin.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ stats_connection_ttl=120
1616

1717
[runner]
1818
# services to start
19-
services=condure,zurl,pushpin-proxy,pushpin-handler
19+
services=condure,pushpin-proxy,pushpin-handler
2020

2121
# plain HTTP port that mongrel2 should listen on
2222
http_port=7000

docker-compose.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,4 @@ services:
3838
redis:
3939
image: "redis:latest"
4040
ports:
41-
- "6379:6379"
42-
43-
pushpin:
44-
image: fanout/pushpin
45-
ports:
46-
- "7000:7000"
47-
- "5560-5563:5560-5563"
48-
- "5555:5555"
49-
volumes:
50-
- ./config/pushpin:/etc/pushpin
51-
command: "pushpin --merge-output"
41+
- "6379:6379"

docker-entrypoint.sh

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
#!/bin/bash
2-
# source - https://github.com/fanout/docker-pushpin/blob/master/docker-entrypoint.sh
32
set -e
43

5-
# Configure Pushpin
6-
if [ -w /usr/lib/pushpin/internal.conf ]; then
7-
sed -i \
8-
-e 's/zurl_out_specs=.*/zurl_out_specs=ipc:\/\/\{rundir\}\/pushpin-zurl-in/' \
9-
-e 's/zurl_out_stream_specs=.*/zurl_out_stream_specs=ipc:\/\/\{rundir\}\/pushpin-zurl-in-stream/' \
10-
-e 's/zurl_in_specs=.*/zurl_in_specs=ipc:\/\/\{rundir\}\/pushpin-zurl-out/' \
11-
/usr/lib/pushpin/internal.conf
12-
else
13-
echo "docker-entrypoint.sh: unable to write to /usr/lib/pushpin/internal.conf, readonly"
14-
fi
15-
164
if [ -w /etc/pushpin/pushpin.conf ]; then
175
sed -i \
18-
-e 's/services=.*/services=condure,zurl,pushpin-proxy,pushpin-handler/' \
6+
-e 's/services=.*/services=condure,pushpin-proxy,pushpin-handler/' \
197
-e 's/push_in_spec=.*/push_in_spec=tcp:\/\/\*:5560/' \
208
-e 's/push_in_http_addr=.*/push_in_http_addr=0.0.0.0/' \
219
-e 's/push_in_sub_specs=.*/push_in_sub_spec=tcp:\/\/\*:5562/' \
2210
-e 's/command_spec=.*/command_spec=tcp:\/\/\*:5563/' \
11+
-e 's/^http_port=.*/http_port=7000/' \
2312
/etc/pushpin/pushpin.conf
2413
else
2514
echo "docker-entrypoint.sh: unable to write to /etc/pushpin/pushpin.conf, readonly"
@@ -30,50 +19,4 @@ if [ -v target ]; then
3019
echo "* ${target},over_http" > /etc/pushpin/routes
3120
fi
3221

33-
# Update pushpin.conf file to use $PORT for http_port
34-
if [ -w /etc/pushpin/pushpin.conf ]; then
35-
PROTOCOL="http_port"
36-
PUSHPIN_PORT=7000
37-
if [ -n "${PORT}" ]; then
38-
PUSHPIN_PORT=${PORT}
39-
fi
40-
41-
if [ "${TLS_ENABLED}" = true ] ; then
42-
echo "https configured"
43-
PROTOCOL="https_ports"
44-
45-
# write ca cert to pushpin certs directory if exists
46-
if [ -n "${TLS_CERT}" ]; then
47-
echo "copying tls cert from ${TLS_CERT} to etc/pushpin/runner/certs/default_${PUSHPIN_PORT}.crt"
48-
cp ${TLS_CERT} etc/pushpin/runner/certs/default_${PUSHPIN_PORT}.crt
49-
fi
50-
51-
# write ca key to pushpin certs directory if exists
52-
if [ -n "${TLS_KEY}" ]; then
53-
echo "copying tls key from ${TLS_CERT} to etc/pushpin/runner/certs/default_${PUSHPIN_PORT}.key"
54-
cp ${TLS_KEY} etc/pushpin/runner/certs/default_${PUSHPIN_PORT}.key
55-
fi
56-
fi
57-
58-
# set port and protocol for pushpin to listen on e.g. listen for https connections on port 6000
59-
echo "Listening for requests on port ${PUSHPIN_PORT}"
60-
sed -i \
61-
-e "s/http_port=7000/${PROTOCOL}=${PUSHPIN_PORT}/" \
62-
/etc/pushpin/pushpin.conf
63-
export PORT=
64-
else
65-
echo "docker-entrypoint.sh: unable to write to /etc/pushpin/pushpin.conf, readonly"
66-
fi
67-
68-
# Update routes file to forward traffic using ssl if tls_enabled is true
69-
if [ -w /etc/pushpin/routes ]; then
70-
if [ "${TLS_ENABLED}" = true ] ; then
71-
sed -i \
72-
-e "s/localhost:8000/localhost:8000,ssl,insecure/" \
73-
/etc/pushpin/routes
74-
fi
75-
else
76-
echo "docker-entrypoint.sh: unable to write to /etc/pushpin/routes, readonly"
77-
fi
78-
7922
exec "$@"

tests/e2e/stream_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func TestEvent(t *testing.T) {
4141
args{
4242
Key: GetServerAPIKey(),
4343
Operation: func() error {
44+
t.Log("Patching feature flag")
4445
parameters := make(map[string]interface{})
4546
parameters["state"] = "on"
4647
resp := PatchFeatureFlag(t, DefaultClient(), GetAccountIdentifier(), GetOrgIdentifier(), "string-flag1", GetProjectIdentifier(), GetEnvironmentIdentifier(), "setFeatureFlagState", parameters)
@@ -61,6 +62,7 @@ func TestEvent(t *testing.T) {
6162
args{
6263
Key: GetServerAPIKey(),
6364
Operation: func() error {
65+
t.Log("Patching feature flag")
6466
parameters := make(map[string]interface{})
6567
parameters["state"] = "off"
6668
resp := PatchFeatureFlag(t, DefaultClient(), GetAccountIdentifier(), GetOrgIdentifier(), "string-flag1", GetProjectIdentifier(), GetEnvironmentIdentifier(), "setFeatureFlagState", parameters)
@@ -109,10 +111,11 @@ func TestEvent(t *testing.T) {
109111
// wait for up to 10 seconds for the expected sse event to come in
110112
select {
111113
case msg := <-eventChan:
114+
t.Log("Event received")
112115
assert.Equal(t, tt.want.sseEvent.Event, msg.Event)
113116
assert.Equal(t, tt.want.sseEvent.Domain, msg.Domain)
114117
assert.Equal(t, tt.want.sseEvent.Identifier, msg.Identifier)
115-
case <-time.After(10 * time.Second):
118+
case <-time.After(20 * time.Second):
116119
t.Error("Timed out waiting for event to come in")
117120
}
118121
result, err := client.StringVariation("string-flag1", nil, "default")

0 commit comments

Comments
 (0)