@@ -77,22 +77,24 @@ func FindInFilesContent(files *[]string, patterns []string, rules *yara.Rules, h
77
77
}
78
78
79
79
// yara scan on file content
80
- yaraResult , err := PerformYaraScan (& b , rules )
81
- if err != nil {
82
- LogMessage (LOG_ERROR , "(ERROR)" , "Error performing yara scan on" , path , err )
83
- continue
84
- }
80
+ if rules != nil && len (rules .GetRules ()) > 0 {
81
+ yaraResult , err := PerformYaraScan (& b , rules )
82
+ if err != nil {
83
+ LogMessage (LOG_ERROR , "(ERROR)" , "Error performing yara scan on" , path , err )
84
+ continue
85
+ }
85
86
86
- if len (yaraResult ) > 0 && ! Contains (matchingFiles , path ) {
87
- matchingFiles = append (matchingFiles , path )
88
- }
87
+ if len (yaraResult ) > 0 && ! Contains (matchingFiles , path ) {
88
+ matchingFiles = append (matchingFiles , path )
89
+ }
89
90
90
- // output yara match results
91
- for i := 0 ; i < len (yaraResult ); i ++ {
92
- LogMessage (LOG_ALERT , "(ALERT)" , "YARA match:" )
93
- LogMessage (LOG_ALERT , " | path:" , path )
94
- LogMessage (LOG_ALERT , " | rule namespace:" , yaraResult [i ].Namespace )
95
- LogMessage (LOG_ALERT , " | rule name:" , yaraResult [i ].Rule )
91
+ // output yara match results
92
+ for i := 0 ; i < len (yaraResult ); i ++ {
93
+ LogMessage (LOG_ALERT , "(ALERT)" , "YARA match:" )
94
+ LogMessage (LOG_ALERT , " | path:" , path )
95
+ LogMessage (LOG_ALERT , " | rule namespace:" , yaraResult [i ].Namespace )
96
+ LogMessage (LOG_ALERT , " | rule name:" , yaraResult [i ].Rule )
97
+ }
96
98
}
97
99
98
100
// if file type is an archive, extract and calculate checksum for every file inside
0 commit comments