Skip to content

Commit 2b96386

Browse files
committed
KAFKA-19881: change CVE scanner workflow to run on active branches
Signed-off-by: PoAn Yang <[email protected]>
1 parent 4a8ad8e commit 2b96386

File tree

2 files changed

+46
-20
lines changed

2 files changed

+46
-20
lines changed

.github/workflows/docker_scan.yml

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,63 @@
1515

1616
name: Docker Image CVE Scanner
1717
on:
18-
schedule:
19-
# This job will run at 3:30 UTC daily
20-
- cron: '30 3 * * *'
18+
pull_request:
19+
branches:
20+
- trunk
21+
# schedule:
22+
# # This job will run at 3:30 UTC daily
23+
# - cron: '30 3 * * *'
2124
workflow_dispatch:
2225
jobs:
2326
scan_jvm:
2427
if: github.repository == 'apache/kafka'
2528
runs-on: ubuntu-latest
2629
strategy:
2730
matrix:
28-
# This is an array of supported tags. Make sure this array only contains the supported tags
29-
supported_image_tag: ['latest', '3.9.1', '4.0.1', '4.1.1']
31+
# This is an array of supported branches. Make sure this array only contains the supported branches
32+
supported_image_branches: ['trunk'] # 4.1, 4.0, 3.9
3033
steps:
34+
- uses: actions/checkout@v5
35+
name: Set up Python 3.10
36+
with:
37+
ref: ${{ matrix.supported_image_branches }}
38+
- uses: actions/setup-python@v6
39+
with:
40+
python-version: "3.10"
41+
- name: Setup Gradle
42+
uses: ./.github/actions/setup-gradle
43+
with:
44+
java-version: 25
45+
gradle-cache-read-only: true
46+
gradle-cache-write-only: false
47+
- name: Compile and validate
48+
run: |
49+
./gradlew --build-cache --info $SCAN_ARG check releaseTarGz -x test
50+
- name: Setup Docker Compose
51+
run: |
52+
sudo curl -L "https://github.com/docker/compose/releases/download/v2.30.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
53+
sudo mv /usr/local/bin/docker-compose /usr/bin/docker-compose
54+
sudo chmod +x /usr/bin/docker-compose
55+
- name: Install dependencies
56+
run: |
57+
python -m pip install --upgrade pip
58+
pip install -r docker/requirements.txt
59+
- name: Build image and run tests
60+
working-directory: ./docker
61+
run: |
62+
python docker_build_test.py kafka/test -tag=test -type=jvm --kafka-archive=../core/build/distributions/kafka_2.13-$(./gradlew properties | grep version: | awk '{print $NF}' | head -n 1)-SNAPSHOT.tgz
3163
- name: Run CVE scan
3264
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # v0.33.1
3365
if: always()
3466
with:
35-
image-ref: apache/kafka:${{ matrix.supported_image_tag }}
67+
image-ref: kafka/test:test
3668
format: 'table'
3769
severity: 'CRITICAL,HIGH'
38-
output: scan_report_jvm_${{ matrix.supported_image_tag }}.txt
70+
output: scan_report_jvm_${{ matrix.supported_image_branches }}.txt
3971
exit-code: '1'
4072
- name: Upload CVE scan report
4173
if: always()
4274
uses: actions/upload-artifact@v4
4375
with:
44-
name: scan_report_jvm_${{ matrix.supported_image_tag }}.txt
45-
path: scan_report_jvm_${{ matrix.supported_image_tag }}.txt
76+
name: scan_report_jvm_${{ matrix.supported_image_branches }}.txt
77+
path: scan_report_jvm_${{ matrix.supported_image_branches }}.txt

docker/README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,18 @@ rc_docker_image: apache/kafka-native:3.8.0-rc0
8585
promoted_docker_image: apache/kafka-native:3.8.0
8686
```
8787

88-
Cron job for checking CVEs in supported docker images
88+
Cron job for checking CVEs in supported branches
8989
-----------------------------------------------------
9090

91-
- `Docker Image CVE Scanner` Github Action Workflow (present in `.github/workflows/docker_scan.yml`) will run nightly CVE scans and generate reports for docker image tags mentioned in the `supported_image_tag` array.
91+
- `Docker Image CVE Scanner` Github Action Workflow (present in `.github/workflows/docker_scan.yml`) will run nightly CVE scans and generate reports for supported versions mentioned in the `supported_image_branches` array.
9292
- This workflow is branch independent. Only the workflow in trunk, i.e. the default branch will be considered.
9393
- In case a Critical or High CVE is detected, the workflow will fail.
9494
- It will generate the scan reports that can be checked by the community.
95-
- For every new release, this should be updated with the latest supported docker images.
95+
- For every new release, this should be updated with the latest supported branches.
9696
- For example:-
9797
```
98-
For supporting apache/kafka:3.6.0, apache/kafka:latest and apache/kafka:3.7.0-rc0, supported_image_tag array should be
99-
supported_image_tag: ['3.6.0', 'latest', '3.7.0-rc0']
100-
```
101-
- When RC for a version gets changed or when a bug fix release happens, this should be updated as well.
102-
- For example:-
103-
```
104-
For supporting apache/kafka:3.6.1, apache/kafka:latest and apache/kafka:3.7.0-rc1, tag array should be
105-
supported_image_tag: ['3.6.1', 'latest', '3.7.0-rc1']
98+
For supporting branches trunk, 4.1, and 4.0, supported_image_branches array should be
99+
supported_image_branches: ['trunk', '4.1', '4.0']
106100
```
107101

108102
Local Setup

0 commit comments

Comments
 (0)