feat(git): disable link generation (#1748)

Add an option to disable link creation. If there are any weird edge cases, it shouldn't block scanning
This commit is contained in:
Richard Gomez authored and GitHub committed 2025-02-10 13:15:44 -06:00
1 parent c6424a6fc3
commit ae26eff464
6 files changed
+27 -26

No files matched your search

+3 -3
View File
@@ -18,7 +18,7 @@ import (
// augmentGitFinding updates the start and end line numbers of a finding to include the
// delta from the git diff
func augmentGitFinding(scmPlatform scm.Platform, remoteUrl string, finding report.Finding, textFragment *gitdiff.TextFragment, f *gitdiff.File) report.Finding {
func augmentGitFinding(remote *RemoteInfo, finding report.Finding, textFragment *gitdiff.TextFragment, f *gitdiff.File) report.Finding {
if !strings.HasPrefix(finding.Match, "file detected") {
finding.StartLine += int(textFragment.NewPosition)
finding.EndLine += int(textFragment.NewPosition)
@@ -34,7 +34,7 @@ func augmentGitFinding(scmPlatform scm.Platform, remoteUrl string, finding repor
finding.Message = f.PatchHeader.Message()
// Results from `git diff` shouldn't have a link.
if finding.Commit != "" {
finding.Link = createScmLink(scmPlatform, remoteUrl, finding)
finding.Link = createScmLink(remote.Platform, remote.Url, finding)
}
}
return finding
@@ -46,7 +46,7 @@ var linkCleaner = strings.NewReplacer(
)
func createScmLink(scmPlatform scm.Platform, remoteUrl string, finding report.Finding) string {
if scmPlatform == scm.NoPlatform {
if scmPlatform == scm.UnknownPlatform || scmPlatform == scm.NoPlatform {
return ""
}