Skip to content

Commit

Permalink
Add fuzzing
Browse files Browse the repository at this point in the history
  • Loading branch information
hkctkuy committed Nov 30, 2024
1 parent e3e8c3a commit 7c7c7c2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
31 changes: 20 additions & 11 deletions libcasr/fuzz/fuzz_targets/parse_stacktrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use libfuzzer_sys::fuzz_target;

use libcasr::{
asan::AsanStacktrace,
csharp::CSharpStacktrace,
gdb::GdbStacktrace,
go::GoStacktrace,
init_ignored_frames,
java::JavaStacktrace,
python::PythonStacktrace,
js::JsStacktrace,
csharp::CSharpStacktrace,
lua::LuaStacktrace,
python::PythonStacktrace,
stacktrace::{CrashLineExt, Filter, ParseStacktrace, Stacktrace},
};

Expand All @@ -30,17 +31,17 @@ fuzz_target!(|data: &[u8]| {
}
}
1 => {
// Go
if let Ok(raw) = GoStacktrace::extract_stacktrace(&s) {
if let Ok(st) = GoStacktrace::parse_stacktrace(&raw) {
// C#
if let Ok(raw) = CSharpStacktrace::extract_stacktrace(&s) {
if let Ok(st) = CSharpStacktrace::parse_stacktrace(&raw) {
let _ = st.crash_line();
}
}
}
2 => {
// Python
if let Ok(raw) = PythonStacktrace::extract_stacktrace(&s) {
if let Ok(st) = PythonStacktrace::parse_stacktrace(&raw) {
// Go
if let Ok(raw) = GoStacktrace::extract_stacktrace(&s) {
if let Ok(st) = GoStacktrace::parse_stacktrace(&raw) {
let _ = st.crash_line();
}
}
Expand All @@ -62,9 +63,17 @@ fuzz_target!(|data: &[u8]| {
}
}
5 => {
// C#
if let Ok(raw) = CSharpStacktrace::extract_stacktrace(&s) {
if let Ok(st) = CSharpStacktrace::parse_stacktrace(&raw) {
// Lua
if let Ok(raw) = LuaStacktrace::extract_stacktrace(&s) {
if let Ok(st) = LuaStacktrace::parse_stacktrace(&raw) {
let _ = st.crash_line();
}
}
}
6 => {
// Python
if let Ok(raw) = PythonStacktrace::extract_stacktrace(&s) {
if let Ok(st) = PythonStacktrace::parse_stacktrace(&raw) {
let _ = st.crash_line();
}
}
Expand Down
13 changes: 13 additions & 0 deletions libcasr/fuzz/init_corpus/lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
lua: /usr/local/share/lua/5.4/luacheck/parser.lua:28: error
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.4/luacheck/parser.lua:28: in function 'luacheck.parser.syntax_error'
/usr/local/share/lua/5.4/luacheck/parser.lua:96: in upvalue 'parse_error'
/usr/local/share/lua/5.4/luacheck/parser.lua:535: in upvalue 'parse_simple_expression'
/usr/local/share/lua/5.4/luacheck/parser.lua:894: in function </usr/local/share/lua/5.4/luacheck/parser.lua:886>
(...tail calls...)
/usr/local/share/lua/5.4/luacheck/parser.lua:974: in upvalue 'parse_block'
/usr/local/share/lua/5.4/luacheck/parser.lua:1020: in function 'luacheck.parser.parse'
luacheck_parser_parse.lua:6: in local 'TestOneInput'
luacheck_parser_parse.lua:18: in main chunk
[C]: in ?

0 comments on commit 7c7c7c2

Please sign in to comment.