fix: vulnerability issue in docker image

fix failure

fxi arch

fix image name

fix failure

test: update trivy test

fix test

install go  1.16

go

fix failure

fix failure
This commit is contained in:
andyzhangx 2021-09-23 07:30:20 +00:00
parent be980cc87f
commit ea9e9e65aa
3 changed files with 43 additions and 2 deletions

40
.github/workflows/trivy.yaml vendored Normal file
View File

@ -0,0 +1,40 @@
name: Trivy vulnerability scanner
on:
push:
branches:
- master
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-18.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install go
uses: actions/setup-go@v2
with:
go-version: ^1.16
- name: Build an image from Dockerfile
run: |
export PUBLISH=true
export REGISTRY=test
export IMAGE_VERSION=latest
export DOCKER_CLI_EXPERIMENTAL=enabled
export ARCH=amd64
go version
make nfs
make container-build
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'test/nfsplugin:latest-linux-amd64'
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN'

View File

@ -20,8 +20,9 @@ ARG ARCH
# Copy nfsplugin from build _output directory
COPY bin/${ARCH}/nfsplugin /nfsplugin
RUN apt update && apt-mark unhold libcap2
# this is a workaround to install nfs-common & nfs-kernel-server and don't quit with error
# https://github.com/kubernetes-sigs/blob-csi-driver/issues/214#issuecomment-781602430
RUN apt update && apt install ca-certificates mount nfs-common nfs-kernel-server -y || true
RUN apt install ca-certificates mount libssl1.1 nfs-common nfs-kernel-server -y || true
ENTRYPOINT ["/nfsplugin"]

View File

@ -27,7 +27,7 @@ include release-tools/build.make
GIT_COMMIT = $(shell git rev-parse HEAD)
BUILD_DATE = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
IMAGE_VERSION = v3.0.0
IMAGE_VERSION ?= v3.0.0
LDFLAGS = -X ${PKG}/pkg/nfs.driverVersion=${IMAGE_VERSION} -X ${PKG}/pkg/nfs.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/nfs.buildDate=${BUILD_DATE}
EXT_LDFLAGS = -s -w -extldflags "-static"
# Use a custom version for E2E tests if we are testing in CI