From 86374a192686d14cf4808d15dacc39a65a5ef987 Mon Sep 17 00:00:00 2001 From: Robi Nino Date: Mon, 7 Mar 2022 15:49:14 +0200 Subject: [PATCH] Add Static Analysis (#1465) --- .github/PULL_REQUEST_TEMPLATE.md | 1 + .github/workflows/analysis.yml | 29 ++++++++ README.md | 12 ++-- artifactory/cli.go | 7 +- artifactory_test.go | 17 +++-- buildinfo_test.go | 1 - buildtools/cli.go | 56 +++++++-------- completion/shells/generate_scripts_test.go | 2 + config/cli.go | 5 +- distribution_test.go | 3 +- docker_test.go | 55 +++++++-------- docs/common/helputils.go | 4 +- general/cisetup/cisetup.go | 79 +++++++++++----------- general/cisetup/utils.go | 3 + go.mod | 6 +- go.sum | 8 +-- go_test.go | 2 +- gradle_test.go | 3 +- inttestutils/buildinfo.go | 3 + main_test.go | 3 +- maven_test.go | 1 - npm_test.go | 1 + pip_test.go | 26 +++---- plugins/commands/uninstall_test.go | 2 +- plugins_test.go | 4 +- scan/cli.go | 2 +- staticcheck.conf | 1 + unit_test.go | 2 +- utils/cliutils/codegangstautils.go | 4 +- utils/cliutils/utils.go | 36 ++++------ utils/progressbar/progressbar.go | 6 +- utils/tests/proxy/server/server.go | 3 + utils/tests/utils.go | 2 +- xray/cli.go | 21 +++--- 34 files changed, 218 insertions(+), 192 deletions(-) create mode 100644 .github/workflows/analysis.yml create mode 100644 staticcheck.conf diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a2ff77c50..f10575440 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,5 @@ - [ ] All [tests](https://github.com/jfrog/jfrog-cli#tests) passed. If this feature is not already covered by the tests, I added new tests. +- [ ] All [static analysis checks](https://github.com/jfrog/jfrog-cli/actions/workflows/analysis.yml) passed. - [ ] This pull request is on the dev branch. - [ ] I used gofmt for formatting the code before submitting the pull request. ----- diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml new file mode 100644 index 000000000..c62a825c3 --- /dev/null +++ b/.github/workflows/analysis.yml @@ -0,0 +1,29 @@ +name: "Static Analysis" +on: ["push", "pull_request"] +jobs: + Static-Check: + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.17.x + - name: Static Code Analysis + uses: dominikh/staticcheck-action@v1 + + Go-Sec: + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.17.x + - name: Install gosec + run: curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin + - name: Run gosec + # Temporary ignoring G301,G302,G306 + run: gosec -exclude=G204,G301,G302,G304,G306 -exclude-dir=\.*test\.* ./... \ No newline at end of file diff --git a/README.md b/README.md index a6fbfca55..194031e88 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,12 @@ -| Branch | Status | -| :----: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | -| v2 | [![JFrog CLI Tests](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml/badge.svg?branch=v2)](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml) | -| dev | [![JFrog CLI Tests](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml/badge.svg?branch=dev)](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml) | -| v1 | [![JFrog CLI Tests](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml/badge.svg?branch=v1)](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml) | -| dev-v1 | [![JFrog CLI Tests](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml/badge.svg?branch=dev-v1)](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml) | +| Branch | Status | +|:------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| +| v2 | [![JFrog CLI Tests](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml/badge.svg?branch=v2)](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml) [![Static Analysis](https://github.com/jfrog/jfrog-cli/actions/workflows/analysis.yml/badge.svg?branch=v2)](https://github.com/jfrog/jfrog-cli/actions/workflows/analysis.yml) | +| dev | [![JFrog CLI Tests](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml/badge.svg?branch=dev)](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml) [![Static Analysis](https://github.com/jfrog/jfrog-cli/actions/workflows/analysis.yml/badge.svg?branch=dev)](https://github.com/jfrog/jfrog-cli/actions/workflows/analysis.yml) | +| v1 | [![JFrog CLI Tests](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml/badge.svg?branch=v1)](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml) | +| dev-v1 | [![JFrog CLI Tests](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml/badge.svg?branch=dev-v1)](https://github.com/jfrog/jfrog-cli/actions/workflows/tests.yml) | # Table of Contents diff --git a/artifactory/cli.go b/artifactory/cli.go index bb31b23c9..9e12ddd42 100644 --- a/artifactory/cli.go +++ b/artifactory/cli.go @@ -23,7 +23,6 @@ import ( "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" containerutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container" "github.com/jfrog/jfrog-cli-core/v2/common/commands" - coreCommonCommands "github.com/jfrog/jfrog-cli-core/v2/common/commands" "github.com/jfrog/jfrog-cli-core/v2/common/spec" corecommon "github.com/jfrog/jfrog-cli-core/v2/docs/common" coreConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config" @@ -1846,7 +1845,7 @@ func curlCmd(c *cli.Context) error { } func newRtCurlCommand(c *cli.Context) (*curl.RtCurlCommand, error) { - curlCommand := coreCommonCommands.NewCurlCommand().SetArguments(cliutils.ExtractCommand(c)) + curlCommand := commands.NewCurlCommand().SetArguments(cliutils.ExtractCommand(c)) rtCurlCommand := curl.NewRtCurlCommand(*curlCommand) rtDetails, err := rtCurlCommand.GetServerDetails() if err != nil { @@ -1870,8 +1869,8 @@ func pipDeprecatedInstallCmd(c *cli.Context) error { // Get pip configuration. pipConfig, err := utils.GetResolutionOnlyConfiguration(utils.Pip) if err != nil { - return errors.New(fmt.Sprintf("Error occurred while attempting to read pip-configuration file: %s\n"+ - "Please run 'jfrog rt pip-config' command prior to running 'jfrog rt %s'.", err.Error(), "pip-install")) + return fmt.Errorf("error occurred while attempting to read pip-configuration file: %s\n"+ + "Please run 'jfrog rt pip-config' command prior to running 'jfrog rt %s'", err.Error(), "pip-install") } // Set arg values. diff --git a/artifactory_test.go b/artifactory_test.go index 1764cf892..86b05e71c 100644 --- a/artifactory_test.go +++ b/artifactory_test.go @@ -1109,6 +1109,7 @@ func TestArtifactoryUploadAsArchive(t *testing.T) { assert.NoError(t, err) runRt(t, "upload", "--spec="+uploadSpecFile) searchFilePath, err := tests.CreateSpec(tests.SearchAllRepo1) + assert.NoError(t, err) verifyExistInArtifactory(tests.GetUploadAsArchive(), searchFilePath, t) // Verify the properties are valid @@ -1190,6 +1191,7 @@ func TestArtifactoryUploadAsArchiveWithIncludeDirs(t *testing.T) { assert.NoError(t, fileutils.RemoveTempDir(tests.Out), "Couldn't remove temp dir") assert.NoError(t, os.MkdirAll(tests.Out, 0777)) downloadSpecFile, err = tests.CreateSpec(tests.DownloadWithoutExplodeArchives) + assert.NoError(t, err) runRt(t, "download", "--spec="+downloadSpecFile) // Change working directory to the zip file's location and unzip it. wd, err := os.Getwd() @@ -1322,6 +1324,7 @@ func TestArtifactorySelfSignedCert(t *testing.T) { fileSpec := spec.NewBuilder().Pattern(tests.RtRepo1 + "/*.zip").Recursive(true).BuildSpec() assert.NoError(t, err) parsedUrl, err := url.Parse(serverDetails.ArtifactoryUrl) + assert.NoError(t, err) serverDetails.ArtifactoryUrl = "https://127.0.0.1:" + cliproxy.GetProxyHttpsPort() + parsedUrl.RequestURI() // The server is using self-signed certificates @@ -1383,6 +1386,7 @@ func TestArtifactoryClientCert(t *testing.T) { fileSpec := spec.NewBuilder().Pattern(tests.RtRepo1 + "/*.zip").Recursive(true).BuildSpec() assert.NoError(t, err) parsedUrl, err := url.Parse(serverDetails.ArtifactoryUrl) + assert.NoError(t, err) serverDetails.ArtifactoryUrl = "https://127.0.0.1:" + cliproxy.GetProxyHttpsPort() + parsedUrl.RequestURI() serverDetails.InsecureTls = true @@ -1536,6 +1540,7 @@ func prepareArtifactoryUrlForProxyTest(t *testing.T) string { rtUrl, err := url.Parse(serverDetails.ArtifactoryUrl) assert.NoError(t, err) rtHost, port, err := net.SplitHostPort(rtUrl.Host) + assert.NoError(t, err) if rtHost == "localhost" || rtHost == "127.0.0.1" { externalIp, err := getExternalIP() assert.NoError(t, err) @@ -2183,8 +2188,8 @@ func TestSymlinkInsideSymlinkDirWithRecursionIssueUpload(t *testing.T) { func validateSymLink(localLinkPath, localFilePath string, t *testing.T) { // In macOS, localFilePath may lead to /var/folders/dn instead of /private/var/folders/dn. - // EvalSymlinks in localLinkPath should fix it. - localFilePath, err := filepath.EvalSymlinks(localLinkPath) + // EvalSymlinks on localFilePath will fix it a head of the comparison at the end of this function. + localFilePath, err := filepath.EvalSymlinks(localFilePath) assert.NoError(t, err) exists := fileutils.IsPathSymlink(localLinkPath) @@ -3236,6 +3241,7 @@ func TestArtifactoryDownloadByArchiveEntriesCli(t *testing.T) { func triggerArchiveIndexing(t *testing.T) { client, err := httpclient.ClientBuilder().Build() + assert.NoError(t, err) resp, _, err := client.SendPost(serverDetails.ArtifactoryUrl+"api/archiveIndex/"+tests.RtRepo1, []byte{}, artHttpDetails, "") if err != nil { assert.NoError(t, err, "archive indexing failed") @@ -4848,7 +4854,7 @@ func TestArtifactoryReplicationCreate(t *testing.T) { runRt(t, "rpldel", tests.RtRepo1) // Validate delete replication - result, err = servicesManager.GetReplication(tests.RtRepo1) + _, err = servicesManager.GetReplication(tests.RtRepo1) assert.Error(t, err) // Cleanup cleanArtifactoryTest() @@ -5093,6 +5099,7 @@ func simpleUploadWithAntPatternSpec(t *testing.T) { assert.NoError(t, err) verifyExistInArtifactory(tests.GetSimpleAntPatternUploadExpectedRepo1(), searchFilePath, t) searchFilePath, err = tests.CreateSpec(tests.SearchRepo1NonExistFile) + assert.NoError(t, err) verifyDoesntExistInArtifactory(searchFilePath, t) } @@ -5118,6 +5125,7 @@ func TestUploadWithAntPatternAndExclusionsSpec(t *testing.T) { assert.NoError(t, err) verifyExistInArtifactory(tests.GetAntPatternUploadWithExclusionsExpectedRepo1(), searchFilePath, t) searchFilePath, err = tests.CreateSpec(tests.SearchRepo1NonExistFileAntExclusions) + assert.NoError(t, err) verifyDoesntExistInArtifactory(searchFilePath, t) cleanArtifactoryTest() } @@ -5312,11 +5320,12 @@ func prepareTerraformProject(projectName string, t *testing.T, copyDirs bool) st // Copy terraform tests to test environment, so we can change project's config file. assert.NoError(t, fileutils.CopyDir(projectPath, testdataTarget, copyDirs, nil)) paths, err := fileutils.ListFilesRecursiveWalkIntoDirSymlink(testdataTarget, false) + assert.NoError(t, err) for _, f := range paths { fmt.Println(f) } configFileDir := filepath.Join(filepath.FromSlash(testdataTarget), ".jfrog", "projects") - configFileDir, err = tests.ReplaceTemplateVariables(filepath.Join(configFileDir, "terraform.yaml"), configFileDir) + _, err = tests.ReplaceTemplateVariables(filepath.Join(configFileDir, "terraform.yaml"), configFileDir) assert.NoError(t, err) return testdataTarget } diff --git a/buildinfo_test.go b/buildinfo_test.go index 7f7899045..6b0e5b568 100644 --- a/buildinfo_test.go +++ b/buildinfo_test.go @@ -916,5 +916,4 @@ type buildAddDepsBuildInfoTestParams struct { expectedDependencies []string buildName string buildNumber string - validationFunc func(*testing.T, buildAddDepsBuildInfoTestParams) } diff --git a/buildtools/cli.go b/buildtools/cli.go index f55fe1e94..9d0e5a538 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -3,17 +3,6 @@ package buildtools import ( "errors" "fmt" - "os" - "strconv" - "strings" - - "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/terraform" - terraformdocs "github.com/jfrog/jfrog-cli/docs/artifactory/terraform" - "github.com/jfrog/jfrog-cli/docs/artifactory/terraformconfig" - - commandUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils" - containerutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container" - "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container" "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/dotnet" "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/golang" @@ -21,13 +10,17 @@ import ( "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/mvn" "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/npm" "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/python" - commandsutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils" + "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/terraform" + commandsUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils" "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/yarn" "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" + containerutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container" "github.com/jfrog/jfrog-cli-core/v2/common/commands" corecommon "github.com/jfrog/jfrog-cli-core/v2/docs/common" coreConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config" "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" + terraformdocs "github.com/jfrog/jfrog-cli/docs/artifactory/terraform" + "github.com/jfrog/jfrog-cli/docs/artifactory/terraformconfig" "github.com/jfrog/jfrog-cli/docs/buildtools/docker" dotnetdocs "github.com/jfrog/jfrog-cli/docs/buildtools/dotnet" "github.com/jfrog/jfrog-cli/docs/buildtools/dotnetconfig" @@ -54,6 +47,9 @@ import ( "github.com/jfrog/jfrog-client-go/utils/errorutils" "github.com/jfrog/jfrog-client-go/utils/log" "github.com/urfave/cli" + "os" + "strconv" + "strings" ) const ( @@ -380,7 +376,7 @@ func MvnCmd(c *cli.Context) error { return err } if !exists { - return errors.New("No config file was found! Before running the mvn command on a project for the first time, the project should be configured with the mvn-config command. ") + return errors.New("no config file was found! Before running the mvn command on a project for the first time, the project should be configured with the mvn-config command") } if c.NArg() < 1 { return cliutils.WrongNumberOfArgumentsHandler(c) @@ -413,7 +409,7 @@ func MvnCmd(c *cli.Context) error { if !xrayScan && format != "" { return cliutils.PrintHelpAndReturnError("The --format option can be sent only with the --scan option", c) } - scanOutputFormat, err := commandsutils.GetXrayOutputFormat(format) + scanOutputFormat, err := commandsUtils.GetXrayOutputFormat(format) if err != nil { return err } @@ -438,7 +434,7 @@ func GradleCmd(c *cli.Context) error { return err } if !exists { - return errors.New("No config file was found! Before running the gradle command on a project for the first time, the project should be configured with the gradle-config command. ") + return errors.New("no config file was found! Before running the gradle command on a project for the first time, the project should be configured with the gradle-config command") } // Found a config file. Continue as native command. if c.NArg() < 1 { @@ -468,7 +464,7 @@ func GradleCmd(c *cli.Context) error { if !xrayScan && format != "" { return cliutils.PrintHelpAndReturnError("The --format option can be sent only with the --scan option", c) } - scanOutputFormat, err := commandsutils.GetXrayOutputFormat(format) + scanOutputFormat, err := commandsUtils.GetXrayOutputFormat(format) if err != nil { return err } @@ -493,7 +489,7 @@ func YarnCmd(c *cli.Context) error { return err } if !exists { - return errors.New(fmt.Sprintf("No config file was found! Before running the yarn command on a project for the first time, the project should be configured using the yarn-config command.")) + return fmt.Errorf("no config file was found! Before running the yarn command on a project for the first time, the project should be configured using the yarn-config command") } yarnCmd := yarn.NewYarnCommand().SetConfigFilePath(configFilePath).SetArgs(c.Args()) @@ -513,7 +509,7 @@ func NugetCmd(c *cli.Context) error { } if !exists { - return errors.New(fmt.Sprintf("No config file was found! Before running the nuget command on a project for the first time, the project should be configured using the nuget-config command.")) + return fmt.Errorf("no config file was found! Before running the nuget command on a project for the first time, the project should be configured using the nuget-config command") } rtDetails, targetRepo, useNugetV2, err := getNugetAndDotnetConfigFields(configFilePath) @@ -552,7 +548,7 @@ func DotnetCmd(c *cli.Context) error { return err } if !exists { - return errors.New(fmt.Sprintf("No config file was found! Before running the dotnet command on a project for the first time, the project should be configured using the dotnet-config command.")) + return fmt.Errorf("no config file was found! Before running the dotnet command on a project for the first time, the project should be configured using the dotnet-config command") } rtDetails, targetRepo, useNugetV2, err := getNugetAndDotnetConfigFields(configFilePath) @@ -582,7 +578,7 @@ func DotnetCmd(c *cli.Context) error { func getNugetAndDotnetConfigFields(configFilePath string) (rtDetails *coreConfig.ServerDetails, targetRepo string, useNugetV2 bool, err error) { vConfig, err := utils.ReadConfigFile(configFilePath, utils.YAML) if err != nil { - return nil, "", false, errors.New(fmt.Sprintf("Error occurred while attempting to read nuget-configuration file: %s", err.Error())) + return nil, "", false, fmt.Errorf("error occurred while attempting to read nuget-configuration file: %s", err.Error()) } projectConfig, err := utils.GetRepoConfigByPrefix(configFilePath, utils.ProjectConfigResolverPrefix, vConfig) if err != nil { @@ -656,13 +652,13 @@ func goCmdVerification(c *cli.Context) (string, error) { } // Verify config file is found. if !exists { - return "", errors.New(fmt.Sprintf("No config file was found! Before running the go command on a project for the first time, the project should be configured using the go-config command.")) + return "", fmt.Errorf("no config file was found! Before running the go command on a project for the first time, the project should be configured using the go-config command") } log.Debug("Go config file was found in:", configFilePath) return configFilePath, nil } -func printDetailedSummaryReportMvnGradle(originalErr error, result *commandsutils.Result) (err error) { +func printDetailedSummaryReportMvnGradle(originalErr error, result *commandsUtils.Result) (err error) { if len(result.Reader().GetFilesPaths()) == 0 { return errorutils.CheckErrorf("empty reader - no files paths") } @@ -712,7 +708,7 @@ func pullCmd(c *cli.Context, image string) error { if show, err := cliutils.ShowGenericCmdHelpIfNeeded(c, c.Args(), "dockerpullhelp"); show || err != nil { return err } - _, rtDetails, _, skipLogin, filteredDockerArgs, buildConfiguration, err := commandUtils.ExtractDockerOptionsFromArgs(c.Args()) + _, rtDetails, _, skipLogin, filteredDockerArgs, buildConfiguration, err := commandsUtils.ExtractDockerOptionsFromArgs(c.Args()) if err != nil { return err } @@ -735,7 +731,7 @@ func pushCmd(c *cli.Context, image string) error { if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil { return err } - threads, rtDetails, detailedSummary, skipLogin, filteredDockerArgs, buildConfiguration, err := commandUtils.ExtractDockerOptionsFromArgs(c.Args()) + threads, rtDetails, detailedSummary, skipLogin, filteredDockerArgs, buildConfiguration, err := commandsUtils.ExtractDockerOptionsFromArgs(c.Args()) if err != nil { return err } @@ -762,7 +758,7 @@ func dockerNativeCmd(c *cli.Context) error { if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil { return err } - _, _, _, _, cleanArgs, _, err := commandUtils.ExtractDockerOptionsFromArgs(c.Args()) + _, _, _, _, cleanArgs, _, err := commandsUtils.ExtractDockerOptionsFromArgs(c.Args()) if err != nil { return err } @@ -885,8 +881,8 @@ func pythonCmd(c *cli.Context, projectType utils.ProjectType) error { // Get pip configuration. pythonConfig, err := utils.GetResolutionOnlyConfiguration(projectType) if err != nil { - return errors.New(fmt.Sprintf("Error occurred while attempting to read %[1]s-configuration file: %[2]s\n"+ - "Please run 'jfrog rt %[1]s-config' command prior to running 'jfrog %[1]s'.", projectType.String(), err.Error())) + return fmt.Errorf("error occurred while attempting to read %[1]s-configuration file: %[2]s\n"+ + "Please run 'jfrog rt %[1]s-config' command prior to running 'jfrog %[1]s'", projectType.String(), err.Error()) } // Set arg values. @@ -915,7 +911,7 @@ func pythonInstallCmd(rtDetails *coreConfig.ServerDetails, targetRepo string, ar pipenvCmd.SetServerDetails(rtDetails).SetRepo(targetRepo).SetArgs(args) return commands.Exec(pipenvCmd) default: - return errors.New(fmt.Sprintf("python project type: %s is currently not supported", projectType.String())) + return fmt.Errorf("python project type: %s is currently not supported", projectType.String()) } } @@ -930,7 +926,7 @@ func pythonNativeCmd(cmdName string, rtDetails *coreConfig.ServerDetails, target pipenvCmd.SetServerDetails(rtDetails).SetRepo(targetRepo).SetArgs(args).SetCommandName(cmdName) return commands.Exec(pipenvCmd) default: - return errors.New(fmt.Sprintf("python project type: %s is currently not supported", projectType.String())) + return fmt.Errorf("python project type: %s is currently not supported", projectType.String()) } } @@ -959,7 +955,7 @@ func getTerraformConfigAndArgs(c *cli.Context) (configFilePath string, args []st } if !exists { - return "", nil, errors.New("No config file was found! Before running the terraform command on a project for the first time, the project should be configured using the terraform-config command. ") + return "", nil, errors.New("no config file was found! Before running the terraform command on a project for the first time, the project should be configured using the terraform-config command") } args = cliutils.ExtractCommand(c) return diff --git a/completion/shells/generate_scripts_test.go b/completion/shells/generate_scripts_test.go index 89ea1ec4a..529284126 100644 --- a/completion/shells/generate_scripts_test.go +++ b/completion/shells/generate_scripts_test.go @@ -44,6 +44,7 @@ func TestGenerateScripts(t *testing.T) { }() assert.NoError(t, err) b, err := ioutil.ReadAll(bashFile) + assert.NoError(t, err) assert.Equal(t, bash.BashAutocomplete, string(b)) // Check zsh completion script @@ -53,5 +54,6 @@ func TestGenerateScripts(t *testing.T) { }() assert.NoError(t, err) b, err = ioutil.ReadAll(zshFile) + assert.NoError(t, err) assert.Equal(t, zsh.ZshAutocomplete, string(b)) } diff --git a/config/cli.go b/config/cli.go index b55e5d2f8..a8257c533 100644 --- a/config/cli.go +++ b/config/cli.go @@ -170,8 +170,7 @@ func deleteCmd(c *cli.Context) error { // Clear all configurations if c.NArg() == 0 { - commands.ClearConfig(!quiet) - return nil + return commands.ClearConfig(!quiet) } // Delete single configuration @@ -221,7 +220,7 @@ func ValidateServerId(serverId string) error { reservedIds := []string{"delete", "use", "show", "clear"} for _, reservedId := range reservedIds { if serverId == reservedId { - return errors.New(fmt.Sprintf("Server can't have one of the following ID's: %s\n %s", strings.Join(reservedIds, ", "), cliutils.GetDocumentationMessage())) + return fmt.Errorf("server can't have one of the following ID's: %s\n %s", strings.Join(reservedIds, ", "), cliutils.GetDocumentationMessage()) } } return nil diff --git a/distribution_test.go b/distribution_test.go index e5686af04..4f9460740 100644 --- a/distribution_test.go +++ b/distribution_test.go @@ -191,9 +191,10 @@ func TestBundleDownloadNoPattern(t *testing.T) { err = tests.ValidateListsIdentical(tests.GetBuildSimpleDownload(), paths) assert.NoError(t, err) - // Download by bundle name and version version without pattern, b2 and b3 should not be downloaded, b1 should + // Download by bundle name and version without pattern, b2 and b3 should not be downloaded, b1 should tests.CleanFileSystem() specFile, err = tests.CreateSpec(tests.BundleDownloadSpecNoPattern) + assert.NoError(t, err) runRt(t, "dl", "--spec="+specFile, "--flat") // Validate files are downloaded by bundle version diff --git a/docker_test.go b/docker_test.go index 92a63fd5c..f6a448ab1 100644 --- a/docker_test.go +++ b/docker_test.go @@ -3,39 +3,34 @@ package main import ( "encoding/json" "fmt" - "github.com/jfrog/jfrog-cli-core/v2/xray/commands" - "github.com/jfrog/jfrog-cli-core/v2/xray/commands/scan" - clientUtils "github.com/jfrog/jfrog-client-go/xray/services/utils" - "io/ioutil" - "os" - "path" - "path/filepath" - "strconv" - "strings" - "testing" - "time" - "github.com/jfrog/build-info-go/entities" - buildinfo "github.com/jfrog/build-info-go/entities" - - "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" - "github.com/jfrog/jfrog-cli-core/v2/common/spec" - gofrogcmd "github.com/jfrog/gofrog/io" "github.com/jfrog/gofrog/version" - corecontainer "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container" - corecontainercmds "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container" + coreContainer "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container" "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic" + "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container" + "github.com/jfrog/jfrog-cli-core/v2/common/spec" "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" + "github.com/jfrog/jfrog-cli-core/v2/xray/commands" + "github.com/jfrog/jfrog-cli-core/v2/xray/commands/scan" "github.com/jfrog/jfrog-cli/inttestutils" "github.com/jfrog/jfrog-cli/utils/tests" "github.com/jfrog/jfrog-client-go/auth" clientutils "github.com/jfrog/jfrog-client-go/utils" "github.com/jfrog/jfrog-client-go/utils/io/fileutils" clientTestUtils "github.com/jfrog/jfrog-client-go/utils/tests" + clientUtils "github.com/jfrog/jfrog-client-go/xray/services/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "io/ioutil" + "os" + "path" + "path/filepath" + "strconv" + "strings" + "testing" + "time" ) const ( @@ -71,8 +66,8 @@ func initNativeDockerWithArtTest(t *testing.T) func() { require.NoError(t, err) rtVersion, err := servicesManager.GetVersion() require.NoError(t, err) - if !version.NewVersion(rtVersion).AtLeast(corecontainercmds.MinRtVersionForRepoFetching) { - t.Skip("Skipping native docker test. Artifactory version " + corecontainercmds.MinRtVersionForRepoFetching + " or higher is required (actual is'" + rtVersion + "').") + if !version.NewVersion(rtVersion).AtLeast(coreContainer.MinRtVersionForRepoFetching) { + t.Skip("Skipping native docker test. Artifactory version " + coreContainer.MinRtVersionForRepoFetching + " or higher is required (actual is'" + rtVersion + "').") } // Create server config to use with the command. createJfrogHomeConfig(t, true) @@ -124,7 +119,7 @@ func TestContainerPushWithDetailedSummary(t *testing.T) { buildNumber := "1" for _, repo := range []string{*tests.DockerLocalRepo, *tests.DockerVirtualRepo} { // Testing detailed summary without buildinfo - pushCommand := corecontainer.NewPushCommand(containerManager) + pushCommand := coreContainer.NewPushCommand(containerManager) pushCommand.SetThreads(1).SetDetailedSummary(true).SetCmdParams([]string{"push", imageTag}).SetBuildConfiguration(new(utils.BuildConfiguration)).SetRepo(*tests.DockerLocalRepo).SetServerDetails(serverDetails).SetImageTag(imageTag) assert.NoError(t, pushCommand.Run()) result := pushCommand.Result() @@ -146,7 +141,7 @@ func TestContainerPushWithDetailedSummary(t *testing.T) { assert.Equal(t, 64, len(transferDetails.Sha256), "Summary validation failed - invalid sha256 has returned from artifactory") } - inttestutils.ValidateGeneratedBuildInfoModule(t, tests.DockerBuildName, buildNumber, "", []string{module}, buildinfo.Docker) + inttestutils.ValidateGeneratedBuildInfoModule(t, tests.DockerBuildName, buildNumber, "", []string{module}, entities.Docker) runRt(t, "build-publish", tests.DockerBuildName, buildNumber) imagePath := path.Join(repo, imageName, "1") + "/" @@ -180,7 +175,7 @@ func runPushTest(containerManager container.ContainerManagerType, imageName, mod } defer inttestutils.ContainerTestCleanup(t, serverDetails, artHttpDetails, imageName, tests.DockerBuildName, repo) - inttestutils.ValidateGeneratedBuildInfoModule(t, tests.DockerBuildName, buildNumber, "", []string{module}, buildinfo.Docker) + inttestutils.ValidateGeneratedBuildInfoModule(t, tests.DockerBuildName, buildNumber, "", []string{module}, entities.Docker) runRt(t, "build-publish", tests.DockerBuildName, buildNumber) imagePath := path.Join(repo, imageName, "1") + "/" @@ -264,6 +259,7 @@ func TestRunPushFatManifestImage(t *testing.T) { searchCmd := generic.NewSearchCommand() searchCmd.SetServerDetails(serverDetails).SetSpec(spec) reader, err := searchCmd.Search() + assert.NoError(t, err) totalResults, err := reader.Length() assert.NoError(t, err) assert.Equal(t, 10, totalResults) @@ -373,7 +369,7 @@ func TestContainerFatManifestPull(t *testing.T) { return } buildInfo := publishedBuildInfo.BuildInfo - validateBuildInfo(buildInfo, t, 6, 0, imageName+":2.2", buildinfo.Docker) + validateBuildInfo(buildInfo, t, 6, 0, imageName+":2.2", entities.Docker) inttestutils.DeleteBuild(serverDetails.ArtifactoryUrl, tests.DockerBuildName, artHttpDetails) } @@ -418,7 +414,7 @@ func validateContainerBuild(buildName, buildNumber, imagePath, module string, ex return } buildInfo := publishedBuildInfo.BuildInfo - validateBuildInfo(buildInfo, t, expectedDependencies, expectedArtifacts, module, buildinfo.Docker) + validateBuildInfo(buildInfo, t, expectedDependencies, expectedArtifacts, module, entities.Docker) } func validateContainerImage(t *testing.T, imagePath string, expectedItemsInArtifactory int) { @@ -457,7 +453,7 @@ func TestKanikoBuildCollect(t *testing.T) { return } buildInfo := publishedBuildInfo.BuildInfo - validateBuildInfo(buildInfo, t, 0, 3, imageTag, buildinfo.Docker) + validateBuildInfo(buildInfo, t, 0, 3, imageTag, entities.Docker) // Cleanup. inttestutils.ContainerTestCleanup(t, serverDetails, artHttpDetails, imageName, tests.DockerBuildName, repo) @@ -522,7 +518,7 @@ func TestDockerScan(t *testing.T) { func runDockerScan(t *testing.T, imageName, watchName string, minViolations, minVulnerabilities, minLicenses int) { // Pull image from docker repo imageTag := path.Join(*tests.DockerRepoDomain, imageName) - dockerPullCommand := corecontainer.NewPullCommand(container.DockerClient) + dockerPullCommand := coreContainer.NewPullCommand(container.DockerClient) dockerPullCommand.SetCmdParams([]string{"pull", imageTag}).SetImageTag(imageTag).SetRepo(*tests.DockerVirtualRepo).SetServerDetails(serverDetails).SetBuildConfiguration(new(utils.BuildConfiguration)) if assert.NoError(t, dockerPullCommand.Run()) { defer inttestutils.DeleteTestImage(t, imageTag, container.DockerClient) @@ -589,6 +585,7 @@ func getExpectedFatManifestBuildInfo(t *testing.T) entities.BuildInfo { buildinfoFile, err := tests.ReplaceTemplateVariables(filepath.Join(testDir, tests.ExpectedFatManifestBuildInfo), tests.Out) assert.NoError(t, err) buildinfoFile, err = filepath.Abs(buildinfoFile) + assert.NoError(t, err) data, err := ioutil.ReadFile(buildinfoFile) assert.NoError(t, err) var buildinfo entities.BuildInfo @@ -607,7 +604,7 @@ func TestNativeDockerPushPull(t *testing.T) { // Add docker cli flag '-D' to check we ignore them runNativeDocker(t, "docker", "-D", "push", image, "--build-name="+tests.DockerBuildName, "--build-number="+pushBuildNumber, "--module="+module) - inttestutils.ValidateGeneratedBuildInfoModule(t, tests.DockerBuildName, pushBuildNumber, "", []string{module}, buildinfo.Docker) + inttestutils.ValidateGeneratedBuildInfoModule(t, tests.DockerBuildName, pushBuildNumber, "", []string{module}, entities.Docker) runRt(t, "build-publish", tests.DockerBuildName, pushBuildNumber) imagePath := path.Join(*tests.DockerLocalRepo, tests.DockerImageName, pushBuildNumber) + "/" validateContainerBuild(tests.DockerBuildName, pushBuildNumber, imagePath, module, 7, 5, 7, t) diff --git a/docs/common/helputils.go b/docs/common/helputils.go index 9f1b4644e..b8802de8a 100644 --- a/docs/common/helputils.go +++ b/docs/common/helputils.go @@ -4,8 +4,6 @@ import "strings" func CreateEnvVars(envVars ...string) string { var s []string - for _, envVar := range envVars { - s = append(s, envVar) - } + s = append(s, envVars...) return strings.Join(s[:], "\n\n") } diff --git a/general/cisetup/cisetup.go b/general/cisetup/cisetup.go index 1c4cc37f1..02f4f3aa6 100644 --- a/general/cisetup/cisetup.go +++ b/general/cisetup/cisetup.go @@ -4,44 +4,39 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" - "os" - "path" - "path/filepath" - "strings" - "syscall" - + "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" - + "github.com/go-git/go-git/v5/plumbing/transport" + "github.com/go-git/go-git/v5/plumbing/transport/http" "github.com/gookit/color" + "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/buildinfo" "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/permissiontarget" "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/usersmanagement" + rtutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" + coreCommonCommands "github.com/jfrog/jfrog-cli-core/v2/common/commands" "github.com/jfrog/jfrog-cli-core/v2/general/cisetup" repoutils "github.com/jfrog/jfrog-cli-core/v2/general/project" - "github.com/jfrog/jfrog-client-go/pipelines" - pipelinesservices "github.com/jfrog/jfrog-client-go/pipelines/services" - "github.com/jfrog/jfrog-client-go/utils" - - "github.com/go-git/go-git/v5" - "github.com/go-git/go-git/v5/plumbing/transport" - "github.com/go-git/go-git/v5/plumbing/transport/http" - "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/buildinfo" - rtutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" - "github.com/jfrog/jfrog-cli-core/v2/common/commands" - corecommoncommands "github.com/jfrog/jfrog-cli-core/v2/common/commands" - "github.com/jfrog/jfrog-cli-core/v2/utils/config" - utilsconfig "github.com/jfrog/jfrog-cli-core/v2/utils/config" + utilsConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config" "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" "github.com/jfrog/jfrog-cli-core/v2/utils/ioutils" buildinfocmd "github.com/jfrog/jfrog-client-go/artifactory/buildinfo" "github.com/jfrog/jfrog-client-go/artifactory/services" clientConfig "github.com/jfrog/jfrog-client-go/config" + "github.com/jfrog/jfrog-client-go/pipelines" + pipelinesservices "github.com/jfrog/jfrog-client-go/pipelines/services" + "github.com/jfrog/jfrog-client-go/utils" "github.com/jfrog/jfrog-client-go/utils/errorutils" "github.com/jfrog/jfrog-client-go/utils/io/fileutils" "github.com/jfrog/jfrog-client-go/utils/log" xrayservices "github.com/jfrog/jfrog-client-go/xray/services" xrayutils "github.com/jfrog/jfrog-client-go/xray/services/utils" - "golang.org/x/crypto/ssh/terminal" + "golang.org/x/term" + "io/ioutil" + "os" + "path" + "path/filepath" + "strings" + "syscall" ) const ( @@ -166,7 +161,7 @@ func saveVcsConf(conf *cisetup.CiSetupData) error { if err != nil { return errorutils.CheckError(err) } - err = ioutil.WriteFile(filepath.Join(homeDirPath, VcsConfigFile), []byte(content.String()), 0600) + err = ioutil.WriteFile(filepath.Join(homeDirPath, VcsConfigFile), content.Bytes(), 0600) return errorutils.CheckError(err) } @@ -249,7 +244,7 @@ func saveIfNoError(errCheck error, conf *cisetup.CiSetupData) error { } func runIdePhase() error { - serverDetails, err := utilsconfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) + serverDetails, err := utilsConfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) if err != nil { return err } @@ -260,7 +255,7 @@ func runIdePhase() error { return createPermissionTarget(serverDetails) } -func createGroup(serverDetails *utilsconfig.ServerDetails) error { +func createGroup(serverDetails *utilsConfig.ServerDetails) error { log.Info("Creating group...") groupCreateCmd := usersmanagement.NewGroupCreateCommand() groupCreateCmd.SetName(ideGroupName).SetServerDetails(serverDetails).SetReplaceIfExists(false) @@ -274,7 +269,7 @@ func createGroup(serverDetails *utilsconfig.ServerDetails) error { return nil } -func createPermissionTarget(serverDetails *utilsconfig.ServerDetails) error { +func createPermissionTarget(serverDetails *utilsConfig.ServerDetails) error { ptTemplate := fmt.Sprintf(permissionTargetTemplate, ideGroupName, permissionTargetName) tempDir, err := fileutils.CreateTempDir() if err != nil { @@ -311,7 +306,7 @@ func getPipelinesToken() (string, error) { if err != nil { return "", err } - byteToken, err = terminal.ReadPassword(int(syscall.Stdin)) + byteToken, err = term.ReadPassword(int(syscall.Stdin)) if err != nil { return "", errorutils.CheckError(err) } @@ -323,14 +318,14 @@ func getPipelinesToken() (string, error) { func runConfigCmd() (err error) { for { - configCmd := corecommoncommands.NewConfigCommand().SetInteractive(true).SetServerId(cisetup.ConfigServerId).SetEncPassword(true) + configCmd := coreCommonCommands.NewConfigCommand().SetInteractive(true).SetServerId(cisetup.ConfigServerId).SetEncPassword(true) err = configCmd.Config() if err != nil { log.Error(err) continue } // Validate JFrog credentials by execute get repo command - serviceDetails, err := utilsconfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) + serviceDetails, err := utilsConfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) if err != nil { return err } @@ -437,7 +432,7 @@ func (cc *CiSetupCommand) saveCiConfigToFile(ciConfig []byte, fileName string) e } func (cc *CiSetupCommand) getPipelinesCompletionInstruction(pipelinesFileName string) ([]string, error) { - serviceDetails, err := utilsconfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) + serviceDetails, err := utilsConfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) if err != nil { return []string{}, err } @@ -536,22 +531,22 @@ func (cc *CiSetupCommand) publishFirstBuild() (err error) { buildConfiguration := rtutils.NewBuildConfiguration(cc.data.BuildName, DefaultFirstBuildNumber, "", "") buildAddGitConfigurationCmd = buildAddGitConfigurationCmd.SetBuildConfiguration(buildConfiguration) log.Info("Generating an initial build-info...") - err = commands.Exec(buildAddGitConfigurationCmd) + err = coreCommonCommands.Exec(buildAddGitConfigurationCmd) if err != nil { return err } // Run BP Command. - serviceDetails, err := utilsconfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) + serviceDetails, err := utilsConfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) if err != nil { return err } buildInfoConfiguration := buildinfocmd.Configuration{DryRun: false} buildPublishCmd := buildinfo.NewBuildPublishCommand().SetServerDetails(serviceDetails).SetBuildConfiguration(buildConfiguration).SetConfig(&buildInfoConfiguration) - return commands.Exec(buildPublishCmd) + return coreCommonCommands.Exec(buildPublishCmd) } func (cc *CiSetupCommand) xrayConfigPhase() (err error) { - serviceDetails, err := utilsconfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) + serviceDetails, err := utilsConfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) if err != nil { return err } @@ -562,6 +557,9 @@ func (cc *CiSetupCommand) xrayConfigPhase() (err error) { // Index the build. buildsToIndex := []string{cc.data.BuildName} err = xrayManager.AddBuildsToIndexing(buildsToIndex) + if err != nil { + return err + } // Create new default policy. policyParams := xrayutils.NewPolicyParams() policyParams.Name = "ci-pipeline-security-policy" @@ -676,7 +674,7 @@ func getRepoSelectionFromUser(repos *[]services.RepositoryDetails, promptString return repo, nil } -func handleNewLocalRepository(serviceDetails *utilsconfig.ServerDetails, technologyType coreutils.Technology) (repo string) { +func handleNewLocalRepository(serviceDetails *utilsConfig.ServerDetails, technologyType coreutils.Technology) (repo string) { // Create local repository for { var newLocalRepo string @@ -691,7 +689,7 @@ func handleNewLocalRepository(serviceDetails *utilsconfig.ServerDetails, technol } func (cc *CiSetupCommand) interactivelyCreateRepos(technologyType coreutils.Technology) (err error) { - serviceDetails, err := utilsconfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) + serviceDetails, err := utilsConfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) if err != nil { return err } @@ -713,7 +711,7 @@ func (cc *CiSetupCommand) interactivelyCreateRepos(technologyType coreutils.Tech } cc.data.BuiltTechnology.LocalReleasesRepo = localRepo if technologyType == coreutils.Maven { - localRepo, err = getRepoSelectionFromUser(localRepos, fmt.Sprintf("Create or select an Artifactory snapshots Repository to deploy the build artifacts to")) + localRepo, err = getRepoSelectionFromUser(localRepos, "Create or select an Artifactory snapshots Repository to deploy the build artifacts to") if err != nil { return err } @@ -779,6 +777,9 @@ func (cc *CiSetupCommand) interactivelyCreateRepos(technologyType coreutils.Tech _, err := GetVirtualRepo(serviceDetails, virtualRepoName) if err == nil { err = CreateVirtualRepo(serviceDetails, technologyType, virtualRepoName, remoteRepo) + if err != nil { + return err + } break } else { virtualRepoName = fmt.Sprintf("%s-%d", virtualRepoName, i) @@ -979,7 +980,7 @@ func (cc *CiSetupCommand) gitPhase() (err error) { if err != nil { return err } - byteToken, err := terminal.ReadPassword(int(syscall.Stdin)) + byteToken, err := term.ReadPassword(int(syscall.Stdin)) if err != nil { log.Error(err) continue @@ -1012,7 +1013,7 @@ func (cc *CiSetupCommand) ciProviderPhase() (err error) { } if ciType == cisetup.Pipelines { // validate that pipelines is available. - serviceDetails, err := config.GetSpecificConfig(cisetup.ConfigServerId, false, false) + serviceDetails, err := utilsConfig.GetSpecificConfig(cisetup.ConfigServerId, false, false) if err != nil { log.Error(err) continue diff --git a/general/cisetup/utils.go b/general/cisetup/utils.go index cc3931add..94e025169 100644 --- a/general/cisetup/utils.go +++ b/general/cisetup/utils.go @@ -26,6 +26,9 @@ var buildCmdByTech = map[coreutils.Technology]string{ func CreateXrayServiceManager(serviceDetails *utilsconfig.ServerDetails) (*xray.XrayServicesManager, error) { xrayDetails, err := serviceDetails.CreateXrayAuthConfig() + if err != nil { + return nil, err + } serviceConfig, err := config.NewConfigBuilder(). SetServiceDetails(xrayDetails). Build() diff --git a/go.mod b/go.mod index e3ef6e804..fba2acaa8 100644 --- a/go.mod +++ b/go.mod @@ -20,13 +20,13 @@ require ( github.com/urfave/cli v1.22.5 github.com/vbauerster/mpb/v7 v7.1.5 github.com/xeipuuv/gojsonschema v1.2.0 - golang.org/x/crypto v0.0.0-20211202192323-5770296d904e + golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 gopkg.in/yaml.v2 v2.4.0 ) -replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.10.1-0.20220302130831-956e355b32cb +replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.10.1-0.20220307134618-940f00d5517b -replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.10.2-0.20220302134028-0bb5e5cc9291 +replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.10.2-0.20220307134746-4905ef6d1def // replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.0.7-0.20211128152632-e218c460d703 diff --git a/go.sum b/go.sum index 2f5038a8b..1228c53c3 100644 --- a/go.sum +++ b/go.sum @@ -240,10 +240,10 @@ github.com/jfrog/build-info-go v1.1.0 h1:vokwJ/FV64S+6ZCCt2dDhoFhOdBVBsnKc7ug/QF github.com/jfrog/build-info-go v1.1.0/go.mod h1:QyeMfNGt4W0eWazrd7j6uZVN5KTpB05nxF/MwvGnTqs= github.com/jfrog/gofrog v1.1.1 h1:uRjeZWidQl4FmKP4Zpj5hSKJp3gSIWW9VUwbQdVEVRU= github.com/jfrog/gofrog v1.1.1/go.mod h1:9YN5v4LlsCfLIXpwQnzSf1wVtgjdHM20FzuIu58RMI4= -github.com/jfrog/jfrog-cli-core/v2 v2.10.2-0.20220302134028-0bb5e5cc9291 h1:bqs4PPFw04gQ5YhEf6TrELdqi+xlhiHp6wjDMc9VVUc= -github.com/jfrog/jfrog-cli-core/v2 v2.10.2-0.20220302134028-0bb5e5cc9291/go.mod h1:NwrZRwu6mWCyCDFxbqgZzIkkjj1x+BSwCGduYN+8GPc= -github.com/jfrog/jfrog-client-go v1.10.1-0.20220302130831-956e355b32cb h1:Ti9kMqo5M6eliuLNhPtovw7tO4RMffME7iWPCML2rhg= -github.com/jfrog/jfrog-client-go v1.10.1-0.20220302130831-956e355b32cb/go.mod h1:baffLcHNfaxTSHA8EiGgswBGF0DqQQaXaraE+OJwSHg= +github.com/jfrog/jfrog-cli-core/v2 v2.10.2-0.20220307134746-4905ef6d1def h1:nm8wAIaXePpS69mEIDnpZ87i9C1GreFrWZVyjMjhixA= +github.com/jfrog/jfrog-cli-core/v2 v2.10.2-0.20220307134746-4905ef6d1def/go.mod h1:sg9I4dg/3UP/4KU4vTSD9kqnlCekX+ETkk0b/dvQkGw= +github.com/jfrog/jfrog-client-go v1.10.1-0.20220307134618-940f00d5517b h1:kevqGjB7WZE9GXoLAH8gE+I0Jg+9sS9N/ostHpXs9Js= +github.com/jfrog/jfrog-client-go v1.10.1-0.20220307134618-940f00d5517b/go.mod h1:baffLcHNfaxTSHA8EiGgswBGF0DqQQaXaraE+OJwSHg= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 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= diff --git a/go_test.go b/go_test.go index 31bbad5e2..1e8d17f2b 100644 --- a/go_test.go +++ b/go_test.go @@ -213,7 +213,7 @@ func prepareGoProject(projectName, configDestDir string, t *testing.T, copyDirs configDestDir = filepath.Join(projectPath, ".jfrog") } configFileDir := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "go", projectName, ".jfrog", "projects") - configFileDir, err = tests.ReplaceTemplateVariables(filepath.Join(configFileDir, "go.yaml"), filepath.Join(configDestDir, "projects")) + _, err = tests.ReplaceTemplateVariables(filepath.Join(configFileDir, "go.yaml"), filepath.Join(configDestDir, "projects")) assert.NoError(t, err) clientTestUtils.ChangeDirAndAssert(t, projectPath) log.Info("Using Go project located at ", projectPath) diff --git a/gradle_test.go b/gradle_test.go index 93d3689fd..28f72fdcc 100644 --- a/gradle_test.go +++ b/gradle_test.go @@ -22,7 +22,6 @@ import ( ) const ( - gradleFlagName = "gradle" gradleModuleId = ":minimal-example:1.0" ) @@ -137,7 +136,7 @@ func TestGradleBuildWithServerIDWithUsesPlugin(t *testing.T) { destPath := filepath.Join(filepath.Dir(buildGradlePath), ".jfrog", "projects") createConfigFile(destPath, configFilePath, t) err := os.Rename(filepath.Join(destPath, tests.GradleServerIDUsesPluginConfig), filepath.Join(destPath, "gradle.yaml")) - + assert.NoError(t, err) oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) buildName := tests.GradleBuildName buildNumber := "1" diff --git a/inttestutils/buildinfo.go b/inttestutils/buildinfo.go index d771664c3..a41d66cd6 100644 --- a/inttestutils/buildinfo.go +++ b/inttestutils/buildinfo.go @@ -25,6 +25,9 @@ func DeleteBuild(artifactoryUrl, buildName string, artHttpDetails httputils.Http restApi := path.Join("api/build/", buildName) params := map[string]string{"deleteAll": "1"} requestFullUrl, err := utils.BuildArtifactoryUrl(artifactoryUrl, restApi, params) + if err != nil { + log.Error(err) + } resp, body, err := client.SendDelete(requestFullUrl, nil, artHttpDetails, "") if err != nil { diff --git a/main_test.go b/main_test.go index aa7a32094..0196eb19b 100644 --- a/main_test.go +++ b/main_test.go @@ -116,6 +116,7 @@ func createJfrogHomeConfig(t *testing.T, encryptPassword bool) { config, err := commands.GetConfig("default", false) if err == nil && config.ServerId != "" { err = tests.NewJfrogCli(execMain, "jfrog config", "").Exec("rm", "default", "--quiet") + assert.NoError(t, err) } *tests.JfrogUrl = utils.AddTrailingSlashIfNeeded(*tests.JfrogUrl) err = tests.NewJfrogCli(execMain, "jfrog config", credentials).Exec("add", "default", "--interactive=false", "--artifactory-url="+*tests.JfrogUrl+tests.ArtifactoryEndpoint, "--xray-url="+*tests.JfrogUrl+tests.XrayEndpoint, "--enc-password="+strconv.FormatBool(encryptPassword)) @@ -240,7 +241,7 @@ func createConfigFile(inDir, configFilePath string, t *testing.T) { if _, err := os.Stat(inDir); os.IsNotExist(err) { assert.NoError(t, os.MkdirAll(inDir, 0777)) } - configFilePath, err := tests.ReplaceTemplateVariables(configFilePath, inDir) + _, err := tests.ReplaceTemplateVariables(configFilePath, inDir) assert.NoError(t, err) } diff --git a/maven_test.go b/maven_test.go index 9976fcda2..dc8da6361 100644 --- a/maven_test.go +++ b/maven_test.go @@ -22,7 +22,6 @@ import ( "github.com/stretchr/testify/assert" ) -const mavenFlagName = "maven" const mavenTestsProxyPort = "1028" const localRepoSystemProperty = "-Dmaven.repo.local=" diff --git a/npm_test.go b/npm_test.go index 417ac075b..d129c2017 100644 --- a/npm_test.go +++ b/npm_test.go @@ -453,6 +453,7 @@ func TestYarn(t *testing.T) { assert.NoError(t, err) // Get original http white list config origWhitelist, err := yarn.ConfigGet("unsafeHttpWhitelist", yarnExecPath, true) + assert.NoError(t, err) assert.NoError(t, yarn.ConfigSet("unsafeHttpWhitelist", "[\"localhost\"]", yarnExecPath, true)) defer func() { // Restore original whitelist config diff --git a/pip_test.go b/pip_test.go index d2c6eef0f..7f496783a 100644 --- a/pip_test.go +++ b/pip_test.go @@ -62,7 +62,7 @@ func testPipInstall(t *testing.T, isLegacy bool) { // Run test cases. for buildNumber, test := range allTests { t.Run(test.name, func(t *testing.T) { - err, cleanVirtualEnv := prepareVirtualEnv(t) + cleanVirtualEnv, err := prepareVirtualEnv(t) assert.NoError(t, err) if isLegacy { @@ -80,34 +80,34 @@ func testPipInstall(t *testing.T, isLegacy bool) { tests.CleanFileSystem() } -func prepareVirtualEnv(t *testing.T) (error, func()) { +func prepareVirtualEnv(t *testing.T) (func(), error) { // Create temp directory tmpDir, removeTempDir := coretests.CreateTempDirWithCallbackAndAssert(t) // Change current working directory to the temp directory currentDir, err := os.Getwd() if err != nil { - return err, removeTempDir + return removeTempDir, err } restoreCwd := clientTestUtils.ChangeDirWithCallback(t, currentDir, tmpDir) defer restoreCwd() // Create virtual environment if err = piputils.RunVirtualEnv(); err != nil { - return err, func() { + return func() { removeTempDir() - } + }, err } // Set cache dir unSetEnvCallback := clientTestUtils.SetEnvWithCallbackAndAssert(t, "PIP_CACHE_DIR", filepath.Join(tmpDir, "cache")) // Add virtual-environment path to 'PATH' for executing all pip and python commands inside the virtual-environment. - err, restorePathEnv := setPathEnvForPipInstall(t) - return err, func() { + restorePathEnv, err := setPathEnvForPipInstall(t) + return func() { removeTempDir() restorePathEnv() unSetEnvCallback() - } + }, err } func testPipCmd(t *testing.T, projectPath, buildNumber, module string, expectedDependencies int, args []string) { @@ -185,17 +185,17 @@ func initPipTest(t *testing.T) { require.True(t, isRepoExist(tests.PypiVirtualRepo), "Pypi test virtual repository doesn't exist.") } -func setPathEnvForPipInstall(t *testing.T) (error, func()) { +func setPathEnvForPipInstall(t *testing.T) (func(), error) { // Get absolute path to virtual environment virtualEnvPath, err := filepath.Abs(filepath.Join("venv", venvBinDirByOS())) if err != nil { - return err, func() {} + return func() {}, err } // Keep original value of 'PATH'. pathValue, exists := os.LookupEnv("PATH") if !exists { - return errors.New("Couldn't find PATH variable, failing pip tests"), func() {} + return func() {}, errors.New("Couldn't find PATH variable, failing pip tests") } // Append the path. @@ -206,9 +206,9 @@ func setPathEnvForPipInstall(t *testing.T) (error, func()) { newPathValue = fmt.Sprintf("%s:%s", virtualEnvPath, pathValue) } // Return original PATH value. - return os.Setenv("PATH", newPathValue), func() { + return func() { clientTestUtils.SetEnvAndAssert(t, "PATH", pathValue) - } + }, os.Setenv("PATH", newPathValue) } // Get the name of the directory inside venv dir that contains the bin files (different name in different OS's) diff --git a/plugins/commands/uninstall_test.go b/plugins/commands/uninstall_test.go index 9cd195ff0..6bed951f3 100644 --- a/plugins/commands/uninstall_test.go +++ b/plugins/commands/uninstall_test.go @@ -21,7 +21,7 @@ const pluginMockPath = "../../testdata/plugins/plugin-mock" func TestRunUninstallCmd(t *testing.T) { // Create temp jfrog home - err, cleanUpJfrogHome := coreTests.SetJfrogHome() + cleanUpJfrogHome, err := coreTests.SetJfrogHome() if err != nil { return } diff --git a/plugins_test.go b/plugins_test.go index a03e1d704..9a3c0295e 100644 --- a/plugins_test.go +++ b/plugins_test.go @@ -26,7 +26,7 @@ const customPluginName = "custom-plugin" func TestPluginInstallUninstallOfficialRegistry(t *testing.T) { initPluginsTest(t) // Create temp jfrog home - err, cleanUpJfrogHome := coreTests.SetJfrogHome() + cleanUpJfrogHome, err := coreTests.SetJfrogHome() if err != nil { return } @@ -161,7 +161,7 @@ func initPluginsTest(t *testing.T) { func TestPublishInstallCustomServer(t *testing.T) { initPluginsTest(t) // Create temp jfrog home - err, cleanUpJfrogHome := coreTests.SetJfrogHome() + cleanUpJfrogHome, err := coreTests.SetJfrogHome() if err != nil { return } diff --git a/scan/cli.go b/scan/cli.go index ce9882466..5260b005b 100644 --- a/scan/cli.go +++ b/scan/cli.go @@ -176,7 +176,7 @@ func AuditCmd(c *cli.Context) error { case coreutils.Pipenv: err = AuditPipenvCmd(c) case coreutils.Dotnet: - break + // Will be handled by Nuget. case coreutils.Nuget: err = AuditNugetCmd(c) default: diff --git a/staticcheck.conf b/staticcheck.conf new file mode 100644 index 000000000..d21e556ef --- /dev/null +++ b/staticcheck.conf @@ -0,0 +1 @@ +checks = ["all", "-ST1000", "-ST1003", "-ST1020", "-ST1021", "-ST1022"] \ No newline at end of file diff --git a/unit_test.go b/unit_test.go index a0976b2d9..9cc17f64f 100644 --- a/unit_test.go +++ b/unit_test.go @@ -18,7 +18,7 @@ const ( func TestUnitTests(t *testing.T) { // Create temp jfrog home - err, cleanUpJfrogHome := coreTests.SetJfrogHome() + cleanUpJfrogHome, err := coreTests.SetJfrogHome() if err != nil { log.Error(err) os.Exit(1) diff --git a/utils/cliutils/codegangstautils.go b/utils/cliutils/codegangstautils.go index 7c2412df6..04c15add3 100644 --- a/utils/cliutils/codegangstautils.go +++ b/utils/cliutils/codegangstautils.go @@ -21,9 +21,7 @@ func GetIntFlagValue(c *cli.Context, flagName string, defValue int) (int, error) func GetStringsArrFlagValue(c *cli.Context, flagName string) (resultArray []string) { if c.IsSet(flagName) { - for _, singleValue := range strings.Split(c.String(flagName), ";") { - resultArray = append(resultArray, singleValue) - } + resultArray = append(resultArray, strings.Split(c.String(flagName), ";")...) } return } diff --git a/utils/cliutils/utils.go b/utils/cliutils/utils.go index 62acc4180..9061ba7c3 100644 --- a/utils/cliutils/utils.go +++ b/utils/cliutils/utils.go @@ -2,29 +2,25 @@ package cliutils import ( "fmt" - "os" - "path/filepath" - "strings" - corecontainercmds "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container" commandUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils" artifactoryUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" containerutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container" - speccore "github.com/jfrog/jfrog-cli-core/v2/common/spec" - coreCommonCommands "github.com/jfrog/jfrog-cli-core/v2/common/commands" - "github.com/jfrog/jfrog-cli-core/v2/utils/config" + speccore "github.com/jfrog/jfrog-cli-core/v2/common/spec" coreConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config" "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" "github.com/jfrog/jfrog-cli-core/v2/utils/ioutils" "github.com/jfrog/jfrog-cli/utils/summary" - "github.com/jfrog/jfrog-client-go/utils" clientutils "github.com/jfrog/jfrog-client-go/utils" "github.com/jfrog/jfrog-client-go/utils/errorutils" "github.com/jfrog/jfrog-client-go/utils/io/content" "github.com/jfrog/jfrog-client-go/utils/log" "github.com/pkg/errors" "github.com/urfave/cli" + "os" + "path/filepath" + "strings" ) type CommandDomain string @@ -189,7 +185,7 @@ func CreateSummaryReportString(success, failed int, failNoOp bool, err error) (s if errorutils.CheckError(mErr) != nil { return "", mErr } - return utils.IndentJson(summaryContent), nil + return clientutils.IndentJson(summaryContent), nil } func CreateBuildInfoSummaryReportString(success, failed int, sha256 string, err error) (string, error) { @@ -198,7 +194,7 @@ func CreateBuildInfoSummaryReportString(success, failed int, sha256 string, err if errorutils.CheckError(mErr) != nil { return "", mErr } - return utils.IndentJson(buildInfoSummaryContent), mErr + return clientutils.IndentJson(buildInfoSummaryContent), mErr } func PrintHelpAndReturnError(msg string, context *cli.Context) error { @@ -277,7 +273,7 @@ func getOrDefaultEnv(arg, envKey string) string { } func ShouldOfferConfig() (bool, error) { - exists, err := config.IsServerConfExists() + exists, err := coreConfig.IsServerConfExists() if err != nil || exists { return false, err } @@ -287,7 +283,7 @@ func ShouldOfferConfig() (bool, error) { return false, err } if ci { - config.SaveServersConf(make([]*config.ServerDetails, 0)) + _ = coreConfig.SaveServersConf(make([]*coreConfig.ServerDetails, 0)) return false, nil } @@ -298,14 +294,14 @@ func ShouldOfferConfig() (bool, error) { "Configure now?", coreutils.CI) confirmed := coreutils.AskYesNo(msg, false) if !confirmed { - config.SaveServersConf(make([]*config.ServerDetails, 0)) + _ = coreConfig.SaveServersConf(make([]*coreConfig.ServerDetails, 0)) return false, nil } return true, nil } -func CreateServerDetailsFromFlags(c *cli.Context) (details *config.ServerDetails) { - details = new(config.ServerDetails) +func CreateServerDetailsFromFlags(c *cli.Context) (details *coreConfig.ServerDetails) { + details = new(coreConfig.ServerDetails) details.Url = clientutils.AddTrailingSlashIfNeeded(c.String(url)) details.ArtifactoryUrl = clientutils.AddTrailingSlashIfNeeded(c.String(configRtUrl)) details.DistributionUrl = clientutils.AddTrailingSlashIfNeeded(c.String(configDistUrl)) @@ -349,10 +345,7 @@ func overrideStringIfSet(field *string, c *cli.Context, fieldName string) { // If `fieldName` exist in the cli args, read it to `field` as an array split by `;`. func overrideArrayIfSet(field *[]string, c *cli.Context, fieldName string) { if c.IsSet(fieldName) { - *field = nil - for _, singleValue := range strings.Split(c.String(fieldName), ";") { - *field = append(*field, singleValue) - } + *field = append([]string{}, strings.Split(c.String(fieldName), ";")...) } } @@ -601,10 +594,7 @@ func logNonNativeCommandDeprecation(cmdName, oldSubcommand string) { } func shouldLogWarning() bool { - if strings.ToLower(os.Getenv(JfrogCliAvoidDeprecationWarnings)) == "true" { - return false - } - return true + return strings.ToLower(os.Getenv(JfrogCliAvoidDeprecationWarnings)) != "true" } func SetCliExecutableName(executablePath string) { diff --git a/utils/progressbar/progressbar.go b/utils/progressbar/progressbar.go index 49e6d559a..ab2dc3dbc 100644 --- a/utils/progressbar/progressbar.go +++ b/utils/progressbar/progressbar.go @@ -1,6 +1,7 @@ package progressbar import ( + "golang.org/x/term" "net/url" "os" "strings" @@ -17,7 +18,6 @@ import ( "github.com/jfrog/jfrog-client-go/utils/log" "github.com/vbauerster/mpb/v7" "github.com/vbauerster/mpb/v7/decor" - "golang.org/x/crypto/ssh/terminal" ) var terminalWidth int @@ -270,12 +270,12 @@ func shouldInitProgressBar() (bool, error) { // Check if Stderr is a terminal func isTerminal() bool { - return terminal.IsTerminal(int(os.Stderr.Fd())) + return term.IsTerminal(int(os.Stderr.Fd())) } // Get terminal dimensions func setTerminalWidthVar() error { - width, _, err := terminal.GetSize(int(os.Stderr.Fd())) + width, _, err := term.GetSize(int(os.Stderr.Fd())) // -5 to avoid edges terminalWidth = width - 5 return err diff --git a/utils/tests/proxy/server/server.go b/utils/tests/proxy/server/server.go index 275090150..b367cf217 100644 --- a/utils/tests/proxy/server/server.go +++ b/utils/tests/proxy/server/server.go @@ -99,6 +99,9 @@ func httpProxyHandler(w http.ResponseWriter, r *http.Request) { copyHeaders(w.Header(), resp.Header) w.WriteHeader(resp.StatusCode) _, err = io.Copy(w, resp.Body) + if err != nil { + clilog.Error(err) + } if err := resp.Body.Close(); err != nil { clilog.Error("Can't close response body %v", err) } diff --git a/utils/tests/utils.go b/utils/tests/utils.go index 16ce7e77a..6c55a91d9 100644 --- a/utils/tests/utils.go +++ b/utils/tests/utils.go @@ -131,7 +131,7 @@ func VerifyExistLocally(expected, actual []string, t *testing.T) { func ValidateListsIdentical(expected, actual []string) error { if len(actual) != len(expected) { - return errors.New(fmt.Sprintf("Unexpected behavior, \nexpected: [%s], \nfound: [%s]", strings.Join(expected, ", "), strings.Join(actual, ", "))) + return fmt.Errorf("unexpected behavior, \nexpected: [%s], \nfound: [%s]", strings.Join(expected, ", "), strings.Join(actual, ", ")) } err := compare(expected, actual) return err diff --git a/xray/cli.go b/xray/cli.go index e4ce40d70..7d04eda2d 100644 --- a/xray/cli.go +++ b/xray/cli.go @@ -2,27 +2,24 @@ package xray import ( "errors" - auditgodocs "github.com/jfrog/jfrog-cli/docs/xray/auditgo" - "github.com/jfrog/jfrog-cli/docs/xray/auditgradle" - "github.com/jfrog/jfrog-cli/docs/xray/auditmvn" - auditnpmdocs "github.com/jfrog/jfrog-cli/docs/xray/auditnpm" - auditpipdocs "github.com/jfrog/jfrog-cli/docs/xray/auditpip" - scandocs "github.com/jfrog/jfrog-cli/docs/xray/scan" - - "github.com/jfrog/jfrog-cli/scan" - "time" - - "github.com/jfrog/jfrog-cli-core/v2/common/commands" corecommon "github.com/jfrog/jfrog-cli-core/v2/common/commands" corecommondocs "github.com/jfrog/jfrog-cli-core/v2/docs/common" "github.com/jfrog/jfrog-cli-core/v2/xray/commands/curl" "github.com/jfrog/jfrog-cli-core/v2/xray/commands/offlineupdate" "github.com/jfrog/jfrog-cli/docs/common" + auditgodocs "github.com/jfrog/jfrog-cli/docs/xray/auditgo" + "github.com/jfrog/jfrog-cli/docs/xray/auditgradle" + "github.com/jfrog/jfrog-cli/docs/xray/auditmvn" + auditnpmdocs "github.com/jfrog/jfrog-cli/docs/xray/auditnpm" + auditpipdocs "github.com/jfrog/jfrog-cli/docs/xray/auditpip" curldocs "github.com/jfrog/jfrog-cli/docs/xray/curl" offlineupdatedocs "github.com/jfrog/jfrog-cli/docs/xray/offlineupdate" + scandocs "github.com/jfrog/jfrog-cli/docs/xray/scan" + "github.com/jfrog/jfrog-cli/scan" "github.com/jfrog/jfrog-cli/utils/cliutils" "github.com/jfrog/jfrog-client-go/utils/errorutils" "github.com/urfave/cli" + "time" ) const DateFormat = "2006-01-02" @@ -185,7 +182,7 @@ func curlCmd(c *cli.Context) error { if err != nil { return err } - return commands.Exec(xrCurlCmd) + return corecommon.Exec(xrCurlCmd) } func newXrCurlCommand(c *cli.Context) (*curl.XrCurlCommand, error) {