@@ -420,20 +420,24 @@ func GetSourceRoots(module jfrogappsconfig.Module, scanner *jfrogappsconfig.Scan
420420 return roots , nil
421421}
422422
423- func GetExcludePatterns (module jfrogappsconfig.Module , scanner * jfrogappsconfig.Scanner , exclusions ... string ) []string {
424- if len (exclusions ) > 0 {
425- return filterUniqueAndConvertToFilesExcludePatterns (exclusions )
423+ func GetExcludePatterns (module jfrogappsconfig.Module , scanner * jfrogappsconfig.Scanner , centralConfigExclusions []string , cliExclusions ... string ) []string {
424+ uniqueExcludePatterns := datastructures .MakeSet [string ]()
425+ if len (cliExclusions ) > 0 || len (centralConfigExclusions ) > 0 {
426+ // Adding exclusions from CLI requires to convert them to file exclude patterns
427+ uniqueExcludePatterns .AddElements (convertToFilesExcludePatterns (cliExclusions )... )
428+ // Adding exclusions from centralized config, no need to convert
429+ uniqueExcludePatterns .AddElements (centralConfigExclusions ... )
430+ return uniqueExcludePatterns .ToSlice ()
426431 }
427-
428432 // Adding exclusions from jfrog-apps-config IF no exclusions provided from other source (flags, env vars, config profile)
429- excludePatterns := module .ExcludePatterns
433+ uniqueExcludePatterns . AddElements ( module .ExcludePatterns ... )
430434 if scanner != nil {
431- excludePatterns = append ( excludePatterns , scanner .ExcludePatterns ... )
435+ uniqueExcludePatterns . AddElements ( scanner .ExcludePatterns ... )
432436 }
433- if len ( excludePatterns ) == 0 {
437+ if uniqueExcludePatterns . Size ( ) == 0 {
434438 return utils .DefaultJasExcludePatterns
435439 }
436- return excludePatterns
440+ return uniqueExcludePatterns . ToSlice ()
437441}
438442
439443// This function convert every exclude pattern to a file exclude pattern form.
@@ -453,6 +457,21 @@ func filterUniqueAndConvertToFilesExcludePatterns(excludePatterns []string) []st
453457 return uniqueExcludePatterns .ToSlice ()
454458}
455459
460+ // This function convert every exclude pattern to a file exclude pattern form.
461+ // Checks are being made since some of the exclude patters we get here might already be in a file exclude pattern
462+ func convertToFilesExcludePatterns (excludePatterns []string ) (converted []string ) {
463+ for _ , excludePattern := range excludePatterns {
464+ if ! strings .HasPrefix (excludePattern , "**/" ) {
465+ excludePattern = "**/" + excludePattern
466+ }
467+ if ! strings .HasSuffix (excludePattern , "/**" ) {
468+ excludePattern += "/**"
469+ }
470+ converted = append (converted , excludePattern )
471+ }
472+ return converted
473+ }
474+
456475func CheckForSecretValidation (xrayManager * xray.XrayServicesManager , xrayVersion string , validateSecrets bool ) bool {
457476 dynamicTokenVersionMismatchErr := goclientutils .ValidateMinimumVersion (goclientutils .Xray , xrayVersion , jasutils .DynamicTokenValidationMinXrayVersion )
458477 if dynamicTokenVersionMismatchErr != nil {
0 commit comments