Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libcasr] Add JS stacktrace parsing #158

Merged
merged 10 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion libcasr/fuzz/fuzz_targets/parse_stacktrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use libcasr::{
init_ignored_frames,
java::JavaStacktrace,
python::PythonStacktrace,
js::JSStacktrace,
stacktrace::{CrashLineExt, Filter, ParseStacktrace, Stacktrace},
};

Expand All @@ -17,7 +18,7 @@ fuzz_target!(|data: &[u8]| {
return;
}
let s = String::from_utf8_lossy(&data[1..]);
init_ignored_frames!("cpp", "rust", "python", "go", "java");
init_ignored_frames!("cpp", "rust", "python", "go", "java", "js");
anfedotoff marked this conversation as resolved.
Show resolved Hide resolved
match data[0] % 5 {
0 => {
// Asan
Expand Down Expand Up @@ -51,6 +52,14 @@ fuzz_target!(|data: &[u8]| {
}
}
}
4 => {
// JS
if let Ok(raw) = JSStacktrace::extract_stacktrace(&s) {
if let Ok(st) = JSStacktrace::parse_stacktrace(&raw) {
let _ = st.crash_line();
}
}
}
_ => {
// Gdb
if let Ok(raw) = GdbStacktrace::extract_stacktrace(&s) {
Expand Down
13 changes: 13 additions & 0 deletions libcasr/fuzz/init_corpus/js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Error: 1
anfedotoff marked this conversation as resolved.
Show resolved Hide resolved
at eval (eval at <anonymous> (eval at g (/fuzz/FuzzTarget_jazzer.js:7:7)), <anonymous>:4:23)
at eval (eval at g (/fuzz/FuzzTarget_jazzer.js:7:7), <anonymous>:8:13)
at g (/fuzz/FuzzTarget_jazzer.js:14:13)
at fuzz (/fuzz/FuzzTarget_jazzer.js:29:9)
at module.exports.fuzz (/fuzz/FuzzTarget_jazzer.js:51:5)
at result (/fuzz/node_modules/@jazzer.js/core/core.ts:335:15)
Error: 2
at eval (eval at g (/fuzz/FuzzTarget_jazzer.js:7:7), <anonymous>:9:54)
at g (/fuzz/FuzzTarget_jazzer.js:14:13)
at fuzz (/fuzz/FuzzTarget_jazzer.js:29:9)
at module.exports.fuzz (/fuzz/FuzzTarget_jazzer.js:51:5)
at result (/fuzz/node_modules/@jazzer.js/core/core.ts:335:15)
16 changes: 16 additions & 0 deletions libcasr/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ pub const STACK_FRAME_FUNCTION_IGNORE_REGEXES_JAVA: &[&str] = &[
r"^javax\.",
];

/// Regular expressions for JS functions to be ignored.
pub const STACK_FRAME_FUNCTION_IGNORE_REGEXES_JS: &[&str] = &[
// TODO
r"^<anonymous>$",
];

/// Regular expressions for python functions to be ignored.
pub const STACK_FRAME_FUNCTION_IGNORE_REGEXES_PYTHON: &[&str] = &[
// TODO
Expand Down Expand Up @@ -228,6 +234,16 @@ pub const STACK_FRAME_FILEPATH_IGNORE_REGEXES_JAVA: &[&str] = &[
r"^[^.]$",
];

/// Regular expressions for paths to JS files that should be ignored.
pub const STACK_FRAME_FILEPATH_IGNORE_REGEXES_JS: &[&str] = &[
// TODO
r"^<anonymous>$",
r"^native$",
// JS internal modules
r"^(|node:)internal/?",
r"^(|node:)events/?",
];

/// Regular expressions for paths to python files that should be ignored.
pub const STACK_FRAME_FILEPATH_IGNORE_REGEXES_PYTHON: &[&str] = &[
// TODO
Expand Down
Loading
Loading