Skip to content

Commit

Permalink
swift audit fixes + small fix to cocoapods version
Browse files Browse the repository at this point in the history
  • Loading branch information
barv-jfrog committed Dec 8, 2024
1 parent 9d7503c commit dba18a6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 28 deletions.
21 changes: 21 additions & 0 deletions commands/audit/sca/cocoapods/cocoapods.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-cli-security/utils/formats/sarifutils"
"github.com/jfrog/jfrog-cli-security/utils/techutils"
"github.com/jfrog/jfrog-cli-security/utils/xray"
"github.com/jfrog/jfrog-cli-security/utils/xray/scangraph"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/log"
xrayUtils "github.com/jfrog/jfrog-client-go/xray/services/utils"
"github.com/owenrumney/go-sarif/v2/sarif"
Expand Down Expand Up @@ -200,6 +203,24 @@ func GetDependenciesData(currentDir string) (string, error) {
}

func BuildDependencyTree(params utils.AuditParams) (dependencyTree []*xrayUtils.GraphNode, uniqueDeps []string, err error) {
details, err := params.ServerDetails()
if err != nil {
return nil, nil, err
}
xrayManager, err := xray.CreateXrayServiceManager(details)
if err != nil {
return nil, nil, err
}
xrayVersion, err := xrayManager.GetVersion()
if err != nil {
log.Error("Could not get xray version")
return nil, nil, err
}
err = clientutils.ValidateMinimumVersion(clientutils.Xray, xrayVersion, scangraph.CocoapodsScanMinXrayVersion)
if err != nil {
log.Warn(fmt.Sprintf("Your xray version %s does not support cocoapods which is supported on versions %s and above", xrayVersion, scangraph.CocoapodsScanMinXrayVersion))
return nil, nil, err
}
currentDir, err := coreutils.GetWorkingDirectory()
if err != nil {
return nil, nil, err
Expand Down
21 changes: 21 additions & 0 deletions commands/audit/sca/swift/swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-cli-security/utils/formats/sarifutils"
"github.com/jfrog/jfrog-cli-security/utils/techutils"
"github.com/jfrog/jfrog-cli-security/utils/xray"
"github.com/jfrog/jfrog-cli-security/utils/xray/scangraph"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/log"
xrayUtils "github.com/jfrog/jfrog-client-go/xray/services/utils"
"github.com/owenrumney/go-sarif/v2/sarif"
Expand Down Expand Up @@ -160,6 +163,24 @@ func GetDependenciesData(exePath, currentDir string) (*Dependencies, error) {
}

func BuildDependencyTree(params utils.AuditParams) (dependencyTree []*xrayUtils.GraphNode, uniqueDeps []string, err error) {
details, err := params.ServerDetails()
if err != nil {
return nil, nil, err
}
xrayManager, err := xray.CreateXrayServiceManager(details)
if err != nil {
return nil, nil, err
}
xrayVersion, err := xrayManager.GetVersion()
if err != nil {
log.Error("Could not get xray version")
return nil, nil, err
}
err = clientutils.ValidateMinimumVersion(clientutils.Xray, xrayVersion, scangraph.SwiftScanMinXrayVersion)
if err != nil {
log.Warn(fmt.Sprintf("Your xray version %s does not support cocoapods which is supported on versions %s and above", xrayVersion, scangraph.SwiftScanMinXrayVersion))
return nil, nil, err
}
currentDir, err := coreutils.GetWorkingDirectory()
if err != nil {
return nil, nil, err
Expand Down
28 changes: 0 additions & 28 deletions commands/audit/scarunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,36 +257,8 @@ func GetTechDependencyTree(params xrayutils.AuditParams, artifactoryServerDetail
case techutils.Nuget:
depTreeResult.FullDepTrees, uniqueDeps, err = nuget.BuildDependencyTree(params)
case techutils.Cocoapods:
xrayManager, err := xray.CreateXrayServiceManager(artifactoryServerDetails)
if err != nil {
return depTreeResult, err
}
xrayVersion, err := xrayManager.GetVersion()
if err != nil {
log.Error("Could not get xray version")
return depTreeResult, err
}
err = clientutils.ValidateMinimumVersion(clientutils.Xray, xrayVersion, scangraph.CocoapodsScanMinXrayVersion)
if err != nil {
log.Warn(fmt.Sprintf("Your xray version %s does not support cocoapods which is supported on versions %s and above", xrayVersion, scangraph.CocoapodsScanMinXrayVersion))
return depTreeResult, err
}
depTreeResult.FullDepTrees, uniqueDeps, err = cocoapods.BuildDependencyTree(params)
case techutils.Swift:
xrayManager, err := xray.CreateXrayServiceManager(artifactoryServerDetails)
if err != nil {
return depTreeResult, err
}
xrayVersion, err := xrayManager.GetVersion()
if err != nil {
log.Error("Could not get xray version")
return depTreeResult, err
}
err = clientutils.ValidateMinimumVersion(clientutils.Xray, xrayVersion, scangraph.SwiftScanMinXrayVersion)
if err != nil {
log.Warn(fmt.Sprintf("Your xray version %s does not support swift which is supported on versions %s and above", xrayVersion, scangraph.SwiftScanMinXrayVersion))
return depTreeResult, err
}
depTreeResult.FullDepTrees, uniqueDeps, err = swift.BuildDependencyTree(params)
default:
err = errorutils.CheckErrorf("%s is currently not supported", string(tech))
Expand Down

0 comments on commit dba18a6

Please sign in to comment.