From 61e10bcceccaa177f0897abffe27a54da26e05f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:08:41 +0000 Subject: [PATCH] Bump github.com/jfrog/jfrog-cli-core/v2 from 2.57.1 to 2.57.3 Bumps [github.com/jfrog/jfrog-cli-core/v2](https://github.com/jfrog/jfrog-cli-core) from 2.57.1 to 2.57.3. - [Release notes](https://github.com/jfrog/jfrog-cli-core/releases) - [Commits](https://github.com/jfrog/jfrog-cli-core/compare/v2.57.1...v2.57.3) --- updated-dependencies: - dependency-name: github.com/jfrog/jfrog-cli-core/v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 6 +- go.sum | 12 ++-- .../jfrog/build-info-go/build/utils/yarn.go | 22 +++++-- .../jfrog/build-info-go/build/yarn.go | 8 ++- .../v2/artifactory/utils/utils.go | 26 +++++++- .../jfrog-cli-core/v2/utils/config/config.go | 17 ++++-- .../v2/utils/coreutils/coreconsts.go | 2 + .../jfrog-client-go/http/httpclient/client.go | 4 ++ .../jfrog-client-go/jfconnect/manager.go | 45 ++++++++++++++ .../jfconnect/services/metrics.go | 60 +++++++++++++++++++ .../jfrog/jfrog-client-go/utils/utils.go | 2 +- .../jfrog-client-go/xray/services/xsc/xsc.go | 10 +++- .../jfrog/jfrog-client-go/xsc/manager.go | 9 ++- .../jfrog/jfrog-client-go/xsc/service.go | 6 +- .../jfrog-client-go/xsc/services/profile.go | 46 +++++++++++--- vendor/modules.txt | 8 ++- 16 files changed, 243 insertions(+), 40 deletions(-) create mode 100644 vendor/github.com/jfrog/jfrog-client-go/jfconnect/manager.go create mode 100644 vendor/github.com/jfrog/jfrog-client-go/jfconnect/services/metrics.go diff --git a/go.mod b/go.mod index 3b3fc383..6f2be369 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.23.4 require ( github.com/Masterminds/semver v1.5.0 - github.com/jfrog/jfrog-cli-core/v2 v2.57.1 - github.com/jfrog/jfrog-client-go v1.48.3 + github.com/jfrog/jfrog-cli-core/v2 v2.57.3 + github.com/jfrog/jfrog-client-go v1.48.5 gopkg.in/yaml.v3 v3.0.1 ) @@ -38,7 +38,7 @@ require ( github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jedib0t/go-pretty/v6 v6.6.5 // indirect github.com/jfrog/archiver/v3 v3.6.1 // indirect - github.com/jfrog/build-info-go v1.10.6 // indirect + github.com/jfrog/build-info-go v1.10.7 // indirect github.com/jfrog/gofrog v1.7.6 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/klauspost/compress v1.17.11 // indirect diff --git a/go.sum b/go.sum index dd4bf41b..8354c71a 100644 --- a/go.sum +++ b/go.sum @@ -90,14 +90,14 @@ github.com/jedib0t/go-pretty/v6 v6.6.5 h1:9PgMJOVBedpgYLI56jQRJYqngxYAAzfEUua+3N github.com/jedib0t/go-pretty/v6 v6.6.5/go.mod h1:Uq/HrbhuFty5WSVNfjpQQe47x16RwVGXIveNGEyGtHs= github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI= github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw= -github.com/jfrog/build-info-go v1.10.6 h1:zH1ZhXlVfi5DlFyunygHjrdOcnv5qxfeLqmsfD4+lc4= -github.com/jfrog/build-info-go v1.10.6/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE= +github.com/jfrog/build-info-go v1.10.7 h1:10NVHYg0193gJpQft+S4WQfvYMtj5jlwwhJRvkFJtBE= +github.com/jfrog/build-info-go v1.10.7/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE= github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s= github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4= -github.com/jfrog/jfrog-cli-core/v2 v2.57.1 h1:YVuiSoavDisE8Dc9TOhYo5fE3d2C4/BrXuLDO/SZpJo= -github.com/jfrog/jfrog-cli-core/v2 v2.57.1/go.mod h1:e95/VWV6LL+UUxSNTJZ+sLmqJhCO5lDRhhLUQMV8WK4= -github.com/jfrog/jfrog-client-go v1.48.3 h1:HJpKGul0f/S2i7Uf7K/GwS1EUGiirt1LWXL1lanKNhU= -github.com/jfrog/jfrog-client-go v1.48.3/go.mod h1:1a7bmQHkRmPEza9wva2+WVrYzrGbosrMymq57kyG5gU= +github.com/jfrog/jfrog-cli-core/v2 v2.57.3 h1:xqVHCIgcaJoRmLe79Qks1+9wIO7NigMjLFI9hRqL3sQ= +github.com/jfrog/jfrog-cli-core/v2 v2.57.3/go.mod h1:+43WrzRL8GIRde9YMwEQpXPzwZC1JZlZjO/K2ZsyJHc= +github.com/jfrog/jfrog-client-go v1.48.5 h1:q8v8oZ2HwwVw6+ZCwKbuIpUmxpWUeZzvTASQl/QKxKw= +github.com/jfrog/jfrog-client-go v1.48.5/go.mod h1:2ySOMva54L3EYYIlCBYBTcTgqfrrQ19gtpA/MWfA/ec= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= diff --git a/vendor/github.com/jfrog/build-info-go/build/utils/yarn.go b/vendor/github.com/jfrog/build-info-go/build/utils/yarn.go index 4068f54b..efbd8bc8 100644 --- a/vendor/github.com/jfrog/build-info-go/build/utils/yarn.go +++ b/vendor/github.com/jfrog/build-info-go/build/utils/yarn.go @@ -132,6 +132,7 @@ func GetYarnDependencies(executablePath, srcPath string, packageInfo *PackageInf } else { dependenciesMap, root, err = buildYarnV1DependencyMap(packageInfo, responseStr, allowPartialResults, log) } + log.Debug(fmt.Sprintf("final dependencies map: %+v", dependenciesMap)) return } @@ -183,6 +184,16 @@ func buildYarnV1DependencyMap(packageInfo *PackageInfo, responseStr string, allo if err != nil { return } + if packageCleanName == "" || packageVersion == "" { + // If we enter this case it means we got an unexpected name for a dependency that might cause issues later on when constructing the tree + log.Debug(fmt.Sprintf("got an unexpected dependency name when building Yarn V1 dependency map.\nfull name: '%s' | clean name: '%s' | clean version: '%s'", curDependency.Name, packageCleanName, packageVersion)) + if allowPartialResults { + log.Warn(fmt.Sprintf("got an unexpected package name during Yarn V1 dependencies map calculation: %s\nFinal rasults may be partial", curDependency.Name)) + continue + } + err = fmt.Errorf("couldn't parse correctly the following dependency during Yarn V1 dependencies map calculation: %s", curDependency.Name) + return + } // We insert to dependenciesMap dependencies with the resolved versions only. All dependencies at the responseStr first level contain resolved versions only (their children may contain caret version ranges). dependenciesMap[curDependency.Name] = &YarnDependency{ Value: curDependency.Name, @@ -313,7 +324,7 @@ func buildYarn1Root(packageInfo *PackageInfo, packNameToFullName map[string]stri return rootDependency } -// splitNameAndVersion splits package name for package version for th following formats ONLY: package-name@version, package-name@npm:version +// Splits the package name and version for the following formats ONLY: package-name@version and package-name@npm:version func splitNameAndVersion(packageFullName string) (packageCleanName string, packageVersion string, err error) { packageFullName = strings.Replace(packageFullName, "npm:", "", 1) indexOfLastAt := strings.LastIndex(packageFullName, "@") @@ -367,14 +378,17 @@ type YarnDependency struct { Details YarnDepDetails `json:"children,omitempty"` } -func (yd *YarnDependency) Name() string { +func (yd *YarnDependency) Name() (string, error) { + if yd.Value == "" { + return "", fmt.Errorf("got an empty name yarn dependency: %+v", yd) + } // Find the first index of '@', starting from position 1. In scoped dependencies (like '@jfrog/package-name@npm:1.2.3') we want to keep the first '@' as part of the name. if strings.Contains(yd.Value[1:], "@") { atSignIndex := strings.Index(yd.Value[1:], "@") + 1 - return yd.Value[:atSignIndex] + return yd.Value[:atSignIndex], nil } // In some cases when using yarn V1 we encounter package names without their version (project's package name) - return yd.Value + return yd.Value, nil } type YarnDepDetails struct { diff --git a/vendor/github.com/jfrog/build-info-go/build/yarn.go b/vendor/github.com/jfrog/build-info-go/build/yarn.go index 1585087f..3e30a975 100644 --- a/vendor/github.com/jfrog/build-info-go/build/yarn.go +++ b/vendor/github.com/jfrog/build-info-go/build/yarn.go @@ -93,7 +93,11 @@ func (ym *YarnModule) getDependenciesMap() (map[string]*entities.Dependency, err func (ym *YarnModule) appendDependencyRecursively(yarnDependency *buildutils.YarnDependency, pathToRoot []string, yarnDependenciesMap map[string]*buildutils.YarnDependency, buildInfoDependencies map[string]*entities.Dependency) error { - id := yarnDependency.Name() + ":" + yarnDependency.Details.Version + depName, err := yarnDependency.Name() + if err != nil { + return err + } + id := depName + ":" + yarnDependency.Details.Version // To avoid infinite loops in case of circular dependencies, the dependency won't be added if it's already in pathToRoot if slices.Contains(pathToRoot, id) { @@ -106,7 +110,7 @@ func (ym *YarnModule) appendDependencyRecursively(yarnDependency *buildutils.Yar if !exist { return fmt.Errorf("an error occurred while creating dependencies tree: dependency %s was not found", dependencyPtr.Locator) } - err := ym.appendDependencyRecursively(innerYarnDep, append([]string{id}, pathToRoot...), yarnDependenciesMap, + err = ym.appendDependencyRecursively(innerYarnDep, append([]string{id}, pathToRoot...), yarnDependenciesMap, buildInfoDependencies) if err != nil { return err diff --git a/vendor/github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/utils.go b/vendor/github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/utils.go index f105cae2..68831475 100644 --- a/vendor/github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/utils.go +++ b/vendor/github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/utils.go @@ -4,8 +4,6 @@ import ( "context" "encoding/json" "errors" - ioutils "github.com/jfrog/gofrog/io" - "github.com/jfrog/jfrog-client-go/evidence" "io" "net/http" "net/url" @@ -16,6 +14,9 @@ import ( "strings" "time" + ioutils "github.com/jfrog/gofrog/io" + "github.com/jfrog/jfrog-client-go/evidence" + "github.com/jfrog/jfrog-cli-core/v2/utils/config" "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" "github.com/jfrog/jfrog-client-go/access" @@ -24,6 +25,7 @@ import ( clientConfig "github.com/jfrog/jfrog-client-go/config" "github.com/jfrog/jfrog-client-go/distribution" "github.com/jfrog/jfrog-client-go/http/httpclient" + "github.com/jfrog/jfrog-client-go/jfconnect" "github.com/jfrog/jfrog-client-go/lifecycle" "github.com/jfrog/jfrog-client-go/metadata" clientUtils "github.com/jfrog/jfrog-client-go/utils" @@ -260,6 +262,26 @@ func CreateMetadataServiceManager(serviceDetails *config.ServerDetails, isDryRun return metadata.NewManager(serviceConfig) } +func CreateJfConnectServiceManager(serverDetails *config.ServerDetails) (jfconnect.Manager, error) { + certsPath, err := coreutils.GetJfrogCertsDir() + if err != nil { + return nil, err + } + jfConnectAuth, err := serverDetails.CreateJfConnectAuthConfig() + if err != nil { + return nil, err + } + serviceConfig, err := clientConfig.NewConfigBuilder(). + SetServiceDetails(jfConnectAuth). + SetCertificatesPath(certsPath). + SetInsecureTls(serverDetails.InsecureTls). + Build() + if err != nil { + return nil, err + } + return jfconnect.NewManager(serviceConfig) +} + // This error indicates that the build was scanned by Xray, but Xray found issues with the build. // If Xray failed to scan the build, for example due to a networking issue, a regular error should be returned. var errBuildScan = errors.New("issues found during xray build scan") diff --git a/vendor/github.com/jfrog/jfrog-cli-core/v2/utils/config/config.go b/vendor/github.com/jfrog/jfrog-cli-core/v2/utils/config/config.go index 010e2ef0..c3a15cdf 100644 --- a/vendor/github.com/jfrog/jfrog-cli-core/v2/utils/config/config.go +++ b/vendor/github.com/jfrog/jfrog-cli-core/v2/utils/config/config.go @@ -4,6 +4,12 @@ import ( "bytes" "encoding/json" "errors" + "os" + "path/filepath" + "strconv" + "strings" + "time" + "github.com/buger/jsonparser" biutils "github.com/jfrog/build-info-go/utils" "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" @@ -22,11 +28,6 @@ import ( "github.com/jfrog/jfrog-client-go/utils/log" xrayAuth "github.com/jfrog/jfrog-client-go/xray/auth" xscAuth "github.com/jfrog/jfrog-client-go/xsc/auth" - "os" - "path/filepath" - "strconv" - "strings" - "time" ) func init() { @@ -747,6 +748,12 @@ func (serverDetails *ServerDetails) CreateAccessAuthConfig() (auth.ServiceDetail return serverDetails.createAuthConfig(pAuth) } +func (serverDetails *ServerDetails) CreateJfConnectAuthConfig() (auth.ServiceDetails, error) { + pAuth := accessAuth.NewAccessDetails() + pAuth.SetUrl(utils.AddTrailingSlashIfNeeded(serverDetails.Url) + "jfconnect/") + return serverDetails.createAuthConfig(pAuth) +} + func (serverDetails *ServerDetails) CreateLifecycleAuthConfig() (auth.ServiceDetails, error) { lcAuth := lifecycleAuth.NewLifecycleDetails() lcAuth.SetUrl(serverDetails.LifecycleUrl) diff --git a/vendor/github.com/jfrog/jfrog-cli-core/v2/utils/coreutils/coreconsts.go b/vendor/github.com/jfrog/jfrog-cli-core/v2/utils/coreutils/coreconsts.go index 9e83bc8b..541d1feb 100644 --- a/vendor/github.com/jfrog/jfrog-cli-core/v2/utils/coreutils/coreconsts.go +++ b/vendor/github.com/jfrog/jfrog-cli-core/v2/utils/coreutils/coreconsts.go @@ -67,6 +67,8 @@ var ( BuildName = "JFROG_CLI_BUILD_NAME" BuildNumber = "JFROG_CLI_BUILD_NUMBER" Project = "JFROG_CLI_BUILD_PROJECT" + SigningKey = "JFROG_CLI_SIGNING_KEY" + KeyAlias = "JFROG_CLI_KEY_ALIAS" //#nosec G101 EncryptionKey = "JFROG_CLI_ENCRYPTION_KEY" ) diff --git a/vendor/github.com/jfrog/jfrog-client-go/http/httpclient/client.go b/vendor/github.com/jfrog/jfrog-client-go/http/httpclient/client.go index bc829797..93800932 100644 --- a/vendor/github.com/jfrog/jfrog-client-go/http/httpclient/client.go +++ b/vendor/github.com/jfrog/jfrog-client-go/http/httpclient/client.go @@ -133,6 +133,10 @@ func (jc *HttpClient) Send(method, url string, content []byte, followRedirect, c } resp, respBody, redirectUrl, err = jc.doRequest(req, content, followRedirect, closeBody, httpClientsDetails) if err != nil { + if strings.Contains(err.Error(), "unsupported protocol scheme") { + // Wrong URL, so no need to retry + return false, fmt.Errorf("%w\nThe recieved error indicats an invalid URL: %q, Please ensure the URL includes a valid scheme like 'http://' or 'https://'.", err, url) + } return true, err } // Response must not be nil diff --git a/vendor/github.com/jfrog/jfrog-client-go/jfconnect/manager.go b/vendor/github.com/jfrog/jfrog-client-go/jfconnect/manager.go new file mode 100644 index 00000000..20aee5e8 --- /dev/null +++ b/vendor/github.com/jfrog/jfrog-client-go/jfconnect/manager.go @@ -0,0 +1,45 @@ +package jfconnect + +import ( + "github.com/jfrog/jfrog-client-go/config" + "github.com/jfrog/jfrog-client-go/http/jfroghttpclient" + "github.com/jfrog/jfrog-client-go/jfconnect/services" +) + +type Manager interface { + PostVisibilityMetric(services.VisibilityMetric) error +} + +type jfConnectManager struct { + client *jfroghttpclient.JfrogHttpClient + config config.Config +} + +func NewManager(config config.Config) (Manager, error) { + details := config.GetServiceDetails() + var err error + manager := &jfConnectManager{config: config} + manager.client, err = jfroghttpclient.JfrogClientBuilder(). + SetCertificatesPath(config.GetCertificatesPath()). + SetInsecureTls(config.IsInsecureTls()). + SetClientCertPath(details.GetClientCertPath()). + SetClientCertKeyPath(details.GetClientCertKeyPath()). + AppendPreRequestInterceptor(details.RunPreRequestFunctions). + SetContext(config.GetContext()). + SetDialTimeout(config.GetDialTimeout()). + SetOverallRequestTimeout(config.GetOverallRequestTimeout()). + SetRetries(config.GetHttpRetries()). + SetRetryWaitMilliSecs(config.GetHttpRetryWaitMilliSecs()). + Build() + + return manager, err +} + +func (jm *jfConnectManager) Client() *jfroghttpclient.JfrogHttpClient { + return jm.client +} + +func (jm *jfConnectManager) PostVisibilityMetric(metric services.VisibilityMetric) error { + jfConnectService := services.NewJfConnectService(jm.config.GetServiceDetails(), jm.client) + return jfConnectService.PostVisibilityMetric(metric) +} diff --git a/vendor/github.com/jfrog/jfrog-client-go/jfconnect/services/metrics.go b/vendor/github.com/jfrog/jfrog-client-go/jfconnect/services/metrics.go new file mode 100644 index 00000000..e7ff4954 --- /dev/null +++ b/vendor/github.com/jfrog/jfrog-client-go/jfconnect/services/metrics.go @@ -0,0 +1,60 @@ +package services + +import ( + "encoding/json" + "net/http" + + "github.com/jfrog/jfrog-client-go/auth" + "github.com/jfrog/jfrog-client-go/http/jfroghttpclient" + clientutils "github.com/jfrog/jfrog-client-go/utils" + "github.com/jfrog/jfrog-client-go/utils/errorutils" +) + +const LogMetricApiEndpoint = "api/v1/backoffice/metrics/log" + +type JfConnectService struct { + client *jfroghttpclient.JfrogHttpClient + serviceDetails *auth.ServiceDetails +} + +func NewJfConnectService(serviceDetails auth.ServiceDetails, client *jfroghttpclient.JfrogHttpClient) *JfConnectService { + return &JfConnectService{serviceDetails: &serviceDetails, client: client} +} + +func (jcs *JfConnectService) GetJfConnectDetails() auth.ServiceDetails { + return *jcs.serviceDetails +} + +func (jcs *JfConnectService) PostVisibilityMetric(metric VisibilityMetric) error { + metricJson, err := json.Marshal(metric) + if err != nil { + return errorutils.CheckError(err) + } + details := jcs.GetJfConnectDetails() + httpClientDetails := details.CreateHttpClientDetails() + httpClientDetails.SetContentTypeApplicationJson() + + url := clientutils.AddTrailingSlashIfNeeded(details.GetUrl()) + url += LogMetricApiEndpoint + resp, body, err := jcs.client.SendPost(url, metricJson, &httpClientDetails) + if err != nil { + return err + } + return errorutils.CheckResponseStatusWithBody(resp, body, http.StatusCreated, http.StatusOK) +} + +type Labels struct { + ProductID string `json:"product_id"` + FeatureID string `json:"feature_id"` + OIDCUsed string `json:"oidc_used"` + JobID string `json:"job_id"` + RunID string `json:"run_id"` + GitRepo string `json:"git_repo"` + GhTokenForCodeScanningAlertsProvided string `json:"gh_token_for_code_scanning_alerts_provided"` +} + +type VisibilityMetric struct { + Value int `json:"value"` + MetricsName string `json:"metrics_name"` + Labels Labels `json:"labels"` +} diff --git a/vendor/github.com/jfrog/jfrog-client-go/utils/utils.go b/vendor/github.com/jfrog/jfrog-client-go/utils/utils.go index 17bec088..b9c13f3c 100644 --- a/vendor/github.com/jfrog/jfrog-client-go/utils/utils.go +++ b/vendor/github.com/jfrog/jfrog-client-go/utils/utils.go @@ -28,7 +28,7 @@ import ( const ( Development = "development" Agent = "jfrog-client-go" - Version = "1.48.1" + Version = "1.48.4" ) const xrayDevVersion = "3.x-dev" diff --git a/vendor/github.com/jfrog/jfrog-client-go/xray/services/xsc/xsc.go b/vendor/github.com/jfrog/jfrog-client-go/xray/services/xsc/xsc.go index cc5119a9..1e3003ed 100644 --- a/vendor/github.com/jfrog/jfrog-client-go/xray/services/xsc/xsc.go +++ b/vendor/github.com/jfrog/jfrog-client-go/xray/services/xsc/xsc.go @@ -47,8 +47,14 @@ func (xs *XscInnerService) GetAnalyticsGeneralEvent(msi string) (*services.XscAn return eventService.GetGeneralEvent(msi) } -func (xs *XscInnerService) GetConfigProfile(profileName string) (*services.ConfigProfile, error) { +func (xs *XscInnerService) GetConfigProfileByName(profileName string) (*services.ConfigProfile, error) { configProfileService := services.NewConfigurationProfileService(xs.client) configProfileService.XrayDetails = xs.XrayDetails - return configProfileService.GetConfigurationProfile(profileName) + return configProfileService.GetConfigurationProfileByName(profileName) +} + +func (xs *XscInnerService) GetConfigProfileByUrl(repoUrl string) (*services.ConfigProfile, error) { + configProfileService := services.NewConfigurationProfileService(xs.client) + configProfileService.XrayDetails = xs.XrayDetails + return configProfileService.GetConfigurationProfileByUrl(repoUrl) } diff --git a/vendor/github.com/jfrog/jfrog-client-go/xsc/manager.go b/vendor/github.com/jfrog/jfrog-client-go/xsc/manager.go index 04423674..f14f55d4 100644 --- a/vendor/github.com/jfrog/jfrog-client-go/xsc/manager.go +++ b/vendor/github.com/jfrog/jfrog-client-go/xsc/manager.go @@ -77,8 +77,13 @@ func (sm *XscServicesManager) GetAnalyticsGeneralEvent(msi string) (*services.Xs return eventService.GetGeneralEvent(msi) } -func (sm *XscServicesManager) GetConfigProfile(profileName string) (*services.ConfigProfile, error) { +func (sm *XscServicesManager) GetConfigProfileByName(profileName string) (*services.ConfigProfile, error) { configProfileService := services.NewConfigurationProfileService(sm.client) configProfileService.XscDetails = sm.config.GetServiceDetails() - return configProfileService.GetConfigurationProfile(profileName) + return configProfileService.GetConfigurationProfileByName(profileName) +} + +func (sm *XscServicesManager) GetConfigProfileByUrl(_ string) (*services.ConfigProfile, error) { + // Empty implementation required for alignment with interface, implemented only at the new service inside the Xray service + return nil, nil } diff --git a/vendor/github.com/jfrog/jfrog-client-go/xsc/service.go b/vendor/github.com/jfrog/jfrog-client-go/xsc/service.go index 6094b5b0..9fccf85d 100644 --- a/vendor/github.com/jfrog/jfrog-client-go/xsc/service.go +++ b/vendor/github.com/jfrog/jfrog-client-go/xsc/service.go @@ -15,6 +15,8 @@ type XscService interface { UpdateAnalyticsGeneralEvent(event services.XscAnalyticsGeneralEventFinalize) error // GetAnalyticsGeneralEvent returns general event that match the msi provided. GetAnalyticsGeneralEvent(msi string) (*services.XscAnalyticsGeneralEvent, error) - // GetConfigProfile returns the configuration profile that match the profile name provided. - GetConfigProfile(profileName string) (*services.ConfigProfile, error) + // GetConfigProfileByName returns the configuration profile that match the profile name provided. + GetConfigProfileByName(profileName string) (*services.ConfigProfile, error) + // GetConfigProfileByUrl returns the configuration profile related to the provided repository url. + GetConfigProfileByUrl(profileUrl string) (*services.ConfigProfile, error) } diff --git a/vendor/github.com/jfrog/jfrog-client-go/xsc/services/profile.go b/vendor/github.com/jfrog/jfrog-client-go/xsc/services/profile.go index 2db33d7d..0f646f38 100644 --- a/vendor/github.com/jfrog/jfrog-client-go/xsc/services/profile.go +++ b/vendor/github.com/jfrog/jfrog-client-go/xsc/services/profile.go @@ -2,6 +2,7 @@ package services import ( "encoding/json" + "errors" "fmt" "net/http" @@ -13,9 +14,12 @@ import ( ) const ( - ConfigProfileMinXscVersion = "1.11.0" - xscConfigProfileApi = "profile" - xscDeprecatedConfigProfileApiSuffix = "api/v1/" + xscConfigProfileApi + ConfigProfileMinXscVersion = "1.11.0" + ConfigProfileByUrlMinXrayVersion = "3.110.0" + xscConfigProfileByNameApi = "profile" + xscConfigProfileByUrlApi = "profile_repos" + xscDeprecatedConfigProfileByNameApiSuffix = "api/v1/" + xscConfigProfileByNameApi + getProfileByUrlBody = "{\"repo_url\":\"%s\"}" ) type ConfigurationProfileService struct { @@ -100,22 +104,22 @@ type ServicesScannerConfig struct { ExcludePatterns []string `json:"exclude_patterns,omitempty"` } -func (cp *ConfigurationProfileService) sendConfigProfileRequest(profileName string) (url string, resp *http.Response, body []byte, err error) { +func (cp *ConfigurationProfileService) sendConfigProfileByNameRequest(profileName string) (url string, resp *http.Response, body []byte, err error) { if cp.XrayDetails != nil { httpDetails := cp.XrayDetails.CreateHttpClientDetails() - url = fmt.Sprintf("%s%s%s/%s", utils.AddTrailingSlashIfNeeded(cp.XrayDetails.GetUrl()), xscutils.XscInXraySuffix, xscConfigProfileApi, profileName) + url = fmt.Sprintf("%s%s%s/%s", utils.AddTrailingSlashIfNeeded(cp.XrayDetails.GetUrl()), xscutils.XscInXraySuffix, xscConfigProfileByNameApi, profileName) resp, body, _, err = cp.client.SendGet(url, true, &httpDetails) return } // Backward compatibility httpDetails := cp.XscDetails.CreateHttpClientDetails() - url = fmt.Sprintf("%s%s/%s", utils.AddTrailingSlashIfNeeded(cp.XscDetails.GetUrl()), xscDeprecatedConfigProfileApiSuffix, profileName) + url = fmt.Sprintf("%s%s/%s", utils.AddTrailingSlashIfNeeded(cp.XscDetails.GetUrl()), xscDeprecatedConfigProfileByNameApiSuffix, profileName) resp, body, _, err = cp.client.SendGet(url, true, &httpDetails) return } -func (cp *ConfigurationProfileService) GetConfigurationProfile(profileName string) (*ConfigProfile, error) { - url, res, body, err := cp.sendConfigProfileRequest(profileName) +func (cp *ConfigurationProfileService) GetConfigurationProfileByName(profileName string) (*ConfigProfile, error) { + url, res, body, err := cp.sendConfigProfileByNameRequest(profileName) if err != nil { return nil, fmt.Errorf("failed to send GET query to '%s': %q", url, err) } @@ -127,3 +131,29 @@ func (cp *ConfigurationProfileService) GetConfigurationProfile(profileName strin err = errorutils.CheckError(json.Unmarshal(body, &profile)) return &profile, err } + +func (cp *ConfigurationProfileService) sendConfigProfileByUrlRequest(repoUrl string) (url string, resp *http.Response, body []byte, err error) { + if cp.XrayDetails == nil { + err = errors.New("received empty Xray details") + return + } + httpDetails := cp.XrayDetails.CreateHttpClientDetails() + url = fmt.Sprintf("%s%s%s", utils.AddTrailingSlashIfNeeded(cp.XrayDetails.GetUrl()), xscutils.XscInXraySuffix, xscConfigProfileByUrlApi) + requestContent := []byte(fmt.Sprintf(getProfileByUrlBody, repoUrl)) + resp, body, err = cp.client.SendPost(url, requestContent, &httpDetails) + return +} + +func (cp *ConfigurationProfileService) GetConfigurationProfileByUrl(url string) (*ConfigProfile, error) { + url, res, body, err := cp.sendConfigProfileByUrlRequest(url) + if err != nil { + return nil, fmt.Errorf("failed to send POST query to '%s': %q", url, err) + } + if err = errorutils.CheckResponseStatusWithBody(res, body, http.StatusOK); err != nil { + return nil, err + } + + var profile ConfigProfile + err = errorutils.CheckError(json.Unmarshal(body, &profile)) + return &profile, err +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 41023cd7..10b848ef 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -201,7 +201,7 @@ github.com/jedib0t/go-pretty/v6/text # github.com/jfrog/archiver/v3 v3.6.1 ## explicit; go 1.20 github.com/jfrog/archiver/v3 -# github.com/jfrog/build-info-go v1.10.6 +# github.com/jfrog/build-info-go v1.10.7 ## explicit; go 1.22 github.com/jfrog/build-info-go/build github.com/jfrog/build-info-go/build/utils @@ -225,7 +225,7 @@ github.com/jfrog/gofrog/safeconvert github.com/jfrog/gofrog/stringutils github.com/jfrog/gofrog/unarchive github.com/jfrog/gofrog/version -# github.com/jfrog/jfrog-cli-core/v2 v2.57.1 +# github.com/jfrog/jfrog-cli-core/v2 v2.57.3 ## explicit; go 1.23.3 github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils @@ -242,7 +242,7 @@ github.com/jfrog/jfrog-cli-core/v2/utils/ioutils github.com/jfrog/jfrog-cli-core/v2/utils/lock github.com/jfrog/jfrog-cli-core/v2/utils/log github.com/jfrog/jfrog-cli-core/v2/utils/osutils -# github.com/jfrog/jfrog-client-go v1.48.3 +# github.com/jfrog/jfrog-client-go v1.48.5 ## explicit; go 1.22.9 github.com/jfrog/jfrog-client-go/access github.com/jfrog/jfrog-client-go/access/auth @@ -265,6 +265,8 @@ github.com/jfrog/jfrog-client-go/evidence/auth github.com/jfrog/jfrog-client-go/evidence/services github.com/jfrog/jfrog-client-go/http/httpclient github.com/jfrog/jfrog-client-go/http/jfroghttpclient +github.com/jfrog/jfrog-client-go/jfconnect +github.com/jfrog/jfrog-client-go/jfconnect/services github.com/jfrog/jfrog-client-go/lifecycle github.com/jfrog/jfrog-client-go/lifecycle/auth github.com/jfrog/jfrog-client-go/lifecycle/services