crytic / tealer

Static Analyzer for Teal
GNU Affero General Public License v3.0
62 stars 14 forks source link

Add support to filter execution paths from output #142

Closed S3v3ru5 closed 1 year ago

S3v3ru5 commented 1 year ago

Adds a command line argument --filter-paths

  --filter-paths FILTER_PATHS
                        Excludes execution paths matching the regex from detector's output.

filter-paths option takes in a regex and uses it to filter reported execution paths by detector(s). The regex is matched against the short form notation of the execution path.

short_form = " -> ".join(block_id(block) for block in path)

Ex:

$ tealer test_code.teal --detect feeCheck
...
         path: 0 -> 1 -> 2 -> 3 -> 4 -> 7
         check file: missing_fee_check_1.dot

         path: 0 -> 1 -> 2 -> 3 -> 8
         check file: missing_fee_check_2.dot

         path: 0 -> 1 -> 10
         check file: missing_fee_check_3.dot

         path: 0 -> 11 -> 13 -> 14 -> 16 -> 12
         check file: missing_fee_check_4.dot

Using filter-paths

$ tealer test_code.teal --detect feeCheck --filter-paths "1 -> . -> 3"
...
         path: 0 -> 1 -> 10
         check file: missing_fee_check_1.dot

         path: 0 -> 11 -> 13 -> 14 -> 16 -> 12
         check file: missing_fee_check_2.dot