Skip to content

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

Description

@hunn-it
  • 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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions