Skip to content

Only strip refs/heads/ prefix from branch name when present - #254

Merged
sauliusbc merged 2 commits into
mainfrom
fix/branch-name-and-mayhem-project
Sep 4, 2026
Merged

Only strip refs/heads/ prefix from branch name when present#254
sauliusbc merged 2 commits into
mainfrom
fix/branch-name-and-mayhem-project

Conversation

@sauliusbc

@sauliusbc sauliusbc commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

GITHUB_REF_NAME is already the short ref name, so unconditionally slicing off "refs/heads/".length characters chopped real characters off the branch name instead. For short names this silently fell back to "main"; for longer names it could leave a leading -, which crashed the mayhem CLI's argument parser (e.g. delta-repro-buggy-mhh-run-11 -> -buggy-mhh-run-11).

Extracted resolveBranchName(), which checks for the prefix before stripping it.

GITHUB_REF_NAME is already the short ref name, so unconditionally
slicing off "refs/heads/".length characters chopped real characters
off the branch name instead. That silently mislabeled short branch
names (e.g. "mayhem" -> "" -> falls back to "main") and could crash
the mayhem CLI's argument parser for longer names where the slice
left a leading "-" (e.g. "delta-repro-buggy-mhh-run-11" ->
"-buggy-mhh-run-11", read as a flag).
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Mayhem Automated Code Testing Report

❗ 1 Defects Found

CWE Severity Defect Description
7.1 Improper Input Validation The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.

Testing details found at https://app.mayhem.security/forallsecure/mcode-action/mayhemit/47

@sauliusbc sauliusbc changed the title Fix/branch name and mayhem project Only strip refs/heads/ prefix from branch name when present Sep 4, 2026
@sauliusbc
sauliusbc marked this pull request as ready for review September 4, 2026 14:16
@sauliusbc
sauliusbc merged commit 8dd6c9e into main Sep 4, 2026
8 checks passed
@sauliusbc
sauliusbc deleted the fix/branch-name-and-mayhem-project branch September 4, 2026 14:21
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