Skip to content

Commit 73e0f58

Browse files
authored
fix(ci): pin versions of Go tools and scan only Dockerfile misconfigurations (#208)
This pull request fixes a few issues that are making our daily builds fail: - The newest version of revive requires Go 1.23, which fails the build for some applications which are still on Go 1.22 - [job](https://semaphore.semaphoreci.com/jobs/4a1e5113-c36c-45ed-9514-059510015678#L557). It's always a good practice to pin the versions of the tools used in CI, so we do that here. - For some applications, we are not building the image before checking it with trivy, which causes the CI job to fail - [job](https://semaphore.semaphoreci.com/jobs/a23a9e73-1a76-4143-b1a4-197e778ed9b6) - We are currently ignoring the severity in the `trivy config` command, which causes some LOW misconfigurations to fail builds. Also, those LOW misconfigurations come from Kubernetes YAMLs, which is a newer thing that trivy can do. Since our goal with using trivy config was to scan for misconfigurations in Dockerfiles, we should not scan Kubernetes templates at all for now, so we update the security toolbox to be more direct with what we want to scan in `trivy config` Ref: renderedtext/tasks#7804
1 parent 8ac8b7d commit 73e0f58

File tree

11 files changed

+23
-16
lines changed

11 files changed

+23
-16
lines changed

.semaphore/daily-builds.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ blocks:
512512
- make check.ex.deps
513513
- name: "\U0001F6E1️ Check docker"
514514
commands:
515+
- make build
515516
- make check.docker
516517
- name: "Dashboardhub: \U0001F9EA QA"
517518
dependencies: ["Dashboardhub: \U0001F4CB Provision Test Image"]
@@ -3096,6 +3097,7 @@ blocks:
30963097
- make check.js.deps
30973098
- name: "\U0001F6E1️ Check docker"
30983099
commands:
3100+
- make build
30993101
- make check.docker CHECK_DOCKER_OPTS='--skip-dirs node_modules'
31003102
# Velocity
31013103
- name: "Velocity: \U0001F4CB Provision Prod Image"

.semaphore/semaphore.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ blocks:
557557
- make check.ex.deps
558558
- name: "\U0001F6E1️ Check docker"
559559
commands:
560+
- make build
560561
- make check.docker
561562
- name: "Dashboardhub: \U0001F9EA QA"
562563
dependencies: ["Dashboardhub: \U0001F4CB Provision Test Image"]
@@ -3398,6 +3399,7 @@ blocks:
33983399
- make check.js.deps
33993400
- name: "\U0001F6E1️ Check docker"
34003401
commands:
3402+
- make build
34013403
- make check.docker CHECK_DOCKER_OPTS='--skip-dirs node_modules'
34023404
# Velocity
34033405
- name: "Velocity: \U0001F4CB Provision Prod Image"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ ifeq ($(CI),)
126126
-v $(ROOT_MAKEFILE_PATH)/security-toolbox:$(SECURITY_TOOLBOX_TMP_DIR) \
127127
-v $(XDG_RUNTIME_DIR)/docker.sock:/var/run/docker.sock \
128128
registry.semaphoreci.com/ruby:3 \
129-
bash -c '$(SECURITY_TOOLBOX_TMP_DIR)/docker -d --image $(IMAGE):$(IMAGE_TAG) $(CHECK_DOCKER_OPTS)'
129+
bash -c '$(SECURITY_TOOLBOX_TMP_DIR)/docker -d --image $(IMAGE):$(IMAGE_TAG) -s CRITICAL $(CHECK_DOCKER_OPTS)'
130130
else
131131
# ruby version is set in prologue
132132
$(ROOT_MAKEFILE_PATH)/security-toolbox/docker -d --image $(IMAGE):$(IMAGE_TAG) -s CRITICAL $(CHECK_DOCKER_OPTS)

artifacthub/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ RUN curl -sL https://github.com/google/protobuf/releases/download/v3.20.0/protoc
3636
mv bin/protoc /usr/local/bin/protoc
3737

3838
WORKDIR /app
39-
RUN go install github.com/mgechev/revive@latest
40-
RUN go install gotest.tools/gotestsum@latest
39+
RUN go install github.com/mgechev/revive@v1.7.0
40+
RUN go install gotest.tools/gotestsum@v1.12.1
4141
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
4242
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
4343

bootstrapper/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ RUN curl -sL https://github.com/google/protobuf/releases/download/v28.0/protoc-2
2929
mv bin/protoc /usr/local/bin/protoc
3030

3131
WORKDIR /app
32-
RUN go install github.com/mgechev/revive@latest
33-
RUN go install gotest.tools/gotestsum@latest
32+
RUN go install github.com/mgechev/revive@v1.7.0
33+
RUN go install gotest.tools/gotestsum@v1.12.1
3434
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
3535
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
3636
RUN export PATH="$PATH:$(go env GOPATH)/bin"

ee/velocity/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ RUN curl -sL https://github.com/google/protobuf/releases/download/v3.3.0/protoc-
3838
mv bin/protoc /usr/local/bin/protoc
3939

4040
WORKDIR /app
41-
RUN go install github.com/mgechev/revive@latest
42-
RUN go install gotest.tools/gotestsum@latest
41+
RUN go install github.com/mgechev/revive@v1.7.0
42+
RUN go install gotest.tools/gotestsum@v1.12.1
4343
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
4444
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
4545

encryptor/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ RUN curl -sL https://github.com/google/protobuf/releases/download/v3.3.0/protoc-
3030
mv bin/protoc /usr/local/bin/protoc
3131

3232
WORKDIR /app
33-
RUN go install github.com/mgechev/revive@latest
34-
RUN go install gotest.tools/gotestsum@latest
33+
RUN go install github.com/mgechev/revive@v1.7.0
34+
RUN go install gotest.tools/gotestsum@v1.12.1
3535
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
3636

3737
CMD [ "/bin/bash", "-c \"while sleep 1000; do :; done\"" ]

loghub2/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ RUN curl -sL https://github.com/google/protobuf/releases/download/v3.3.0/protoc-
3030
mv bin/protoc /usr/local/bin/protoc
3131

3232
WORKDIR /app
33-
RUN go install github.com/mgechev/revive@latest
34-
RUN go install gotest.tools/gotestsum@latest
33+
RUN go install github.com/mgechev/revive@v1.7.0
34+
RUN go install gotest.tools/gotestsum@v1.12.1
3535
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
3636
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
3737

public-api-gateway/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ RUN curl -sL https://github.com/google/protobuf/releases/download/v3.3.0/protoc-
3131
mv bin/protoc /usr/local/bin/protoc
3232

3333
WORKDIR /app
34-
RUN go install github.com/mgechev/revive@latest
35-
RUN go install gotest.tools/gotestsum@latest
34+
RUN go install github.com/mgechev/revive@v1.7.0
35+
RUN go install gotest.tools/gotestsum@v1.12.1
3636
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
3737
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
3838
RUN rm -rf build && CGO_ENABLED=0 go build -o build/server main.go

security-toolbox/policies/docker/trivy_config.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ def initialize(args)
1010
end
1111

1212
@skip_dirs = args[:skip_dirs].to_s.split(",") || []
13+
@severity = args[:severity] || "HIGH,CRITICAL"
1314
end
1415

1516
def test
1617
command = [
1718
"trivy",
1819
"config",
19-
"--exit-code 1"
20+
"--severity #{@severity}",
21+
"--exit-code 1",
22+
"--misconfig-scanners dockerfile"
2023
]
2124

2225
@skip_files.each do |skip_file|

0 commit comments

Comments
 (0)