diff --git a/utils/coreutils/techutils.go b/utils/coreutils/techutils.go index f01e36c18..fe43da4e2 100644 --- a/utils/coreutils/techutils.go +++ b/utils/coreutils/techutils.go @@ -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)) diff --git a/xray/commands/audit/auditparams.go b/xray/commands/audit/auditparams.go index 9dc42e3c2..ac78a70ee 100644 --- a/xray/commands/audit/auditparams.go +++ b/xray/commands/audit/auditparams.go @@ -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 @@ -21,6 +23,7 @@ func NewAuditParams() *AuditParams { return &AuditParams{ xrayGraphScanParams: &services.XrayGraphScanParams{}, AuditBasicParams: &xrayutils.AuditBasicParams{}, + recursively: true, } } @@ -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 diff --git a/xray/commands/audit/scarunner.go b/xray/commands/audit/scarunner.go index c2938a1db..99a9553cc 100644 --- a/xray/commands/audit/scarunner.go +++ b/xray/commands/audit/scarunner.go @@ -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 { diff --git a/xray/utils/results.go b/xray/utils/results.go index 89ba3f275..8d1eb507f 100644 --- a/xray/utils/results.go +++ b/xray/utils/results.go @@ -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 {