Skip to content

Enhance reusable workflows#80

Open
Yaswant Pradhan (yaswant) wants to merge 171 commits into
mainfrom
develop
Open

Enhance reusable workflows#80
Yaswant Pradhan (yaswant) wants to merge 171 commits into
mainfrom
develop

Conversation

@yaswant

@yaswant Yaswant Pradhan (yaswant) commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

PR Summary

Hardens the GitHub Actions security baseline across all workflows.

Code Reviewer: James Bruten (@james-bruten-mo)

Downstream pull requests

List of downstream PR's need coordinated merge.

Action pinning

  • All third-party actions replaced with immutable 40-char commit SHAs (e.g. actions/checkout@v6@df4cb1c…).
  • actions/github-script in track-review-project.yaml upgraded from v8 → v9 as part of the pin.

Credential & permission scoping

  • persist-credentials: false added to every actions/checkout step
  • Top-level permissions: {} set on caller workflows; granular contents: read / pull-requests: write / actions: read pushed down to job level in call-track-review-project.yaml, call-trigger-project-workflow.yaml, and trigger-project-workflow.yaml
  • fortran-lint.yaml gains an explicit contents: read job permission.

Template-injection fixes (zizmor)

  • cla-check.yaml: step outputs and inputs.cla-url moved to env: vars, read via process.env.* in the github-script block.
  • fortran-lint.yaml: all string/path inputs moved to env: vars; boolean flags resolved in shell using a bash array.
  • track-review-project.yaml: inputs.project_org and inputs.project_number moved to env: vars. Also, included PROJECT_ACTION_PAT secret as required parameter to avoid secret inheritance in caller workflow (breaking change! See updated README for usage).

CLA workflow logic

  • Merge-ref detection replaced: git ls-remote → gh api repos/.../pulls/… (avoids unauthenticated git network call).
  • CONTRIBUTORS.md modification check rewritten: git diff → GitHub Contents API + base64 | tr | cmp (avoids authenticated git fetch from fork). File modification now checked against content instead of just file state.

Tooling & config

  • New dependabot.yaml: monthly schedule, major-version updates blocked, all action updates grouped into a single PR
  • New zizmor.yaml: suppresses unpinned-uses, dangerous-triggers, and secrets-inherit for the two caller workflows that use secrets: inherit
  • .yamllint: updated ignore syntax; added comments and comments-indentation rules.
  • PR template: minor formatting tidy-up, emoji section headers, few typo fixes.

To enforce strict GitHub Actions security baselines, we now use immutable 40-character commit SHAs.

✅ Code Quality Checklist

(Some checks are automatically carried out via the CI pipeline)

  • I have performed a self-review of my own code
  • My code follows the project's style guidelines
  • The modified workflow's README has been updated, if required
  • The changes have been sufficiently tested (see MetOffice/git_playground/pull/137)

🤖 AI Assistance and Attribution

  • Some of the content of this change has been produced with the assistance of Generative AI tool name (e.g., Met Office Github Copilot Enterprise, Github Copilot Personal, ChatGPT GPT-4, etc) and I have followed the Simulation Systems AI policy (including attribution labels)

💻 Code Review

  • The changes are approriate and testing has been sufficient

Co-authored-by: Yaswant Pradhan <2984440+yaswant@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 16, 2026 19:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the repository’s reusable GitHub Actions workflows by pinning third-party actions to immutable SHAs, tightening permissions/credential usage, and addressing template-injection risks while adding/adjusting linting and automation configuration.

Changes:

  • Pin all third-party actions to commit SHAs and add persist-credentials: false to checkouts.
  • Reduce default token permissions (often permissions: {}) and scope required permissions to specific jobs/steps.
  • Add/extend CI tooling (actionlint, zizmor, markdown lint) and introduce Dependabot/Zizmor configuration.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
track-review-project/README.md Updates usage examples (permissions, runner version, PAT secret wiring).
README.md Formatting and readability improvements.
pyproject.toml Adds new linting dependencies and configures rumdl.
labeler/action.yaml Hardens composite action input handling and reduces expression interpolation in shell.
cla-check/README.md Updates documentation to reflect new permission model and security notes.
.yamllint Updates ignore syntax and adds comment-related rules.
.github/zizmor.yaml Adds Zizmor rule suppressions for specific workflows.
.github/workflows/validate.yaml Pins actions, tightens permissions, and adds security/tooling lint steps (actionlint/zizmor/rumdl).
.github/workflows/validate_symlinks.yaml Pins checkout and scopes permissions/credentials.
.github/workflows/umdp3_fixer.yaml Pins actions and scopes permissions/credentials.
.github/workflows/trigger-project-workflow.yaml Scopes permissions to job and adjusts artifact naming.
.github/workflows/track-review-project.yaml Requires PAT secret; refactors env usage; improves safety around inputs and project updates.
.github/workflows/sphinx-docs.yaml Moves permissions to job level and updates pinned actions/uv settings.
.github/workflows/label-pr.yaml Sets workflow-level empty permissions and scopes job permissions.
.github/workflows/fortran-lint.yaml Moves risky interpolations to env/shell-safe argument assembly; pins actions and scopes permissions.
.github/workflows/deploy-sphinx-docs.yaml Pins actions and scopes permissions.
.github/workflows/cla-check.yaml Moves contexts to env to mitigate injection; replaces merge-ref detection and contributors comparison logic.
.github/workflows/check-cr-approved.yaml Tightens permissions and adds an early PR-context guard.
.github/workflows/call-trigger-project-workflow.yaml Adds top-level empty permissions and scopes job permissions.
.github/workflows/call-track-review-project.yaml Adds top-level empty permissions, adds execution gating, and wires PAT secret explicitly.
.github/workflows/build-sphinx-docs.yaml Pins actions, scopes permissions, and loosens requirements input.
.github/pull_request_template.md Formatting tweaks and typo fixes.
.github/dependabot.yaml Adds Dependabot configuration for GitHub Actions updates with grouping/major blocking.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +29 to +31
permissions:
actions: read # Required to view the status of the upstream triggered workflow run
repository-projects: write # Required to add or mutate tasks inside GitHub Project 376
Comment on lines 245 to +255
item_id=$(gh api graphql -f query='
mutation($project:ID!, $pr:ID!) {
addProjectV2ItemById(input: {projectId: $project, contentId: $pr}) {
item { id }
}
}' -f project="$project_id" -f pr="$PR_ID" --jq '.data.addProjectV2ItemById.item.id')

# Update all fields in single mutation
if [[ -z "$item_id" ]]; then
echo "::warning::Could not resolve Project Board Item ID. PR may already be tracked."
exit 0
fi
| xargs -r uv run shellcheck -S warning \
&& echo "All checks passed!"

# Run shellcheck on discoverd files, treating warnings as errors
Comment on lines +107 to +117
ARGS=()

[ "$RESPECT_GITIGNORE" = "true" ] && ARGS+=("--respect-gitignore")
[ "$SHOW_FIXES" = "true" ] && ARGS+=("--show-fixes")
[ "$SHOW_STATISTICS" = "true" ] && ARGS+=("--statistics")

uvx --from "fortitude-lint==$FORTITUDE_VERSION" fortitude check \
"${ARGS[@]}" \
"--file-extensions=$FILE_EXTENSIONS" \
${CONFIG_PATH:+"--config-file=$CONFIG_PATH"} \
"$SOURCE_PATH"
….toml and conf.py, and update virtual environment caching logic
Copilot AI review requested due to automatic review settings July 16, 2026 22:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Labels

security Changes to prevent code vulnerabilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security hardening: Pin third-party actions to immutable commit SHAs

4 participants