Skip to content

Commit 47085ee

Browse files
joliveirinhajcsf
authored andcommitted
TUN-9467: add vulncheck to cloudflared
* TUN-9467: add vulncheck to cloudflared
1 parent a408612 commit 47085ee

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

.gitlab-ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
variables:
2+
# Define GOPATH within the project directory to allow GitLab CI to cache it.
3+
# By default, Go places modules in GOMODCACHE, often outside the project.
4+
# Explicitly setting GOMODCACHE ensures it's within the cached path.
5+
GOPATH: "$CI_PROJECT_DIR/.go"
6+
GOMODCACHE: "$GOPATH/pkg/mod"
7+
GO_BIN_DIR: "$GOPATH/bin"
8+
9+
cache:
10+
# Cache Go modules and the binaries.
11+
# The 'key' ensures a unique cache per branch, or you can use a fixed key
12+
# for a shared cache across all branches if that fits your workflow.
13+
key: "$CI_COMMIT_REF_SLUG"
14+
paths:
15+
- ${GOPATH}/pkg/mod/ # For Go modules
16+
- ${GO_BIN_DIR}/
17+
118
stages: [build, release]
219

320
default:
@@ -37,6 +54,23 @@ default:
3754
when: always
3855
- when: never
3956

57+
58+
# Template for Go setup, including caching and installation
59+
.go_setup:
60+
image: docker-registry.cfdata.org/stash/devtools/ci-builders/golang-1.24/master:3090-3e32590@sha256:fc81df4f8322f022d93712ee40bb1e5752fdbe9868d1e5a23fd851ad6fbecb91
61+
before_script:
62+
- mkdir -p ${GOPATH} ${GOMODCACHE} ${GO_BIN_DIR}
63+
- export PATH=$PATH:${GO_BIN_DIR}
64+
- go env -w GOMODCACHE=${GOMODCACHE} # Ensure go uses the cached module path
65+
66+
# Check if govulncheck is already installed and install it if not
67+
- if [ ! -f ${GO_BIN_DIR}/govulncheck ]; then
68+
echo "govulncheck not found in cache, installing...";
69+
go install golang.org/x/vuln/cmd/govulncheck@latest;
70+
else
71+
echo "govulncheck found in cache, skipping installation.";
72+
fi
73+
4074
# -----------------------------------------------
4175
# Stage 1: Build on every PR
4276
# -----------------------------------------------
@@ -64,6 +98,14 @@ build_cloudflared_macos: &build
6498
- echo "Executing ${BUILD_SCRIPT}"
6599
- exec ${BUILD_SCRIPT}
66100

101+
vulncheck:
102+
stage: build
103+
extends: .go_setup
104+
rules:
105+
- !reference [.default_rules, run_on_branch]
106+
script:
107+
- make vulncheck
108+
67109
# -----------------------------------------------
68110
# Stage 1: Build and sign only on releases
69111
# -----------------------------------------------

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# use a builder image for building cloudflare
22
ARG TARGET_GOOS
33
ARG TARGET_GOARCH
4-
FROM golang:1.24.2 AS builder
4+
FROM golang:1.24.4 AS builder
55
ENV GO111MODULE=on \
66
CGO_ENABLED=0 \
77
TARGET_GOOS=${TARGET_GOOS} \

Dockerfile.amd64

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# use a builder image for building cloudflare
2-
FROM golang:1.24.2 AS builder
2+
FROM golang:1.24.4 AS builder
33
ENV GO111MODULE=on \
44
CGO_ENABLED=0 \
55
# the CONTAINER_BUILD envvar is used set github.com/cloudflare/cloudflared/metrics.Runtime=virtual

Dockerfile.arm64

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# use a builder image for building cloudflare
2-
FROM golang:1.24.2 AS builder
2+
FROM golang:1.24.4 AS builder
33
ENV GO111MODULE=on \
44
CGO_ENABLED=0 \
55
# the CONTAINER_BUILD envvar is used set github.com/cloudflare/cloudflared/metrics.Runtime=virtual

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ all: cloudflared test
129129
clean:
130130
go clean
131131

132+
.PHONY: vulncheck
133+
vulncheck:
134+
@govulncheck ./...
135+
132136
.PHONY: cloudflared
133137
cloudflared:
134138
ifeq ($(FIPS), true)

0 commit comments

Comments
 (0)