Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Xray Source Control Service #896

Closed
wants to merge 99 commits into from
Closed
Show file tree
Hide file tree
Changes from 93 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
5c110c7
add new attributes to technologiesData
EyalDelarea Feb 23, 2023
9dc0c98
add installation command to poetry package manager
EyalDelarea Feb 23, 2023
cc80c8a
add packageVersionOperator command to poetry package manager
EyalDelarea Feb 23, 2023
4c3dd20
Merge branch 'master' of https://github.com/jfrog/jfrog-cli-core
EyalDelarea Mar 5, 2023
813c79a
Merge branch 'dev' of https://github.com/jfrog/jfrog-cli-core
EyalDelarea Mar 7, 2023
6ad8772
Merge branch 'master' of https://github.com/jfrog/jfrog-cli-core
EyalDelarea Mar 18, 2023
4d20901
Upgrade jfrog-cli-core to 2.31.1 (#739)
omerzi Apr 5, 2023
9b4006e
Added the Frogbot badge to the README (#745)
eyalbe4 Apr 13, 2023
1381a8b
Merge remote-tracking branch 'upstream/dev' into mastercore
sverdlov93 Apr 19, 2023
f8e3a22
Merge remote-tracking branch 'upstream/dev' into mastercore
sverdlov93 Apr 19, 2023
4f7259c
Merge remote-tracking branch 'origin/dev'
omerzi May 2, 2023
932793d
Merge remote-tracking branch 'origin/dev'
omerzi May 3, 2023
2ddeac0
Merge branch 'dev'
eyalbe4 May 16, 2023
11ce1e8
Merge branch 'dev' into master
talarian1 May 17, 2023
521d832
Merge branch 'dev'
talarian1 May 17, 2023
f470da2
Merge remote-tracking branch 'origin/dev'
talarian1 May 17, 2023
2c85766
Merge remote-tracking branch 'origin/dev'
omerzi May 21, 2023
ae0b91d
Merge remote-tracking branch 'origin/dev'
talarian1 May 23, 2023
5a53932
Merge remote-tracking branch 'upstream/dev'
yahavi May 23, 2023
c07d9fb
Merge remote-tracking branch 'upstream/dev'
yahavi May 23, 2023
7040b6a
Merge remote-tracking branch 'origin/dev'
talarian1 May 24, 2023
e91d430
Merge branch 'dev'
eyalbe4 May 26, 2023
2680fdb
Upgrade jfrog-cli-core to 2.34.6
talarian1 May 28, 2023
b4ddac8
Merge branch 'master' into dev
eyalbe4 May 31, 2023
6dca5e7
Merge branch 'dev'
eyalbe4 May 31, 2023
9fa7b09
Merge remote-tracking branch 'origin/dev'
talarian1 May 31, 2023
a46fb01
Merge branch 'dev'
yahavi Jun 1, 2023
94469f4
Merge branch 'dev'
eyalbe4 Jun 4, 2023
b330d82
Merge branch 'dev'
eyalbe4 Jun 10, 2023
7141b4c
Merge branch 'master' into dev
omerzi Jun 27, 2023
ec17933
Merge branch 'dev'
eyalbe4 Jun 27, 2023
83ced5a
Merge branch 'dev'
RobiNino Jun 29, 2023
9e57a49
Merge branch 'dev'
yahavi Jul 4, 2023
fe4c82a
Merge branch 'master' into dev
omerzi Jul 12, 2023
47a0f3f
Upgrade jfrog-cli-core to 2.38.0
omerzi Jul 12, 2023
40e7d2d
Remove Secrets Scanner Sacanners Names config (#862)
talarian1 Jul 16, 2023
0be3aae
Upgrade jfrog-cli-core to 2.39.0
omerzi Jul 18, 2023
0a4b112
Merge remote-tracking branch 'origin/dev'
omerzi Jul 19, 2023
64ee611
Merge remote-tracking branch 'origin/dev'
omerzi Jul 19, 2023
d32579e
Merge remote-tracking branch 'origin/dev'
omerzi Jul 23, 2023
f79600c
Merge branch 'dev'
eyalbe4 Jul 31, 2023
db385fe
Merge branch 'dev'
eyalbe4 Aug 3, 2023
8e0ea69
Merge branch 'master' of https://github.com/jfrog/jfrog-cli-core
EyalDelarea Aug 15, 2023
203a303
Refactor to interface
EyalDelarea Aug 15, 2023
0a4c6dd
Split scan service
EyalDelarea Aug 15, 2023
a3860cf
Pull dev
EyalDelarea Aug 16, 2023
c35658f
Working XSC call
EyalDelarea Aug 16, 2023
c9a6c6d
Check XSC
EyalDelarea Aug 16, 2023
26665de
Check XSC
EyalDelarea Aug 16, 2023
33c5f6a
fix multi-scan-id
EyalDelarea Aug 16, 2023
ad71ffa
Fix code analysis errors
EyalDelarea Aug 16, 2023
177bf7b
remove testings object
EyalDelarea Aug 16, 2023
76eae4b
fix always using xsc
EyalDelarea Aug 17, 2023
fd6d7d2
fix static check
EyalDelarea Aug 17, 2023
c845f56
update go.mod
EyalDelarea Aug 17, 2023
f537f57
Fix choose XSC server when enabled
EyalDelarea Aug 17, 2023
3f8ba64
Handle XSC/XRAY url provided from flags and config.
EyalDelarea Aug 17, 2023
2703ea9
update go.mod
EyalDelarea Aug 17, 2023
15b1b89
Refactor
EyalDelarea Aug 17, 2023
7f03d26
Set tech after detection
EyalDelarea Aug 20, 2023
54e9636
pull dev
EyalDelarea Aug 20, 2023
7f29321
Update deps
EyalDelarea Aug 21, 2023
da848fe
update deps
EyalDelarea Aug 21, 2023
1c5b610
pull dev
EyalDelarea Aug 22, 2023
c06269d
move xsc endpoint const
EyalDelarea Aug 22, 2023
6e5b7f7
pull dev
EyalDelarea Aug 23, 2023
764490c
Update deps
EyalDelarea Aug 23, 2023
40a7068
Merge remote-tracking branch 'upstream/dev' into xsc
EyalDelarea Aug 24, 2023
8aa7d33
merge
EyalDelarea Aug 24, 2023
2dcae54
pass multi scan id as extra arg
EyalDelarea Aug 27, 2023
74017fb
Merge remote-tracking branch 'upstream/dev' into xsc
EyalDelarea Aug 27, 2023
35af079
pull dev
EyalDelarea Aug 27, 2023
a2e0bec
fix new arg
EyalDelarea Aug 27, 2023
f524051
pull dev
EyalDelarea Aug 28, 2023
e1ab392
pull dev
EyalDelarea Aug 29, 2023
64b367d
update deps
EyalDelarea Aug 29, 2023
196ae26
Remove testings code, add flag to provide multi scan id
EyalDelarea Aug 30, 2023
15d7d74
pull dev
EyalDelarea Aug 31, 2023
d476255
pass multi-scan-id
EyalDelarea Aug 31, 2023
7a49915
remove print
EyalDelarea Aug 31, 2023
5dcc2fa
update deps and log for debugging
EyalDelarea Aug 31, 2023
df51758
merge dev
EyalDelarea Sep 3, 2023
ccb508c
Add debug logs
EyalDelarea Sep 3, 2023
688e693
pull dev
EyalDelarea Sep 4, 2023
623cdbd
fix MSI flag
EyalDelarea Sep 4, 2023
2f79c0d
pull dev
EyalDelarea Sep 5, 2023
570d81c
fix pull dev
EyalDelarea Sep 5, 2023
5f3ac87
add xsc min version
EyalDelarea Sep 5, 2023
a9521b4
pull dev
EyalDelarea Sep 6, 2023
8455ea2
Merge branch 'dev' of https://github.com/jfrog/jfrog-cli-core into xsc
EyalDelarea Sep 6, 2023
80f33a6
update jfrog-client-go
EyalDelarea Sep 6, 2023
6ed3b67
refactor
EyalDelarea Sep 7, 2023
9c23e7a
Fix comments and remove TODO
EyalDelarea Sep 7, 2023
8215745
pull client
EyalDelarea Sep 8, 2023
74ff464
pull dev
EyalDelarea Sep 8, 2023
1a8083e
update deps
EyalDelarea Sep 8, 2023
fd3454b
CR
EyalDelarea Sep 10, 2023
e3e3e88
update deps
EyalDelarea Sep 10, 2023
ce13fce
Merge branch 'dev' of https://github.com/jfrog/jfrog-cli-core into xsc
EyalDelarea Sep 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
)

replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230831152946-6ed2ae1aa57f
replace github.com/jfrog/jfrog-client-go => github.com/eyaldelarea/jfrog-client-go v1.28.4-0.20230907064804-16e49175c49f

replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230905120411-62d1bdd4eb38

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/eyaldelarea/jfrog-client-go v1.28.4-0.20230907064804-16e49175c49f h1:V9d6ThTH0cpDAE3iffShj5AM/3zrkdW2BihzrLN1BPg=
github.com/eyaldelarea/jfrog-client-go v1.28.4-0.20230907064804-16e49175c49f/go.mod h1:soD5VL3X+G+0KKUNSlb0CSdF9nwHsQZCr0xqOGedAHM=
github.com/forPelevin/gomoji v1.1.8 h1:JElzDdt0TyiUlecy6PfITDL6eGvIaxqYH1V52zrd0qQ=
github.com/forPelevin/gomoji v1.1.8/go.mod h1:8+Z3KNGkdslmeGZBC3tCrwMrcPy5GRzAD+gL9NAwMXg=
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
Expand Down Expand Up @@ -198,8 +200,6 @@ github.com/jfrog/build-info-go v1.8.9-0.20230905120411-62d1bdd4eb38 h1:XyAcwWP2a
github.com/jfrog/build-info-go v1.8.9-0.20230905120411-62d1bdd4eb38/go.mod h1:QEskae5fQpjeY2PBzsjWtUQVskYSNDF2sSmw/Gx44dQ=
github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk=
github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0=
github.com/jfrog/jfrog-client-go v1.28.1-0.20230831152946-6ed2ae1aa57f h1:S6l0o2sKFLRJ+QYVB5U/PJhrnwFSmKFFY7eHpRPRH8A=
github.com/jfrog/jfrog-client-go v1.28.1-0.20230831152946-6ed2ae1aa57f/go.mod h1:uUnMrqHX7Xi+OCaZEE4b3BtsmGeOSCB7XqaEWVXEH/E=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down
8 changes: 6 additions & 2 deletions utils/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,12 @@ func getConfigFile() (content []byte, err error) {
}

func (config *Config) Clone() (*Config, error) {
bytes, err := json.Marshal(config)
configBytes, err := json.Marshal(config)
if err != nil {
return nil, errorutils.CheckError(err)
}
clone := &Config{}
if err = json.Unmarshal(bytes, clone); err != nil {
if err = json.Unmarshal(configBytes, clone); err != nil {
return nil, errorutils.CheckError(err)
}
return clone, nil
Expand Down Expand Up @@ -567,6 +567,8 @@ func (o *ConfigV0) Convert() *ConfigV4 {

type ServerDetails struct {
Url string `json:"url,omitempty"`
XscUrl string `json:"-"`
XscVersion string `json:"-"`
SshUrl string `json:"-"`
ArtifactoryUrl string `json:"artifactoryUrl,omitempty"`
DistributionUrl string `json:"distributionUrl,omitempty"`
Expand Down Expand Up @@ -703,6 +705,8 @@ func (serverDetails *ServerDetails) CreateDistAuthConfig() (auth.ServiceDetails,

func (serverDetails *ServerDetails) CreateXrayAuthConfig() (auth.ServiceDetails, error) {
artAuth := xrayAuth.NewXrayDetails()
artAuth.SetXscUrl(serverDetails.XscUrl)
artAuth.SetXscVersion(serverDetails.XscVersion)
artAuth.SetUrl(serverDetails.XrayUrl)
return serverDetails.createAuthConfig(artAuth)
}
Expand Down
3 changes: 3 additions & 0 deletions utils/coreutils/coreconsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ var (
Project = "JFROG_CLI_BUILD_PROJECT"
//#nosec G101
EncryptionKey = "JFROG_CLI_ENCRYPTION_KEY"

// Manually sets XSC Multi-Scan-ID for testing purposes.
MultiScanId = "JFROG_CLI_XSC_MULTI_SCAN_ID"
)
2 changes: 1 addition & 1 deletion utils/usage/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (ur *UsageReporter) reportToXray(features ...ReportFeature) (err error) {
err = errorutils.CheckErrorf("Nothing to send.")
return
}
return xrayusage.SendXrayUsageEvents(*serviceManager, events...)
return xrayusage.SendXrayUsageEvents(serviceManager, events...)
}

func (ur *UsageReporter) reportToArtifactory(features ...ReportFeature) (err error) {
Expand Down
91 changes: 58 additions & 33 deletions xray/commands/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package audit

import (
"errors"
"fmt"
rtutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-cli-core/v2/xray/scangraph"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/log"
"github.com/jfrog/jfrog-client-go/xray"
"github.com/jfrog/jfrog-client-go/xray/services"
"github.com/jfrog/jfrog-client-go/xray/manager"
"github.com/jfrog/jfrog-client-go/xray/scan"
"golang.org/x/sync/errgroup"
"os"

Expand All @@ -26,6 +27,12 @@ type AuditCommand struct {
AuditParams
}

type XrayEntitlements struct {
errGroup *errgroup.Group
Jas bool
Xsc bool
}

func NewGenericAuditCommand() *AuditCommand {
return &AuditCommand{AuditParams: *NewAuditParams()}
}
Expand Down Expand Up @@ -65,11 +72,12 @@ func (auditCmd *AuditCommand) SetPrintExtendedTable(printExtendedTable bool) *Au
return auditCmd
}

func (auditCmd *AuditCommand) CreateXrayGraphScanParams() *services.XrayGraphScanParams {
params := &services.XrayGraphScanParams{
RepoPath: auditCmd.targetRepoPath,
Watches: auditCmd.watches,
ScanType: services.Dependency,
func (auditCmd *AuditCommand) CreateXrayGraphScanParams() *scan.XrayGraphScanParams {
params := &scan.XrayGraphScanParams{
RepoPath: auditCmd.targetRepoPath,
Watches: auditCmd.watches,
ScanType: scan.Dependency,
MultiScanId: os.Getenv(coreutils.MultiScanId),
}
if auditCmd.projectKey == "" {
params.ProjectKey = os.Getenv(coreutils.Project)
Expand Down Expand Up @@ -140,6 +148,7 @@ type Results struct {
ScaError error
JasError error
ExtendedScanResults *xrayutils.ExtendedScanResults
ScannedTechnologies []coreutils.Technology
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
}

func NewAuditResults() *Results {
Expand All @@ -150,52 +159,68 @@ func NewAuditResults() *Results {
// Returns an audit Results object containing all the scan results.
// If the current server is entitled for JAS, the advanced security results will be included in the scan results.
func RunAudit(auditParams *AuditParams) (results *Results, err error) {
var entitlements *XrayEntitlements
var serverDetails *config.ServerDetails

// Initialize Results struct
results = NewAuditResults()

serverDetails, err := auditParams.ServerDetails()
if err != nil {
return
}
var xrayManager *xray.XrayServicesManager
xrayManager, auditParams.xrayVersion, err = xrayutils.CreateXrayServiceManagerAndGetVersion(serverDetails)
if err != nil {
return
}
if err = clientutils.ValidateMinimumVersion(clientutils.Xray, auditParams.xrayVersion, scangraph.GraphScanMinXrayVersion); err != nil {
if serverDetails, err = auditParams.ServerDetails(); err != nil {
return
}
results.ExtendedScanResults.EntitledForJas, err = isEntitledForJas(xrayManager, auditParams.xrayVersion)
if err != nil {
// Check entitlements for JAS and XSC and update auditParams with results.
if entitlements, err = checkEntitlements(serverDetails, auditParams); err != nil {
return
}

errGroup := new(errgroup.Group)
if results.ExtendedScanResults.EntitledForJas {
// Download (if needed) the analyzer manager in a background routine.
errGroup.Go(rtutils.DownloadAnalyzerManagerIfNeeded)
}

// The sca scan doesn't require the analyzer manager, so it can run separately from the analyzer manager download routine.
results.ScaError = runScaScan(auditParams, results)

// Wait for the Download of the AnalyzerManager to complete.
if err = errGroup.Wait(); err != nil {
if err = entitlements.errGroup.Wait(); err != nil {
return
}

// Run scanners only if the user is entitled for Advanced Security
if results.ExtendedScanResults.EntitledForJas {
results.JasError = runJasScannersAndSetResults(results.ExtendedScanResults, auditParams.DirectDependencies(), serverDetails, auditParams.workingDirs, auditParams.Progress())
if entitlements.Jas {
results.ExtendedScanResults.EntitledForJas = entitlements.Jas
results.JasError = runJasScannersAndSetResults(results.ExtendedScanResults, auditParams.DirectDependencies(), serverDetails, auditParams.workingDirs, auditParams.Progress(), auditParams.xrayGraphScanParams.MultiScanId)
}
return
}

func isEntitledForJas(xrayManager *xray.XrayServicesManager, xrayVersion string) (entitled bool, err error) {
func isEntitledForJas(xrayManager manager.SecurityServiceManager, xrayVersion string) (entitled bool, err error) {
if e := clientutils.ValidateMinimumVersion(clientutils.Xray, xrayVersion, xrayutils.EntitlementsMinVersion); e != nil {
log.Debug(e)
return
}
entitled, err = xrayManager.IsEntitled(xrayutils.ApplicabilityFeatureId)
return
}

// checkEntitlements validates the entitlements for JAS and XSC.
func checkEntitlements(serverDetails *config.ServerDetails, auditParams *AuditParams) (entitlements *XrayEntitlements, err error) {
var xrayManager manager.SecurityServiceManager
if xrayManager, auditParams.xrayVersion, err = xrayutils.CreateXrayServiceManagerAndGetVersion(serverDetails); err != nil {
return
}
// Check entitlements
var jasEntitle, xscEntitled bool
if jasEntitle, err = isEntitledForJas(xrayManager, auditParams.xrayVersion); err != nil {
return
}
// Setting serverDetails.XscVersion is important as this is how we determined if XSC is enabled or not.
if xscEntitled, serverDetails.XscVersion, err = xrayManager.IsXscEnabled(); err != nil {
return
}
entitlements = &XrayEntitlements{Jas: jasEntitle, Xsc: xscEntitled, errGroup: new(errgroup.Group)}
log.Debug(fmt.Sprintf("entitlements results: JAS: %t XSC: %t", jasEntitle, xscEntitled))

// Handle actions needed in case of specific entitlement.
if entitlements.Jas {
// Download the analyzer manager in a background routine.
entitlements.errGroup.Go(rtutils.DownloadAnalyzerManagerIfNeeded)
}
if entitlements.Xsc {
log.Info("XSC version:", serverDetails.XscVersion)
auditParams.xscVersion = serverDetails.XscVersion
}
return
}
11 changes: 6 additions & 5 deletions xray/commands/audit/auditparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ package audit

import (
xrayutils "github.com/jfrog/jfrog-cli-core/v2/xray/utils"
"github.com/jfrog/jfrog-client-go/xray/services"
"github.com/jfrog/jfrog-client-go/xray/scan"
)

type AuditParams struct {
xrayGraphScanParams *services.XrayGraphScanParams
xrayGraphScanParams *scan.XrayGraphScanParams
workingDirs []string
installFunc func(tech string) error
fixableOnly bool
minSeverityFilter string
*xrayutils.AuditBasicParams
xrayVersion string
xscVersion string
}

func NewAuditParams() *AuditParams {
return &AuditParams{
xrayGraphScanParams: &services.XrayGraphScanParams{},
xrayGraphScanParams: &scan.XrayGraphScanParams{},
AuditBasicParams: &xrayutils.AuditBasicParams{},
}
}
Expand All @@ -26,7 +27,7 @@ func (params *AuditParams) InstallFunc() func(tech string) error {
return params.installFunc
}

func (params *AuditParams) XrayGraphScanParams() *services.XrayGraphScanParams {
func (params *AuditParams) XrayGraphScanParams() *scan.XrayGraphScanParams {
return params.xrayGraphScanParams
}

Expand All @@ -38,7 +39,7 @@ func (params *AuditParams) XrayVersion() string {
return params.xrayVersion
}

func (params *AuditParams) SetXrayGraphScanParams(xrayGraphScanParams *services.XrayGraphScanParams) *AuditParams {
func (params *AuditParams) SetXrayGraphScanParams(xrayGraphScanParams *scan.XrayGraphScanParams) *AuditParams {
params.xrayGraphScanParams = xrayGraphScanParams
return params
}
Expand Down
10 changes: 5 additions & 5 deletions xray/commands/audit/jas/applicability/applicabilitymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/jfrog/jfrog-cli-core/v2/xray/utils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/log"
"github.com/jfrog/jfrog-client-go/xray/services"
"github.com/jfrog/jfrog-client-go/xray/scan"
"github.com/owenrumney/go-sarif/v2/sarif"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
Expand All @@ -24,7 +24,7 @@ const (
type ApplicabilityScanManager struct {
applicabilityScanResults map[string]utils.ApplicabilityStatus
directDependenciesCves []string
xrayResults []services.ScanResponse
xrayResults []scan.ScanResponse
scanner *jas.JasScanner
}

Expand All @@ -37,7 +37,7 @@ type ApplicabilityScanManager struct {
// map[string]string: A map containing the applicability result of each XRAY CVE.
// bool: true if the user is entitled to the applicability scan, false otherwise.
// error: An error object (if any).
func RunApplicabilityScan(xrayResults []services.ScanResponse, directDependencies []string,
func RunApplicabilityScan(xrayResults []scan.ScanResponse, directDependencies []string,
scannedTechnologies []coreutils.Technology, scanner *jas.JasScanner) (results map[string]utils.ApplicabilityStatus, err error) {
applicabilityScanManager := newApplicabilityScanManager(xrayResults, directDependencies, scanner)
if !applicabilityScanManager.shouldRunApplicabilityScan(scannedTechnologies) {
Expand All @@ -52,7 +52,7 @@ func RunApplicabilityScan(xrayResults []services.ScanResponse, directDependencie
return
}

func newApplicabilityScanManager(xrayScanResults []services.ScanResponse, directDependencies []string, scanner *jas.JasScanner) (manager *ApplicabilityScanManager) {
func newApplicabilityScanManager(xrayScanResults []scan.ScanResponse, directDependencies []string, scanner *jas.JasScanner) (manager *ApplicabilityScanManager) {
directDependenciesCves := extractDirectDependenciesCvesFromScan(xrayScanResults, directDependencies)
return &ApplicabilityScanManager{
applicabilityScanResults: map[string]utils.ApplicabilityStatus{},
Expand All @@ -64,7 +64,7 @@ func newApplicabilityScanManager(xrayScanResults []services.ScanResponse, direct

// This function gets a list of xray scan responses that contain direct and indirect vulnerabilities and returns only direct
// vulnerabilities of the scanned project, ignoring indirect vulnerabilities
func extractDirectDependenciesCvesFromScan(xrayScanResults []services.ScanResponse, directDependencies []string) []string {
func extractDirectDependenciesCvesFromScan(xrayScanResults []scan.ScanResponse, directDependencies []string) []string {
directsCves := datastructures.MakeSet[string]()
for _, scanResult := range xrayScanResults {
for _, vulnerability := range scanResult.Vulnerabilities {
Expand Down
Loading
Loading