Skip to content

Commit

Permalink
feat(ci): add KICS Scan workflow on PR to master (Checkmarx#4561)
Browse files Browse the repository at this point in the history
Signed-off-by: João Reigota <[email protected]>
  • Loading branch information
joaoReigota1 authored Dec 15, 2021
1 parent f2b1cbb commit a556ad8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/kics-gh-action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: kics-github-action

on:
pull_request:
branches: [master]
workflow_dispatch:

jobs:
kics-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run KICS Scan
uses: checkmarx/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: "./Dockerfile"
ignore_on_exit: results
enable_comments: true
output_path: ./results
output_formats: json,html
type: dockerfile
- uses: actions/upload-artifact@v2
with:
name: results
path: ./results
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.17.3-alpine as build_env
FROM golang:1.17.3-alpine as build_env

# Copy the source from the current directory to the Working Directory inside the container
WORKDIR /app
Expand All @@ -12,8 +12,7 @@ ARG TARGETOS
ARG TARGETARCH

# Copy go mod and sum files
COPY go.mod .
COPY go.sum .
COPY go.mod go.sum ./

# Get dependancies - will also be cached if we won't change mod/sum
RUN go mod download -x
Expand All @@ -32,13 +31,17 @@ USER Checkmarx
HEALTHCHECK CMD wget -q --method=HEAD localhost/system-status.txt

# Runtime image
# Ignore no User Cmd since KICS container is stopped afer scan
# kics-scan ignore-line
FROM alpine:3.14.3

# Install Git
RUN apk add --no-cache \
git=2.32.0-r0

# Copy built binary to the runtime container
# Vulnerability fixed in latest version of KICS remove when gh actions version is updated
# kics-scan ignore-line
COPY --from=build_env /app/bin/kics /app/bin/kics
COPY --from=build_env /app/assets/queries /app/bin/assets/queries
COPY --from=build_env /app/assets/libraries/* /app/bin/assets/libraries/
Expand Down

0 comments on commit a556ad8

Please sign in to comment.