Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
fix(giturl): encode % (#2982)
Richard Gomez1f22522e862f
diff --git a/pkg/giturl/giturl.go b/pkg/giturl/giturl.goindex ce01c95fd..bfc369a74 100644--- a/pkg/giturl/giturl.go+++ b/pkg/giturl/giturl.go@@ -174,6 +174,7 @@ var linePattern = regexp.MustCompile(`L\d+`)// UpdateLinkLineNumber updates the line number in a repository link.// Used post-link generation to refine reported issue locations within large scanned blocks.func UpdateLinkLineNumber(ctx context.Context, link string, newLine int64) string {+ link = strings.Replace(link, "%", "%25", -1)parsedURL, err := url.Parse(link)if err != nil {ctx.Logger().Error(err, "unable to parse link to update line number", "link", link)diff --git a/pkg/giturl/giturl_test.go b/pkg/giturl/giturl_test.goindex 6271d8c9e..620fad27f 100644--- a/pkg/giturl/giturl_test.go+++ b/pkg/giturl/giturl_test.go@@ -289,6 +289,14 @@ func TestUpdateLinkLineNumber(t *testing.T) {},want: "https://github.com/coinbase/cbpay-js/issues/181",},+ {+ name: "Encode percent",+ args: args{+ link: "https://github.com/coinbase/cbpay-js/blob/abcdefg/folder/%/name",+ newLine: int64(0),+ },+ want: "https://github.com/coinbase/cbpay-js/blob/abcdefg/folder/%25/name",+ },{name: "Invalid link",args: args{