Skip to content

Build Plugin Workflow: Add explicit write permission to the build job#2974

Merged
vaurdan merged 1 commit intodevelopfrom
fix/build-workflow-permissions
Nov 26, 2024
Merged

Build Plugin Workflow: Add explicit write permission to the build job#2974
vaurdan merged 1 commit intodevelopfrom
fix/build-workflow-permissions

Conversation

@vaurdan
Copy link
Contributor

@vaurdan vaurdan commented Nov 26, 2024

Description

Adds explicit write permissions to the build job of the Build Plugin workflow. This tries to fix an issue with building PRs from dependabot.

Summary by CodeRabbit

  • Chores
    • Streamlined the workflow by removing an unnecessary branch trigger.
    • Enhanced permissions for the build job.
    • Refined the file staging process for commits.

@vaurdan vaurdan added Maintenance & Fixes Ticket/PR related to codebase maintenance tasks Deps: GitHub Actions Reserved to dependency/dependabot PRs labels Nov 26, 2024
@vaurdan vaurdan self-assigned this Nov 26, 2024
@vaurdan vaurdan requested a review from a team as a code owner November 26, 2024 09:43
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 26, 2024

📝 Walkthrough

Walkthrough

The pull request modifies the workflow configuration for the wp-parsely project by removing the temp-testing-branch from the list of branches that trigger the build workflow on push events. It enhances the build job permissions, allowing write access to contents, pull requests, and issues. Additionally, it updates the job steps to set the BUILT_BRANCH environment variable based on the SOURCE_REF and changes the git add command to refine how files are staged for commit.

Changes

File Path Change Summary
.github/workflows/build-plugin.yml Removed temp-testing-branch from branch triggers, added write permissions to the build job, set BUILT_BRANCH environment variable, and modified git add command to git add -A vendor/ build/.

Possibly related PRs

Suggested reviewers

  • acicovic

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@acicovic acicovic added this to the 3.18.0 milestone Nov 26, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
.github/workflows/build-plugin.yml (2)

17-20: Consider removing unnecessary 'issues' write permission

While the write permissions for contents and pull-requests are necessary for the build job to push changes and update PRs, the issues write permission appears to be unnecessary for this workflow's functionality.

    permissions:
      contents: write
      pull-requests: write
-     issues: write

85-85: Consider using a more precise git add command

The current git add -A vendor/ build/ command will stage all changes (including deletions) in these directories. For better control and to prevent unintended changes, consider using a more specific command.

-          git add -A vendor/ build/
+          git add vendor/ build/

This change will still stage all new and modified files in these directories while being more explicit about what's being staged.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1ebd5e7 and bee6064.

📒 Files selected for processing (1)
  • .github/workflows/build-plugin.yml (2 hunks)
🔇 Additional comments (1)
.github/workflows/build-plugin.yml (1)

Line range hint 74-77: Verify git command injection prevention

The workflow constructs git commit messages using variables. While the current implementation uses printf which is safer than direct string interpolation, consider adding additional safeguards.

✅ Verification successful

Git command injection is properly mitigated

The workflow implements proper safeguards against command injection:

  • Uses printf with proper format string for commit message construction
  • Stores commit message in a file and uses -F flag for commit
  • Variables are properly quoted in git commands
  • Uses GitHub's built-in environment variables (GITHUB_SHA)
  • Sanitizes commit message using tr and awk in a safe manner
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential command injection vulnerabilities in git commands
rg -n '`.*\$.*`.*git' .github/workflows/
rg -n 'git.*\$[^{]' .github/workflows/

Length of output: 247


Script:

#!/bin/bash
# Let's examine the full context of the git command usage
rg -A 5 -B 5 'git log.*\$' .github/workflows/

Length of output: 0


Script:

#!/bin/bash
# Let's check the entire workflow file to understand the context better
cat .github/workflows/build-plugin.yml

Length of output: 3012

🧰 Tools
🪛 actionlint (1.7.4)

23-23: shellcheck reported issue in this script: SC2086:info:1:44: Double quote to prevent globbing and word splitting

(shellcheck)

@vaurdan vaurdan merged commit 71775e7 into develop Nov 26, 2024
@vaurdan vaurdan deleted the fix/build-workflow-permissions branch November 26, 2024 09:46
github-actions bot added a commit that referenced this pull request Nov 26, 2024
…ssions Build Plugin Workflow: Add explicit write permission to the build job" (71775e7)
@acicovic acicovic removed the Deps: GitHub Actions Reserved to dependency/dependabot PRs label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintenance & Fixes Ticket/PR related to codebase maintenance tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants