diff --git a/go.mod b/go.mod index 20330670..031fe141 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.6 require ( github.com/Masterminds/semver v1.5.0 github.com/jfrog/jfrog-cli-core/v2 v2.55.3 - github.com/jfrog/jfrog-client-go v1.44.2 + github.com/jfrog/jfrog-client-go v1.45.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 0d76957a..8d8122cf 100644 --- a/go.sum +++ b/go.sum @@ -98,8 +98,8 @@ github.com/jfrog/gofrog v1.7.5 h1:dFgtEDefJdlq9cqTRoe09RLxS5Bxbe1Ev5+E6SmZHcg= github.com/jfrog/gofrog v1.7.5/go.mod h1:jyGiCgiqSSR7k86hcUSu67XVvmvkkgWTmPsH25wI298= github.com/jfrog/jfrog-cli-core/v2 v2.55.3 h1:/PWlB8yxJlUjB9TdhQ5TIFjMMDXujNy5WJBFOOUoldc= github.com/jfrog/jfrog-cli-core/v2 v2.55.3/go.mod h1:2/Ccqq0ayMqIuH5AAoneX0CowwdrNWQcs5aKz8iDYkE= -github.com/jfrog/jfrog-client-go v1.44.2 h1:5t8tx6NOth6Xq24SdF3MYSd6vo0bTibW93nads2DEuY= -github.com/jfrog/jfrog-client-go v1.44.2/go.mod h1:f5Jfv+RGKVr4smOp4a4pxyBKdlpLG7R894kx2XW+w8c= +github.com/jfrog/jfrog-client-go v1.45.0 h1:CX+xlMdcvnG509PExwqJ17hzwVtFfkpeCyeKmDKKRNY= +github.com/jfrog/jfrog-client-go v1.45.0/go.mod h1:f5Jfv+RGKVr4smOp4a4pxyBKdlpLG7R894kx2XW+w8c= 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/jfrog-client-go/utils/utils.go b/vendor/github.com/jfrog/jfrog-client-go/utils/utils.go index cdb32db5..fb620c4e 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.44.2" + Version = "1.45.0" ) type MinVersionProduct string 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 010dac24..ff07b47b 100644 --- a/vendor/github.com/jfrog/jfrog-client-go/xsc/manager.go +++ b/vendor/github.com/jfrog/jfrog-client-go/xsc/manager.go @@ -75,3 +75,9 @@ func (sm *XscServicesManager) GetAnalyticsGeneralEvent(msi string) (*services.Xs eventService.XscDetails = sm.config.GetServiceDetails() return eventService.GetGeneralEvent(msi) } + +func (sm *XscServicesManager) GetConfigProfile(profileName string) (*services.ConfigProfile, error) { + configProfileService := services.NewConfigurationProfileService(sm.client) + configProfileService.XscDetails = sm.config.GetServiceDetails() + return configProfileService.GetConfigurationProfile(profileName) +} 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 new file mode 100644 index 00000000..7b750f91 --- /dev/null +++ b/vendor/github.com/jfrog/jfrog-client-go/xsc/services/profile.go @@ -0,0 +1,113 @@ +package services + +import ( + "encoding/json" + "fmt" + "github.com/jfrog/jfrog-client-go/auth" + "github.com/jfrog/jfrog-client-go/http/jfroghttpclient" + "github.com/jfrog/jfrog-client-go/utils" + "github.com/jfrog/jfrog-client-go/utils/errorutils" + "net/http" +) + +const ( + ConfigProfileMinXscVersion = "1.11.0" + xscConfigProfileApi = "api/v1/profile" +) + +type ConfigurationProfileService struct { + client *jfroghttpclient.JfrogHttpClient + XscDetails auth.ServiceDetails +} + +func NewConfigurationProfileService(client *jfroghttpclient.JfrogHttpClient) *ConfigurationProfileService { + return &ConfigurationProfileService{client: client} +} + +type ConfigProfile struct { + ProfileName string `json:"profile_name"` + FrogbotConfig FrogbotConfig `json:"frogbot_config,omitempty"` + Modules []Module `json:"modules"` + IsDefault bool `json:"is_default,omitempty"` +} + +type FrogbotConfig struct { + EmailAuthor string `json:"email_author,omitempty"` + AggregateFixes bool `json:"aggregate_fixes,omitempty"` + AvoidPreviousPrCommentsDeletion bool `json:"avoid_previous_pr_comments_deletion,omitempty"` + BranchNameTemplate string `json:"branch_name_template,omitempty"` + PrTitleTemplate string `json:"pr_title_template,omitempty"` + PrCommentTitle string `json:"pr_comment_title,omitempty"` + CommitMessageTemplate string `json:"commit_message_template,omitempty"` + ShowSecretsAsPrComment bool `json:"show_secrets_as_pr_comment,omitempty"` +} + +type Module struct { + ModuleId int32 `json:"module_id,omitempty"` + ModuleName string `json:"module_name"` + PathFromRoot string `json:"path_from_root"` + ReleasesRepo string `json:"releases_repo,omitempty"` + AnalyzerManagerVersion string `json:"analyzer_manager_version,omitempty"` + AdditionalPathsForModule []string `json:"additional_paths_for_module,omitempty"` + ExcludePaths []string `json:"exclude_paths,omitempty"` + ScanConfig ScanConfig `json:"scan_config"` + ProtectedBranches []string `json:"protected_branches,omitempty"` + IncludeExcludeMode int32 `json:"include_exclude_mode,omitempty"` + IncludeExcludePattern string `json:"include_exclude_pattern,omitempty"` + ReportAnalytics bool `json:"report_analytics,omitempty"` +} + +type ScanConfig struct { + ScanTimeout int32 `json:"scan_timeout,omitempty"` + ExcludePattern string `json:"exclude_pattern,omitempty"` + EnableScaScan bool `json:"enable_sca_scan,omitempty"` + EnableContextualAnalysisScan bool `json:"enable_contextual_analysis_scan,omitempty"` + SastScannerConfig SastScannerConfig `json:"sast_scanner_config,omitempty"` + SecretsScannerConfig SecretsScannerConfig `json:"secrets_scanner_config,omitempty"` + IacScannerConfig IacScannerConfig `json:"iac_scanner_config,omitempty"` + ApplicationsScannerConfig ApplicationsScannerConfig `json:"applications_scanner_config,omitempty"` + ServicesScannerConfig ServicesScannerConfig `json:"services_scanner_config,omitempty"` +} + +type SastScannerConfig struct { + EnableSastScan bool `json:"enable_sast_scan,omitempty"` + Language string `json:"language,omitempty"` + ExcludePatterns []string `json:"exclude_patterns,omitempty"` + ExcludeRules []string `json:"exclude_rules,omitempty"` +} + +type SecretsScannerConfig struct { + EnableSecretsScan bool `json:"enable_secrets_scan,omitempty"` + ExcludePatterns []string `json:"exclude_patterns,omitempty"` +} + +type IacScannerConfig struct { + EnableIacScan bool `json:"enable_iac_scan,omitempty"` + ExcludePatterns []string `json:"exclude_patterns,omitempty"` +} + +type ApplicationsScannerConfig struct { + EnableApplicationsScan bool `json:"enable_applications_scan,omitempty"` + ExcludePatterns []string `json:"exclude_patterns,omitempty"` +} + +type ServicesScannerConfig struct { + EnableServicesScan bool `json:"enable_services_scan,omitempty"` + ExcludePatterns []string `json:"exclude_patterns,omitempty"` +} + +func (cp *ConfigurationProfileService) GetConfigurationProfile(profileName string) (*ConfigProfile, error) { + httpDetails := cp.XscDetails.CreateHttpClientDetails() + url := fmt.Sprintf("%s%s/%s", utils.AddTrailingSlashIfNeeded(cp.XscDetails.GetUrl()), xscConfigProfileApi, profileName) + res, body, _, err := cp.client.SendGet(url, true, &httpDetails) + if err != nil { + return nil, fmt.Errorf("failed to send GET 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 bcee2fc2..dc55e686 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -237,7 +237,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.44.2 +# github.com/jfrog/jfrog-client-go v1.45.0 ## explicit; go 1.22 github.com/jfrog/jfrog-client-go/access github.com/jfrog/jfrog-client-go/access/auth