Skip to content

Commit f547aac

Browse files
author
JFrog Pipelines Step
committed
Merge remote-tracking branch 'origin/dev'
2 parents 0e11f39 + 720fb6d commit f547aac

File tree

21 files changed

+1002
-143
lines changed

21 files changed

+1002
-143
lines changed

.github/workflows/release-gate.yml

Lines changed: 609 additions & 0 deletions
Large diffs are not rendered by default.

go.mod

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
module github.com/jfrog/frogbot/v2
22

3-
go 1.25.5
3+
go 1.25.7
44

55
require (
66
github.com/CycloneDX/cyclonedx-go v0.9.3
7-
github.com/go-git/go-git/v5 v5.16.3
7+
github.com/go-git/go-git/v5 v5.16.5
88
github.com/golang/mock v1.6.0
99
github.com/google/go-github/v45 v45.2.0
10-
github.com/jfrog/build-info-go v1.13.1-0.20251230063402-e9f0a3564df1
11-
github.com/jfrog/froggit-go v1.20.6
10+
github.com/jfrog/build-info-go v1.13.1-0.20260216093441-40a4dc563294
11+
github.com/jfrog/froggit-go v1.21.0
1212
github.com/jfrog/gofrog v1.7.6
13-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260102083738-35bd3de75e6c
14-
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251223102649-e659f6937251
15-
github.com/jfrog/jfrog-cli-security v1.25.0
16-
github.com/jfrog/jfrog-client-go v1.55.1-0.20251230061734-d954605bdb23
13+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260303101540-67cc7f55724b
14+
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260225195817-bc599cec3973
15+
github.com/jfrog/jfrog-cli-security v1.26.3
16+
github.com/jfrog/jfrog-client-go v1.55.1-0.20260225080504-17057750d47b
1717
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible
1818
github.com/owenrumney/go-sarif/v3 v3.2.3
1919
github.com/stretchr/testify v1.11.1
2020
github.com/urfave/cli/v2 v2.27.7
2121
github.com/xeipuuv/gojsonschema v1.2.0
2222
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39
23+
golang.org/x/mod v0.30.0
2324
gopkg.in/yaml.v2 v2.4.0
2425
gopkg.in/yaml.v3 v3.0.1
2526
)
@@ -35,7 +36,7 @@ require (
3536
github.com/chzyer/readline v1.5.1 // indirect
3637
github.com/clipperhouse/stringish v0.1.1 // indirect
3738
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
38-
github.com/cloudflare/circl v1.6.1 // indirect
39+
github.com/cloudflare/circl v1.6.3 // indirect
3940
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
4041
github.com/cyphar/filepath-securejoin v0.6.0 // indirect
4142
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
@@ -111,7 +112,6 @@ require (
111112
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
112113
go.yaml.in/yaml/v3 v3.0.4 // indirect
113114
golang.org/x/crypto v0.45.0 // indirect
114-
golang.org/x/mod v0.30.0 // indirect
115115
golang.org/x/net v0.47.0 // indirect
116116
golang.org/x/oauth2 v0.33.0 // indirect
117117
golang.org/x/sync v0.18.0 // indirect

go.sum

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfa
4242
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
4343
github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4=
4444
github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
45-
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
46-
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
45+
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
46+
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
4747
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
4848
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
4949
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
@@ -79,10 +79,10 @@ github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UN
7979
github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU=
8080
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
8181
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
82-
github.com/go-git/go-git/v5 v5.16.3 h1:Z8BtvxZ09bYm/yYNgPKCzgWtaRqDTgIKRgIRHBfU6Z8=
83-
github.com/go-git/go-git/v5 v5.16.3/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8=
84-
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
85-
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
82+
github.com/go-git/go-git/v5 v5.16.5 h1:mdkuqblwr57kVfXri5TTH+nMFLNUxIj9Z7F5ykFbw5s=
83+
github.com/go-git/go-git/v5 v5.16.5/go.mod h1:QOMLpNf1qxuSY4StA/ArOdfFR2TrKEjJiye2kel2m+M=
84+
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
85+
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
8686
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
8787
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
8888
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
@@ -136,22 +136,22 @@ github.com/jedib0t/go-pretty/v6 v6.7.5 h1:9dJSWTJnsXJVVAbvxIFxeHf/JxoJd7GUl5o3Uz
136136
github.com/jedib0t/go-pretty/v6 v6.7.5/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU=
137137
github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI=
138138
github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw=
139-
github.com/jfrog/build-info-go v1.13.1-0.20251230063402-e9f0a3564df1 h1:ZT/hph6QcpTi9Fam9MJiouJ6g0H8Hx9p2Mnah2zPnks=
140-
github.com/jfrog/build-info-go v1.13.1-0.20251230063402-e9f0a3564df1/go.mod h1:+OCtMb22/D+u7Wne5lzkjJjaWr0LRZcHlDwTH86Mpwo=
141-
github.com/jfrog/froggit-go v1.20.6 h1:Xp7+LlEh0m1KGrQstb+u0aGfjRUtv1eh9xQBV3571jQ=
142-
github.com/jfrog/froggit-go v1.20.6/go.mod h1:obSG1SlsWjktkuqmKtpq7MNTTL63e0ot+ucTnlOMV88=
139+
github.com/jfrog/build-info-go v1.13.1-0.20260216093441-40a4dc563294 h1:7aJGdrjibtWT1VPLH+GYyoZsAsoca8/fMrvGIvkZ8Fs=
140+
github.com/jfrog/build-info-go v1.13.1-0.20260216093441-40a4dc563294/go.mod h1:+OCtMb22/D+u7Wne5lzkjJjaWr0LRZcHlDwTH86Mpwo=
141+
github.com/jfrog/froggit-go v1.21.0 h1:OFz5eqK1zgqrzXtPdyStVKSMqNJg96RNqRKmXSXOHsk=
142+
github.com/jfrog/froggit-go v1.21.0/go.mod h1:obSG1SlsWjktkuqmKtpq7MNTTL63e0ot+ucTnlOMV88=
143143
github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
144144
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
145145
github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY=
146146
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
147-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260102083738-35bd3de75e6c h1:M+rFtXyVuK//0zDk7dtA3Yu8cKHJrT9us2pxYPsoIq4=
148-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260102083738-35bd3de75e6c/go.mod h1:RneaDbEkoOAAHs6mAVxK666EB8GrNaCyNwyS452vVd0=
149-
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251223102649-e659f6937251 h1:WTyDOaYJUwY6zQujZuL9JQ9Q9+QWj9p31tLb4bJnu4U=
150-
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251223102649-e659f6937251/go.mod h1:REkU0OfnLYZbQIjD2Cg85DAVP0SRZuV/PxiDfCJiJOc=
151-
github.com/jfrog/jfrog-cli-security v1.25.0 h1:DM29QsMkFLRD6adKCWISe3uHFVaOodIN56NH7ThpKKU=
152-
github.com/jfrog/jfrog-cli-security v1.25.0/go.mod h1:IV/+JhaLmyeMb8IAoJZYUq4gONW5BdrxgdT4w7SXgz0=
153-
github.com/jfrog/jfrog-client-go v1.55.1-0.20251230061734-d954605bdb23 h1:tL4NUrnSiFN6MeK27z96ehiKXhYZDY2DyH95ogNRHrY=
154-
github.com/jfrog/jfrog-client-go v1.55.1-0.20251230061734-d954605bdb23/go.mod h1:sCE06+GngPoyrGO0c+vmhgMoVSP83UMNiZnIuNPzU8U=
147+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260303101540-67cc7f55724b h1:RFVA0SoRC1Hf54BdDkt3mv4x5t3600AqUcpA5Fy3n3E=
148+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260303101540-67cc7f55724b/go.mod h1:IRUe9nYwCUq8V2WRDUd4bddwiXXdkxvNQ36+0U0uHqI=
149+
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260225195817-bc599cec3973 h1:awB01Y4m0cWzmXuR3waf5IQnoQxDlbUmqT+FMWOpjbs=
150+
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260225195817-bc599cec3973/go.mod h1:yhi+XpiEx18a3t8CZ6M2VpAf3EGqKpBhTzoPBTFe0dk=
151+
github.com/jfrog/jfrog-cli-security v1.26.3 h1:991m5HZrFxR8GOg5ALxTGxih73+wTPmLvlLG0VaXDxk=
152+
github.com/jfrog/jfrog-cli-security v1.26.3/go.mod h1:eZLjW37Z6f1DbeKCsL+NnYSm41hQnV1wV6NpLfIOwLw=
153+
github.com/jfrog/jfrog-client-go v1.55.1-0.20260225080504-17057750d47b h1:mSxcMTXtnrYMVhCGk7ui2ERh6yLoUVUQhXaNwd3FhL8=
154+
github.com/jfrog/jfrog-client-go v1.55.1-0.20260225080504-17057750d47b/go.mod h1:sCE06+GngPoyrGO0c+vmhgMoVSP83UMNiZnIuNPzU8U=
155155
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
156156
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
157157
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible h1:jdpOPRN1zP63Td1hDQbZW73xKmzDvZHzVdNYxhnTMDA=
@@ -313,16 +313,16 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
313313
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
314314
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
315315
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
316-
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
317-
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
318-
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
319-
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
316+
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
317+
go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
318+
go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
319+
go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
320320
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
321321
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
322322
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
323323
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
324-
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
325-
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
324+
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
325+
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
326326
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
327327
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
328328
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

packagehandlers/conanpackagehandler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (conan *ConanPackageHandler) updateConanFile(conanFilePath string, vulnDeta
6868
log.Debug(fmt.Sprintf("impacted dependency '%s' not found in descriptor '%s', moving to the next descriptor if exists...", impactedDependency, conanFilePath))
6969
return false, nil
7070
}
71-
if err = os.WriteFile(conanFilePath, []byte(fixedFile), 0600); err != nil {
71+
if err = os.WriteFile(conanFilePath, []byte(fixedFile), 0600); err != nil { // #nosec G703
7272
err = fmt.Errorf("an error occured while writing the fixed version of %s to the requirements file '%s': %s", vulnDetails.ImpactedDependencyName, conanFilePath, err.Error())
7373
}
7474
isFileChanged = true

packagehandlers/gradlepackagehandler.go

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

33
import (
44
"fmt"
5-
"github.com/jfrog/frogbot/v2/utils"
65
"os"
76
"regexp"
87
"strings"
8+
9+
"github.com/jfrog/frogbot/v2/utils"
910
)
1011

1112
const (
@@ -149,7 +150,7 @@ func writeUpdatedBuildFile(filePath string, fileContent string) (err error) {
149150
return
150151
}
151152

152-
err = os.WriteFile(filePath, []byte(fileContent), fileInfo.Mode())
153+
err = os.WriteFile(filePath, []byte(fileContent), fileInfo.Mode()) // #nosec G703
153154
if err != nil {
154155
err = fmt.Errorf("couldn't write fixes to file '%s': %q", filePath, err)
155156
}

release/pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resources:
55
path: jfrog/frogbot
66
branches:
77
include: dev
8-
gitProvider: il_automation
8+
gitProvider: frogbot_v2_release_git_token
99

1010
pipelines:
1111
- name: release_frogbot
@@ -28,7 +28,7 @@ pipelines:
2828
- name: frogbotGit
2929
trigger: false
3030
integrations:
31-
- name: il_automation
31+
- name: frogbot_v2_release_git_token
3232
- name: ecosys_entplus_deployer
3333
execution:
3434
onExecute:
@@ -46,7 +46,7 @@ pipelines:
4646

4747
# Configure Git and merge from the dev
4848
- git checkout master
49-
- git remote set-url origin https://$int_il_automation_token@github.com/jfrog/frogbot.git
49+
- git remote set-url origin https://$int_frogbot_v2_release_git_token_token@github.com/jfrog/frogbot.git
5050
- git merge origin/dev
5151
- git tag v${NEXT_VERSION}
5252

scanpullrequest/scanpullrequest.go

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func scanPullRequest(repo *utils.Repository, client vcsclient.VcsClient) (err er
105105
log.Info("-----------------------------------------------------------")
106106

107107
// Audit PR code
108-
issues, resultContext, err := auditPullRequestAndReport(repo, client)
108+
issues, resultContext, scanResults, err := auditPullRequestAndReport(repo, client)
109109
if err != nil {
110110
return
111111
}
@@ -124,6 +124,12 @@ func scanPullRequest(repo *utils.Repository, client vcsclient.VcsClient) (err er
124124
return
125125
}
126126

127+
if repo.Git.UploadPrSecurityResultsToVcs && repo.GitProvider == vcsutils.GitHub && scanResults != nil {
128+
if uploadErr := utils.UploadPrSarifToGithubSecurityTab(scanResults, repo, pullRequestDetails.ID, client, &repo.Server, repo.XrayVersion, repo.JFrogProjectKey); uploadErr != nil {
129+
log.Warn(fmt.Sprintf("Failed to upload PR security results to GitHub Code Scanning: %s", uploadErr.Error()))
130+
}
131+
}
132+
127133
// Fail the Frogbot task if a security issue is found and Frogbot isn't configured to avoid the failure.
128134
if toFailTaskStatus(repo, issues) {
129135
err = errors.New(SecurityIssueFoundErr)
@@ -143,7 +149,7 @@ func toFailTaskStatus(repo *utils.Repository, issues *issues.ScansIssuesCollecti
143149
}
144150
}
145151

146-
func auditPullRequestAndReport(repoConfig *utils.Repository, client vcsclient.VcsClient) (issuesCollection *issues.ScansIssuesCollection, resultContext results.ResultContext, err error) {
152+
func auditPullRequestAndReport(repoConfig *utils.Repository, client vcsclient.VcsClient) (issuesCollection *issues.ScansIssuesCollection, resultContext results.ResultContext, scanResults *results.SecurityCommandResults, err error) {
147153
// Prepare
148154
scanDetails, err := createBaseScanDetails(repoConfig, client)
149155
if err != nil {
@@ -175,8 +181,7 @@ func auditPullRequestAndReport(repoConfig *utils.Repository, client vcsclient.Vc
175181
)
176182
}
177183
}()
178-
// Audit PR code
179-
issuesCollection, err = auditPullRequestCode(repoConfig, scanDetails, sourceBranchWd, targetBranchWd)
184+
issuesCollection, scanResults, err = auditPullRequestCode(repoConfig, scanDetails, sourceBranchWd, targetBranchWd)
180185
return
181186
}
182187

@@ -224,8 +229,9 @@ func prepareSourceCodeForScan(repoConfig *utils.Repository, scanDetails *utils.S
224229
return
225230
}
226231

227-
func auditPullRequestCode(repoConfig *utils.Repository, scanDetails *utils.ScanDetails, sourceBranchWd, targetBranchWd string) (issuesCollection *issues.ScansIssuesCollection, err error) {
232+
func auditPullRequestCode(repoConfig *utils.Repository, scanDetails *utils.ScanDetails, sourceBranchWd, targetBranchWd string) (issuesCollection *issues.ScansIssuesCollection, scanResults *results.SecurityCommandResults, err error) {
228233
issuesCollection = &issues.ScansIssuesCollection{}
234+
var aggregatedScanResults *results.SecurityCommandResults
229235

230236
for i := range repoConfig.Projects {
231237
// Reset scan details for each project
@@ -241,10 +247,18 @@ func auditPullRequestCode(repoConfig *utils.Repository, scanDetails *utils.ScanD
241247
scanDetails.SetResultsToCompare(targetScanResults)
242248
}
243249
}
244-
// Scan source branch of the project
245250
log.Debug("Scanning source branch code...")
246-
if issues, e := auditPullRequestSourceCode(repoConfig, scanDetails, sourceBranchWd, targetBranchWd); e == nil {
251+
if issues, sourceScanResults, e := auditPullRequestSourceCode(repoConfig, scanDetails, sourceBranchWd, targetBranchWd); e == nil {
247252
issuesCollection.Append(issues)
253+
if sourceScanResults != nil {
254+
if aggregatedScanResults == nil {
255+
aggregatedScanResults = results.NewCommandResults(sourceScanResults.CmdType)
256+
aggregatedScanResults.ResultsMetaData = sourceScanResults.ResultsMetaData
257+
aggregatedScanResults.EntitledForJas = sourceScanResults.EntitledForJas
258+
aggregatedScanResults.SecretValidation = sourceScanResults.SecretValidation
259+
}
260+
aggregatedScanResults.Targets = append(aggregatedScanResults.Targets, sourceScanResults.Targets...)
261+
}
248262
continue
249263
} else {
250264
if issues != nil {
@@ -254,6 +268,9 @@ func auditPullRequestCode(repoConfig *utils.Repository, scanDetails *utils.ScanD
254268
err = errors.Join(err, fmt.Errorf("failed to audit source branch code for %v project. Error: %s", repoConfig.Projects[i].WorkingDirs, e.Error()))
255269
}
256270
}
271+
if aggregatedScanResults != nil && len(aggregatedScanResults.Targets) > 0 {
272+
scanResults = aggregatedScanResults
273+
}
257274

258275
return
259276
}
@@ -264,8 +281,8 @@ func auditPullRequestTargetCode(scanDetails *utils.ScanDetails, targetBranchWd s
264281
return
265282
}
266283

267-
func auditPullRequestSourceCode(repoConfig *utils.Repository, scanDetails *utils.ScanDetails, sourceBranchWd, targetBranchWd string) (issuesCollection *issues.ScansIssuesCollection, err error) {
268-
scanResults := scanDetails.RunInstallAndAudit(utils.GetFullPathWorkingDirs(scanDetails.Project.WorkingDirs, sourceBranchWd)...)
284+
func auditPullRequestSourceCode(repoConfig *utils.Repository, scanDetails *utils.ScanDetails, sourceBranchWd, targetBranchWd string) (issuesCollection *issues.ScansIssuesCollection, scanResults *results.SecurityCommandResults, err error) {
285+
scanResults = scanDetails.RunInstallAndAudit(utils.GetFullPathWorkingDirs(scanDetails.Project.WorkingDirs, sourceBranchWd)...)
269286
if err = scanResults.GetErrors(); err != nil {
270287
issuesCollection = &issues.ScansIssuesCollection{ScanStatus: getResultScanStatues(scanResults)}
271288
return

scanpullrequest/scanpullrequest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ func TestAuditDiffInPullRequest(t *testing.T) {
478478
defer cleanUpTest()
479479

480480
assert.Len(t, repoConfig, 1)
481-
issuesCollection, _, err := auditPullRequestAndReport(&repoConfig[0], client)
481+
issuesCollection, _, _, err := auditPullRequestAndReport(&repoConfig[0], client)
482482
assert.NoError(t, err)
483483
assert.NotNil(t, issuesCollection)
484484
assert.Len(t, issuesCollection.IacVulnerabilities, test.expectedIssues.Iac)

0 commit comments

Comments
 (0)