opnsense / opnsense/plugins

Git backup plugin has multiple issues when configured for GitHub over SSH.

Open
#5,606 1 comment 0 reactions 0 assignees View on GitHub

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

  1. Install os-git-backup.
  2. Configure a GitHub repository using SSH.
  3. Use a repository whose default branch is main.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.