Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set analyzer manager version by environment variable #935

Merged
merged 4 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions xray/commands/audit/jasrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package audit

import (
"errors"
"github.com/jfrog/gofrog/version"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/xray/commands/audit/jas"
"github.com/jfrog/jfrog-cli-core/v2/xray/commands/audit/jas/applicability"
Expand Down Expand Up @@ -49,7 +48,7 @@ func runJasScannersAndSetResults(scanResults *utils.ExtendedScanResults, directD
if err != nil {
return
}
if !version.NewVersion(utils.AnalyzerManagerVersion).AtLeast(utils.MinAnalyzerManagerVersionForSast) {
if !utils.IsSastSupported() {
return
}
if progress != nil {
Expand Down
18 changes: 15 additions & 3 deletions xray/utils/analyzermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utils
import (
"errors"
"fmt"
"github.com/jfrog/gofrog/version"
"os"
"os/exec"
"path"
Expand Down Expand Up @@ -41,8 +42,8 @@ const (
EntitlementsMinVersion = "3.66.5"
ApplicabilityFeatureId = "contextual_analysis"
AnalyzerManagerZipName = "analyzerManager.zip"
AnalyzerManagerVersion = "1.2.4.1953469"
MinAnalyzerManagerVersionForSast = "1.3"
defaultAnalyzerManagerVersion = "1.2.4.1953469"
minAnalyzerManagerVersionForSast = "1.3"
analyzerManagerDownloadPath = "xsc-gen-exe-analyzer-manager-local/v1"
analyzerManagerDirName = "analyzerManager"
analyzerManagerExecutableName = "analyzerManager"
Expand Down Expand Up @@ -142,7 +143,18 @@ func GetAnalyzerManagerDownloadPath() (string, error) {
if err != nil {
return "", err
}
return path.Join(analyzerManagerDownloadPath, AnalyzerManagerVersion, osAndArc, AnalyzerManagerZipName), nil
return path.Join(analyzerManagerDownloadPath, GetAnalyzerManagerVersion(), osAndArc, AnalyzerManagerZipName), nil
}

func GetAnalyzerManagerVersion() string {
if analyzerManagerVersion, exists := os.LookupEnv("JFROG_CLI_ANALYZER_MANAGER_VERSION"); exists {
return analyzerManagerVersion
}
return defaultAnalyzerManagerVersion
}

func IsSastSupported() bool {
return version.NewVersion(GetAnalyzerManagerVersion()).AtLeast(minAnalyzerManagerVersionForSast)
}

func GetAnalyzerManagerDirAbsolutePath() (string, error) {
Expand Down
3 changes: 1 addition & 2 deletions xray/utils/resultwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strconv"
"strings"

"github.com/jfrog/gofrog/version"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-cli-core/v2/xray/formats"
clientUtils "github.com/jfrog/jfrog-client-go/utils"
Expand Down Expand Up @@ -114,7 +113,7 @@ func printScanResultsTables(results *ExtendedScanResults, isBinaryScan, includeV
if err = PrintIacTable(results.IacScanResults, results.EntitledForJas); err != nil {
return
}
if !version.NewVersion(AnalyzerManagerVersion).AtLeast(MinAnalyzerManagerVersionForSast) {
if !IsSastSupported() {
return
}
return PrintSastTable(results.SastResults, results.EntitledForJas)
Expand Down
Loading