From b8db994cc285eb7ea7c4af150381aee9c98c7b0d Mon Sep 17 00:00:00 2001 From: Hadar Shpivak Date: Sun, 20 Oct 2024 20:30:10 +0300 Subject: [PATCH] am 110 + fix xray-url cred and test jas-scanner --- audit_test.go | 21 ++------------------- jas/analyzermanager.go | 2 +- jas/common.go | 8 ++++---- tests/utils/test_config.go | 3 ++- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/audit_test.go b/audit_test.go index ba3518ec..c83c81fe 100644 --- a/audit_test.go +++ b/audit_test.go @@ -17,6 +17,7 @@ import ( "github.com/jfrog/jfrog-cli-security/utils/formats" "github.com/jfrog/jfrog-cli-security/utils/validations" + testsUtils "github.com/jfrog/jfrog-cli-security/tests/utils" xrayUtils "github.com/jfrog/jfrog-client-go/xray/services/utils" "github.com/stretchr/testify/assert" @@ -753,8 +754,7 @@ func TestXrayAuditNotEntitledForJasWithXrayUrl(t *testing.T) { } func TestXrayAuditJasSimpleJsonWithXrayUrl(t *testing.T) { - cliToRun, cleanUp := securityTestUtils.InitTestWithMockCommandOrParams(t, true, getRealAuditCommand) - defer cleanUp() + cliToRun := testsUtils.GetTestCli(cli.GetJfrogCliSecurityApp(), true) output := testXrayAuditJas(t, cliToRun, filepath.Join("jas", "jas"), "3", false, false) validations.VerifySimpleJsonResults(t, output, validations.ValidationParams{ Sast: 1, @@ -768,20 +768,3 @@ func TestXrayAuditJasSimpleJsonWithXrayUrl(t *testing.T) { NotApplicable: 2, }) } - -func getRealAuditCommand() components.Command { - return components.Command{ - Name: docs.Audit, - Flags: docs.GetCommandFlags(docs.Audit), - Category: "Security", - Action: cli.AuditCmd, - } -} - -//func getRealAuditCommand() []components.Command { -// var cmds []components.Command -// for i := range cli.GetJfrogCliSecurityApp().Subcommands { -// cmds = append(cmds, cli.GetJfrogCliSecurityApp().Subcommands[i].Commands...) -// } -// return cmds -//} diff --git a/jas/analyzermanager.go b/jas/analyzermanager.go index ca531cec..b531fdaa 100644 --- a/jas/analyzermanager.go +++ b/jas/analyzermanager.go @@ -24,7 +24,7 @@ import ( const ( ApplicabilityFeatureId = "contextual_analysis" AnalyzerManagerZipName = "analyzerManager.zip" - defaultAnalyzerManagerVersion = "1.9.9" + defaultAnalyzerManagerVersion = "1.10.0" analyzerManagerDownloadPath = "xsc-gen-exe-analyzer-manager-local/v1" analyzerManagerDirName = "analyzerManager" analyzerManagerExecutableName = "analyzerManager" diff --git a/jas/common.go b/jas/common.go index 7fda7e00..2154f3c1 100644 --- a/jas/common.go +++ b/jas/common.go @@ -55,12 +55,12 @@ func CreateJasScanner(serverDetails *config.ServerDetails, validateSecrets bool, if len(serverDetails.XrayUrl) != 0 { log.Debug("Xray URL provided without platform URL") } else { + if len(serverDetails.ArtifactoryUrl) != 0 { + log.Debug("Artifactory URL provided without platform URL") + } log.Warn(NoServerUrlWarn) + return } - if len(serverDetails.ArtifactoryUrl) != 0 { - log.Debug("Artifactory URL provided without platform URL") - } - return } scanner = &JasScanner{} if scanner.EnvVars, err = getJasEnvVars(serverDetails, validateSecrets, envVars); err != nil { diff --git a/tests/utils/test_config.go b/tests/utils/test_config.go index 312b9452..9a8966da 100644 --- a/tests/utils/test_config.go +++ b/tests/utils/test_config.go @@ -61,12 +61,13 @@ func GetTestCli(testApplication components.App, xrayUrlOnly bool) (testCli *core func authenticateXray(xrayUrlOnly bool) string { *configTests.JfrogUrl = clientUtils.AddTrailingSlashIfNeeded(*configTests.JfrogUrl) + cred := fmt.Sprintf("--url=%s", *configTests.JfrogUrl) if xrayUrlOnly { + cred = fmt.Sprintf("--xray-url=%s", configTests.XrDetails.XrayUrl) configTests.XrDetails = &config.ServerDetails{XrayUrl: *configTests.JfrogUrl + configTests.XrayEndpoint} } else { configTests.XrDetails = &config.ServerDetails{Url: *configTests.JfrogUrl, ArtifactoryUrl: *configTests.JfrogUrl + configTests.ArtifactoryEndpoint, XrayUrl: *configTests.JfrogUrl + configTests.XrayEndpoint} } - cred := fmt.Sprintf("--url=%s", configTests.XrDetails.XrayUrl) if *configTests.JfrogAccessToken != "" { configTests.XrDetails.AccessToken = *configTests.JfrogAccessToken cred += fmt.Sprintf(" --access-token=%s", configTests.XrDetails.AccessToken)