From 07be942c9e9e342586e303557fdc7321d31c3416 Mon Sep 17 00:00:00 2001 From: Bhanu Reddy Date: Mon, 4 Sep 2023 15:05:34 +0530 Subject: [PATCH 1/3] Introducing validate signed pipelines --- go.mod | 2 +- go.sum | 4 +- pipelines/commands/ValidateSignedPipelines.go | 78 +++++++++++++++++++ 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 pipelines/commands/ValidateSignedPipelines.go diff --git a/go.mod b/go.mod index fffdf86a1..2d6d32d43 100644 --- a/go.mod +++ b/go.mod @@ -94,7 +94,7 @@ 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.20230831152946-6ed2ae1aa57f +replace github.com/jfrog/jfrog-client-go => github.com/bhanurp/jfrog-client-go v0.0.0-20230904192757-e76adff9e71b replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230831151231-e5e7bd035ddc diff --git a/go.sum b/go.sum index 27735d28e..885880f01 100644 --- a/go.sum +++ b/go.sum @@ -60,6 +60,8 @@ github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/bhanurp/jfrog-client-go v0.0.0-20230904192757-e76adff9e71b h1:tRC1vjvgb6EFMzU8aTHxYN0D3R84a/HHV1LgC1j5rDI= +github.com/bhanurp/jfrog-client-go v0.0.0-20230904192757-e76adff9e71b/go.mod h1:uUnMrqHX7Xi+OCaZEE4b3BtsmGeOSCB7XqaEWVXEH/E= github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oMMlVBbn9M= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= @@ -198,8 +200,6 @@ github.com/jfrog/build-info-go v1.8.9-0.20230831151231-e5e7bd035ddc h1:pqu82clhP github.com/jfrog/build-info-go v1.8.9-0.20230831151231-e5e7bd035ddc/go.mod h1:QEskae5fQpjeY2PBzsjWtUQVskYSNDF2sSmw/Gx44dQ= github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk= github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0= -github.com/jfrog/jfrog-client-go v1.28.1-0.20230831152946-6ed2ae1aa57f h1:S6l0o2sKFLRJ+QYVB5U/PJhrnwFSmKFFY7eHpRPRH8A= -github.com/jfrog/jfrog-client-go v1.28.1-0.20230831152946-6ed2ae1aa57f/go.mod h1:uUnMrqHX7Xi+OCaZEE4b3BtsmGeOSCB7XqaEWVXEH/E= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= diff --git a/pipelines/commands/ValidateSignedPipelines.go b/pipelines/commands/ValidateSignedPipelines.go new file mode 100644 index 000000000..717ba501b --- /dev/null +++ b/pipelines/commands/ValidateSignedPipelines.go @@ -0,0 +1,78 @@ +package commands + +import ( + "github.com/jfrog/jfrog-cli-core/v2/pipelines/manager" + "github.com/jfrog/jfrog-cli-core/v2/utils/config" +) + +type ValidateSignedPipelinesCommand struct { + serverDetails *config.ServerDetails + artifactType string + buildName string + buildNumber string + projectKey string + artifactPath string + releaseBundleName string + releaseBundleVersion string +} + +func NewValidateSignedPipelinesCommand() *ValidateSignedPipelinesCommand { + return &ValidateSignedPipelinesCommand{} +} + +func (vspc *ValidateSignedPipelinesCommand) ServerDetails() (*config.ServerDetails, error) { + return vspc.serverDetails, nil +} + +func (vspc *ValidateSignedPipelinesCommand) SetServerDetails(serverDetails *config.ServerDetails) *ValidateSignedPipelinesCommand { + vspc.serverDetails = serverDetails + return vspc +} + +func (vspc *ValidateSignedPipelinesCommand) CommandName() string { + return "pl_validate_signed_pipelines" +} + +func (vspc *ValidateSignedPipelinesCommand) SetArtifactType(artifact string) *ValidateSignedPipelinesCommand { + vspc.artifactType = artifact + return vspc +} + +func (vspc *ValidateSignedPipelinesCommand) SetBuildName(name string) *ValidateSignedPipelinesCommand { + vspc.buildName = name + return vspc +} + +func (vspc *ValidateSignedPipelinesCommand) SetBuildNumber(number string) *ValidateSignedPipelinesCommand { + vspc.buildNumber = number + return vspc +} + +func (vspc *ValidateSignedPipelinesCommand) SetProjectKey(project string) *ValidateSignedPipelinesCommand { + vspc.projectKey = project + return vspc +} + +func (vspc *ValidateSignedPipelinesCommand) SetArtifactPath(artifact string) *ValidateSignedPipelinesCommand { + vspc.artifactPath = artifact + return vspc +} + +func (vspc *ValidateSignedPipelinesCommand) SetReleaseBundleName(name string) *ValidateSignedPipelinesCommand { + vspc.releaseBundleName = name + return vspc +} + +func (vspc *ValidateSignedPipelinesCommand) SetReleaseBundleVersion(version string) *ValidateSignedPipelinesCommand { + vspc.releaseBundleVersion = version + return vspc +} + +func (vspc *ValidateSignedPipelinesCommand) Run() error { + serviceManager, err := manager.CreateServiceManager(vspc.serverDetails) + if err != nil { + return err + } + err = serviceManager.ValidateSignedPipelines(vspc.artifactType, vspc.buildName, vspc.buildNumber, vspc.projectKey, vspc.artifactPath, vspc.releaseBundleName, vspc.releaseBundleVersion) + return err +} From 0ccd69810a0f73ad4f65038ff2c7b06dd7775525 Mon Sep 17 00:00:00 2001 From: Bhanu Reddy Date: Mon, 13 Nov 2023 16:43:08 +0530 Subject: [PATCH 2/3] Converted signed pipelines api parameters --- go.mod | 4 ++-- go.sum | 18 ++++++++++-------- pipelines/commands/ValidateSignedPipelines.go | 16 +++++++++++++++- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index a32e750d1..5a2bbd90f 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/google/uuid v1.3.1 github.com/gookit/color v1.5.4 github.com/jedib0t/go-pretty/v6 v6.4.8 - github.com/jfrog/build-info-go v1.9.14 + github.com/jfrog/build-info-go v1.9.15 github.com/jfrog/gofrog v1.3.1 github.com/jfrog/jfrog-apps-config v1.0.1 github.com/jfrog/jfrog-client-go v1.34.3 @@ -99,6 +99,6 @@ require ( gopkg.in/warnings.v0 v0.1.2 // indirect ) -replace github.com/jfrog/jfrog-client-go => github.com/bhanurp/jfrog-client-go v0.0.0-20230904192757-e76adff9e71b +replace github.com/jfrog/jfrog-client-go => github.com/bhanurp/jfrog-client-go v0.0.0-20231113111033-dfe217ecc7df replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20231031143744-13f94ab07bbc diff --git a/go.sum b/go.sum index 40fbfe8ac..4047c2f00 100644 --- a/go.sum +++ b/go.sum @@ -60,8 +60,8 @@ github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/bhanurp/jfrog-client-go v0.0.0-20230904192757-e76adff9e71b h1:tRC1vjvgb6EFMzU8aTHxYN0D3R84a/HHV1LgC1j5rDI= -github.com/bhanurp/jfrog-client-go v0.0.0-20230904192757-e76adff9e71b/go.mod h1:uUnMrqHX7Xi+OCaZEE4b3BtsmGeOSCB7XqaEWVXEH/E= +github.com/bhanurp/jfrog-client-go v0.0.0-20231113111033-dfe217ecc7df h1:1nUnhxY7v7m2fe9Hk8nT9fPuZ5HgirtFLrEm1Tm6aEE= +github.com/bhanurp/jfrog-client-go v0.0.0-20231113111033-dfe217ecc7df/go.mod h1:0PVhP6xGvBBaUzOU9LKf5OYkke/gY2IFILHA++iabFM= github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oMMlVBbn9M= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= @@ -196,12 +196,14 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jedib0t/go-pretty/v6 v6.4.7 h1:lwiTJr1DEkAgzljsUsORmWsVn5MQjt1BPJdPCtJ6KXE= -github.com/jedib0t/go-pretty/v6 v6.4.7/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs= -github.com/jfrog/build-info-go v1.8.9-0.20230831151231-e5e7bd035ddc h1:pqu82clhPKyUKJcljMuxYa+kviaWnHycLNCLqZZNl30= -github.com/jfrog/build-info-go v1.8.9-0.20230831151231-e5e7bd035ddc/go.mod h1:QEskae5fQpjeY2PBzsjWtUQVskYSNDF2sSmw/Gx44dQ= -github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk= -github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0= +github.com/jedib0t/go-pretty/v6 v6.4.8 h1:HiNzyMSEpsBaduKhmK+CwcpulEeBrTmxutz4oX/oWkg= +github.com/jedib0t/go-pretty/v6 v6.4.8/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs= +github.com/jfrog/build-info-go v1.8.9-0.20231031143744-13f94ab07bbc h1:MFejgCB90z7nA/KP48lF1t04tYuXAAQc53cBaFd9zcw= +github.com/jfrog/build-info-go v1.8.9-0.20231031143744-13f94ab07bbc/go.mod h1:ujJ8XQZMdT2tMkLSMJNyDd1pCY+duwHdjV+9or9FLIg= +github.com/jfrog/gofrog v1.3.1 h1:QqAwQXCVReT724uga1AYqG/ZyrNQ6f+iTxmzkb+YFQk= +github.com/jfrog/gofrog v1.3.1/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0= +github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY= +github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= diff --git a/pipelines/commands/ValidateSignedPipelines.go b/pipelines/commands/ValidateSignedPipelines.go index 717ba501b..71dd9b6a7 100644 --- a/pipelines/commands/ValidateSignedPipelines.go +++ b/pipelines/commands/ValidateSignedPipelines.go @@ -3,6 +3,7 @@ package commands import ( "github.com/jfrog/jfrog-cli-core/v2/pipelines/manager" "github.com/jfrog/jfrog-cli-core/v2/utils/config" + "github.com/jfrog/jfrog-client-go/pipelines/services" ) type ValidateSignedPipelinesCommand struct { @@ -73,6 +74,19 @@ func (vspc *ValidateSignedPipelinesCommand) Run() error { if err != nil { return err } - err = serviceManager.ValidateSignedPipelines(vspc.artifactType, vspc.buildName, vspc.buildNumber, vspc.projectKey, vspc.artifactPath, vspc.releaseBundleName, vspc.releaseBundleVersion) + artifactTypeInfo := services.ArtifactTypeInfo{} + artifactTypeInfo.BuildNumber = vspc.buildNumber + artifactTypeInfo.BuildName = vspc.buildName + artifactTypeInfo.ProjectKey = vspc.projectKey + artifactTypeInfo.ArtifactPath = vspc.artifactPath + artifactTypeInfo.RbName = vspc.releaseBundleName + artifactTypeInfo.RbVersion = vspc.releaseBundleVersion + artifactType := services.Artifact + if vspc.artifactType == "buildInfo" { + artifactType = services.BuildInfo + } else if vspc.artifactType == "releaseBundle" { + artifactType = services.ReleaseBundle + } + err = serviceManager.ValidateSignedPipelines(artifactTypeInfo, artifactType) return err } From 596b8dcf454a05702db561e738137f22e163cbf5 Mon Sep 17 00:00:00 2001 From: Bhanu Reddy Date: Wed, 29 Nov 2023 07:40:28 +0530 Subject: [PATCH 3/3] Updated artifact type and build failures --- artifactory/commands/buildinfo/adddependencies.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- pipelines/commands/ValidateSignedPipelines.go | 4 ++-- xray/commands/scan/scan.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/artifactory/commands/buildinfo/adddependencies.go b/artifactory/commands/buildinfo/adddependencies.go index 1754a546c..7dd3258f0 100644 --- a/artifactory/commands/buildinfo/adddependencies.go +++ b/artifactory/commands/buildinfo/adddependencies.go @@ -262,7 +262,7 @@ func collectPatternMatchingFiles(addDepsParams *specutils.CommonParams, rootPath return nil, err } - paths, err := fspatterns.ListFiles(rootPath, addDepsParams.IsRecursive(), addDepsParams.IsIncludeDirs(), true, excludePathPattern) + paths, err := fspatterns.ListFiles(rootPath, addDepsParams.IsRecursive(), addDepsParams.IsIncludeDirs(), true, false, excludePathPattern) if err != nil { return nil, err } diff --git a/go.mod b/go.mod index 5a2bbd90f..737d98b1b 100644 --- a/go.mod +++ b/go.mod @@ -99,6 +99,6 @@ require ( gopkg.in/warnings.v0 v0.1.2 // indirect ) -replace github.com/jfrog/jfrog-client-go => github.com/bhanurp/jfrog-client-go v0.0.0-20231113111033-dfe217ecc7df +replace github.com/jfrog/jfrog-client-go => github.com/bhanurp/jfrog-client-go v0.0.0-20231129012627-32b9ad75d217 replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20231031143744-13f94ab07bbc diff --git a/go.sum b/go.sum index 4047c2f00..d47ef486a 100644 --- a/go.sum +++ b/go.sum @@ -60,8 +60,8 @@ github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/bhanurp/jfrog-client-go v0.0.0-20231113111033-dfe217ecc7df h1:1nUnhxY7v7m2fe9Hk8nT9fPuZ5HgirtFLrEm1Tm6aEE= -github.com/bhanurp/jfrog-client-go v0.0.0-20231113111033-dfe217ecc7df/go.mod h1:0PVhP6xGvBBaUzOU9LKf5OYkke/gY2IFILHA++iabFM= +github.com/bhanurp/jfrog-client-go v0.0.0-20231129012627-32b9ad75d217 h1:y4zDWb6mA35S1iudNJg6jmG6E75/kGJhW/qNAcXqdnE= +github.com/bhanurp/jfrog-client-go v0.0.0-20231129012627-32b9ad75d217/go.mod h1:0PVhP6xGvBBaUzOU9LKf5OYkke/gY2IFILHA++iabFM= github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oMMlVBbn9M= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= diff --git a/pipelines/commands/ValidateSignedPipelines.go b/pipelines/commands/ValidateSignedPipelines.go index 71dd9b6a7..3142df872 100644 --- a/pipelines/commands/ValidateSignedPipelines.go +++ b/pipelines/commands/ValidateSignedPipelines.go @@ -82,9 +82,9 @@ func (vspc *ValidateSignedPipelinesCommand) Run() error { artifactTypeInfo.RbName = vspc.releaseBundleName artifactTypeInfo.RbVersion = vspc.releaseBundleVersion artifactType := services.Artifact - if vspc.artifactType == "buildInfo" { + if vspc.artifactType == services.BuildInfo.String() { artifactType = services.BuildInfo - } else if vspc.artifactType == "releaseBundle" { + } else if vspc.artifactType == services.ReleaseBundle.String() { artifactType = services.ReleaseBundle } err = serviceManager.ValidateSignedPipelines(artifactTypeInfo, artifactType) diff --git a/xray/commands/scan/scan.go b/xray/commands/scan/scan.go index 7a291a21c..705c666b2 100644 --- a/xray/commands/scan/scan.go +++ b/xray/commands/scan/scan.go @@ -410,7 +410,7 @@ func collectPatternMatchingFiles(fileData spec.File, rootPath string, dataHandle return err } - paths, err := fspatterns.ListFiles(rootPath, recursive, false, false, excludePathPattern) + paths, err := fspatterns.ListFiles(rootPath, recursive, false, false, false, excludePathPattern) if err != nil { return err }