13x54n / sunya

This repo is deprecated and moved to the new url.
https://github.com/Sunya-Inc/sunya
MIT License
1 stars 0 forks source link

🐛 Caracal detect is not running while detecting the cairo project. #11

Closed 13x54n closed 4 months ago

13x54n commented 4 months ago

Describe the bug Caracal from crytic is Static Analyzer for Starknet smart contracts.

To Reproduce Since this repository is monolithic and everything is build all together, the base project is wrap-up of Vite (React.js) & Scarb project.

Expected behavior When I run:

caracal detect ./

It should either give me vulnerabilities detected or no vulnerability message. But this is what I got instead:

notsolexy@lexyjr:~/Documents/sunya$ caracal detect ./
Compiling with Scarb. Found Scarb.toml.
thread 'main' panicked at src/core/core_unit.rs:31:78:
called `Result::unwrap()` on an `Err` value: TypeSpecialization { concrete_id: ConcreteTypeId { id: 1, debug_name: Some("Const<felt252, 476442828812030857794232422692155113556837216824>") }, error: TypeSpecialization { type_id: GenericTypeId("Const"), error: UnsupportedId("Const") } }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
notsolexy@lexyjr:~/Documents/sunya$ RUST_BACKTRACE=1 !!
RUST_BACKTRACE=1 caracal detect ./
Compiling with Scarb. Found Scarb.toml.
thread 'main' panicked at src/core/core_unit.rs:31:78:
called `Result::unwrap()` on an `Err` value: TypeSpecialization { concrete_id: ConcreteTypeId { id: 1, debug_name: Some("Const<felt252, 476442828812030857794232422692155113556837216824>") }, error: TypeSpecialization { type_id: GenericTypeId("Const"), error: UnsupportedId("Const") } }
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut
   4: rayon::iter::plumbing::Folder::consume_iter
   5: rayon::iter::plumbing::bridge_producer_consumer::helper
   6: rayon::iter::collect::collect_with_consumer
   7: caracal::core::core_unit::CoreUnit::new
   8: <caracal::cli::commands::detect::DetectArgs as caracal::cli::commands::Cmd>::run
   9: caracal::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
notsolexy@lexyjr:~/Documents/sunya$ RUST_BACKTRACE=full caracal detect ./
Compiling with Scarb. Found Scarb.toml.
thread 'main' panicked at src/core/core_unit.rs:31:78:
called `Result::unwrap()` on an `Err` value: TypeSpecialization { concrete_id: ConcreteTypeId { id: 1, debug_name: Some("Const<felt252, 476442828812030857794232422692155113556837216824>") }, error: TypeSpecialization { type_id: GenericTypeId("Const"), error: UnsupportedId("Const") } }
stack backtrace:
   0:     0x59fc958cc415 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1e1a1972118942ad
   1:     0x59fc958f49ab - core::fmt::write::hc090a2ffd6b28c4a
   2:     0x59fc958c991f - std::io::Write::write_fmt::h8898bac6ff039a23
   3:     0x59fc958cc1ee - std::sys_common::backtrace::print::ha96650907276675e
   4:     0x59fc958cd659 - std::panicking::default_hook::{{closure}}::h215c2a0a8346e0e0
   5:     0x59fc958cd39d - std::panicking::default_hook::h207342be97478370
   6:     0x59fc958cdaf3 - std::panicking::rust_panic_with_hook::hac8bdceee1e4fe2c
   7:     0x59fc958cd9d4 - std::panicking::begin_panic_handler::{{closure}}::h00d785e82757ce3c
   8:     0x59fc958cc8d9 - std::sys_common::backtrace::__rust_end_short_backtrace::h1628d957bcd06996
   9:     0x59fc958cd707 - rust_begin_unwind
  10:     0x59fc94a8f153 - core::panicking::panic_fmt::hdc63834ffaaefae5
  11:     0x59fc94a8f606 - core::result::unwrap_failed::h82b551e0ff2b2176
  12:     0x59fc94ab3b70 - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut::hc180ffccc4362721
  13:     0x59fc94ad2cbb - rayon::iter::plumbing::Folder::consume_iter::ha7a55117cd2703c7
  14:     0x59fc94b91677 - rayon::iter::plumbing::bridge_producer_consumer::helper::h569aa7c6c6beea36
  15:     0x59fc94ad2b5a - rayon::iter::collect::collect_with_consumer::h0a800268214a4c51
  16:     0x59fc94ac077b - caracal::core::core_unit::CoreUnit::new::hc97dfdad718e0b64
  17:     0x59fc94a9c5af - <caracal::cli::commands::detect::DetectArgs as caracal::cli::commands::Cmd>::run::h6e78611f539cd743
  18:     0x59fc94ab1c8c - caracal::main::he4947808748261a7
  19:     0x59fc94aaf0c3 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd90cc6cc25a8d901
  20:     0x59fc94aabcad - std::rt::lang_start::{{closure}}::hb60b77344446719e
  21:     0x59fc958c18a0 - std::rt::lang_start_internal::h3ed4fe7b2f419135
  22:     0x59fc94ab1ce5 - main
  23:     0x7c4452e2a1ca - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  24:     0x7c4452e2a28b - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:360:3
  25:     0x59fc94a8f825 - _start
  26:                0x0 - <unknown>
notsolexy@lexyjr:~/Documents/sunya$ 

🐛 Note: If the error is related to Sierra not found like:

notsolexy@lexyjr:~/Documents/sunya$ caracal detect ./
Compiling with Scarb. Found Scarb.toml.
Error: Compiled sierra files not found. Ensure in Scarb.toml you have
[[target.starknet-contract]]
sierra = true

It simply means your lib.cairo or any .cairo file content is not compiled as Starknet Smart Contract.

13x54n commented 4 months ago

This pull request with commit contains the security analysis model that checks for vulnerabilities using our datasets.

PR https://github.com/13x54n/sunya/pull/17