Skip to content

Commit

Permalink
Add option to disable Jas scans
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Oct 29, 2024
1 parent 092691b commit 70d5e3e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
3 changes: 2 additions & 1 deletion scanpullrequest/scanpullrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ func auditPullRequest(repoConfig *utils.Repository, client vcsclient.VcsClient,
SetFixableOnly(repoConfig.FixableOnly).
SetFailOnInstallationErrors(*repoConfig.FailOnSecurityIssues).
SetConfigProfile(repoConfig.ConfigProfile).
SetSkipAutoInstall(repoConfig.SkipAutoInstall)
SetSkipAutoInstall(repoConfig.SkipAutoInstall).
SetDisableJas(repoConfig.DisableJas)
if scanDetails, err = scanDetails.SetMinSeverity(repoConfig.MinSeverity); err != nil {
return
}
Expand Down
8 changes: 4 additions & 4 deletions scanrepository/scanrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"errors"
"fmt"
"github.com/go-git/go-git/v5"
biutils "github.com/jfrog/build-info-go/utils"
"os"
"path/filepath"
"regexp"
"strings"

"github.com/go-git/go-git/v5"
biutils "github.com/jfrog/build-info-go/utils"

"github.com/jfrog/frogbot/v2/packagehandlers"
"github.com/jfrog/frogbot/v2/utils"
"github.com/jfrog/frogbot/v2/utils/outputwriter"
Expand Down Expand Up @@ -123,8 +124,7 @@ func (cfp *ScanRepositoryCmd) setCommandPrerequisites(repository *utils.Reposito
SetFailOnInstallationErrors(*repository.FailOnSecurityIssues).
SetFixableOnly(repository.FixableOnly).
SetSkipAutoInstall(repository.SkipAutoInstall).
SetFixableOnly(repository.FixableOnly).
SetAllowPartialResults(repository.AllowPartialResults)
SetAllowPartialResults(repository.AllowPartialResults).SetDisableJas(repository.DisableJas)
if cfp.scanDetails, err = cfp.scanDetails.SetMinSeverity(repository.MinSeverity); err != nil {
return
}
Expand Down
1 change: 1 addition & 0 deletions utils/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const (
DepsRepoEnv = "JF_DEPS_REPO"
MinSeverityEnv = "JF_MIN_SEVERITY"
FixableOnlyEnv = "JF_FIXABLE_ONLY"
DisableJasEnv = "JF_DISABLE_ADVANCE_SECURITY"
DetectionOnlyEnv = "JF_SKIP_AUTOFIX"
AllowedLicensesEnv = "JF_ALLOWED_LICENSES"
SkipAutoInstallEnv = "JF_SKIP_AUTO_INSTALL"
Expand Down
15 changes: 11 additions & 4 deletions utils/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import (
"context"
"errors"
"fmt"
"github.com/jfrog/jfrog-cli-security/utils/techutils"
"github.com/jfrog/jfrog-cli-security/utils/xsc"
"github.com/jfrog/jfrog-client-go/xsc/services"
"golang.org/x/exp/slices"
"net/http"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/jfrog/jfrog-cli-security/utils/techutils"
"github.com/jfrog/jfrog-cli-security/utils/xsc"
"github.com/jfrog/jfrog-client-go/xsc/services"
"golang.org/x/exp/slices"

"github.com/jfrog/frogbot/v2/utils/outputwriter"
securityutils "github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-cli-security/utils/severityutils"
Expand Down Expand Up @@ -153,6 +154,7 @@ type Scan struct {
FailOnSecurityIssues *bool `yaml:"failOnSecurityIssues,omitempty"`
AvoidPreviousPrCommentsDeletion bool `yaml:"avoidPreviousPrCommentsDeletion,omitempty"`
MinSeverity string `yaml:"minSeverity,omitempty"`
DisableJas bool `yaml:"disableJas,omitempty"`
AllowedLicenses []string `yaml:"allowedLicenses,omitempty"`
Projects []Project `yaml:"projects,omitempty"`
EmailDetails `yaml:",inline"`
Expand Down Expand Up @@ -213,6 +215,11 @@ func (s *Scan) setDefaultsIfNeeded() (err error) {
return
}
}
if !s.DisableJas {
if s.DisableJas, err = getBoolEnv(DisableJasEnv, false); err != nil {
return
}
}
if !s.DetectionOnly {
if s.DetectionOnly, err = getBoolEnv(DetectionOnlyEnv, false); err != nil {
return
Expand Down
15 changes: 13 additions & 2 deletions utils/scandetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"errors"
"fmt"
clientservices "github.com/jfrog/jfrog-client-go/xsc/services"
"os"
"path/filepath"

clientservices "github.com/jfrog/jfrog-client-go/xsc/services"

"github.com/jfrog/froggit-go/vcsclient"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
Expand All @@ -28,6 +29,7 @@ type ScanDetails struct {
client vcsclient.VcsClient
failOnInstallationErrors bool
fixableOnly bool
disableJas bool
skipAutoInstall bool
minSeverityFilter severityutils.Severity
baseBranch string
Expand All @@ -39,6 +41,11 @@ func NewScanDetails(client vcsclient.VcsClient, server *config.ServerDetails, gi
return &ScanDetails{client: client, ServerDetails: server, Git: git}
}

func (sc *ScanDetails) SetDisableJas(disable bool) *ScanDetails {
sc.disableJas = disable
return sc
}

func (sc *ScanDetails) SetFailOnInstallationErrors(toFail bool) *ScanDetails {
sc.failOnInstallationErrors = toFail
return sc
Expand Down Expand Up @@ -107,6 +114,10 @@ func (sc *ScanDetails) FixableOnly() bool {
return sc.fixableOnly
}

func (sc *ScanDetails) DisableJas() bool {
return sc.disableJas
}

func (sc *ScanDetails) MinSeverityFilter() severityutils.Severity {
return sc.minSeverityFilter
}
Expand Down Expand Up @@ -186,7 +197,7 @@ func (sc *ScanDetails) RunInstallAndAudit(workDirs ...string) (auditResults *res
SetGraphBasicParams(auditBasicParams).
SetCommonGraphScanParams(sc.CreateCommonGraphScanParams()).
SetConfigProfile(sc.configProfile)
auditParams.SetExclusions(sc.PathExclusions).SetIsRecursiveScan(sc.IsRecursiveScan)
auditParams.SetExclusions(sc.PathExclusions).SetIsRecursiveScan(sc.IsRecursiveScan).SetUseJas(!sc.DisableJas())

auditResults, err = audit.RunAudit(auditParams)

Expand Down

0 comments on commit 70d5e3e

Please sign in to comment.