Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
eyalbe4 committed Jun 10, 2024
2 parents 0e5f28c + d887950 commit a291658
Show file tree
Hide file tree
Showing 24 changed files with 181 additions and 2,782 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x
cache: false

- name: Static Code Analysis
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x
cache: false

- name: Run Gosec Security Scanner
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/frogbot-scan-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ jobs:
# "frogbot" GitHub environment can approve the pull request to be scanned.
environment: frogbot
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
cache: false

- uses: jfrog/frogbot@v2
env:
JFROG_CLI_LOG_LEVEL: "DEBUG"
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/frogbot-scan-repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
# The repository scanning will be triggered periodically on the following branches.
branch: [ "dev" ]
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
cache: false

- uses: jfrog/frogbot@v2
env:
JFROG_CLI_LOG_LEVEL: "DEBUG"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x
cache: false

- name: Install NuGet
Expand Down
22 changes: 11 additions & 11 deletions artifactory/commands/golang/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,12 @@ func (gc *GoCommand) run() (err error) {
if err != nil {
return
}
repoUrl, err := goutils.GetArtifactoryRemoteRepoUrl(resolverDetails, gc.resolverParams.TargetRepo())
// If noFallback=false, missing packages will be fetched directly from VCS
repoUrl, err := goutils.GetArtifactoryRemoteRepoUrl(resolverDetails, gc.resolverParams.TargetRepo(), goutils.GoProxyUrlParams{Direct: !gc.noFallback})
if err != nil {
return
}
// If noFallback=false, missing packages will be fetched directly from VCS
if !gc.noFallback {
repoUrl += "|direct"
}

err = biutils.RunGo(gc.goArg, repoUrl)
if errorutils.CheckError(err) != nil {
err = coreutils.ConvertExitCodeError(err)
Expand Down Expand Up @@ -330,19 +328,21 @@ func buildPackageVersionRequest(name, branchName string) string {
return path.Join(packageVersionRequest, "latest.info")
}

func SetArtifactoryAsResolutionServer(serverDetails *config.ServerDetails, depsRepo string) (err error) {
err = setGoProxy(serverDetails, depsRepo)
if err != nil {
func SetArtifactoryAsResolutionServer(serverDetails *config.ServerDetails, depsRepo string, goProxyParams goutils.GoProxyUrlParams) (err error) {
if err = setGoProxy(serverDetails, depsRepo, goProxyParams); err != nil {
err = fmt.Errorf("failed while setting Artifactory as a dependencies resolution registry: %s", err.Error())
}
return
}

func setGoProxy(server *config.ServerDetails, remoteGoRepo string) error {
repoUrl, err := goutils.GetArtifactoryRemoteRepoUrl(server, remoteGoRepo)
func setGoProxy(server *config.ServerDetails, remoteGoRepo string, goProxyParams goutils.GoProxyUrlParams) error {
repoUrl, err := goutils.GetArtifactoryRemoteRepoUrl(server, remoteGoRepo, goProxyParams)
if err != nil {
return err
}
repoUrl += "|direct"
return os.Setenv("GOPROXY", repoUrl)
}

func SetGoModCache(cacheFolder string) error {
return os.Setenv("GOMODCACHE", cacheFolder)
}
12 changes: 11 additions & 1 deletion artifactory/commands/golang/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package golang
import (
"fmt"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
goutils "github.com/jfrog/jfrog-cli-core/v2/utils/golang"
testsutils "github.com/jfrog/jfrog-client-go/utils/tests"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -60,9 +61,18 @@ func TestSetArtifactoryAsResolutionServer(t *testing.T) {
cleanup := testsutils.SetEnvWithCallbackAndAssert(t, "GOPROXY", "")
defer cleanup()

assert.NoError(t, SetArtifactoryAsResolutionServer(server, repo))
assert.NoError(t, SetArtifactoryAsResolutionServer(server, repo, goutils.GoProxyUrlParams{Direct: true}))

serverUrlWithoutHttp := strings.TrimPrefix(server.ArtifactoryUrl, "http://")
expectedGoProxy := fmt.Sprintf("http://%s:%s@%sapi/go/%s|direct", server.User, server.Password, serverUrlWithoutHttp, repo)
assert.Equal(t, expectedGoProxy, os.Getenv("GOPROXY"))

// Verify that the EndpointPrefix value is correctly added to the GOPROXY.
// In this test case, the endpoint prefix is set to api/curation/audit/.
// This parameter allows downloading dependencies from a custom API instead of the default one.
assert.NoError(t, SetArtifactoryAsResolutionServer(server, repo, goutils.GoProxyUrlParams{Direct: true, EndpointPrefix: coreutils.CurationPassThroughApi}))

serverUrlWithoutHttp = strings.TrimPrefix(server.ArtifactoryUrl, "http://")
expectedGoProxy = fmt.Sprintf("http://%s:%s@%sapi/curation/audit/api/go/%s|direct", server.User, server.Password, serverUrlWithoutHttp, repo)
assert.Equal(t, expectedGoProxy, os.Getenv("GOPROXY"))
}
22 changes: 22 additions & 0 deletions artifactory/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
ioutils "github.com/jfrog/gofrog/io"
"github.com/jfrog/jfrog-client-go/evidence"
"io"
"net/http"
"net/url"
Expand Down Expand Up @@ -214,6 +215,27 @@ func CreateLifecycleServiceManager(serviceDetails *config.ServerDetails, isDryRu
return lifecycle.New(serviceConfig)
}

func CreateEvidenceServiceManager(serviceDetails *config.ServerDetails, isDryRun bool) (*evidence.EvidenceServicesManager, error) {
certsPath, err := coreutils.GetJfrogCertsDir()
if err != nil {
return nil, err
}
evdAuth, err := serviceDetails.CreateEvidenceAuthConfig()
if err != nil {
return nil, err
}
serviceConfig, err := clientConfig.NewConfigBuilder().
SetServiceDetails(evdAuth).
SetCertificatesPath(certsPath).
SetInsecureTls(serviceDetails.InsecureTls).
SetDryRun(isDryRun).
Build()
if err != nil {
return nil, err
}
return evidence.New(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")
Expand Down
68 changes: 0 additions & 68 deletions general/cisetup/cisetup.go

This file was deleted.

69 changes: 0 additions & 69 deletions general/cisetup/githubactionsfilegenerator.go

This file was deleted.

Loading

0 comments on commit a291658

Please sign in to comment.