Skip to content

Commit

Permalink
am 110 + fix xray-url cred and test jas-scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
hadarshjfrog committed Oct 28, 2024
1 parent 63c7e1d commit b8db994
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 25 deletions.
21 changes: 2 additions & 19 deletions audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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
//}
2 changes: 1 addition & 1 deletion jas/analyzermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions jas/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion tests/utils/test_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b8db994

Please sign in to comment.