Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions xray/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (sm *XrayServicesManager) AddBuildsToIndexing(buildNames []string) error {
func (sm *XrayServicesManager) IsTokenValidationEnabled() (isEnabled bool, err error) {
jasConfigService := services.NewJasConfigService(sm.client)
jasConfigService.XrayDetails = sm.config.GetServiceDetails()
jasConfigService.ScopeProjectKey = sm.scopeProjectKey
return jasConfigService.GetJasConfigTokenValidation()
}

Expand Down
12 changes: 9 additions & 3 deletions xray/services/jasconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package services
import (
"encoding/json"
"errors"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"net/http"

"github.com/jfrog/jfrog-client-go/auth"
Expand All @@ -16,8 +17,9 @@ const (

// JasConfigService returns the https client and Xray details
type JasConfigService struct {
client *jfroghttpclient.JfrogHttpClient
XrayDetails auth.ServiceDetails
client *jfroghttpclient.JfrogHttpClient
XrayDetails auth.ServiceDetails
ScopeProjectKey string
}

// NewJasConfigService creates a new service to retrieve the version of Xray
Expand All @@ -33,7 +35,7 @@ func (jcs *JasConfigService) GetXrayDetails() auth.ServiceDetails {
// GetJasConfigTokenValidation returns token validation status in xray
func (jcs *JasConfigService) GetJasConfigTokenValidation() (bool, error) {
httpDetails := jcs.XrayDetails.CreateHttpClientDetails()
resp, body, _, err := jcs.client.SendGet(jcs.XrayDetails.GetUrl()+jasConfigApiURL, true, &httpDetails)
resp, body, _, err := jcs.client.SendGet(jcs.getUrlForJasConfigApi(), true, &httpDetails)
if err != nil {
return false, errors.New("failed while attempting to get JFrog Xray Jas Configuration: " + err.Error())
}
Expand All @@ -47,6 +49,10 @@ func (jcs *JasConfigService) GetJasConfigTokenValidation() (bool, error) {
return *jasConfig.TokenValidationToggle, nil
}

func (jcs *JasConfigService) getUrlForJasConfigApi() string {
return clientutils.AppendScopedProjectKeyParam(jcs.XrayDetails.GetUrl()+jasConfigApiURL, jcs.ScopeProjectKey)
}

type JasConfig struct {
TokenValidationToggle *bool `json:"enable_token_validation_scanning,omitempty"`
}
Loading