-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (76 loc) · 2.58 KB
/
Copy pathcheckov.yml
File metadata and controls
91 lines (76 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Checkov
on:
pull_request:
types: [opened, synchronize, reopened]
branches: [main, develop]
push:
branches: [main, develop]
workflow_dispatch:
permissions:
contents: read
jobs:
dockerfile-checks:
name: Blocking Dockerfile checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Run blocking Checkov Dockerfile checks
run: |
set -euo pipefail
dockerfile_glob='**/Dockerfile*'
echo "Checking files matching ${dockerfile_glob}"
mapfile -t dockerfiles < <(
find . -type f \( -name 'Dockerfile' -o -name 'Dockerfile.*' \) \
-not -path './.git/*' \
-not -path './node_modules/*' \
| sort
)
if [ "${#dockerfiles[@]}" -eq 0 ]; then
echo "No Dockerfiles found."
exit 0
fi
checks="CKV_DOCKER_3,CKV_DOCKER_8,CKV_DOCKER_7,CKV2_DOCKER_2,CKV2_DOCKER_3,CKV2_DOCKER_7,CKV2_DOCKER_8"
for file in "${dockerfiles[@]}"; do
echo "Checking $file"
docker run --rm -v "$PWD:/repo" bridgecrew/checkov:latest \
--framework dockerfile \
--file "/repo/${file#./}" \
--check "$checks" \
--quiet
done
advisory-config-checks:
name: Advisory config checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Run advisory deployment scan
continue-on-error: true
run: |
set -euo pipefail
mkdir -p checkov-advisory
docker run --rm -v "$PWD:/repo" bridgecrew/checkov:latest \
--framework kubernetes \
--directory /repo/deployments/openshift/kustomize \
--quiet \
--output json \
--output-file-path /repo/checkov-advisory/deployments.json
- name: Run advisory GitHub workflow scan
continue-on-error: true
run: |
set -euo pipefail
# Advisory workflow scope: .github/workflows/*.yml
docker run --rm -v "$PWD:/repo" bridgecrew/checkov:latest \
--framework github_actions \
--directory /repo/.github/workflows \
--quiet \
--output json \
--output-file-path /repo/checkov-advisory/workflows.json
- name: Upload advisory scan artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: checkov-advisory-results
path: checkov-advisory/
if-no-files-found: error