From 1b154032882c3065f0add9e2af9473afa7b4f0da Mon Sep 17 00:00:00 2001 From: Eran Turgeman Date: Wed, 2 Jul 2025 16:13:03 +0300 Subject: [PATCH 1/3] Adding new AppTrust service manager --- utils/apptrust/apptrustmanager.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 utils/apptrust/apptrustmanager.go diff --git a/utils/apptrust/apptrustmanager.go b/utils/apptrust/apptrustmanager.go new file mode 100644 index 000000000..17b20fea0 --- /dev/null +++ b/utils/apptrust/apptrustmanager.go @@ -0,0 +1,30 @@ +package apptrust + +import ( + "github.com/jfrog/jfrog-cli-core/v2/utils/config" + "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" + "github.com/jfrog/jfrog-client-go/apptrust" + clientconfig "github.com/jfrog/jfrog-client-go/config" +) + +func CreateApptrustServiceManager(serviceDetails *config.ServerDetails) (*apptrust.ApptrustServicesManager, error) { + certsPath, err := coreutils.GetJfrogCertsDir() + if err != nil { + return nil, err + } + + apptrustDetails, err := serviceDetails.CreateApptrustAuthConfig() + if err != nil { + return nil, err + } + + serviceConfig, err := clientconfig.NewConfigBuilder(). + SetServiceDetails(apptrustDetails). + SetCertificatesPath(certsPath). + SetInsecureTls(serviceDetails.InsecureTls). + Build() + if err != nil { + return nil, err + } + return apptrust.New(serviceConfig) +} From 78ae99ae0e4fec0db28877bfc8f4f57fae5cf318 Mon Sep 17 00:00:00 2001 From: Eran Turgeman Date: Wed, 2 Jul 2025 16:13:25 +0300 Subject: [PATCH 2/3] Adding Evaluation service implementation + empty test file --- utils/apptrust/evaluate.go | 38 +++++++++++++++++++++++++++++++++ utils/apptrust/evaluate_test.go | 10 +++++++++ 2 files changed, 48 insertions(+) create mode 100644 utils/apptrust/evaluate.go create mode 100644 utils/apptrust/evaluate_test.go diff --git a/utils/apptrust/evaluate.go b/utils/apptrust/evaluate.go new file mode 100644 index 000000000..a9d56131c --- /dev/null +++ b/utils/apptrust/evaluate.go @@ -0,0 +1,38 @@ +package apptrust + +import ( + "fmt" + "github.com/jfrog/jfrog-cli-core/v2/utils/config" + "github.com/jfrog/jfrog-client-go/apptrust/services" +) + +const ( + evaluationPrAction = "application:pr" + evaluationDevelopmentStage = "development" + evaluationPrResourceType = "pr" +) + +func GetEvaluation(serverDetails *config.ServerDetails, applicationKey, msi, gitRepoUrl string) (*services.EvaluateResponse, error) { + apptrustService, err := CreateApptrustServiceManager(serverDetails) + if err != nil { + return nil, err + } + + // TODO eran: the parameters here got changed, revisit implementation + requestParams := services.EvaluateRequest{ + Action: evaluationPrAction, // TODO eran: are there other options here? + Context: services.EvaluateContext{Stage: evaluationDevelopmentStage}, // TODO eran: are there other options here? + Resource: services.EvaluateResource{ + ApplicationKey: applicationKey, + Type: evaluationPrResourceType, // TODO eran: are there other options here? + MultiScanId: msi, + GitRepoUrl: gitRepoUrl, + }, + } + + evaluation, err := apptrustService.Evaluate(requestParams) + if err != nil { + return nil, fmt.Errorf("failed to get evaluation for '%s' application with msi '%s' and git repo '%s': %w", applicationKey, msi, err) + } + return &evaluation, nil +} diff --git a/utils/apptrust/evaluate_test.go b/utils/apptrust/evaluate_test.go new file mode 100644 index 000000000..97fdb4129 --- /dev/null +++ b/utils/apptrust/evaluate_test.go @@ -0,0 +1,10 @@ +package apptrust + +import ( + "testing" +) + +// TODO eran: complete after figuring out the final input and output of the evaluation +func TestGetEvaluation(t *testing.T) { + +} From 455219884d2ebd412b772aba46e12e0f80eebf32 Mon Sep 17 00:00:00 2001 From: Eran Turgeman Date: Wed, 2 Jul 2025 16:13:35 +0300 Subject: [PATCH 3/3] go mod --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 515b7af7f..a6c3dafdd 100644 --- a/go.mod +++ b/go.mod @@ -115,9 +115,9 @@ 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.20250619121353-6ff3439c999d +replace github.com/jfrog/jfrog-client-go => github.com/eranturgeman/jfrog-client-go v0.0.0-20250702124746-524e5e2eec7f -replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250619122826-54ff6f65b128 +replace github.com/jfrog/jfrog-cli-core/v2 => github.com/eranturgeman/jfrog-cli-core/v2 v2.0.0-20250702130655-9799dfaf931c replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory v0.3.3-0.20250619124342-b7fdc5494ce6 diff --git a/go.sum b/go.sum index 5ac16191e..4d9675e24 100644 --- a/go.sum +++ b/go.sum @@ -57,6 +57,10 @@ github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVoIbS6XaE= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/eranturgeman/jfrog-cli-core/v2 v2.0.0-20250702130655-9799dfaf931c h1:IomGo8cqcZw0WBA+sL+1bnFAI6/lXLplnixO4G24XTI= +github.com/eranturgeman/jfrog-cli-core/v2 v2.0.0-20250702130655-9799dfaf931c/go.mod h1:Os+FBzbs7k1NCI6K5ewzIwD+nluk1WQvAnIbWrPlwmo= +github.com/eranturgeman/jfrog-client-go v0.0.0-20250702124746-524e5e2eec7f h1:iDmYR8j+b8xmcLGYXjmD3O6EZGJhhMLtCzVywa+bIWM= +github.com/eranturgeman/jfrog-client-go v0.0.0-20250702124746-524e5e2eec7f/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/forPelevin/gomoji v1.3.0 h1:WPIOLWB1bvRYlKZnSSEevLt3IfKlLs+tK+YA9fFYlkE= @@ -126,10 +130,6 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w= github.com/jfrog/jfrog-cli-artifactory v0.3.3-0.20250619124342-b7fdc5494ce6 h1:0hTNoMFqzN8rhxWLZ5EIvxM1KRg1wynVA1tGu0BJbtI= github.com/jfrog/jfrog-cli-artifactory v0.3.3-0.20250619124342-b7fdc5494ce6/go.mod h1:WRA+JW1jaESrUaGhHgTl3tFKx0EVHe1qNuN86QC6ma0= -github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250619122826-54ff6f65b128 h1:SdNS8Z1H1c1wgtHxZJNjLf9cWx+zdfXDQPmjUwQ55Bo= -github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250619122826-54ff6f65b128/go.mod h1:JDMYJHxU3W0/jaiiSljHLAcd0QeEGwpAwsnOqVR8c/0= -github.com/jfrog/jfrog-client-go v1.28.1-0.20250619121353-6ff3439c999d h1:0TNgRnYr92lmxC4my2P07MqaWmYBuLP/sgoCD5k/fhA= -github.com/jfrog/jfrog-client-go v1.28.1-0.20250619121353-6ff3439c999d/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=