Repository navigation
[ci] Submit Gradle dependency graphs to GitHub - #13600
Conversation
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The workflow exposes repository-write credentials to pull-request and manual runs that only generate artifacts, allowing checked-out Gradle build scripts to use unnecessary write access.
1 open issue
What changed in this PR
Adds Gradle dependency submission to GitHub so Dependabot can detect vulnerabilities in transitive Maven dependencies used by .NET for Android.
Changes:
- Derives the seven Gradle project roots from Dependabot configuration.
- Reuses repository-defined JDK, Java compatibility, and Gradle versions.
- Submits graphs on matching pushes to
main; pull requests and manual runs generate and upload artifacts only.
| File | Description |
|---|---|
.github/workflows/gradle-dependency-submission.yml |
Adds configuration discovery and per-project dependency graph generation with event-based submission. |
Review effort: Balanced
|
The
The submission to GitHub runs for the first time on the first push to |
Co-authored-by: Copilot App <[email protected]>
|
@dalexsoto review |
Co-authored-by: Copilot App <[email protected]>
dalexsoto
left a comment
There was a problem hiding this comment.
Reviewed 7bc0f671 against main at 0f521ede (1 file). This is a static, read-only review.
The matrix setup is solid. The dependabot.yml, Configuration.props and Gradle wrapper parsing all fail loudly, all seven build roots resolve, and only push submits.
One blocker, about the permissions point raised earlier:
- The Gradle job still has a write token on
pull_requestandworkflow_dispatch.permissions: contents: write(lines 64-65) applies to the only job that runs Gradle, on every trigger.persist-credentials: falsekeeps the token out of.git/config, butgradle/actions/dependency-submissiontakesgithub-token(default${{ github.token }}), which the runner exposes as theINPUT_GITHUB-TOKENenvironment variable. The action then starts Gradle without overriding the environment, so build scripts, plugins and dependencies evaluated from an unmerged same-repo branch can still read acontents: writetoken, even ingenerate-and-uploadmode. Fork PRs are fine because GitHub downgrades their token.
Suggested fix: run the matrix with contents: read and dependency-graph: generate-and-upload for every event, and add a separate push-only job (needs: the matrix, contents: write, dependency-graph: download-and-submit) that never runs Gradle.
Non-blocking: once a job holds a write token, consider SHA-pinning gradle/actions/dependency-submission.
Co-authored-by: Copilot App <[email protected]>
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
Reviewed 2017f257 against main at fa31e490 (merge base 5f53a70f; of the 6 newer main commits only an r8 bump touches a Gradle file, and it does not affect the parsed inputs). This is a static, read-only review.
The previous blocker is fixed in 2017f25. Gradle now runs only in the dependency-graph matrix with contents: read and generate-and-upload. The only contents: write job is the push-only dependency-submission job, which has no checkout and uses download-and-submit, a mode that returns before Gradle is provisioned or run in gradle/actions v6. That job downloads the same run's artifacts with the runner's artifact token, so it does not need actions: read. The matrix artifacts get distinct names because the job correlator includes the matrix value. The dependabot.yml roots, the Configuration.props versions and the Gradle wrapper version are unchanged on current main.
Two small non-blocking suggestions: add cache-disabled: true to the submit step, which otherwise uses the action's default proprietary enhanced cache provider, and consider pinning gradle/actions/dependency-submission to a commit SHA in the job that holds the write token.

GitHub's dependency graph for this repository has no Maven packages. Dependabot version updates read the direct dependencies in our
build.gradlefiles, but Dependabot alerts and security updates use the dependency graph. As a result, we get no alerts for transitive Gradle dependencies, such as Guava, Bouncy Castle, and Commons Lang undercom.android.tools.build:manifest-merger.Add a workflow that uses
gradle/actions/dependency-submissionto submit a graph for each Gradle project:gradleentries in.github/dependabot.yml, so there is only one list to maintain.Configuration.props. The Gradle version comes frombuild-tools/gradle/gradle/wrapper/gradle-wrapper.properties.-PjavaSourceVerand-PjavaTargetVerare required. Without them,src/manifestmergerdefaults to Java 8 and its Java 17manifest-mergerdependency is silently left out of the graph.main, a separate job withcontents: writesubmits them withdownload-and-submit. That job never runs Gradle, so build scripts, plugins, and dependencies never see a write token. Pull requests and manual runs only generate the graphs, so build changes are checked before merge.GitHub's automatic dependency submission also runs on this repository and fails on NuGet restore with
NETSDK1139, because the Android workload is not installed. There is no setting to turn it off for one ecosystem only, so it must be disabled in the repository settings. This workflow does not need it.Validation:
FAILEDentries. Thesrc/manifestmergergraph includesmanifest-merger:32.5.1, Guava33.4.0-jre, Bouncy Castle1.80.2, and Commons Lang3.16.0.yq4.54.3 (the version onubuntu-latest): it produced the seven directories, JDK 25.0.4.1, Java 17, and Gradle 9.6.0. The| uniquefilter was added after that run.pull_requestrun on this PR exercises the full workflow in generate-and-upload mode. The submit job runs only after merge.