crytic / tealer

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

Update parser to construct separate subroutine CFGs #167

Closed S3v3ru5 closed 1 year ago

S3v3ru5 commented 1 year ago

For each stage of the parsing, new function is added which has the same functionality with the difference that this new variant constructs the new CFG. New CFG is CFG where callsub instructions are not connected to the subroutine entry block and subroutine retsub blocks are not connected to return points.

Parsing is done two times, the first time to construct the old CFG using the old functions for each pass and the second time to construct the new CFG using the new functions of each pass. Separate objects of instructions, basic blocks, and subroutines are created for the old and new CFG.

The Teal class is updated to store the new CFG objects alongside the old CFG objects. Every function, class member, and the properties have a _NEW suffix to differentiate between objects of the same name in old and new CFG. At the end of the refactoring, The old properties, and functions should be removed, and run the tests after that, update the _NEW functions, ... to the old names in a separate PR.

Some tests are updated to use the new CFG, and new objects, and test them. An additional test is also added which takes the new CFG and compares it against the old CFG.

protected-access is disabled for now because all _NEW do not have corresponding class properties. We should enable it at the end of the refactoring.

S3v3ru5 commented 1 year ago

Builds on #163