Skip to content

Add read-only permissions and self-repo actions in java_tests.yml - #41626

Merged
Amar3tto merged 1 commit into
masterfrom
codescan/gha-java-tests-permissions
Nov 25, 2026
Merged

Amar3tto merged 1 commit into
masterfrom
codescan/gha-java-tests-permissions

Conversation

@derrickaw

@derrickaw derrickaw commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria:

  • The PR remediates confirmed, live Code Scanning finding(s) (CodeQL / zizmor) on master without altering intended public API or workflow semantics
  • The fix is minimal, idiomatic, and avoids suppressing alerts or masking underlying defects
  • Relevant unit tests, linters, and CI checks have been verified

If you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :)

Summary

Resolves all 11 open Code Scanning findings (CodeQL actions/missing-workflow-permissions, zizmor/excessive-permissions, and zizmor/self-repository — alerts #24, #26, #1565, #1567, #1930, #3130–#3132, #3134, #3135, #3158) in .github/workflows/java_tests.yml:

  • Add explicit top-level permissions: contents: read so neither java_unit_tests nor java_wordcount_direct_runner inherits default repository write scopes (actions/upload-artifact@v7 uses the Actions runtime token rather than GITHUB_TOKEN).
  • Switch all 6 local composite action references (setup-environment-action and gradle-command-self-hosted-action) from ./.github/... to GitHub's $/... self-repository syntax.

Verification

  • Sample workflow_dispatch run of java_tests.yml on branch codescan/gha-java-tests-permissions: https://github.com/apache/beam/actions/runs/45431447081 (success across all 6 matrix jobs: Java Unit Tests and Java Wordcount Direct Runner on ubuntu-24.04, macos-latest, and windows-latest)
  • ./gradlew :beam-test-gha:preCommit, zizmor, and CodeQL

@derrickaw

Copy link
Copy Markdown
Collaborator Author

/gemini review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This PR hardens .github/workflows/java_tests.yml by adding top-level permissions: contents: read and migrating local composite action references from workspace-relative (./.github/...) to GitHub's self-repository ($/.github/...) syntax. The changes are minimal, accurate, and resolve the targeted CodeQL and zizmor code scanning findings without affecting test execution.

🔍 General Feedback

  • contents: read is sufficient for all steps in both java_unit_tests and java_wordcount_direct_runner (actions/checkout, environment setup, Gradle execution, and actions/upload-artifact).
  • All local composite action invocations in the workflow have been consistently updated to use the $/ self-repository prefix.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions github-actions Bot added build size/s S: 10-49 lines changed labels Nov 24, 2026
@derrickaw derrickaw added the ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review label Nov 24, 2026
@derrickaw derrickaw removed the ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review label Nov 24, 2026
@derrickaw
derrickaw marked this pull request as ready for review November 24, 2026 19:19
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @Amar3tto for label build.
Backup reviewer: Abacn (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

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.

2 participants