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
For SSH, the code always injects the configured username into the URL.
Example:
Repository URL:
git@github.com:abc/reponame.git
User:
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
which hardcodes the local branch.
If AI was used, please disclose:
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
For SSH, the code always injects the configured username into the URL.
Example:
Repository URL:
User:
becomes
which obviously fails.
Likewise,
also becomes
The plugin should either
2. Local branch is hardcoded to
masterThe push command is constructed as
The local branch name is hardcoded:
If the local repository is on
main(or any other branch), the plugin fails withThe plugin should either
master.To Reproduce
main.Expected behavior
The plugin should successfully initialize the repository and push regardless of whether the repository uses
masterormain.SSH URLs should not be modified into invalid URLs by injecting the username a second time.
Additional information
The relevant code is located in
Specifically:
and
"master:{$mdl->branch}"which hardcodes the local branch.