Git backup plugin has multiple issues when configured for GitHub over SSH.
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 863
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 10
Description
- I have read the contributing guidelines.
- I am convinced that my issue is new after checking open and closed issues.
- AI tools were used to create part of this report.
If AI was used, please disclose:
- Model used: ChatGPT (OpenAI GPT-5.5)
- Extent of AI involvement: Assisted with code analysis and wording.
Describe the bug
The Git backup plugin has multiple issues when configured for GitHub over SSH.
1. Invalid SSH URL construction
The configuration dialog requires both
- Repository URL
- User Name
For SSH, the code always injects the configured username into the URL.
Example:
Repository URL:
git@github.com:abc/reponame.git
User:
git
becomes
git@git@github.com:abc/reponame.git
which obviously fails.
Likewise,
ssh://git@github.com/abc/reponame.git
also becomes
ssh://git@git@github.com/abc/reponame.git
The plugin should either
- accept a complete SSH URL without modifying it, or
- ignore the username field for SSH URLs when one is already present.
2. Local branch is hardcoded to master
The push command is constructed as
git push origin master:<configured branch>
The local branch name is hardcoded:
$pushtxt = Shell::shell_safe($gitfrmt, [$targetdir, "master:{$mdl->branch}"]);
If the local repository is on main (or any other branch), the plugin fails with
error: src refspec master does not match any
The plugin should either
- detect the current branch automatically, or
- create/check out the expected branch during initialization instead of assuming
master.
To Reproduce
- Install os-git-backup.
- Configure a GitHub repository using SSH.
- Use a repository whose default branch is
main. - Save the Git backup configuration.
Expected behavior
The plugin should successfully initialize the repository and push regardless of whether the repository uses master or main.
SSH URLs should not be modified into invalid URLs by injecting the username a second time.
Additional information
The relevant code is located in
/usr/local/opnsense/mvc/app/library/OPNsense/Backup/Git.php
Specifically:
$url = substr($url, 0, $pos + 2) . urlencode((string)$mdl->user) . "@" . substr($url, $pos + 2);
and
"master:{$mdl->branch}"
which hardcodes the local branch.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in /usr/local/opnsense/mvc/app/library/OPNsense/Backup/Git.php and inspect the URL construction around the provided $url expression and the push command using "master:{$mdl->branch}". Reproduce the SSH configuration and a repository using main, then adjust both behaviors so complete SSH URLs remain valid and pushes work with the local branch. Done means initialization and pushing succeed for both SSH URLs and non-master branches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, github, php
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100