
Searaify 2.0是以太坊基金会和链条支持的以太坊智能合约的安全扫描仪。 Searifify背后的核心研究是在Eth Zurich的安全,可靠和智能的系统实验室进行的。
它是受欢迎的Securefy Security扫描仪的后继产品(您可以在此处找到旧版本)。
建造容器:
sudo docker build -t securify .
运行容器:
sudo docker run -it -v <contract-dir-full-path>:/share securify /share/<contract>.sol
注意:要通过Docker运行代码,其坚固性版本与0.5.12不同,您将需要修改Dockerfile顶部的变量ARG SOLC=0.5.12以指向您的版本。使用正确的版本构建后,您不应遇到错误。
以下说明假定已经安装了Python。除此之外,Securefy需要在系统上安装solc , souffle和graphviz :
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
按照此处的说明:https://souffle-lang.github.io/download.html
请不要选择不稳定的版本,因为它可能在任何时候破裂。
sudo apt install graphviz
安装先决条件后,我们可以设置Python虚拟环境,我们将在该虚拟环境中运行该项目中的脚本。
在项目的根文件夹中,执行以下命令以设置并激活虚拟环境:
virtualenv --python=/usr/bin/python3.7 venv
source venv/bin/activate
验证python版本实际上是3.7 :
python --version
设置LD_LIBRARY_PATH :
cd <securify_root>/securify/staticanalysis/libfunctors
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`
最后,通过从<securify_root>文件夹中运行以下命令来安装项目的依赖项:
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
现在,您可以开始使用Seareify框架了。
请记住:在执行框架的脚本之前,您需要使用以下命令来激活虚拟环境:
source venv/bin/activate
当前,Seareify2仅支持不包含进口声明的合同的平面合同。
要分析当地合同,简单地运行:
securify <contract_source>.sol [--use-patterns Pattern1 Pattern2 ...]
或使用Etherscan.io API从区块链下载它:
securify <contract_address> --from-blockchain [--key <key-file>]
请注意,您需要Etherscan.io的API-KEY来使用此功能。
分析针对特定严重性水平的合同:
securify <contract_source>.sol [--include-severity Severity1 Severity2]
securify <contract_source>.sol [--exclude-severity Severity1 Severity2]
为了使所有可用模式运行:
securify --list
| ID | 图案名称 | 严重程度 | Slither ID | SWC ID | 评论 |
|---|---|---|---|---|---|
| 1 | Todamount | 批判的 | - | SWC-114 | |
| 2 | Todreceiver | 批判的 | - | SWC-114 | |
| 3 | Todtransfer | 批判的 | - | SWC-114 | |
| 4 | 不受限制地 | 批判的 | - | SWC-124 | |
| 5 | Right Toleftoverride | 高的 | rtlo | SWC-130 | |
| 6 | Shadowedstatevaria | 高的 | shadowing-state , shadowing-abstract | SWC-119 | |
| 7 | 不受限制的自我毁灭 | 高的 | suicidal | SWC-106 | |
| 8 | 非初始化的州 | 高的 | uninitialized-state | SWC-109 | |
| 9 | 非初始化的距离 | 高的 | uninitialized-storage | SWC-109 | |
| 10 | 不受限制的DelegateCall | 高的 | controlled-delegatecall | SWC-112 | |
| 11 | 道 | 高的 | reentrancy-eth | SWC-107 | |
| 12 | ERC20接口 | 中等的 | erc20-interface | - | |
| 13 | ERC721结界 | 中等的 | erc721-interface | - | |
| 14 | 不正确的平等 | 中等的 | incorrect-equality | SWC-132 | |
| 15 | 锁定 | 中等的 | locked-ether | - | |
| 16 | 重新进入 | 中等的 | reentrancy-no-eth | SWC-107 | |
| 17 | txorigin | 中等的 | tx-origin | SWC-115 | |
| 18 | 未手持感受 | 中等的 | unchecked-lowlevel | - | |
| 19 | 无限制流 | 中等的 | unchecked-send | SWC-105 | |
| 20 | 非专业的local | 中等的 | uninitialized-local | SWC-109 | |
| 21 | 未使用的记录 | 中等的 | unused-return | SWC-104 | |
| 22 | Shadowedbuiltin | 低的 | shadowing-builtin | - | |
| 23 | Shadowedlocalvarable | 低的 | shadowing-local | - | |
| 24 | CallTodeFaultConstructor? | 低的 | void-cst | - | |
| 25 | Callinloop | 低的 | calls-loop | SWC-104 | |
| 26 | 重新进入 | 低的 | reentrancy-benign | SWC-107 | |
| 27 | 时间戳 | 低的 | timestamp | SWC-116 | |
| 28 | 组装 | 信息 | assembly | - | |
| 29 | ERC20索引 | 信息 | erc20-indexed | - | |
| 30 | LowlevelCalls | 信息 | low-level-calls | - | |
| 31 | 命名 | 信息 | naming-convention | - | |
| 32 | 解决方案 | 信息 | solc-version | SWC-103 | |
| 33 | 无用的州 | 信息 | unused-state | - | |
| 34 | toomanynigits | 信息 | too-many-digits | - | |
| 35 | 构成 | 信息 | constable-states | - | |
| 36 | 外部功能 | 信息 | external-function | - | |
| 37 | StateVariablesDefaultVisible | 信息 | - | SWC-108 |
由于固体编译器对其进行检查(VER。0.5.8):
constant-functiondeprecated-standardspragma以下SWC漏洞不适用于具有pragma> = 5.8的坚固合同,因此未通过Seareify检查: