Skip to content

Commit 18f7489

Browse files
add-needed-code-security-steps
1 parent ddf588a commit 18f7489

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
name: Codecov Scan
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
workflow_dispatch:
10+
11+
jobs:
12+
run:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
21+
with:
22+
go-version-file: go.mod
23+
env:
24+
GOPROXY: direct
25+
GONOSUMDB: "*"
26+
GOPRIVATE: https://github.com/CheckmarxDev/
27+
28+
- name: Install dependencies
29+
run: go install golang.org/x/tools/cmd/cover@latest
30+
31+
- name: Run tests and generate coverage
32+
run: |
33+
go test ./... -coverpkg=./... -v -coverprofile cover.out
34+
35+
36+
- name: Upload coverage to Codecov
37+
uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # v4.3.0
38+
with:
39+
token: ${{ secrets.CODECOV_TOKEN }}
40+
files: ./cover.out
41+
flags: target=auto
42+
fail_ci_if_error: true
43+
verbose: false

.github/workflows/cx-one-scan.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: cx-one-scan
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
schedule:
10+
- cron: '00 7 * * *'
11+
12+
jobs:
13+
cx-one-scan:
14+
name: cx-one-scan
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
- name: Checkmarx One CLI Action
20+
uses: checkmarx/ast-github-action@86e9ae570a811f9a1fb85903647a307aa3bf6253 # 2.0.44
21+
with:
22+
base_uri: ${{ secrets.AST_RND_SCANS_BASE_URI }}
23+
cx_tenant: ${{ secrets.AST_RND_SCANS_TENANT }}
24+
cx_client_id: ${{ secrets.AST_RND_SCANS_CLIENT_ID }}
25+
cx_client_secret: ${{ secrets.AST_RND_SCANS_CLIENT_SECRET }}
26+
additional_params: --tags scs --threshold "sast-critical=1; sast-high=1; sast-medium=1; sast-low=1; sca-critical=1; sca-high=1; sca-medium=1; sca-low=1; iac-security-critical=1; iac-security-high=1; iac-security-medium=1;iac-security-low=1"

.github/workflows/trivy-cache.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Note: This workflow only updates the cache. You should create a separate workflow for your actual Trivy scans.
2+
# In your scan workflow, set TRIVY_SKIP_DB_UPDATE=true and TRIVY_SKIP_JAVA_DB_UPDATE=true.
3+
name: Update Trivy Cache
4+
5+
on:
6+
schedule:
7+
- cron: '0 0 * * *' # Run daily at midnight UTC
8+
workflow_dispatch: # Allow manual triggering
9+
10+
jobs:
11+
update-trivy-db:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Setup oras
15+
uses: oras-project/setup-oras@5c0b487ce3fe0ce3ab0d034e63669e426e294e4d #v1.2.2
16+
17+
- name: Get current date
18+
id: date
19+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
20+
21+
- name: Download and extract the vulnerability DB
22+
run: |
23+
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/db
24+
oras pull ghcr.io/aquasecurity/trivy-db:2
25+
tar -xzf db.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/db
26+
rm db.tar.gz
27+
28+
- name: Download and extract the Java DB
29+
run: |
30+
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/java-db
31+
oras pull ghcr.io/aquasecurity/trivy-java-db:1
32+
tar -xzf javadb.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/java-db
33+
rm javadb.tar.gz
34+
35+
- name: Cache DBs
36+
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 #v4.2.0
37+
with:
38+
path: ${{ github.workspace }}/.cache/trivy
39+
key: cache-trivy-${{ steps.date.outputs.date }}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Trivy-scan
2+
on:
3+
push:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- master
8+
schedule:
9+
- cron: '5 6 * * *' # Runs every day at 06:05 UTC
10+
11+
jobs:
12+
trivy-scan:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Source
16+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
17+
18+
- name: Build and load (not push)
19+
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
20+
with:
21+
load: true
22+
context: .
23+
file: ./Dockerfile
24+
platforms: linux/amd64
25+
push: false
26+
tags: checkmarx/2ms:scanme
27+
28+
- name: Run Trivy Scan
29+
uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # v0.28.0
30+
with:
31+
image-ref: checkmarx/2ms:scanme
32+
vuln-type: os,library
33+
format: table
34+
ignore-unfixed: true
35+
severity: CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN
36+
trivy-config: trivy.yaml
37+
exit-code: '1'
38+
env:
39+
TRIVY_SKIP_DB_UPDATE: true
40+
TRIVY_SKIP_JAVA_DB_UPDATE: true

0 commit comments

Comments
 (0)