Skip to content

ci: automate renaming of Snyk PRs to conventional commits (CN-841)#758

Draft
parker-snyk wants to merge 3 commits intomainfrom
auto-rename-snyk-prs
Draft

ci: automate renaming of Snyk PRs to conventional commits (CN-841)#758
parker-snyk wants to merge 3 commits intomainfrom
auto-rename-snyk-prs

Conversation

@parker-snyk
Copy link
Copy Markdown
Contributor

@parker-snyk parker-snyk commented Feb 24, 2026

Jira Issue: CN-841

Our linter requires the commit message to be a conventional commit. When merging a PR, the title is used as the git commit message by default.

This change automatically renames PRs starting with [Snyk] (e.g., [Snyk] Update) to follow the conventional commit format (e.g., fix: snyk update). This will make it easier for automated vulnerability fixes to merge in without issue and pass the existing pr-title-check job.

Our linter requires the commit message to be a conventional commit. When merging a PR, the title is used as the git commit message by default. This change automatically renames PRs starting with '[Snyk]' (e.g., '[Snyk] Update') to follow the conventional commit format (e.g., 'fix: snyk update'). This will make it easier for automated vulnerability fixes to merge in without issue.
@parker-snyk parker-snyk requested a review from a team as a code owner February 24, 2026 23:37
@snyk-pr-review-bot

This comment has been minimized.

@parker-snyk parker-snyk changed the title ci: automate renaming of Snyk PRs to conventional commits ci: automate renaming of Snyk PRs to conventional commits (CN-841) Feb 24, 2026
@snyk-pr-review-bot
Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 No relevant tests
🔒 Security concerns

Shell injection:
Yes. The workflow is vulnerable to shell injection by directly interpolating untrusted input from github.event.pull_request.title into a shell script (line 23). An attacker or even a benign PR with specific characters (like double quotes) could execute arbitrary commands or break the workflow execution.

⚡ Recommended focus areas for review

Potential Shell Injection 🟠 [major]

Directly interpolating github.event.pull_request.title into a shell script using ${{ ... }} is a security risk. If a PR title contains shell metacharacters such as double quotes, backticks, or $(...), it can lead to command injection or cause the script to fail. For example, a title like [Snyk] Update "package"; whoami would result in the execution of the whoami command. To mitigate this, assign the title to an environment variable and reference that variable within the script.

PR_TITLE="${{ github.event.pull_request.title }}"
Workflow Logic Error 🟠 [major]

The current logic will likely leave the PR with a failing status check that does not automatically recover. First, the Check PR Title step (line 29) uses the github context, which is a static snapshot taken at the start of the run; it will still see the old [Snyk] title and fail. Second, actions performed using the default GITHUB_TOKEN do not trigger new workflow runs. Consequently, the edited event resulting from the gh pr edit command will not trigger a fresh run to validate the new title. The PR will remain in a failed state until a user manually re-runs the CI or pushes a new commit.

gh pr edit ${{ github.event.pull_request.number }} --title "$NEW_TITLE" --repo ${{ github.repository }}
Aggressive Transformation 🟡 [minor]

The tr '[:upper:]' '[:lower:]' command lowercases the entire PR title. This is destructive as it removes intentional casing in dependency names, acronyms, or vulnerability identifiers (e.g., [Snyk] Fix CVE-2024-1234 becomes fix: snyk fix cve-2024-1234). Consider using a more targeted sed command that only replaces the prefix while preserving the rest of the title's casing.

NEW_TITLE=$(echo "$PR_TITLE" | tr '[:upper:]' '[:lower:]' | sed 's/^\[snyk\]/fix: snyk/')

@parker-snyk parker-snyk marked this pull request as draft February 25, 2026 18:42
gh pr edit ${{ github.event.pull_request.number }} --title "$NEW_TITLE" --repo ${{ github.repository }}

- name: Check PR Title
if: ${{ !startsWith(github.event.pull_request.title, '[Snyk]') }}
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.

This means the rest of the semantic PR checking will never happen for '[Snyk]' ... PRs, right? Will something else catch if the stuff after the [Snyk] violates conventional commit spec? Or does it not matter for some reason?

As an aside... have we asked in prod-sec or posted in #snyk-on-snyk-dogfooding if there is a way to change or configure the format of Snyk PRs?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants