|
15 | 15 |
|
16 | 16 | name: Docker Image CVE Scanner |
17 | 17 | 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 * * *' |
21 | 24 | workflow_dispatch: |
| 25 | +# inputs: |
| 26 | +# branch: |
| 27 | +# description: 'Branch to scan (e.g. trunk, 4.2, 4.1). Defaults to the branch the workflow runs on.' |
| 28 | +# required: false |
| 29 | +# default: '' |
22 | 30 | jobs: |
23 | 31 | scan_jvm: |
24 | | - if: github.repository == 'apache/kafka' |
| 32 | +# if: github.repository == 'apache/kafka' |
25 | 33 | runs-on: ubuntu-latest |
26 | | - strategy: |
27 | | - 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.2', '4.0.2', '4.1.2', '4.2.0'] |
30 | 34 | steps: |
31 | | - - name: Run CVE scan |
32 | | - uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # v0.33.1 |
33 | | - if: always() |
| 35 | + - name: Checkout code |
| 36 | + uses: actions/checkout@v5 |
| 37 | +# with: |
| 38 | +# ref: ${{ github.event.inputs.branch || github.ref }} |
| 39 | + - name: Set up Java |
| 40 | + uses: actions/setup-java@v4 |
| 41 | + with: |
| 42 | + distribution: temurin |
| 43 | + java-version: '21' |
| 44 | + - name: Build Kafka distribution tarball |
| 45 | + run: ./gradlew releaseTarGz -x test |
| 46 | + - name: Determine tarball path |
| 47 | + id: tarball |
| 48 | + run: | |
| 49 | + VERSION=$(./gradlew properties -q | grep "^version:" | awk '{print $2}') |
| 50 | + echo "path=core/build/distributions/kafka_2.13-${VERSION}.tgz" >> $GITHUB_OUTPUT |
| 51 | + - name: Set up Python 3.10 |
| 52 | + uses: actions/setup-python@v6 |
34 | 53 | with: |
35 | | - image-ref: apache/kafka:${{ matrix.supported_image_tag }} |
36 | | - format: 'table' |
37 | | - severity: 'CRITICAL,HIGH' |
38 | | - output: scan_report_jvm_${{ matrix.supported_image_tag }}.txt |
39 | | - exit-code: '1' |
| 54 | + python-version: "3.10" |
| 55 | + - name: Install dependencies |
| 56 | + run: | |
| 57 | + python -m pip install --upgrade pip |
| 58 | + pip install -r docker/requirements.txt |
| 59 | + - name: Build Docker image from current branch |
| 60 | + working-directory: ./docker |
| 61 | + run: | |
| 62 | + python docker_build_test.py kafka/branch-scan -tag=test -type=jvm --kafka-archive=../${{ steps.tarball.outputs.path }} -b |
| 63 | + - name: Install Trivy |
| 64 | + run: | |
| 65 | + curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin |
| 66 | +
|
| 67 | + - name: Run CVE scan |
| 68 | + run: | |
| 69 | + trivy image \ |
| 70 | + --format table \ |
| 71 | + --severity CRITICAL,HIGH \ |
| 72 | + --output scan_report_jvm.txt \ |
| 73 | + --exit-code 1 \ |
| 74 | + kafka/branch-scan:test |
| 75 | +
|
40 | 76 | - name: Upload CVE scan report |
41 | 77 | if: always() |
42 | 78 | uses: actions/upload-artifact@v4 |
43 | 79 | with: |
44 | | - name: scan_report_jvm_${{ matrix.supported_image_tag }}.txt |
45 | | - path: scan_report_jvm_${{ matrix.supported_image_tag }}.txt |
| 80 | + name: scan_report_jvm.txt |
| 81 | + path: scan_report_jvm.txt |
0 commit comments