Skip to content

Kafka Connect: Add Trivy CVE scan to CI#15430

Open
rmoff wants to merge 3 commits intoapache:mainfrom
rmoff:trivy-cve-scan-kafka-connect
Open

Kafka Connect: Add Trivy CVE scan to CI#15430
rmoff wants to merge 3 commits intoapache:mainfrom
rmoff:trivy-cve-scan-kafka-connect

Conversation

@rmoff
Copy link
Contributor

@rmoff rmoff commented Feb 24, 2026

Summary

  • Adds a Trivy vulnerability scan to the Kafka Connect CI workflow
  • Runs as part of the existing test job (on one matrix entry only, to avoid redundant scans — dependency CVEs are JVM-independent) — after check completes, it builds distZip, unpacks it, and scans the bundled jars for CRITICAL/HIGH CVEs
  • On push events (main, version branches, RC tags), uploads SARIF results to GitHub's Security tab
  • On PRs, outputs scan results to CI logs for developer visibility
  • Does not fail the build — reports only, matching the approach used by other Apache projects (e.g. Superset)

Context

Discussion on dev@ mailing list: https://lists.apache.org/thread/kbf98950pzstzgon92st7mh9vrbv5yhb

Confluent Marketplace requires a Trivy scan before listing connectors. This has previously caught CVEs that needed patching (e.g. #14985). Running the scan in CI catches vulnerabilities during development and — critically — on RC tags before the release vote starts, when fixes can still be applied.

This is independent of #15212 (adding the KC artifact to the release process) and can land in either order.

Scan the built Kafka Connect distribution zip for known
vulnerabilities using Trivy. This runs alongside the existing
tests on PRs and pushes to main/version branches, and also
on release candidate tags, giving visibility into CVEs before
a release vote starts.

- Table output on all runs (visible in CI logs)
- SARIF upload to GitHub Security tab on push events

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the INFRA label Feb 24, 2026
@rmoff rmoff marked this pull request as draft February 24, 2026 14:12
Match the convention used in spark-ci.yml for third-party actions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rmoff rmoff marked this pull request as ready for review February 24, 2026 14:36
@kevinjqliu
Copy link
Contributor

i think its better to do this in the docker image publishing step, similar to what Superset is doing

@rmoff
Copy link
Contributor Author

rmoff commented Feb 26, 2026

@kevinjqliu I'm not sure I follow. How's this relate to publishing docker images? This is to identify CVEs in the Kafka Connect connector itself. thanks.

@kevinjqliu
Copy link
Contributor

Looking at how Trivy is used in Superset, its scanning the docker image only. In this PR, we're unpacking the jars to scan. I think it makes more sense to build a kafka connect image and then use Trivy to scan the image.

Just my preference

@rymurr
Copy link
Contributor

rymurr commented Feb 27, 2026

Looking at how Trivy is used in Superset, its scanning the docker image only. In this PR, we're unpacking the jars to scan. I think it makes more sense to build a kafka connect image and then use Trivy to scan the image.

Just my preference

Not really clear why we would add the infra to build a docker image just to use trivy. Seems like a direct scan is more parsimonious

Copy link
Contributor

@rymurr rymurr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I just want to see if we can avoid 2x build w/o over complicating the CI job

~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Build Kafka Connect distribution
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really have to build this twice? Does it make sense to do the scan in the same job as the tests? Not a strong preference, just seems unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. changed this behaviour: d52b1b9

scan-ref: '/tmp/kafka-connect-scan'
scanners: 'vuln'
severity: 'CRITICAL,HIGH'
ignore-unfixed: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to make sure I understand: the scan build will break when there is a hihg severity bug? A minor nit would be more comments in the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment the scan is report-only and won't fail the build.

I've also added inline comments explaining the behaviour.

Thinking about it some more, what'd be the ideal behaviour be? If a PR introduces a CVE, ought the build fail? Or maybe log a PR comment?

Address review feedback: move the vulnerability scan steps into the
existing kafka-connect-tests job (gated on JVM 21) instead of running
a separate job that duplicates checkout, setup, and compilation.

Also adds inline comments explaining the scan behaviour and explicit
exit-code: '0' to ensure the scan is report-only (the default would
fail the build on findings).
@kevinjqliu
Copy link
Contributor

Not really clear why we would add the infra to build a docker image just to use trivy. Seems like a direct scan is more parsimonious

Just looking at general patterns from the apache repos. https://grep.app/search?f.repo.pattern=apache%2F&q=uses%3A+aquasecurity%2Ftrivy-action
All the use cases I can find are using trivy for scanning images. (using image-ref: )

The only instance of scan-type: 'fs' i found has it disabled https://github.com/apache/plc4x/blob/eb41533bfab101acb87b9acdaf81c70d2e2fa286/.github/workflows/sast.yaml#L34-L47

From the docs, it seems like Filesystem scan and Container image scan are similar in that they both scan for Vulnerabilities, Misconfigurations, Secrets, and Licenses.

I think it would be helpful here if you can run the change on your fork repo and see if the fs trivy scan catches the currently open CVE for kafka connect (#15440)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants