1
1
use crate :: processor:: {
2
2
new_processing_state_background_thread, CompressionTypeField , FileDataKindField ,
3
- FileFilterField , WarpFileProcessor ,
3
+ FileFilterField , ProcessingFileState , RequestAnalysisField , WarpFileProcessor ,
4
4
} ;
5
5
use crate :: report:: { ReportGenerator , ReportKindField } ;
6
6
use binaryninja:: background_task:: BackgroundTask ;
@@ -30,6 +30,7 @@ impl CreateSignaturesForm {
30
30
form. add_field ( Self :: compression_type_field ( ) ) ;
31
31
form. add_field ( Self :: save_individual_files_field ( ) ) ;
32
32
form. add_field ( Self :: skip_existing_warp_files_field ( ) ) ;
33
+ form. add_field ( Self :: request_analysis_field ( ) ) ;
33
34
form. add_field ( Self :: processing_thread_count_field ( ) ) ;
34
35
Self { form }
35
36
}
@@ -46,7 +47,7 @@ impl CreateSignaturesForm {
46
47
FileFilterField :: to_field ( )
47
48
}
48
49
49
- pub fn file_filter ( & self ) -> Option < Regex > {
50
+ pub fn file_filter ( & self ) -> Option < Result < Regex , regex :: Error > > {
50
51
FileFilterField :: from_form ( & self . form )
51
52
}
52
53
@@ -100,6 +101,14 @@ impl CreateSignaturesForm {
100
101
}
101
102
}
102
103
104
+ pub fn request_analysis_field ( ) -> FormInputField {
105
+ RequestAnalysisField :: default ( ) . to_field ( )
106
+ }
107
+
108
+ pub fn request_analysis ( & self ) -> RequestAnalysisField {
109
+ RequestAnalysisField :: from_form ( & self . form ) . unwrap_or_default ( )
110
+ }
111
+
103
112
pub fn processing_thread_count_field ( ) -> FormInputField {
104
113
let default = rayon:: current_num_threads ( ) ;
105
114
FormInputField :: Integer {
@@ -136,6 +145,7 @@ impl CreateSignatures {
136
145
let compression_type = form. compression_type ( ) ;
137
146
let save_individual_files = form. save_individual_files ( ) ;
138
147
let skip_existing_warp_files = form. skip_existing_warp_files ( ) ;
148
+ let request_analysis = form. request_analysis ( ) ;
139
149
let processing_thread_count = form. processing_thread_count ( ) ;
140
150
141
151
// Save the warp file to the project.
@@ -189,7 +199,8 @@ impl CreateSignatures {
189
199
let mut processor = WarpFileProcessor :: new ( )
190
200
. with_file_data ( file_data_kind)
191
201
. with_compression_type ( compression_type)
192
- . with_skip_warp_files ( skip_existing_warp_files) ;
202
+ . with_skip_warp_files ( skip_existing_warp_files)
203
+ . with_request_analysis ( request_analysis == RequestAnalysisField :: Yes ) ;
193
204
194
205
if save_individual_files {
195
206
processor = processor. with_processed_file_callback ( save_individual_files_cb) ;
@@ -198,7 +209,18 @@ impl CreateSignatures {
198
209
// Construct the user-supplied file filter. This will filter files in the project only, files
199
210
// in an archive will be considered a part of the archive file.
200
211
if let Some ( filter) = form. file_filter ( ) {
201
- processor = processor. with_file_filter ( filter) ;
212
+ match filter {
213
+ Ok ( f) => {
214
+ processor = processor. with_file_filter ( f) ;
215
+ }
216
+ Err ( err) => {
217
+ log:: error!( "Failed to parse file filter: {}" , err) ;
218
+ log:: error!(
219
+ "Consider using a substring instead of a glob pattern, e.g. *.exe => exe"
220
+ ) ;
221
+ return ;
222
+ }
223
+ }
202
224
}
203
225
204
226
// This thread will show the state in a background task.
@@ -234,7 +256,15 @@ impl CreateSignatures {
234
256
log:: error!( "Failed to process project: {}" , e) ;
235
257
}
236
258
} ) ;
237
- log:: info!( "Processing project files took: {:?}" , start. elapsed( ) ) ;
259
+
260
+ let processed_file_count = processor
261
+ . state ( )
262
+ . files_with_state ( ProcessingFileState :: Processed ) ;
263
+ log:: info!(
264
+ "Processing {} project files took: {:?}" ,
265
+ processed_file_count,
266
+ start. elapsed( )
267
+ ) ;
238
268
// Reset the worker thread count to the user specified; either way it will not persist.
239
269
set_worker_thread_count ( previous_worker_thread_count) ;
240
270
// Tells the processing state thread to finish.
0 commit comments