Giter VIP home page Giter VIP logo

aderyn's Introduction



A powerful Solidity static analyzer that takes a bird's eye view over your smart contracts.



Docs Get support Website Twitter


Stargazers Forks Contributors Issues GPL-3.0 License

What is Aderyn?

Aderyn is an open-source public good developer tool. It is a Rust-based solidity smart contract static analyzer designed to help protocol engineers and security researchers find vulnerabilities in Solidity code bases.

Thanks to its collection of static vulnerability detectors, running Cyfrin Aderyn on your Solidity codebase will highlight potential vulnerabilities, drastically reducing the potential for unknown issues in your Solidity code and giving you the time to focus on more complex problems.

Built using Rust, Aderyn integrates seamlessly into small and enterprise-level development workflows, offering lighting-fast command-line functionality and a framework to build custom detectors to adapt to your codebase.

You can read the Cyfrin official documentation for an in-depth look at Aderyn's functionalities.

Features

  • Supports any development framework (Foundry/Hardhat/Truffle/etc)
  • Modular detectors
  • AST Traversal
  • Markdown reports

Installation

Suggested VSCode extensions: rust-analyzer - Rust language support for Visual Studio Code Rust Syntax - Improved Rust syntax highlighting

Installing Aderyn

You can install Aderyn using Cargo, Rust's package manager, or with cyfrinup, the Cyfrin CLI tool.

Using Cyfrinup

Note: If you previously installed aderyn using cargo, run cargo uninstall aderyn before using cyfrinup to avoid conflicts.

Step 1: Install Cyfrinup

Cyfrinup is a CLI tool that simplifies the installation and management of Cyfrin tools. To install Cyfrinup, run the following command in your terminal:

curl -L https://raw.githubusercontent.com/Cyfrin/aderyn/dev/cyfrinup/install | bash

Step 2: Update Path

The installer will prompt you to run a source command. Either run this command, or reload your terminal.

Step 3: Install Aderyn using Cyfrinup

After installing Cyfrinup, you can use it to install Aderyn. Run the following command in your terminal:

cyfrinup

Step 4: Verify installation

aderyn --version

Future Updates

To update Aderyn to the latest version, you can run the cyfrinup:

cyfrinup

Cyfrinup will replace the existing version with the latest one.

Using Cargo

Step 1: Install Rust

