Skip to content

Harden the manual Java SDK verification metadata refresh - #76666

Open
shahar1 wants to merge 5 commits into
apache:mainfrom
shahar1:java-sdk-dependabot-auto-metadata
Open

shahar1 wants to merge 5 commits into
apache:mainfrom
shahar1:java-sdk-dependabot-auto-metadata

Conversation

@shahar1

@shahar1 shahar1 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Why

Dependabot cannot regenerate java-sdk/gradle/verification-metadata.xml, so a committer dispatches java-sdk-dependabot-verification-metadata.yml for each Gradle bump. #76714 made that workflow run the prek hook's script. Two problems remain:

  • The job runs Gradle with a contents: write token. During regeneration, verification is off and dependency code runs.
  • Nothing checks the regenerated file before the bot pushes it.

The job also ran on ubuntu-slim, whose limit is 15 minutes. One dispatch for #76616 took 13m13s.

How

The workflow stays manual (workflow_dispatch only).

  • Three jobs:

    Job Token Work
    resolve read Finds the PR head and refuses a head in another repository
    regenerate read Runs Gradle and uploads only the file. No cache access (cache-mode: none)
    publish write Validates the file, then commits only that path. A non-force push means a moved branch is rejected
  • Validation: publish treats the artifact as untrusted, because a job running dependency code produced it. The new --validate mode rejects:

    • a DOCTYPE
    • any change before <components>, which covers verify-metadata and trusted-artifacts
    • any element or attribute Gradle does not write for a plain checksum entry
    • an entry without a checksum
    • duplicate entries
    • a changed hash for an artifact that stays

    The script and the baseline come from the dispatched ref, normally main. A PR head may hold an older script, which would ignore --validate and run Gradle with the token present. The PR head is not the baseline either, because an entry removed by an earlier bot commit could return with a different hash as a new entry.

    A rejected file needs a human to run the hook and find out why.

What this does not do

It does not run on Dependabot PRs automatically. An earlier revision did. The metadata is checksum-only, so a new entry records what the repository served at that moment, and the validator cannot judge a hash for a new coordinate. The dispatch stays the deliberate step, and the committer who dispatches reviews the new entries. Automating it needs signature verification with trusted keys first.

CI for the bot's commit waits for a maintainer's approval, because GITHUB_TOKEN pushed it. This approval is not a review of the entries, and green CI checks against the same file. java-sdk/DEVELOPMENT.md says this.

Verification

Check Result
scripts/tests/ci/prek/test_regenerate_java_sdk_verification_metadata.py 32 passed
Commit hooks (prek) on the changed files Passed, except lychee-docker
Dispatch on my fork with the #76769 bump, validator and baseline from this PR's head Passed: run, 4m43s. The bot pushed one commit that changes only the metadata file
CI for the bot's commit on the fork Held as action_required until approved. Before the bot commit, Java SDK release verification failed; after approval it passed

lychee-docker did not start, because the local Docker proxy refused the bind mount. The change adds no links to Markdown files.

Not tested: a validator rejection in a real run, which only the unit tests cover. Whether Static checks accepts the bot's file was not run on the fork. An earlier revision of this PR produced a file byte-identical to the hook's output for #76616.

related: #76616


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5.5, Fable 5.2)

Generated-by: Claude Code (Opus 5.5, Fable 5.2) following the guidelines

@uranusjr

uranusjr commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

I don’t think this part can be automated while the metadata is sha256-only. A new entry records whatever the repository served at that moment, so the only safeguard is a human checking new coordinates and hashes. With this trigger, the PR goes green automatically, and since no-one is going to check each entry by hand, it essentially just moves the attack surface from the supply chain to the GitHub Action workers.

Maybe we can add only the workflow_dispatch part? The single generator, the job split and the validator are all good on their own. If we want Dependabot PRs fully automated later, I think PGP verification with <trusted-keys> is the way to go. A bump signed by a key we already trust would then need no human, and only new keys or unsigned artifacts would. We’ll probably need a devlist discussion first.

Dependabot cannot regenerate java-sdk/gradle/verification-metadata.xml, so
its Gradle bumps fail CI until a committer dispatches the refresh workflow.
That workflow then only appended to the file while the prek hook rebuilds it
from an empty list, so even a refreshed PR stayed red on Static checks over
the superseded entries, as apache#76616 did. Regeneration runs dependency code with
verification off, which must not share a job with a write token, and the
result is the trust list itself, so it cannot be committed unchecked.

Claude-Session: https://claude.ai/code/session_01BVx6g77DD1Qpsu2hvLEZxk
A PR head older than the validator carries a script that ignores --validate
and runs Gradle instead, with the write token in its environment. Gradle also
merges duplicate entries, so a duplicate could add a hash to a retained
artifact while the validator only saw the last one.

Claude-Session: https://claude.ai/code/session_01BVx6g77DD1Qpsu2hvLEZxk
The merge commit includes earlier bot commits on the PR, so a checksum entry
removed by one bot commit could return with a different hash in the next and
pass validation as a new entry.

Claude-Session: https://claude.ai/code/session_01BVx6g77DD1Qpsu2hvLEZxk
The metadata is checksum-only, so a new entry records whatever the repository served when it was generated, and only a human checking the new coordinates and hashes makes it trustworthy. Running the refresh on every Dependabot PR would remove the one deliberate step where that review is expected to happen. Automating it needs signature verification with trusted keys first.
A new artifact entry with no sha256 passed validation, because there was nothing to compare against the baseline. The validator's contract is that the file only gains or loses generated checksum entries, and an entry without one is not something Gradle writes.
@shahar1
shahar1 force-pushed the java-sdk-dependabot-auto-metadata branch from e52123e to 67fc15d Compare November 12, 2026 17:54
@shahar1 shahar1 changed the title Refresh Java SDK verification metadata on Dependabot PRs Harden the manual Java SDK verification metadata refresh Nov 12, 2026
@shahar1

shahar1 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

I don’t think this part can be automated while the metadata is sha256-only. A new entry records whatever the repository served at that moment, so the only safeguard is a human checking new coordinates and hashes. With this trigger, the PR goes green automatically, and since no-one is going to check each entry by hand, it essentially just moves the attack surface from the supply chain to the GitHub Action workers.

Maybe we can add only the workflow_dispatch part? The single generator, the job split and the validator are all good on their own. If we want Dependabot PRs fully automated later, I think PGP verification with <trusted-keys> is the way to go. A bump signed by a key we already trust would then need no human, and only new keys or unsigned artifacts would. We’ll probably need a devlist discussion first.

Thanks for the feedback, TP!
I've pivoted this PR towards hardening the existing manual process.
Tested on my fork: https://github.com/shahar1/airflow/actions/runs/43274988083

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants