Skip to content

Commit 5fd7d4a

Browse files
committed
fixing ref issue
1 parent f9f688f commit 5fd7d4a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

sca/bom/snapshotconvertor/githubsnapshotconvertor.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ package snapshotconvertor
22

33
import (
44
"errors"
5+
"fmt"
6+
"path/filepath"
7+
"strings"
8+
"time"
9+
510
"github.com/CycloneDX/cyclonedx-go"
611
"github.com/jfrog/froggit-go/vcsclient"
712
"github.com/jfrog/jfrog-cli-security/utils/formats/cdxutils"
8-
"path/filepath"
9-
"time"
13+
"github.com/jfrog/jfrog-client-go/utils/log"
1014
)
1115

1216
const (
@@ -25,7 +29,7 @@ func CreateGithubSnapshotFromSbom(bom *cyclonedx.BOM, snapshotVersion int, scanT
2529
snapshot := &vcsclient.SbomSnapshot{
2630
Version: snapshotVersion,
2731
Sha: commitSha,
28-
Ref: gitRef,
32+
Ref: ensureFullRef(gitRef),
2933
Job: &vcsclient.JobInfo{
3034
ID: jobId,
3135
Correlator: jobCorrelator,
@@ -92,5 +96,13 @@ func CreateGithubSnapshotFromSbom(bom *cyclonedx.BOM, snapshotVersion int, scanT
9296
manifests[descriptorRelativePath] = manifest
9397
}
9498
snapshot.Manifests = manifests
99+
log.Debug(fmt.Sprintf("Sent Snapshot:/n%v", snapshot))
95100
return snapshot, nil
96101
}
102+
103+
func ensureFullRef(branchName string) string {
104+
if strings.HasPrefix(branchName, "refs/") {
105+
return branchName
106+
}
107+
return "refs/heads/" + branchName
108+
}

0 commit comments

Comments
 (0)