Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of slither static code analysis #94

Merged
merged 5 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ utility-emissions-channel/docker-compose-setup/bin
utility-emissions-channel/docker-compose-setup/bin_mac
utility-emissions-channel/docker-compose-setup/config
utility-emissions-channel/chaincode/node/node_modules

slitherlog.json
45 changes: 45 additions & 0 deletions net-emissions-token-network/runSlither.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import subprocess
import glob, os

solFiles = []

def getSolFiles():
os.chdir("backupContractDir")
for file in glob.glob("*.sol"):
print(file)
solFiles.append(["backupContractDir/"+file, file])

os.chdir("Governance")
for file in glob.glob("*.sol"):
print(file)
solFiles.append(["backupContractDir/Governance/"+file, file])

os.chdir("..")
os.chdir("..")

def getProjectPath():
rootPath = os.getcwd()

def main():
getProjectPath()
subprocess.run(["mv", "contracts", "backupContractDir"])
getSolFiles()
subprocess.run(["mkdir" , "SlitherResults"])
for entry in solFiles:
subprocess.run(["rm" , "-rf", "contracts"])
subprocess.run(["rm" , "-rf", "artifacts"])
subprocess.run(["mkdir" , "contracts"])
subprocess.run(["cp", entry[0], "contracts/"])
subprocess.run(["slither" , ".", "--json", "SlitherResults/"+entry[1]+".json", "--print", "human-summary"])
subprocess.run(["rm" , "-rf", "contracts"])
subprocess.run(["rm" , "-rf", "artifacts"])


#revert everything
subprocess.run(["rm" , "-rf", "contracts"])
subprocess.run(["mv", "backupContractDir", "contracts"])
subprocess.run(["rm" , "-rf", "artifacts"])

if __name__ == "__main__":
main()

10 changes: 10 additions & 0 deletions net-emissions-token-network/runSlither.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Dependancies
# python 3.6+
# pip3
# pip3 install slither-analyzer or https://github.com/crytic/slither
npm install
pip3 install slither-analyzer
rm -f slitherlog.json
python3 runSlither.py
18 changes: 18 additions & 0 deletions net-emissions-token-network/slither.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"detectors_to_run": "all",
"printers_to_run": "human-summary",
"detectors_to_exclude": "",
"exclude_informational": false,
"exclude_low": false,
"exclude_medium": false,
"exclude_high": false,
"solc": "solc",
"solc_args": "",
"solc_disable_warnings": false,
"json": "slitherlog.json",
"disable_color": false,
"filter_paths": "",
"legacy_ast": false
}