Skip to content

Commit

Permalink
add init func to download analyzer manager
Browse files Browse the repository at this point in the history
  • Loading branch information
omerzi committed Aug 16, 2023
1 parent b666f49 commit 4042ff0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion xray/audit/jas/jasmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type AdvancedSecurityScanner struct {
func NewAdvancedSecurityScanner(workingDirs []string, serverDetails *config.ServerDetails) (scanner *AdvancedSecurityScanner, err error) {
scanner = &AdvancedSecurityScanner{}
if scanner.analyzerManager.AnalyzerManagerFullPath, err = utils.GetAnalyzerManagerExecutable(); err != nil {
err = errors.New("unable to locate the analyzer manager package. Advanced security scans cannot be performed without this package")
return
}
var tempDir string
Expand Down
9 changes: 9 additions & 0 deletions xray/audit/jas/jasmanager_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package jas

import (
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
"github.com/jfrog/jfrog-client-go/utils/log"
"github.com/jfrog/jfrog-client-go/xray/services"
xrayUtils "github.com/jfrog/jfrog-client-go/xray/services/utils"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -60,6 +62,13 @@ var fakeServerDetails = config.ServerDetails{
User: "user",
}

func init() {
if err := utils.DownloadAnalyzerManagerIfNeeded(); err != nil {
log.Error("could not download analyzer manager before testing the `jas` package")
return
}
}

func TestGetExtendedScanResults_AnalyzerManagerDoesntExist(t *testing.T) {
tmpDir, err := fileutils.CreateTempDir()
assert.NoError(t, err)
Expand Down

0 comments on commit 4042ff0

Please sign in to comment.