Commit 91349655 authored by clabby's avatar clabby

Semgrep + README

parent 0d86b084
......@@ -4,6 +4,8 @@ Simple CLI tool to scan all accounts in a geth LevelDB for contracts that begin
## Usage
1. Pass the directory of the Geth DB into the tool
```sh
go run eof_crawler.go <db_path>
```
2. Once the indexing has completed, an array of all EOF-prefixed contracts will be written to `eof_contracts.json`.
......@@ -3,7 +3,6 @@ package main
import (
"bytes"
"encoding/json"
"io/ioutil"
"log"
"os"
"time"
......@@ -69,7 +68,10 @@ func main() {
for it.Next() {
// Decode the state account
var data types.StateAccount
rlp.DecodeBytes(it.Value, &data)
err := rlp.DecodeBytes(it.Value, &data)
if err != nil {
log.Fatalf("Failed to decode state account: %v", err)
}
// Check to see if the account has any code associated with it before performing
// more reads from the trie & db.
......@@ -100,7 +102,6 @@ func main() {
code, err := stateDB.ContractCode(crypto.Keccak256Hash(addrBytes), common.BytesToHash(data.CodeHash))
if err != nil {
log.Fatalf("Could not load code for account %x: %v", addr, err)
continue
}
// Check if the contract's runtime bytecode starts with the EOF prefix.
......@@ -125,7 +126,10 @@ func main() {
if err != nil {
log.Fatalf("Cannot marshal EOF contracts: %v", err)
}
err = ioutil.WriteFile("eof_contracts.json", file, 0644)
err = os.WriteFile("eof_contracts.json", file, 0644)
if err != nil {
log.Fatalf("Failed to write EOF contracts array to file: %v", err)
}
log.Printf("Wrote list of EOF contracts to `eof_contracts.json`")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment