Skip to content

Commit 5ad4c91

Browse files
Fix(build): Update Go, base images, and dependencies to fix CVEs
- Upgrades Go build version to 1.24-bookworm. - Updates Ubuntu image to 22.04 and pins all base image digests. - Updates Go modules to patched versions based on grype scans. - Configures FIPS mode for the boring build. - Updated build.yaml This resolves OS and Go vulnerabilities reported in b/386210486. Fixes: b/386210486
1 parent fc3dc6e commit 5ad4c91

File tree

6 files changed

+157
-86
lines changed

6 files changed

+157
-86
lines changed

.github/workflows/build.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
steps:
2626
-
2727
name: Check out code
28-
uses: actions/checkout@v1
28+
uses: actions/checkout@v4
2929
-
3030
name: Reviewdog Lint
31-
uses: reviewdog/action-golangci-lint@v1
31+
uses: reviewdog/action-golangci-lint@v2
3232
with:
3333
reporter: github-check
3434

@@ -38,17 +38,17 @@ jobs:
3838
steps:
3939
-
4040
name: Check out code
41-
uses: actions/checkout@v1
41+
uses: actions/checkout@v4
4242
-
4343
name: Set up Go
44-
uses: actions/setup-go@v2
44+
uses: actions/setup-go@v5
4545
with:
46-
go-version: 1.16
46+
go-version: 1.24
4747
-
4848
name: Run Unit tests
4949
run: go test -coverprofile=coverage.txt ./...
5050
-
5151
name: Upload Coverage report to CodeCov
52-
uses: codecov/codecov-action@v1
52+
uses: codecov/codecov-action@v4
5353
with:
5454
file: ./coverage.txt

.github/workflows/docker.yaml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
name: Build Default Docker image
2525
runs-on: ubuntu-latest
2626
steps:
27-
-
27+
-
2828
name: Check out code
2929
uses: actions/checkout@v2
3030
-
@@ -54,20 +54,26 @@ jobs:
5454
username: ${{ secrets.DOCKER_USERNAME }}
5555
password: ${{ secrets.DOCKER_PASSWORD }}
5656
-
57-
name: Scratch image
57+
name: Default image
5858
uses: docker/build-push-action@v2
5959
with:
6060
context: .
6161
file: ./Dockerfile
6262
push: true
6363
tags: ${{ steps.prep.outputs.tags }}
64-
build-args: LDFLAGS=-s -w -X main.version=${{ steps.prep.outputs.version }} -X main.commit=${{ github.SHA }} -X main.date=${{ steps.prep.outputs.created }}
64+
build-args: |
65+
BUILD_CONTAINER=golang:1.24-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac
66+
RUN_CONTAINER=gcr.io/distroless/static-debian12@sha256:cd64bec9cec257044ce3a8dd3620cf83b387920100332f2b041f19c4d2febf93
67+
CGO_ENABLED=0
68+
GODEBUG=""
69+
GO_TAGS=netgo,osusergo
70+
LDFLAGS=-s -w -X main.version=${{ steps.prep.outputs.version }} -X main.commit=${{ github.SHA }} -X main.date=${{ steps.prep.outputs.created }}
6571
6672
ubuntu:
6773
name: Build Ubuntu Docker image
6874
runs-on: ubuntu-latest
6975
steps:
70-
-
76+
-
7177
name: Check out code
7278
uses: actions/checkout@v2
7379
-
@@ -105,14 +111,18 @@ jobs:
105111
push: true
106112
tags: ${{ steps.prep.outputs.tags }}
107113
build-args: |
108-
RUN_CONTAINER=ubuntu:xenial
114+
BUILD_CONTAINER=golang:1.24-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac
115+
RUN_CONTAINER=ubuntu:22.04@sha256:c7eb020043d8fc2ae0793fb35a37bff1cf33f156d4d4b12ccc7f3ef8706c38b1
116+
CGO_ENABLED=0
117+
GODEBUG=""
118+
GO_TAGS=""
109119
LDFLAGS=-s -w -X main.version=${{ steps.prep.outputs.version }} -X main.commit=${{ github.SHA }} -X main.date=${{ steps.prep.outputs.created }}
110120
111121
boring:
112122
name: Build Boring Crypto Docker image
113123
runs-on: ubuntu-latest
114124
steps:
115-
-
125+
-
116126
name: Check out code
117127
uses: actions/checkout@v2
118128
-
@@ -150,7 +160,10 @@ jobs:
150160
push: true
151161
tags: ${{ steps.prep.outputs.tags }}
152162
build-args: |
153-
BUILD_CONTAINER=goboring/golang:1.16.1b7
154-
RUN_CONTAINER=gcr.io/distroless/base
163+
BUILD_CONTAINER=golang:1.24-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac
164+
RUN_CONTAINER=gcr.io/distroless/base-nossl-debian12@sha256:c0d97a3f0d6ad7d75c6494e3d6da54f09a961b80d755f0a09c7328f5a8edee5e
155165
CGO_ENABLED=1
166+
GODEBUG=fips140=on
167+
GO_TAGS=""
156168
LDFLAGS=-s -w -X main.version=${{ steps.prep.outputs.version }} -X main.commit=${{ github.SHA }} -X main.date=${{ steps.prep.outputs.created }}
169+

Dockerfile

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,45 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# Default build will be a standard Go binary in a distroless container.
16-
# Default LDFLAGS includes `-s -w` to strip symbols for a small binary.
15+
# Default build arguments are set for the 'default' flavor (static, no cgo, no FIPS).
16+
# These are overridden in the .github/workflows/docker.yaml for other flavors.
1717

18-
# Include the following LDFLAGS for version information in the binary:
19-
# LDFLAGS="-X main.version=${BUILD_VERSION} -X main.commit=${BUILD_COMMIT} -X main.date=${BUILD_DATE}"
18+
# Use golang:1.24-bookworm as the builder image.
19+
ARG BUILD_CONTAINER=golang:1.24-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac
2020

21-
# Use the following combination to build an image linked with Boring Crypto:
22-
# --build-arg CGO_ENABLED=1
23-
# --build-arg BUILD_CONTAINER=goboring/golang:1.16b7
24-
# --build-arg RUN_CONTAINER=gcr.io/distroless/base
25-
26-
ARG BUILD_CONTAINER=golang:1.16
27-
ARG RUN_CONTAINER=gcr.io/distroless/static
21+
ARG RUN_CONTAINER=gcr.io/distroless/static-debian12@sha256:cd64bec9cec257044ce3a8dd3620cf83b387920100332f2b041f19c4d2febf93
2822

2923
#--- Build binary in Go container ---#
3024
FROM ${BUILD_CONTAINER} as builder
3125

3226
ARG CGO_ENABLED=0
33-
ARG LDFLAGS="-s -w -X main.version=unknown -X main.commit=unknown -X main.date=unknown"
27+
ARG GODEBUG=""
28+
ARG LDFLAGS="-s -w -X main.version=unknown -X main.commit=unknown -X main.date=unknown"
29+
ARG GO_TAGS="netgo,osusergo" # Tags for static build
30+
31+
# Install git - required for go mod download in some base images.
32+
USER root
33+
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
3434

3535
# Build app
3636
WORKDIR /app
3737
ADD . .
38+
3839
RUN go mod download
39-
RUN CGO_ENABLED=$CGO_ENABLED go build -a \
40+
41+
# Build the application.
42+
RUN echo "Building with: CGO_ENABLED=${CGO_ENABLED} GODEBUG=${GODEBUG} GO_TAGS='${GO_TAGS}'"
43+
RUN GOTOOLCHAIN=local GOOS=linux GOARCH=amd64 CGO_ENABLED=${CGO_ENABLED} GODEBUG=${GODEBUG} go build -a \
44+
-tags="${GO_TAGS}" \
4045
-ldflags "${LDFLAGS}" \
4146
-o apigee-remote-service-envoy .
4247

4348
# add apigee:apigee user
4449
RUN groupadd -g 999 apigee && \
4550
useradd -r -u 999 -g apigee apigee
4651

47-
# remove all write privileges from ca-certificates.crt
48-
RUN chmod 4444 /etc/ssl/certs/ca-certificates.crt
52+
# Adjust ca-certificates permissions if the file exists.
53+
RUN if [ -f /etc/ssl/certs/ca-certificates.crt ]; then chmod a+r /etc/ssl/certs/ca-certificates.crt; fi
4954

5055
#--- Build runtime container ---#
5156
FROM ${RUN_CONTAINER}
@@ -56,6 +61,8 @@ COPY --from=builder /app/apigee-remote-service-envoy .
5661
COPY --from=builder /etc/passwd /etc/group /etc/shadow /etc/
5762
USER apigee
5863

59-
# Run entrypoint
60-
ENTRYPOINT ["/apigee-remote-service-envoy"]
6164
EXPOSE 5000/tcp 5001/tcp
65+
66+
# Run entrypoint.
67+
ENTRYPOINT ["/apigee-remote-service-envoy"]
68+

go.mod

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,57 @@
11
module github.com/apigee/apigee-remote-service-envoy/v2
22

3-
go 1.16
3+
go 1.24.0
4+
5+
toolchain go1.24.8
46

57
// replace github.com/apigee/apigee-remote-service-golib/v2 => ../apigee-remote-service-golib
68

79
require (
810
github.com/apigee/apigee-remote-service-golib/v2 v2.1.3
9-
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad
11+
github.com/envoyproxy/go-control-plane v0.12.0
1012
github.com/gogo/googleapis v1.4.1
11-
github.com/golang/protobuf v1.5.2
12-
github.com/google/go-cmp v0.5.5
13+
github.com/golang/protobuf v1.5.4
14+
github.com/google/go-cmp v0.6.0
1315
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
14-
github.com/lestrrat-go/jwx v1.1.6
15-
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
16+
github.com/lestrrat-go/jwx v1.2.30
1617
github.com/pkg/errors v0.9.1
1718
github.com/prometheus/client_golang v1.12.1
1819
github.com/spf13/cobra v1.1.3
19-
go.uber.org/multierr v1.6.0 // indirect
2020
go.uber.org/zap v1.16.0
21-
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
22-
google.golang.org/appengine v1.6.7 // indirect
23-
google.golang.org/genproto v0.0.0-20210315173758-2651cd453018
24-
google.golang.org/grpc v1.36.0
25-
google.golang.org/protobuf v1.26.0
26-
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
21+
golang.org/x/oauth2 v0.27.0
22+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157
23+
google.golang.org/grpc v1.65.1
24+
google.golang.org/protobuf v1.34.2
2725
gopkg.in/yaml.v3 v3.0.1
2826
)
27+
28+
require (
29+
cloud.google.com/go/compute/metadata v0.3.0 // indirect
30+
github.com/beorn7/perks v1.0.1 // indirect
31+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
32+
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b // indirect
33+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
34+
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
35+
github.com/goccy/go-json v0.10.3 // indirect
36+
github.com/gogo/protobuf v1.3.2 // indirect
37+
github.com/google/uuid v1.6.0 // indirect
38+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
39+
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
40+
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
41+
github.com/lestrrat-go/httpcc v1.0.1 // indirect
42+
github.com/lestrrat-go/iter v1.0.2 // indirect
43+
github.com/lestrrat-go/option v1.0.1 // indirect
44+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
45+
github.com/prometheus/client_model v0.5.0 // indirect
46+
github.com/prometheus/common v0.32.1 // indirect
47+
github.com/prometheus/procfs v0.7.3 // indirect
48+
github.com/rogpeppe/go-internal v1.14.1 // indirect
49+
github.com/spf13/pflag v1.0.5 // indirect
50+
go.uber.org/atomic v1.7.0 // indirect
51+
go.uber.org/multierr v1.6.0 // indirect
52+
golang.org/x/crypto v0.45.0 // indirect
53+
golang.org/x/net v0.47.0 // indirect
54+
golang.org/x/sync v0.18.0 // indirect
55+
golang.org/x/sys v0.38.0 // indirect
56+
golang.org/x/text v0.31.0 // indirect
57+
)

0 commit comments

Comments
 (0)