Skip to content

Commit

Permalink
Merge pull request #33 from Deivitto/4nalyz3r_descriptions_yarn_fix
Browse files Browse the repository at this point in the history
Added 4nalyz3r, added analyze4 for UX, added descriptions to README, yarn PATH fixed
  • Loading branch information
Deivitto authored Aug 19, 2023
2 parents 67c682b + 9985a87 commit c9af46d
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ RUN echo "alias python3='python3.9'" >> ~/.bashrc && \
echo "alias add2='add2lbox'" >> ~/.bashrc && \
source ~/.bashrc

# Append the specified PATH to .bashrc. This is a hotfix. TODO: https://github.com/Deivitto/auditor-docker/issues/31
RUN echo 'export PATH="$PATH:$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin"' >> ~/.bashrc

# ENTRYPOINT ["/bin/bash"] is used to set the default command for the container to start a new Bash shell.
# This ensures that when the container is run, the user will be dropped into an interactive Bash shell by default.
ENTRYPOINT ["/bin/bash"]
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@ Select the option you want to install and voila, you're all set!
### Base Setup:
- **Operating System**: Ubuntu Jammy (22.04)
- **Utilities**: Git, Curl/wget, gawk/ripgrep, z3, pandoc, openssh-client, texlive, solidity plugins for Vim, etc.
- **Ethereum** dependencies.
### Languages & Frameworks:
- **Python**: Version 3.9
- **Rust**: Comprehensive setup with Cargo
- **Julia**: Built-in support.
- **Noir**: Support for the Noir language (Nargo).
- **Circom**: Framework for zkSNARK circuits.
- **Solidity**: Smart contracts language.
- **Vyper**: Smart contracts language.
### Ethereum Development:
A set of most of the famous tools in the ecosystem by different authors.
- **Ethereum** dependencies.
- **Foundry** as modular toolkit for Ethereum application development written in Rust. It includes: **Forge**, **Anvil**, **Cast**, and **Chisel**. Author Paradigm.
- **Halmos** for Symbolic Bounded Model Checker for Ethereum Smart Contracts Bytecode. Author a16z.
- **Heimdall** for advanced EVM smart contract toolkit specialized in bytecode analysis. Author Jon-Becker.
Expand All @@ -110,6 +112,8 @@ A set of most of the famous tools in the ecosystem by different authors.
- **Mythril** for smart contract analysis. Author Consensys.
- **Spearbit Report Generator**, all needed **dependencies** to use the report generator in Spearbit audits
- **Python developer kit**: It includes **Vyper**, **Ape-Vyper**, **Py-solc-x** and **pyevwasm**, can be found in `add2`
- **4nalyz3r**: A comprehensive static analysis tool for smart contracts. Author: Picodes.
- **Ganache** and **Truffle**: Tools such as running a personal blockchain, development environment, testing framework, and asset pipeline for Ethereum. Author: Truffle Suite.
### Node.js Development:
- **NVM**: Node Version Manager to switch between different Node.js versions.
- **Node**: Long Term Support (LTS) version.
Expand Down Expand Up @@ -148,6 +152,22 @@ issue c4 -n UncheckedTransfer -vim
That would create an issue with the Code4rena template, with name UncheckedTransfer and it is opened at the end using vim. For more info run `issue -h`

# Troubleshooting
## `yarn`: command not found

**Issue**: Command not found due to path being overriden

**Where**: Version 0.0.1 of the auditor toolbox

**Breaks**: Launching


Go to the line at .bashrc that is says :home but not $PATH:home
```diff
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
- export PATH="$PATH:/home/whitehat/.nvm/versions/node/v18.17.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/whitehat/.local/bin"
+ export PATH="$PATH:/home/whitehat/.nvm/versions/node/v18.17.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/whitehat/.local/bin"
. "$HOME/.cargo/env"
```
## Parent system out of time
**Issue**: Exit code 100

Expand Down
110 changes: 110 additions & 0 deletions scripts/analyzer_installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash

# Step 1: Clone the repository and install its dependencies
echo "Cloning 4naly3er repository..."
cd $HOME
git clone https://github.com/Picodes/4naly3er .4nalyz3r

echo "Installing dependencies..."
cd .4nalyz3r && yarn

# Step 2: Create the 4nalyz3r script inside ~/scripts
SCRIPT_PATH="${HOME}/scripts/4nalyz3r.sh"
echo "Creating 4nalyz3r script at ${SCRIPT_PATH}..."

mkdir -p ~/scripts
touch $SCRIPT_PATH
chmod +x $SCRIPT_PATH

cat > $SCRIPT_PATH <<EOL
#!/bin/bash
BASE_DIR="\$(pwd)"
SCOPE_FILE_DEFAULT="scope.txt"
SCRIPT_DIR="${HOME}/.4nalyz3r"
EDITOR_FLAG=""
# Help message function
display_help() {
echo "Usage: analyze4 <BASE_PATH> [SCOPE_FILE.txt] [GITHUB_URL] [-vim|-nano]"
echo
echo "Parameters:"
echo " BASE_PATH : The directory path you want to target."
echo " SCOPE_FILE.txt : Path to a scope file (must be in .txt format)."
echo " If not provided, the script will look for a 'scope.txt' in the current directory."
echo " GITHUB_URL : A valid GitHub URL that starts with 'http://' or 'https://'."
echo
echo "Common Usage:"
echo " 1. analyze4 src - When targeting the 'src' directory and no scope file provided."
echo " 2. analyze4 contracts scope.other.txt - When targeting the 'contracts' directory with a custom scope file."
echo " 3. analyze4 . - When you're in the base root directory and targeting it."
echo " 4. analyze4 src https://github.com/your/repo - When specifying a GitHub URL."
echo
echo "After report generation, you can use flags to view it:"
echo " -vim : Open the report using Vim."
echo " -nano : Open the report using Nano."
}
# Check if no arguments are provided or -h is used
if [[ \$# -eq 0 || "\$1" == "-h" ]]; then
display_help
exit 0
fi
while [[ \$# -gt 0 ]]; do
case "\$1" in
"-vim"|"-nano")
EDITOR_FLAG="\$1"
shift
;;
*)
if [[ -z "\$BASE_PATH" ]]; then
BASE_PATH="\${BASE_DIR}/\$1"
elif [[ "\$1" =~ ^https?:// ]]; then
GITHUB_URL="\$1"
else
SCOPE_FILE_PATH="\$1"
fi
shift
;;
esac
done
# If SCOPE_FILE is not provided and a default scope file exists, use it
if [[ -z "\$SCOPE_FILE_PATH" ]] && [[ -f "\${BASE_DIR}/\${SCOPE_FILE_DEFAULT}" ]]; then
SCOPE_FILE_PATH="\${BASE_DIR}/\${SCOPE_FILE_DEFAULT}"
fi
# Change to the script directory and run yarn analyze
pushd \$SCRIPT_DIR > /dev/null
yarn analyze "\$BASE_PATH" "\$SCOPE_FILE_PATH" "\$GITHUB_URL"
popd > /dev/null
# Move report to the current directory
mv "\$SCRIPT_DIR/report.md" "\$BASE_DIR/analyzer_report.md"
# Check for report and open it if desired
REPORT_PATH="\${BASE_DIR}/analyzer_report.md"
if [[ -f \$REPORT_PATH ]]; then
case "\$EDITOR_FLAG" in
"-vim")
vim \$REPORT_PATH
;;
"-nano")
nano \$REPORT_PATH
;;
esac
fi
EOL

# Step 3: Add the analyze4 alias to ~/.bashrc and source it
echo "Adding alias to ~/.bashrc..."
echo 'alias analyze4="bash ~/scripts/4nalyz3r.sh"' >> ~/.bashrc

# Source .bashrc to reflect the changes
source ~/.bashrc

echo "Reloading bash..."
exec bash

echo "Installation complete! You can now use analyze4 command."
8 changes: 7 additions & 1 deletion scripts/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ selection=$(dialog \
--title "Menu" \
--clear \
--cancel-label "Exit" \
--menu "Please select an option:" 0 0 9 \
--menu "Please select an option:" 0 0 10 \
"1" "Install Echidna" \
"2" "Install Certora Prover + Java SDK 11 (requirement)" \
"3" "Install Mythril" \
Expand All @@ -61,6 +61,7 @@ selection=$(dialog \
"7" "Install Python Developer Tools" \
"8" "Install VS Code Audit Extensions" \
"9" "Install Medusa Fuzzer" \
"10" "Install 4nalyz3r" \
2>&1 1>&3)
exit_code=$?
exec 3>&-
Expand Down Expand Up @@ -127,6 +128,11 @@ case $selection in
result="medusa_fuzzer.sh installed successfully!"
display_result "Result"
;;
10)
run_with_progress "/home/whitehat/scripts/analyzer_installer.sh" "4nalyz3r"
result="analyzer_installer.sh installed successfully!"
display_result "Result"
;;
esac

done

0 comments on commit c9af46d

Please sign in to comment.