@@ -420,37 +420,39 @@ 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.
440444// Checks are being made since some of the exclude patters we get here might already be in a file exclude pattern
441- // Additionally, we keep patterns without duplications
442- func filterUniqueAndConvertToFilesExcludePatterns (excludePatterns []string ) []string {
443- uniqueExcludePatterns := datastructures .MakeSet [string ]()
445+ func convertToFilesExcludePatterns (excludePatterns []string ) (converted []string ) {
444446 for _ , excludePattern := range excludePatterns {
445447 if ! strings .HasPrefix (excludePattern , "**/" ) {
446448 excludePattern = "**/" + excludePattern
447449 }
448450 if ! strings .HasSuffix (excludePattern , "/**" ) {
449451 excludePattern += "/**"
450452 }
451- uniqueExcludePatterns . Add ( excludePattern )
453+ converted = append ( converted , excludePattern )
452454 }
453- return uniqueExcludePatterns . ToSlice ()
455+ return converted
454456}
455457
456458func CheckForSecretValidation (xrayManager * xray.XrayServicesManager , xrayVersion string , validateSecrets bool ) bool {
0 commit comments