File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 29
29
"type" : " string" ,
30
30
"multi" : false ,
31
31
"required" : false
32
+ },
33
+ {
34
+ "name" : " rules_limit" ,
35
+ "description" : " Enforce a limit on the number of YARA rules tested against the file" ,
36
+ "type" : " number" ,
37
+ "multi" : false ,
38
+ "required" : false
32
39
}
33
40
]
34
41
}
Original file line number Diff line number Diff line change @@ -160,6 +160,8 @@ def __init__(self):
160
160
161
161
self .github_urls = self .get_param ('config.github_urls' , None , 'No GitHub URLs provided.' )
162
162
self .github_token = self .get_param ('config.github_token' , None , 'No GitHub PAT provided.' )
163
+
164
+ self .rules_limit = self .get_param ('config.rules_limit' , None , 'No rules limit provided.' )
163
165
164
166
self .ruleset = []
165
167
self .ignored_rules = []
@@ -218,6 +220,16 @@ def __init__(self):
218
220
219
221
if not self .ruleset :
220
222
print ("Warning: No valid YARA rules were loaded." )
223
+
224
+ # Enforce the rules limit if set
225
+ if self .rules_limit :
226
+ try :
227
+ limit = int (self .rules_limit )
228
+ if len (self .ruleset ) > limit :
229
+ self .ruleset = self .ruleset [:limit ]
230
+ except ValueError :
231
+ self .error ("Invalid rules_limit value; it should be an integer." )
232
+
221
233
222
234
223
235
def check (self , file_path ):
You can’t perform that action at this time.
0 commit comments