Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packagehandlers/conanpackagehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package packagehandlers
import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/jfrog/frogbot/v2/utils"
Expand Down Expand Up @@ -55,7 +56,8 @@ func (conan *ConanPackageHandler) updateDirectDependency(vulnDetails *utils.Vuln
}

func (conan *ConanPackageHandler) updateConanFile(conanFilePath string, vulnDetails *utils.VulnerabilityDetails) (isFileChanged bool, err error) {
data, err := os.ReadFile(conanFilePath)
cleanPath := filepath.Clean(conanFilePath)
data, err := os.ReadFile(cleanPath)
if err != nil {
return false, fmt.Errorf("an error occurred while attempting to read the requirements file '%s': %s", conanFilePath, err.Error())
}
Expand Down
4 changes: 3 additions & 1 deletion packagehandlers/gradlepackagehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package packagehandlers
import (
"fmt"
"os"
"path/filepath"
"regexp"
"strings"

Expand Down Expand Up @@ -144,7 +145,8 @@ func getVulnerabilityGroupAndName(impactedDependencyName string) (depGroup strin

// Writes the updated content of the descriptor's file into the file
func writeUpdatedBuildFile(filePath string, fileContent string) (err error) {
fileInfo, err := os.Stat(filePath)
cleanPath := filepath.Clean(filePath)
fileInfo, err := os.Stat(cleanPath)
if err != nil {
err = fmt.Errorf("couldn't get file info for file '%s': %s", filePath, err.Error())
return
Expand Down
6 changes: 5 additions & 1 deletion utils/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,11 @@ func (gm *GitManager) GenerateAggregatedFixBranchName(baseBranch string, tech []
if err != nil {
return "", err
}
return formatStringWithPlaceHolders(branchFormat, "", "", hash, baseBranch, false), nil
if branchFormat != AggregatedBranchNameTemplate {
return formatStringWithPlaceHolders(branchFormat, "", "", hash, "", false), nil // custom: no suffix
Copy link
Collaborator

@eranturgeman eranturgeman Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add comments above the rows.
or you can simply remove them as they dont add much value

} else {
return formatStringWithPlaceHolders(branchFormat, "", "", hash, baseBranch, false), nil // default: append base branch
}
}

// dryRunClone clones an existing repository from our testdata folder into the destination folder for testing purposes.
Expand Down
14 changes: 10 additions & 4 deletions utils/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,22 @@ func TestGitManager_GenerateAggregatedFixBranchName(t *testing.T) {
gitManager: GitManager{},
},
{
expected: "[feature]-e4e1fa318f12b3bed84b13ae5c293108-main",
expected: "[feature]-e4e1fa318f12b3bed84b13ae5c293108",
baseBranch: "main",
desc: "Custom template hash only",
desc: "Custom template hash only - no base branch suffix",
gitManager: GitManager{customTemplates: CustomTemplates{branchNameTemplate: "[feature]-${BRANCH_NAME_HASH}"}},
}, {
expected: "[feature]-697bdb58caaed95527fc709da59ca47f-master",
expected: "[feature]-697bdb58caaed95527fc709da59ca47f",
baseBranch: "master",
desc: "Custom template hash only",
desc: "Custom template hash only - no base branch suffix",
gitManager: GitManager{customTemplates: CustomTemplates{branchNameTemplate: "[feature]-${BRANCH_NAME_HASH}"}},
},
{
expected: "bugfix/FRGBT-000_e4e1fa318f12b3bed84b13ae5c293108-",
baseBranch: "main",
desc: "Custom template with IMPACTED_PACKAGE empty (aggregated) - no forced suffix",
gitManager: GitManager{customTemplates: CustomTemplates{branchNameTemplate: "bugfix/FRGBT-000_{BRANCH_NAME_HASH}-{IMPACTED_PACKAGE}"}},
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
Expand Down
Loading