diff --git a/cli/scancommands.go b/cli/scancommands.go index 1bce0f86..c3405b98 100644 --- a/cli/scancommands.go +++ b/cli/scancommands.go @@ -1,14 +1,10 @@ package cli import ( + "errors" "fmt" - enrichDocs "github.com/jfrog/jfrog-cli-security/cli/docs/enrich" - "github.com/jfrog/jfrog-cli-security/commands/enrich" - "os" - "strings" - - "github.com/jfrog/jfrog-cli-core/v2/utils/usage" - + buildInfoUtils "github.com/jfrog/build-info-go/utils" + "github.com/jfrog/gofrog/datastructures" "github.com/jfrog/jfrog-cli-core/v2/common/cliutils" commandsCommon "github.com/jfrog/jfrog-cli-core/v2/common/commands" outputFormat "github.com/jfrog/jfrog-cli-core/v2/common/format" @@ -18,8 +14,15 @@ import ( "github.com/jfrog/jfrog-cli-core/v2/plugins/components" 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/usage" + enrichDocs "github.com/jfrog/jfrog-cli-security/cli/docs/enrich" + "github.com/jfrog/jfrog-cli-security/commands/enrich" + "github.com/jfrog/jfrog-cli-security/utils/xray" "github.com/jfrog/jfrog-client-go/utils/errorutils" "github.com/jfrog/jfrog-client-go/utils/log" + "github.com/urfave/cli" + "os" + "strings" flags "github.com/jfrog/jfrog-cli-security/cli/docs" auditSpecificDocs "github.com/jfrog/jfrog-cli-security/cli/docs/auditspecific" @@ -39,6 +42,7 @@ import ( ) const dockerScanCmdHiddenName = "dockerscan" +const SkipCurationAfterFailureEnv = "JFROG_CLI_SKIP_CURATION_AFTER_FAILURE" func getAuditAndScansCommands() []components.Command { return []components.Command{ @@ -510,21 +514,110 @@ func AuditSpecificCmd(c *components.Context, technology techutils.Technology) er } func CurationCmd(c *components.Context) error { - threads, err := pluginsCommon.GetThreadsCount(c) + curationAuditCommand, err := getCurationCommand(c) + if err != nil { + return err + } + return progressbar.ExecWithProgress(curationAuditCommand) +} + +var supportedCommandsForPostInstallationFailure = datastructures.MakeSetFromElements[string]( + "install", "build", "i", "add", "ci", "get", "mod", +) + +func IsSupportedCommandForCurationInspect(cmd string) bool { + return supportedCommandsForPostInstallationFailure.Exists(cmd) +} + +func WrapCmdWithCurationPostFailureRun(c *cli.Context, cmd func(c *cli.Context) error, technology techutils.Technology, cmdName string) error { + if err := cmd(c); err != nil { + CurationInspectAfterFailure(c, cmdName, technology, err) + return err + } + return nil +} + +func CurationInspectAfterFailure(c *cli.Context, cmdName string, technology techutils.Technology, errFromCmd error) { + if compContexts, errConvertCtx := components.ConvertContext(c); errConvertCtx == nil { + if errPostCuration := CurationCmdPostInstallationFailure(compContexts, technology, cmdName, errFromCmd); errPostCuration != nil { + log.Error(errPostCuration) + } + } else { + log.Error(errConvertCtx) + } +} + +func CurationCmdPostInstallationFailure(c *components.Context, tech techutils.Technology, cmdName string, originError error) error { + // check the command supported + curationAuditCommand, err, runCuration := ShouldRunCurationAfterFailure(c, tech, cmdName, originError) if err != nil { return err } + if !runCuration { + return nil + } + log.Info("Running curation audit after failure") + return progressbar.ExecWithProgress(curationAuditCommand) +} + +func ShouldRunCurationAfterFailure(c *components.Context, tech techutils.Technology, cmdName string, originError error) (curationCmd *curation.CurationAuditCommand, err error, runCuration bool) { + if !IsSupportedCommandForCurationInspect(cmdName) { + return + } + if os.Getenv(coreutils.OutputDirPathEnv) == "" || + os.Getenv(SkipCurationAfterFailureEnv) == "true" { + return + } + // check if the error is a forbidden error, if so, we don't want to run the curation audit automatically. + // this check have two parts: + // 1. check if the error is a forbidden error + // 2. check if the error message contains the forbidden error message, in case the output included in the error message. + forBiddenError := &buildInfoUtils.ForbiddenError{} + if !errors.Is(originError, forBiddenError) && !strings.Contains(originError.Error(), forBiddenError.Error()) && + !buildInfoUtils.IsForbiddenOutput(buildInfoUtils.PackageManager(tech.String()), originError.Error()) { + return + } + // If the command is not running in the context of GitHub actions, we don't want to run the curation audit automatically + curationCmd, err = getCurationCommand(c) + if err != nil { + return + } + // check if user entitled for curation + serverDetails, err := curationCmd.GetAuth(tech) + if err != nil { + return + } + xrayManager, err := xray.CreateXrayServiceManager(serverDetails) + if err != nil { + return + } + entitled, err := curation.IsEntitledForCuration(xrayManager) + if err != nil { + return + } + if !entitled { + log.Info("Curation feature is not entitled, skipping curation audit") + return + } + return curationCmd, nil, true +} + +func getCurationCommand(c *components.Context) (*curation.CurationAuditCommand, error) { + threads, err := pluginsCommon.GetThreadsCount(c) + if err != nil { + return nil, err + } curationAuditCommand := curation.NewCurationAuditCommand(). SetWorkingDirs(splitByCommaAndTrim(c.GetStringFlagValue(flags.WorkingDirs))). SetParallelRequests(threads) serverDetails, err := pluginsCommon.CreateServerDetailsWithConfigOffer(c, true, cliutils.Rt) if err != nil { - return err + return nil, err } format, err := curation.GetCurationOutputFormat(c.GetStringFlagValue(flags.OutputFormat)) if err != nil { - return err + return nil, err } curationAuditCommand.SetServerDetails(serverDetails). SetIsCurationCmd(true). @@ -534,7 +627,7 @@ func CurationCmd(c *components.Context) error { SetInsecureTls(c.GetBoolFlagValue(flags.InsecureTls)). SetNpmScope(c.GetStringFlagValue(flags.DepType)). SetPipRequirementsFile(c.GetStringFlagValue(flags.RequirementsFile)) - return progressbar.ExecWithProgress(curationAuditCommand) + return curationAuditCommand, nil } func DockerScanMockCommand() components.Command { diff --git a/cli/scancommands_test.go b/cli/scancommands_test.go new file mode 100644 index 00000000..7ce82286 --- /dev/null +++ b/cli/scancommands_test.go @@ -0,0 +1,153 @@ +package cli + +import ( + "errors" + commonCommands "github.com/jfrog/jfrog-cli-core/v2/common/commands" + coretests "github.com/jfrog/jfrog-cli-core/v2/common/tests" + "github.com/jfrog/jfrog-cli-core/v2/utils/config" + "github.com/jfrog/jfrog-client-go/utils/io/fileutils" + clienttestutils "github.com/jfrog/jfrog-client-go/utils/tests" + "net/http" + "os" + "path" + "path/filepath" + "strconv" + "strings" + "testing" + + "github.com/jfrog/build-info-go/utils" + "github.com/jfrog/jfrog-cli-core/v2/plugins/components" + "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" + "github.com/jfrog/jfrog-cli-security/utils/techutils" + "github.com/stretchr/testify/assert" +) + +var TestDataDir = filepath.Join("..", "tests", "testdata") + +func TestShouldRunCurationAfterFailure(t *testing.T) { + tests := []struct { + name string + cmdName string + envSkipCuration string + envOutputDirPath string + originError error + isForbiddenOutput bool + isEntitledForCuration bool + expectedRunCuration bool + expectedError error + }{ + { + name: "Unsupported command", + cmdName: "unsupported", + envOutputDirPath: "path", + expectedRunCuration: false, + }, + { + name: "Skip curation after failure", + cmdName: "install", + envSkipCuration: "true", + envOutputDirPath: "path", + expectedRunCuration: false, + }, + { + name: "Output directory path not set", + cmdName: "install", + envOutputDirPath: "", + expectedRunCuration: false, + }, + { + name: "Forbidden error", + cmdName: "install", + originError: &utils.ForbiddenError{}, + envOutputDirPath: "path", + expectedRunCuration: false, + }, + { + name: "Forbidden error in message", + cmdName: "install", + originError: errors.New("403 Forbidden"), + envOutputDirPath: "path", + expectedRunCuration: false, + }, + { + name: "Not entitled for curation", + cmdName: "install", + originError: &utils.ForbiddenError{}, + envOutputDirPath: "path", + isEntitledForCuration: false, + expectedRunCuration: false, + }, + { + name: "Successful curation audit", + cmdName: "install", + originError: &utils.ForbiddenError{}, + envOutputDirPath: "path", + isEntitledForCuration: true, + expectedRunCuration: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + // Set environment variables + if tt.envSkipCuration != "" { + callBack := clienttestutils.SetEnvWithCallbackAndAssert(t, SkipCurationAfterFailureEnv, tt.envSkipCuration) + defer callBack() + } + if tt.envOutputDirPath != "" { + callBack2 := clienttestutils.SetEnvWithCallbackAndAssert(t, coreutils.OutputDirPathEnv, tt.envOutputDirPath) + defer callBack2() + } + + pathToProjectDir := filepath.Join(TestDataDir, "projects", "package-managers", "npm", "npm-project") + + rootDir, err := os.Getwd() + assert.NoError(t, err) + tempHomeDir := path.Join(rootDir, path.Join(pathToProjectDir, ".jfrog")) + callback := clienttestutils.SetEnvWithCallbackAndAssert(t, coreutils.HomeDir, tempHomeDir) + defer callback() + + serverMock, c, _ := coretests.CreateRtRestsMockServer(t, func(w http.ResponseWriter, r *http.Request) { + if strings.Contains(r.URL.String(), "system/version") { + w.WriteHeader(http.StatusOK) + _, err := w.Write([]byte(`{"xray_version":"3.99.0"}`)) + assert.NoError(t, err) + return + } + w.WriteHeader(http.StatusOK) + _, err := w.Write([]byte(`{"feature_id":"curation","entitled":` + strconv.FormatBool(tt.isEntitledForCuration) + `}`)) + assert.NoError(t, err) + }) + defer serverMock.Close() + + configFilePath := createCliConfig(t, c.ArtifactoryUrl, pathToProjectDir) + defer func() { + assert.NoError(t, fileutils.RemoveTempDir(configFilePath)) + }() + + callbackPreTest := clienttestutils.ChangeDirWithCallback(t, rootDir, pathToProjectDir) + defer callbackPreTest() + + _, err, runCuration := ShouldRunCurationAfterFailure(&components.Context{}, techutils.Npm, tt.cmdName, tt.originError) + + // Verify the expected behavior + assert.Equal(t, tt.expectedRunCuration, runCuration) + assert.Equal(t, tt.expectedError, err) + + }) + } +} + +func createCliConfig(t *testing.T, url string, configPath string) string { + server := &config.ServerDetails{ + User: "admin", + Password: "password", + Url: url, + ArtifactoryUrl: url, + XrayUrl: url, + } + configCmd := commonCommands.NewConfigCommand(commonCommands.AddOrEdit, "test"). + SetDetails(server).SetUseBasicAuthOnly(true).SetInteractive(false) + assert.NoError(t, configCmd.Run()) + return filepath.Join(configPath, "jfrog-cli.conf.v"+strconv.Itoa(coreutils.GetCliConfigVersion())) +} diff --git a/commands/audit/sca/common.go b/commands/audit/sca/common.go index 43697bcb..6f60e886 100644 --- a/commands/audit/sca/common.go +++ b/commands/audit/sca/common.go @@ -7,6 +7,7 @@ import ( "strings" "testing" + buildInfoUtils "github.com/jfrog/build-info-go/utils" "github.com/jfrog/jfrog-cli-core/v2/utils/tests" "github.com/jfrog/jfrog-cli-security/utils" "github.com/jfrog/jfrog-cli-security/utils/techutils" @@ -167,24 +168,9 @@ func setPathsForIssues(dependency *xrayUtils.GraphNode, issuesImpactPathsMap map } } -func SuspectCurationBlockedError(isCurationCmd bool, tech techutils.Technology, cmdOutput string) (msgToUser string) { - if !isCurationCmd { - return - } - switch tech { - case techutils.Maven: - if strings.Contains(cmdOutput, "status code: 403") || strings.Contains(strings.ToLower(cmdOutput), "403 forbidden") || - strings.Contains(cmdOutput, "status code: 500") { - msgToUser = fmt.Sprintf(CurationErrorMsgToUserTemplate, techutils.Maven) - } - case techutils.Pip: - if strings.Contains(strings.ToLower(cmdOutput), "http error 403") { - msgToUser = fmt.Sprintf(CurationErrorMsgToUserTemplate, techutils.Pip) - } - case techutils.Go: - if strings.Contains(strings.ToLower(cmdOutput), "403 forbidden") { - msgToUser = fmt.Sprintf(CurationErrorMsgToUserTemplate, techutils.Go) - } +func GetMsgToUserForCurationBlock(isCurationCmd bool, tech techutils.Technology, cmdOutput string) (msgToUser string) { + if isCurationCmd && buildInfoUtils.IsForbiddenOutput(buildInfoUtils.PackageManager(tech.String()), cmdOutput) { + msgToUser = fmt.Sprintf(CurationErrorMsgToUserTemplate, tech) } return } diff --git a/commands/audit/sca/common_test.go b/commands/audit/sca/common_test.go index fd18d5fa..e04f713f 100644 --- a/commands/audit/sca/common_test.go +++ b/commands/audit/sca/common_test.go @@ -339,7 +339,7 @@ func TestSuspectCurationBlockedError(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - assert.Equal(t, SuspectCurationBlockedError(tt.isCurationCmd, tt.tech, tt.output), tt.expect) + assert.Equal(t, GetMsgToUserForCurationBlock(tt.isCurationCmd, tt.tech, tt.output), tt.expect) }) } } diff --git a/commands/audit/sca/go/golang.go b/commands/audit/sca/go/golang.go index 38d95b94..faa2fe6f 100644 --- a/commands/audit/sca/go/golang.go +++ b/commands/audit/sca/go/golang.go @@ -104,7 +104,7 @@ func handleCurationGoError(err error) (bool, error) { if err == nil { return false, nil } - if msgToUser := sca.SuspectCurationBlockedError(true, techutils.Go, err.Error()); msgToUser != "" { + if msgToUser := sca.GetMsgToUserForCurationBlock(true, techutils.Go, err.Error()); msgToUser != "" { return true, errors.New(msgToUser) } return false, nil diff --git a/commands/audit/sca/java/mvn.go b/commands/audit/sca/java/mvn.go index b5efa268..cda87097 100644 --- a/commands/audit/sca/java/mvn.go +++ b/commands/audit/sca/java/mvn.go @@ -180,7 +180,7 @@ func (mdt *MavenDepTreeManager) RunMvnCmd(goals []string) (cmdOutput []byte, err if len(cmdOutput) > 0 { log.Info(stringOutput) } - if msg := sca.SuspectCurationBlockedError(mdt.isCurationCmd, techutils.Maven, stringOutput); msg != "" { + if msg := sca.GetMsgToUserForCurationBlock(mdt.isCurationCmd, techutils.Maven, stringOutput); msg != "" { err = fmt.Errorf("failed running command 'mvn %s\n\n%s", strings.Join(goals, " "), msg) } else { err = fmt.Errorf("failed running command 'mvn %s': %s", strings.Join(goals, " "), err.Error()) diff --git a/commands/audit/sca/python/python.go b/commands/audit/sca/python/python.go index f3391e1a..afef19d8 100644 --- a/commands/audit/sca/python/python.go +++ b/commands/audit/sca/python/python.go @@ -271,7 +271,7 @@ func installPipDeps(auditPython *AuditPython) (restoreEnv func() error, err erro } } if err != nil || reqErr != nil { - if msgToUser := sca.SuspectCurationBlockedError(auditPython.IsCurationCmd, techutils.Pip, errors.Join(err, reqErr).Error()); msgToUser != "" { + if msgToUser := sca.GetMsgToUserForCurationBlock(auditPython.IsCurationCmd, techutils.Pip, errors.Join(err, reqErr).Error()); msgToUser != "" { err = errors.Join(err, errors.New(msgToUser)) } } diff --git a/commands/curation/curationaudit.go b/commands/curation/curationaudit.go index a78d6532..68beaae0 100644 --- a/commands/curation/curationaudit.go +++ b/commands/curation/curationaudit.go @@ -4,26 +4,17 @@ import ( "encoding/json" "errors" "fmt" - "github.com/jfrog/jfrog-cli-security/formats" - "net/http" - "os" - "path/filepath" - "regexp" - "sort" - "strings" - "sync" - - "github.com/jfrog/jfrog-cli-core/v2/common/cliutils" - config "github.com/jfrog/jfrog-cli-core/v2/utils/config" - "github.com/jfrog/gofrog/datastructures" "github.com/jfrog/gofrog/parallel" rtUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" + "github.com/jfrog/jfrog-cli-core/v2/common/cliutils" outFormat "github.com/jfrog/jfrog-cli-core/v2/common/format" "github.com/jfrog/jfrog-cli-core/v2/common/project" + "github.com/jfrog/jfrog-cli-core/v2/utils/config" "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" "github.com/jfrog/jfrog-cli-security/commands/audit" "github.com/jfrog/jfrog-cli-security/commands/audit/sca/python" + "github.com/jfrog/jfrog-cli-security/formats" "github.com/jfrog/jfrog-cli-security/utils" "github.com/jfrog/jfrog-cli-security/utils/techutils" "github.com/jfrog/jfrog-cli-security/utils/xray" @@ -33,7 +24,15 @@ import ( "github.com/jfrog/jfrog-client-go/utils/errorutils" "github.com/jfrog/jfrog-client-go/utils/io/httputils" "github.com/jfrog/jfrog-client-go/utils/log" + xrayClient "github.com/jfrog/jfrog-client-go/xray" xrayUtils "github.com/jfrog/jfrog-client-go/xray/services/utils" + "net/http" + "os" + "path/filepath" + "regexp" + "sort" + "strings" + "sync" ) const ( @@ -314,6 +313,18 @@ func (ca *CurationAuditCommand) doCurateAudit(results map[string]*CurationReport } func (ca *CurationAuditCommand) getRtManagerAndAuth(tech techutils.Technology) (rtManager artifactory.ArtifactoryServicesManager, serverDetails *config.ServerDetails, err error) { + serverDetails, err = ca.GetAuth(tech) + if err != nil { + return + } + rtManager, err = rtUtils.CreateServiceManager(serverDetails, 2, 0, false) + if err != nil { + return + } + return +} + +func (ca *CurationAuditCommand) GetAuth(tech techutils.Technology) (serverDetails *config.ServerDetails, err error) { if ca.PackageManagerConfig == nil { if err = ca.SetRepo(tech); err != nil { return @@ -323,10 +334,6 @@ func (ca *CurationAuditCommand) getRtManagerAndAuth(tech techutils.Technology) ( if err != nil { return } - rtManager, err = rtUtils.CreateServiceManager(serverDetails, 2, 0, false) - if err != nil { - return - } return } @@ -804,3 +811,16 @@ func GetCurationOutputFormat(formatFlagVal string) (format outFormat.OutputForma } return } + +func IsEntitledForCuration(xrayManager *xrayClient.XrayServicesManager) (entitled bool, err error) { + xrayVersion, err := xrayManager.GetVersion() + if err != nil { + return + } + if err = clientutils.ValidateMinimumVersion(clientutils.Xray, xrayVersion, utils.EntitlementsMinVersion); err != nil { + log.Debug(err) + return + } + return xrayManager.IsEntitled("curation") + +} diff --git a/go.mod b/go.mod index 18a5949c..fb5fb580 100644 --- a/go.mod +++ b/go.mod @@ -6,15 +6,16 @@ require ( github.com/beevik/etree v1.4.0 github.com/google/go-github/v56 v56.0.0 github.com/gookit/color v1.5.4 - github.com/jfrog/build-info-go v1.9.33 + github.com/jfrog/build-info-go v1.9.34 github.com/jfrog/froggit-go v1.16.1 github.com/jfrog/gofrog v1.7.5 github.com/jfrog/jfrog-apps-config v1.0.1 github.com/jfrog/jfrog-cli-core/v2 v2.54.1 - github.com/jfrog/jfrog-client-go v1.43.2 + github.com/jfrog/jfrog-client-go v1.44.2 github.com/magiconair/properties v1.8.7 github.com/owenrumney/go-sarif/v2 v2.3.0 github.com/stretchr/testify v1.9.0 + github.com/urfave/cli v1.22.15 golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa golang.org/x/sync v0.8.0 golang.org/x/text v0.17.0 @@ -67,7 +68,7 @@ require ( github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mattn/go-tty v0.0.3 // indirect github.com/microsoft/azure-devops-go-api/azuredevops/v7 v7.1.0 // indirect github.com/minio/sha256-simd v1.0.1 // indirect @@ -92,8 +93,7 @@ require ( github.com/spf13/viper v1.19.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/ulikunitz/xz v0.5.12 // indirect - github.com/urfave/cli v1.22.15 // indirect - github.com/vbauerster/mpb/v8 v8.7.4 // indirect + github.com/vbauerster/mpb/v8 v8.7.5 // indirect github.com/xanzy/go-gitlab v0.95.2 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect @@ -114,10 +114,10 @@ require ( gopkg.in/warnings.v0 v0.1.2 // indirect ) -// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 dev +replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240820213306-d507532c4863 replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240818084221-512e43045068 -//replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go dev +replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20240820163739-bb148903e3de // replace github.com/jfrog/froggit-go => github.com/jfrog/froggit-go dev diff --git a/go.sum b/go.sum index a932f5a7..7b32069b 100644 --- a/go.sum +++ b/go.sum @@ -890,16 +890,16 @@ github.com/jedib0t/go-pretty/v6 v6.5.9 h1:ACteMBRrrmm1gMsXe9PSTOClQ63IXDUt03H5U+ github.com/jedib0t/go-pretty/v6 v6.5.9/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E= github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI= github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw= -github.com/jfrog/build-info-go v1.9.33 h1:TEeTHDc3tEwZe/7kKhm1hQDd5vA/HnVhp1ZczUOWExk= -github.com/jfrog/build-info-go v1.9.33/go.mod h1:JTGnENexG1jRhKWCkQtZuDb0PerlzlSzF5OmMLG9kfc= +github.com/jfrog/build-info-go v1.8.9-0.20240820163739-bb148903e3de h1:1nnH4GCKTXH2jhjTCONI4DMNnS8u9c0bhDFZzl6fE5g= +github.com/jfrog/build-info-go v1.8.9-0.20240820163739-bb148903e3de/go.mod h1:6mdtqjREK76bHNODXakqKR/+ksJ9dvfLS7H57BZtnLY= github.com/jfrog/froggit-go v1.16.1 h1:FBIM1qevX/ag9unfmpGzfmZ36D8ulOJ+DPTSFUk3l5U= github.com/jfrog/froggit-go v1.16.1/go.mod h1:TEJSzgiV+3D/GVGE8Y6j46ut1jrBLD1FL6WdMdKwwCE= github.com/jfrog/gofrog v1.7.5 h1:dFgtEDefJdlq9cqTRoe09RLxS5Bxbe1Ev5+E6SmZHcg= github.com/jfrog/gofrog v1.7.5/go.mod h1:jyGiCgiqSSR7k86hcUSu67XVvmvkkgWTmPsH25wI298= 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/jfrog/jfrog-cli-core/v2 v2.54.1 h1:oNIsqUVJ/P17qEcHgj9/c1nfO23stqqj1sHB7ldFNmQ= -github.com/jfrog/jfrog-cli-core/v2 v2.54.1/go.mod h1:o8Ux0XiXWayxBXbtkMd5Vbs2YJZZDNiS9jtN6yQ4Ur8= +github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240820213306-d507532c4863 h1:gD9gzsdmdrJZaqIJ/f16tuyyl64DPMDw2YQRGmHfooY= +github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240820213306-d507532c4863/go.mod h1:2/Ccqq0ayMqIuH5AAoneX0CowwdrNWQcs5aKz8iDYkE= github.com/jfrog/jfrog-client-go v1.28.1-0.20240818084221-512e43045068 h1:RuZNgGLgv1lsU40OQ04ccZh0K6wA1Ma2dO5Gy8cxdv4= github.com/jfrog/jfrog-client-go v1.28.1-0.20240818084221-512e43045068/go.mod h1:cRCuMvRgWJ6fSdyYs1pknBin41LLcXY94UOl7KHiQ8U= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -955,8 +955,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-tty v0.0.3 h1:5OfyWorkyO7xP52Mq7tB36ajHDG5OHrmBGIS/DtakQI= github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0= @@ -1064,8 +1064,8 @@ github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc= github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.22.15 h1:nuqt+pdC/KqswQKhETJjo7pvn/k4xMUxgW6liI7XpnM= github.com/urfave/cli v1.22.15/go.mod h1:wSan1hmo5zeyLGBjRJbzRTNk8gwoYa2B9n4q9dmRIc0= -github.com/vbauerster/mpb/v8 v8.7.4 h1:p4f16iMfUt3PkAC73SCzAtgtSf8TYDqEbJUT3odPrPo= -github.com/vbauerster/mpb/v8 v8.7.4/go.mod h1:r1B5k2Ljj5KJFCekfihbiqyV4VaaRTANYmvWA2btufI= +github.com/vbauerster/mpb/v8 v8.7.5 h1:hUF3zaNsuaBBwzEFoCvfuX3cpesQXZC0Phm/JcHZQ+c= +github.com/vbauerster/mpb/v8 v8.7.5/go.mod h1:bRCnR7K+mj5WXKsy0NWB6Or+wctYGvVwKn6huwvxKa0= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/xanzy/go-gitlab v0.95.2 h1:4p0IirHqEp5f0baK/aQqr4TR57IsD+8e4fuyAA1yi88= diff --git a/jas/analyzermanager.go b/jas/analyzermanager.go index 2027d031..65e0a610 100644 --- a/jas/analyzermanager.go +++ b/jas/analyzermanager.go @@ -22,7 +22,6 @@ import ( ) const ( - EntitlementsMinVersion = "3.66.5" ApplicabilityFeatureId = "contextual_analysis" AnalyzerManagerZipName = "analyzerManager.zip" defaultAnalyzerManagerVersion = "1.8.13" diff --git a/jas/common.go b/jas/common.go index a03440c5..dd547435 100644 --- a/jas/common.go +++ b/jas/common.go @@ -305,7 +305,7 @@ func GetAnalyzerManagerXscEnvVars(msi string, validateSecrets bool, technologies } func IsEntitledForJas(xrayManager *xray.XrayServicesManager, xrayVersion string) (entitled bool, err error) { - if e := goclientutils.ValidateMinimumVersion(goclientutils.Xray, xrayVersion, EntitlementsMinVersion); e != nil { + if e := goclientutils.ValidateMinimumVersion(goclientutils.Xray, xrayVersion, utils.EntitlementsMinVersion); e != nil { log.Debug(e) return } diff --git a/tests/testdata/projects/package-managers/npm/npm-project/.jfrog/jfrog-cli.conf.v6 b/tests/testdata/projects/package-managers/npm/npm-project/.jfrog/jfrog-cli.conf.v6 deleted file mode 100644 index 1fe23a8c..00000000 --- a/tests/testdata/projects/package-managers/npm/npm-project/.jfrog/jfrog-cli.conf.v6 +++ /dev/null @@ -1,12 +0,0 @@ -{ - "servers": [ - { - "url": "http://127.0.0.1:63400/", - "artifactoryUrl": "http://127.0.0.1:63400/", - "user": "admin", - "password": "password", - "serverId": "test" - } - ], - "version": "6" -} \ No newline at end of file diff --git a/utils/utils.go b/utils/utils.go index bb75ab01..03a23bea 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -6,8 +6,9 @@ import ( ) const ( - NodeModulesPattern = "**/*node_modules*/**" - JfMsiEnvVariable = "JF_MSI" + NodeModulesPattern = "**/*node_modules*/**" + JfMsiEnvVariable = "JF_MSI" + EntitlementsMinVersion = "3.66.5" ) var (