@@ -77,24 +77,38 @@ func LoadCollection(pattern string, logger *log.Entry) ([]AppsecCollection, erro
7777 if appsecRule .SecLangFilesRules != nil {
7878 for _ , rulesFile := range appsecRule .SecLangFilesRules {
7979 logger .Debugf ("Adding rules from %s" , rulesFile )
80- fullPath := filepath .Join (hub .GetDataDir (), rulesFile )
80+ globPattern := filepath .Join (hub .GetDataDir (), rulesFile )
81+
82+ matches , err := filepath .Glob (globPattern )
8183
82- c , err := os .ReadFile (fullPath )
8384 if err != nil {
84- logger .Errorf ("unable to read file %s : %s" , rulesFile , err )
85+ logger .Errorf ("unable to glob %s : %s" , rulesFile , err )
8586 continue
8687 }
8788
88- for line := range strings . SplitSeq ( string ( c ), " \n " ) {
89- if strings . HasPrefix ( line , "#" ) {
90- continue
91- }
89+ if len ( matches ) == 0 {
90+ logger . Warnf ( "no file matched pattern %s" , globPattern )
91+ continue
92+ }
9293
93- if strings .TrimSpace (line ) == "" {
94+ for _ , fullPath := range matches {
95+ c , err := os .ReadFile (fullPath )
96+ if err != nil {
97+ logger .Errorf ("unable to read file %s : %s" , rulesFile , err )
9498 continue
9599 }
96100
97- appsecCol .NativeRules = append (appsecCol .NativeRules , line )
101+ for line := range strings .SplitSeq (string (c ), "\n " ) {
102+ if strings .HasPrefix (line , "#" ) {
103+ continue
104+ }
105+
106+ if strings .TrimSpace (line ) == "" {
107+ continue
108+ }
109+
110+ appsecCol .NativeRules = append (appsecCol .NativeRules , line )
111+ }
98112 }
99113 }
100114 }
0 commit comments