Before installing Aderyn, ensure you have the following:

  • Rust: Aderyn is built in Rust. Before running, you must install Rust and Cargo (Rust's package manager). If you still need to install Rust, follow the instructions on the official Rust website.

Step 2: Install Aderyn using cargo

Aderyn is currently installed using Cargo, Rust's package manager. Open your command line interface and run the following command:

cargo install aderyn

This command downloads and installs the Aderyn package.

Step 3: Verify installation

After the installation, you can verify that Aderyn is correctly installed by checking its version. In your command line, execute:

aderyn --version

This command should return the installed version of Aderyn, confirming that the installation was successful.

Step 4: Update PATH (if necessary)

If you cannot run the aderyn after installation, you may need to add Cargo's bin directory to your PATH. The exact instructions can vary based on your operating system. Typically, it involves adding ~/.cargo/bin to your PATH in your shell profile script (like .bashrc or .zshrc).

Step 5: Future Updates

To update Aderyn to the latest version, you can run the install command again:

cargo install aderyn

Cargo will replace the existing version with the latest one.

Quick Start

Once Aderyn is installed on your system, you can run it against your Foundry-based codebase to find vulnerabilities in your code.

We will use the aderyn-contracts-playground repository in this example. You can follow along by cloning it to your system:

git clone https://github.com/Cyfrin/aderyn-contracts-playground.git

Navigate inside the repository:

cd aderyn-contracts-playground

We usually use several smart contracts and tests to try new detectors. Build the contracts by running:

forge build

Once your smart contracts have been successfully compiled, run Aderyn using the following command:

aderyn [OPTIONS] path/to/your/project

Replace [OPTIONS] with specific command-line arguments as needed.

For an in-depth walkthrough on how to get started using Aderyn, check the Cyfrin official docs

Arguments

Usage: aderyn [OPTIONS] <ROOT>

<ROOT>: The path to the root of the codebase to be analyzed. Defaults to the current directory.

Options:

  • -s, --src: Path to the source contracts. If not provided, or if aderyn can't find famous files to read (like foundry.toml, which it automatically searches for) the ROOT directory will be used.
    • In foundry projects, this is usually the src/ folder unless stated otherwise in foundry.toml.
    • In Hardhat projects, this is usually the contracts/ folder unless stated otherwise in the config.
  • -i, --path-includes <PATH_INCLUDES>: List of path strings to include, delimited by comma (no spaces). Any solidity file path not containing these strings will be ignored
  • -x, --path-excludes <PATH_EXCLUDES>: List of path strings to exclude, delimited by comma (no spaces). Any solidity file path containing these strings will be ignored
  • -o, --output <OUTPUT>: Desired file path for the final report (will overwrite the existing one) [default: report.md]
  • -n, --no-snippets: Do not include code snippets in the report (reduces report size in large repos)
  • -h, --help: Print help
  • -V, --version: Print version

You must provide the root directory of the repo you want to analyze. Alternatively, you can provide a single Solidity file path (this mode requires Foundry to be installed).

Examples:

aderyn /path/to/your/foundry/project/root/directory/

Find more examples on the official Cyfrin Docs

Building a custom Aderyn detector

Aderyn makes it easy to build Static Analysis detectors that can adapt to any Solidity codebase and protocol. This guide will teach you how to build, test, and run your custom Aderyn detectors. To learn how to create your custom Aderyn detectors, checkout the official docs

Docker

You can run Aderyn from a Docker container.

Build the image:

  docker build -t aderyn .

/path/to/project/root should be the path to your Foundry or Hardhat project root directory and it will be mounted to /share in the container.

Run Aderyn:

  docker run -v /path/to/project/root/:/share aderyn

Run with flags:

  docker run -v /path/to/project/root/:/share aderyn -h

Single Solidity File Mode

If it is a Solidity file path, then Aderyn will create a temporary Foundry project, copy the contract into it, compile the contract and then analyze the AST generated by that temporary project.

Contributing & License

Help us build Aderyn ๐Ÿฆœ Please see our contribution guidelines. Aderyn is an open-source software licensed under the GPL-3.0 License.

To build Aderyn locally:

  1. Install Rust,
  2. Clone this repo and cd aderyn/,
  3. make,
  4. Use cargo commands to build, test and run locally.

Credits

This project exists thanks to all the people who contribute.

Attribution

  • AST Visitor code from solc-ast-rs.
  • Original detectors based on 4naly3er detectors.
  • Shoutout to the original king of static analysis slither.

aderyn's People

Contributors

alexroan avatar anaarsonist avatar eversmile12 avatar kevincharm avatar lukapodlesnik avatar patrickalphac avatar rensr avatar tilakmaddy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

aderyn's Issues

Markdown links don't work

This one works:

- [NC Issues](#nc-issues)

Because later in the markdown file, it's actually a markdown link:

# NC Issues

But this one doesn't work:

  - [NC-1: Functions not used internally could be marked external](#NC-1)
markdown-links.mov

Because later it's not actually a markdown link:

<a name="NC-1"></a>

Optional (aka, Im unsure how good this is): Add links to outputs in reports

When you get a markdown report in aderyn, it lists locations like so:

- Found in src/TSwapPool.sol: Line: 229
- Found in src/TSwapPool.sol: Line: 359

It would be cool if those were also links so that they could be CMD + click (on mac) or CTRL + clicked into and developers can go directly to the effected lines, like so:

- Found in [src/TSwapPool.sol](src/TSwapPool.sol) Line: 229

The above example brings you to the effected file, would be sick to even bring it to the line #

thread 'main' panicked at...

I am failing to run aderyn at the root of my project with:

aderyn .

Here is the error:

โฏ aderyn .
Detecting framework...
Framework detected. Hardhat mode engaged.
Hardhat root path: "."
Loading Hardhat build-info file: "./artifacts/build-info/b03ce52c7afbce296e863abe208b9305.json"
Get Detectors
Running 17 detectors
Detectors run, processing found issues
thread 'main' panicked at /Users/daniel.zarifpour/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aderyn-0.0.6/src/ast/source_units.rs:87:18:
byte index 62676 is out of bounds of `/*
    Copyright 2021 Set Labs Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LI`[...]
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

My project contains many contracts with the following header and it seems aderyn is having an issue with that:

/*
    Copyright 2020 Set Labs Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

    SPDX-License-Identifier: Apache-2.0
*/

Here is the full trace:

โฏ RUST_BACKTRACE=full aderyn .
Detecting framework...
Framework detected. Hardhat mode engaged.
Hardhat root path: "."
Loading Hardhat build-info file: "./artifacts/build-info/b03ce52c7afbce296e863abe208b9305.json"

Get Detectors
Running 17 detectors
Detectors run, processing found issues
thread 'main' panicked at /Users/daniel.zarifpour/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aderyn-0.0.6/src/ast/source_units.rs:87:18:
byte index 62676 is out of bounds of `/*
    Copyright 2021 Set Labs Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LI`[...]
stack backtrace:
   0:        0x1029e6c84 - std::backtrace_rs::backtrace::libunwind::trace::hddb53f9645107e69
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:        0x1029e6c84 - std::backtrace_rs::backtrace::trace_unsynchronized::hfcf876f940dc8da4
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x1029e6c84 - std::sys_common::backtrace::_print_fmt::hf62909a9f73a69a7
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys_common/backtrace.rs:67:5
   3:        0x1029e6c84 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4bff038afc05d0ab
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x102a046c0 - core::fmt::rt::Argument::fmt::h676aefe1d8d32022
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/fmt/rt.rs:138:9
   5:        0x102a046c0 - core::fmt::write::he9fa43146d420946
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/fmt/mod.rs:1114:21
   6:        0x1029e46a0 - std::io::Write::write_fmt::hf4fd30c8192b15d9
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/io/mod.rs:1763:15
   7:        0x1029e6ac4 - std::sys_common::backtrace::_print::h8f03427ed63e3fce
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys_common/backtrace.rs:47:5
   8:        0x1029e6ac4 - std::sys_common::backtrace::print::h5d71f7b09493fc9b
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys_common/backtrace.rs:34:9
   9:        0x1029e80c4 - std::panicking::default_hook::{{closure}}::hb75620628e95e648
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:272:22
  10:        0x1029e7ddc - std::panicking::default_hook::h4ac4acc64d21c4ad
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:292:9
  11:        0x1029e8608 - std::panicking::rust_panic_with_hook::h81dc715fa5de32cf
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:731:13
  12:        0x1029e8510 - std::panicking::begin_panic_handler::{{closure}}::h26c73eb75670321f
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:609:13
  13:        0x1029e7110 - std::sys_common::backtrace::__rust_end_short_backtrace::hef4773cf0f80485b
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys_common/backtrace.rs:170:18
  14:        0x1029e827c - rust_begin_unwind
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
  15:        0x102a32b90 - core::panicking::panic_fmt::h10bd3bfe5bb30d67
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
  16:        0x102a08408 - core::str::slice_error_fail_rt::hdce281cf3fc3561d
  17:        0x102a330a8 - core::str::slice_error_fail::h53326690f1daf6e3
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/str/mod.rs:87:9
  18:        0x102861b4c - aderyn::ast::source_units::SourceUnit::source_line::h74190c27986ecc41
  19:        0x102824d30 - aderyn::context::loader::ContextLoader::get_node_sort_key::h85b5ffc4a9880f38
  20:        0x10280a5e4 - alloc::slice::<impl [T]>::sort_by::{{closure}}::hb22f48bd58753205
  21:        0x10280975c - core::slice::sort::merge_sort::had70718c99fc7491
  22:        0x102863d78 - aderyn::report::reporter::Report::post_process::hc49353775940c8cb
  23:        0x102864108 - aderyn::run::hf2588d57cbc1ca8a
  24:        0x10271d4e4 - aderyn::main::h6a1b7fe683a3e355
  25:        0x102731ed0 - std::sys_common::backtrace::__rust_begin_short_backtrace::h58dcbbe961653427
  26:        0x102725fd4 - std::rt::lang_start::{{closure}}::h2a77eb83ec9e8202
  27:        0x1029ded8c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hdb9d57f6813b6639
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:284:13
  28:        0x1029ded8c - std::panicking::try::do_call::h3316be3da4e712e4
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:504:40
  29:        0x1029ded8c - std::panicking::try::h72745351e21d17fd
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:468:19
  30:        0x1029ded8c - std::panic::catch_unwind::h2df3aeb4d14c657e
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panic.rs:142:14
  31:        0x1029ded8c - std::rt::lang_start_internal::{{closure}}::h40cc69f0b809216f
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/rt.rs:148:48
  32:        0x1029ded8c - std::panicking::try::do_call::hdf604766e4bed556
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:504:40
  33:        0x1029ded8c - std::panicking::try::h52de1aaf80258115
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:468:19
  34:        0x1029ded8c - std::panic::catch_unwind::hec154f66f8285e2b
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panic.rs:142:14
  35:        0x1029ded8c - std::rt::lang_start_internal::haeade8bb0e866fa6
                               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/rt.rs:148:20
  36:        0x10271eb7c - _main

Using ERC721::_mint() can be dangerous

I am following @PatrickAlphaC security course.

In T-Swap ERC20 tokens are used not ERC721
while running aderyn It outputs the following Issue.

# Medium Issues

## M-1: Using `ERC721::_mint()` can be dangerous

Using `ERC721::_mint()` can mint ERC721 tokens to addresses which don't support ERC721 tokens. Use `_safeMint()` instead of `_mint()` for ERC721.

- Found in src/TSwapPool.sol [Line: 155](src/TSwapPool.sol#L155)

	```solidity
	        _mint(msg.sender, liquidityTokensToMint);
	```

I think I am using the latest version. Let me know if I have to update anything.

Requesting clarification

So I see this point in medium term goals section in the readme

installer that doesn't require Rust (aderynup)

Doubt:

Rust compiles the code to native binary. (there is no runtime). So if people have to use the aderyn cli we can distribute that cli natively for each architecture - (lookup these commands: rustup target add XXXX) and allow download. Done ! No rust in the picture : )

I feel like cyfrinup would make more sense than aderynup because then you can make the argument that we need a binary to sit in the user's computer which will be responsible for fetching and downloading other binaries offered by cyfrin such as aderyn, etc, etc ... and keep them up to date.

Even then you wouldn't need Rust !

I may be going wrong somewhere in my thought process. If anybody is kind enough to explain I'll be very grateful

Detector: variable assigned to ternary operator output not used

We should add a detector for the following case:

function foo(uint256 amount) external returns(uint256 cappedAmount) {
    cappedAmount = amount > s_maxAmount ? s_maxAmount : amount;
    transfer(amount); // `cappedAmount` should be passed here, but instead remains unused
}

Here, the variable assigned to the output of the ternary operator is unused because the amount input parameter is erroneously passed to the subsequent function call instead of cappedAmount, meaning that the value is not capped as intended.

We should add a detector to alert of this case, when the assigned variable remains unused as it could be indicative of this issue.

NC-2: Functions not used internally could be marked external - doesn't look at modifiers

git clone https://github.com/Cyfrin/6-thunder-loan-audit
cd 6-thunder-loan-audit
make 
aderyn .

In the report, you'll get:

<a name="NC-2"></a>
## NC-2: Functions not used internally could be marked external



- Found in src/upgradedProtocol/ThunderLoanUpgraded.sol: Line: 230
- Found in src/protocol/ThunderLoan.sol: Line: 278
- Found in src/protocol/ThunderLoan.sol: Line: 282
- Found in src/upgradedProtocol/ThunderLoanUpgraded.sol: Line: 279
- Found in src/upgradedProtocol/ThunderLoanUpgraded.sol: Line: 275
- Found in src/protocol/ThunderLoan.sol: Line: 236
- Found in src/upgradedProtocol/ThunderLoanUpgraded.sol: Line: 271
- Found in src/protocol/ThunderLoan.sol: Line: 286

But this function:

- Found in src/protocol/ThunderLoan.sol: Line: 278

is used in a modifier

nSLOC is not correct

git clone https://github.com/Cyfrin/6-thunder-loan-audit
cd 6-thunder-loan-audit
make 
aderyn .

You'll see the nSLOC output is incorrect

add scopefile option

Instead of passing in a comma separated list into the CLI, it would be nice to read from a scopefile where the newline character acted as the comma. Let me know if this is not clear.

Enhancement: Speed up ordering of issue instances

Once the issues are all ready for the report, report.post_process is called. This runs through all the known issue instances and orders by absolute_path and source_line number. This can take quite some time because it's ordering over everything at the end. Instead: Order as each instance is inserted?

Error Detecting Framework

I installed Rust on my system and tried to use Aderyn on my solidity projects. On running aderyn . in my VSCode terminal of the project directory, I get the error

shiven@Shivendras-MacBook-Pro vulnerability-detection-exercises % aderyn .
Detecting framework...
Error detecting framework

I even tried running Aderyn after mentioning the full path to the project directory, but no luck!

Aderyn not working correctly.

I am using VSCode and i am using Gitbash terminal.So i installed aderyn according to the repository guidance and while it runs without errors when i give the aderyn . command and the report.md is created the report never finds any results even in the projects of the course.

Below is the text i get when running the command:


$ aderyn .
Detecting framework...
Framework detected: Foundry mode engaged.
Foundry root path: "."
[โ ’] Compiling...
[โ †] Compiling 41 files with 0.8.20
[โ ”] Solc 0.8.20 finished in 15.36s
Compiler run successful!
Foundry src path: ".\\src"
Get Detectors
Running 18 detectors
Detectors run, processing found issues 
Found issues processed. Printing report
Report printed to report.md

A report.md is created but everytime it looks like this with no results:

Aderyn Analysis Report

This report was generated by Aderyn, a static analysis tool built by Cyfrin, a blockchain security company. This report is not a substitute for manual audit or security review. It should not be relied upon for any purpose other than to assist in the identification of potential security vulnerabilities.

Table of Contents

Summary

Files Summary

Key Value
.sol Files 0
Total nSLOC 0

Files Details

Filepath nSLOC
Total 0

Issue Summary

Category No. of Issues
Critical 0
High 0
Medium 0
Low 0
NC 0

I get the same results in avery project i have tried using it.No change.How can i make it work?Is there something else i should have installed that it is not mentioned in the repository?

VSCode Extension

Aderyn VScode extension that live-highlights code with issues.

Discussion: Expand the definition of a detector

Currently, the definition of a detector is a piece of code that finds and stores issues and makes them available to the report writer.

Following a discussion with Chase, this idea is to broaden that definition so that detectors are reusable and can do more granular, repeatable things without printing the results to a report.

For example, a detector could be written solely to find all instances where a state variable was altered (feed it a state variable VariableDeclaration and find all Assignments with it on the leftHandSide). This detector would be called by other detectors rather than by the aderyn driver, so it would not produce items for the report.

We could implement this sort of reusable feature in the browser package, which currently hosts the Extractor and Parent builtin functionality. However, that locks detector developers into only the functionality in the core code. Now that we have the nyth development framework available, it would be great if we could leverage the existing concepts (detectors) and tooling to produce the same outcome, enabling developers to create their own "builtins" whilst they work on their reporting detectors.

There aren't a huge amount of changes to achieve this. The ones that come to mind are:

  • Change found_instances to have a value of NodeId (i64), change macro
  • Add an extra parameter to Detector.detect for reusable purposes, ignore for normal detectors?
  • Unkown unknowns (I'll look into these ASAP)

The other options are:

  • Introduce a new concept, separate from detectors, that covers this. Add the new concept to nyth with a new command and teach what it's for.
  • Continue to build out the built-ins (Extractors) without any of this stuff. (<- This is not really an option if we want to leverage the community to rapidly write useful detectors, IMO).

cc: @TilakMaddy

Foundry loader doesn't account for multiple compiler versions

Error reading Foundry output file: /Users/alexroan/Documents/Rust/aderyn/tests/contract-playground/out/InheritanceBase.sol/InheritanceBase.json: No such file or directory (os error 2)
Error reading Foundry output file: /Users/alexroan/Documents/Rust/aderyn/tests/contract-playground/out/IContractInheritance.sol/IContractInheritance.json: No such file or directory (os error 2)
Error reading Foundry output file: /Users/alexroan/Documents/Rust/aderyn/tests/contract-playground/out/Counter.sol/Counter.json: No such file or directory (os error 2)

When this happens:
Screenshot 2023-12-19 at 16 42 39

Missing files with SLOC

Aderyn is missing files when giving the sloc report.

Steps:

git clone https://github.com/Cyfrin/1-horse-store-s23
cd 1-horse-store-s23
aderyn .

The report will miss src/horseStoreV1/HorseStore.sol. It will instead output:

## Files Details

| Filepath | nSLOC |
| --- | --- |
| src/horseStoreV1/HorseStoreYul.sol | 16 |
| src/horseStoreV1/interfaces/ISimpleStorage.sol | 5 |
| src/horseStoreV2/IHorseStore.sol | 7 |
| **Total** | **28** |

Cannot install aderyn

I have successfully installed rust and cargo - I get verification for both when running "--version" for each. However, I cannot successfully install aderyn - I keep getting these errors in the command line when running ''' cargo install aderyn '''

'''
error: linker cc not found
|
= note: No such file or directory (os error 2)

error: could not compile rayon-core (build script) due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile serde (build script) due to previous error
error: could not compile crossbeam-utils (build script) due to previous error
error: could not compile proc-macro2 (build script) due to previous error
error: failed to compile aderyn v0.0.12, intermediate artifacts can be found at /tmp/cargo-installg4LkPc.
To reuse those artifacts with a future compilation, set the environment variable CARGO_TARGET_DIR to that path.
'''

Any help is much appreciated.

AST -> Contract File's line number may not always function as desired

Potentially could be an issue (not sure tho)

So, in our (AST -> File line) mapping logic as highlighted below it appears to me like we rely on type 1 format style to be present in the Compiler's output AST

According to the spec here, following 2 types are possible are equivalent

This means the following source mappings represent the same information:

(Type 1)

1:2:1;1:9:1;2:1:2;2:1:2;2:1:2

(Type 2)

1:2:1;:9;2:1:2;;

let values: Vec<Option<usize>> = src
.split(':')
.map(|token| {
if token.is_empty() {
None
} else {
token
.parse()
.map_err(|error| io::Error::new(io::ErrorKind::InvalidData, error))
.ok()
}
})
.collect();
let index = values
.first()
.and_then(|&value| value)
.ok_or_else(|| eyre!("not found"))?;

In addition to that here's a note that looks slightly concerning too.

Important to note is that when the verbatim builtin is used, the >source mappings will be invalid: The builtin is considered a single instruction instead of potentially multiple.

(found as a note at the end of this document)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.