@@ -8,7 +8,7 @@ use core::{
88 fmt:: { Debug , Formatter } ,
99 marker:: PhantomData ,
1010} ;
11- use std:: { iter , sync:: Arc } ;
11+ use std:: sync:: Arc ;
1212
1313use deno_core:: { v8, ModuleId , ModuleSpecifier } ;
1414use deno_runtime:: worker:: MainWorker ;
@@ -20,7 +20,7 @@ use libafl::{
2020 Error ,
2121} ;
2222use tokio:: runtime:: Runtime ;
23- use v8:: { Function , HandleScope , Local , TryCatch } ;
23+ use v8:: { Function , Local , TryCatch } ;
2424
2525use crate :: { values:: IntoJSValue , Mutex } ;
2626
@@ -118,6 +118,11 @@ where
118118 res
119119 } )
120120 }
121+
122+ /// Fetches the ID of the main module for hooking
123+ pub fn main_module_id ( & self ) -> ModuleId {
124+ self . id
125+ }
121126}
122127
123128impl < ' rt , EM , I , OT , S , Z > Executor < EM , I , S , Z > for V8Executor < ' rt , EM , I , OT , S , Z >
@@ -164,66 +169,3 @@ where
164169 . finish_non_exhaustive ( )
165170 }
166171}
167-
168- #[ allow( dead_code) ]
169- fn js_err_to_libafl ( scope : & mut TryCatch < HandleScope > ) -> Option < Error > {
170- if !scope. has_caught ( ) {
171- None
172- } else {
173- let exception = scope. exception ( ) . unwrap ( ) ;
174- let exception_string = exception
175- . to_string ( scope)
176- . unwrap ( )
177- . to_rust_string_lossy ( scope) ;
178- let message = if let Some ( message) = scope. message ( ) {
179- message
180- } else {
181- return Some ( Error :: illegal_state ( format ! (
182- "Provided script threw an error while executing: {}" ,
183- exception_string
184- ) ) ) ;
185- } ;
186-
187- let filename = message. get_script_resource_name ( scope) . map_or_else (
188- || "(unknown)" . into ( ) ,
189- |s| s. to_string ( scope) . unwrap ( ) . to_rust_string_lossy ( scope) ,
190- ) ;
191- let line_number = message. get_line_number ( scope) . unwrap_or_default ( ) ;
192-
193- let source_line = message
194- . get_source_line ( scope)
195- . map ( |s| s. to_string ( scope) . unwrap ( ) . to_rust_string_lossy ( scope) )
196- . unwrap ( ) ;
197-
198- let start_column = message. get_start_column ( ) ;
199- let end_column = message. get_end_column ( ) ;
200-
201- let err_underline = iter:: repeat ( ' ' )
202- . take ( start_column)
203- . chain ( iter:: repeat ( '^' ) . take ( end_column - start_column) )
204- . collect :: < String > ( ) ;
205-
206- if let Some ( stack_trace) = scope. stack_trace ( ) {
207- let stack_trace = unsafe { Local :: < v8:: String > :: cast ( stack_trace) } ;
208- let stack_trace = stack_trace
209- . to_string ( scope)
210- . map ( |s| s. to_rust_string_lossy ( scope) ) ;
211-
212- if let Some ( stack_trace) = stack_trace {
213- return Some ( Error :: illegal_state ( format ! (
214- "Encountered uncaught JS exception while executing: {}:{}: {}\n {}\n {}\n {}" ,
215- filename,
216- line_number,
217- exception_string,
218- source_line,
219- err_underline,
220- stack_trace
221- ) ) ) ;
222- }
223- }
224- Some ( Error :: illegal_state ( format ! (
225- "Encountered uncaught JS exception while executing: {}:{}: {}\n {}\n {}" ,
226- filename, line_number, exception_string, source_line, err_underline
227- ) ) )
228- }
229- }
0 commit comments