Skip to content

Commit e2f9bd6

Browse files
authored
only add provenance if git url is good (#366)
1 parent 7bdfec0 commit e2f9bd6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

formatters/sarif/sarif.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,15 @@ func (f *Format) Format(ctx context.Context, packages []*models.PackageInsights)
5050

5151
sourceGitRepoURI := pkg.GetSourceGitRepoURI()
5252

53-
versionControlProvenance := sarif.NewVersionControlDetails().
54-
WithRevisionID(pkg.SourceGitCommitSha).
55-
WithBranch(pkg.SourceGitRef)
56-
5753
if IsValidGitURL(sourceGitRepoURI) {
58-
versionControlProvenance = versionControlProvenance.
54+
versionControlProvenance := sarif.NewVersionControlDetails().
55+
WithRevisionID(pkg.SourceGitCommitSha).
56+
WithBranch(pkg.SourceGitRef).
5957
WithRepositoryURI(sourceGitRepoURI)
58+
run.AddVersionControlProvenance(
59+
versionControlProvenance,
60+
)
6061
}
61-
run.AddVersionControlProvenance(
62-
versionControlProvenance,
63-
)
6462

6563
findingsByPurl := make(map[string][]results.Finding)
6664
for _, finding := range pkg.FindingsResults.Findings {

0 commit comments

Comments
 (0)