Skip to content

Commit

Permalink
add parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Oct 22, 2023
1 parent c13dadf commit d97299e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
18 changes: 0 additions & 18 deletions utils/coreutils/techutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,24 +394,6 @@ func detectTechnologiesByFilePaths(paths []string, isCiSetup bool) (detected map
return detected
}

// func t(path string, techData TechData) (exclude bool, detected bool) {
// // If the project contains a file/directory with a name that ends with an excluded suffix, then this technology is excluded.
// for _, excludeFile := range techData.exclude {
// if strings.HasSuffix(path, excludeFile) {
// return true, false
// }
// }
// // If this technology was already excluded, there's no need to look for indicator files/directories.
// if _, exist := exclude[techName]; !exist {
// // If the project contains a file/directory with a name that ends with the indicator suffix, then the project probably uses this technology.
// for _, indicator := range techData.indicators {
// if strings.HasSuffix(path, indicator) {
// return false, true
// }
// }
// }
// }

// DetectedTechnologiesToSlice returns a string slice that includes all the names of the detected technologies.
func DetectedTechnologiesToSlice(detected map[Technology]bool) []string {
keys := make([]string, 0, len(detected))
Expand Down
21 changes: 21 additions & 0 deletions xray/commands/audit/auditparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
type AuditParams struct {
xrayGraphScanParams *services.XrayGraphScanParams
workingDirs []string
excludePattern string
recursively bool
installFunc func(tech string) error
fixableOnly bool
minSeverityFilter string
Expand All @@ -21,6 +23,7 @@ func NewAuditParams() *AuditParams {
return &AuditParams{
xrayGraphScanParams: &services.XrayGraphScanParams{},
AuditBasicParams: &xrayutils.AuditBasicParams{},
recursively: true,
}
}

Expand All @@ -40,6 +43,24 @@ func (params *AuditParams) XrayVersion() string {
return params.xrayVersion
}

func (params *AuditParams) ExcludePattern() string {
return params.excludePattern
}

func (params *AuditParams) Recursively() bool {
return params.recursively
}

func (params *AuditParams) SetRecursively(recursively bool) *AuditParams {
params.recursively = recursively
return params
}

func (params *AuditParams) SetExcludePattern(excludePattern string) *AuditParams {
params.excludePattern = excludePattern
return params
}

func (params *AuditParams) SetXrayGraphScanParams(xrayGraphScanParams *services.XrayGraphScanParams) *AuditParams {
params.xrayGraphScanParams = xrayGraphScanParams
return params
Expand Down
4 changes: 1 addition & 3 deletions xray/commands/audit/scarunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ func runScaScan(params *AuditParams, results *xrayutils.Results) (err error) {

// Calculate the scans to preform
func getScaScansToPreform(currentWorkingDir string, params *AuditParams) (scansToPreform []*xrayutils.ScaScanResult) {
isRecursive := true
excludePattern := ""
for _, requestedDirectory := range getRequestedDirectoriesToScan(currentWorkingDir, params) {
// Detect descriptors and technologies in the requested directory.
techToWorkingDirs := coreutils.DetectTechnologiesDescriptors(requestedDirectory, isRecursive, params.Technologies(), getRequestedDescriptors(params), excludePattern)
techToWorkingDirs := coreutils.DetectTechnologiesDescriptors(requestedDirectory, params.Recursively(), params.Technologies(), getRequestedDescriptors(params), params.ExcludePattern())
// Create scans to preform
for tech, workingDirs := range techToWorkingDirs {
if tech == coreutils.Dotnet {
Expand Down
11 changes: 5 additions & 6 deletions xray/utils/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ func (r *Results) IsIssuesFound() bool {
}

type ScaScanResult struct {
Technology coreutils.Technology `json:"Technology"`
WorkingDirectory string `json:"WorkingDirectory"`
Descriptors []string `json:"Descriptors,omitempty"`
XrayResults []services.ScanResponse `json:"XrayResults,omitempty"`

IsMultipleRootProject *bool `json:"IsMultipleRootProject,omitempty"`
Technology coreutils.Technology `json:"Technology"`
WorkingDirectory string `json:"WorkingDirectory"`
XrayResults []services.ScanResponse `json:"XrayResults,omitempty"`
Descriptors []string `json:"Descriptors,omitempty"`
IsMultipleRootProject *bool `json:"IsMultipleRootProject,omitempty"`
}

func (s ScaScanResult) HasInformation() bool {
Expand Down

0 comments on commit d97299e

Please sign in to comment.