angr/tests/analyses/__init__.py
Pamplemousse d35d857e61
CFG visitor on a slice (#2042)
* ForwardAnalysis: Add a `SliceVisitor`

  * Add `SliceToSink` to model a slice where all paths flow into a given
  sink Function;
  * Update `ReachingDefinitionsAnalysis` to be able to analyse such a
  slice.

* Tests: Move tests for RDA in subfolder

As more tests related to the "analyses" are to be added later.

* SliceVisitor: Improve

  * CFG slicing:
    - Feature to slice any graph moved to the `slice_to_sink` module;
    - Update the nodes' reference to the new CFG.
  * Feature to remove elements from `_sorted_nodes` (to forcefully skip
  certain nodes, esp. when already visited by an upstream analysis).
  * Cleaner subject initialisation.

* SliceVisitor: Slice a function graph

  * Feature to slice a function graph generated from the same CFG the
  `slice_to_sink` was generated from;
  * Use THIS when slicing function graphs in RDA (otherwise, the
  resulting graph is *WRONG* - missing edges).

* SliceToSink: s/slice_graph/slice_cfg_graph

  * more explicit
  * as we will add a function to slice a callgraph

* SliceToSink: Add a `path_between` function

* SliceVisitor: Should not compute the slice of the CFG

As more complex behavior will be added later (slicing,
context-sensitization, second slicing), it becomes obvious that
`SliceVisitor` has too many responsabilities.

Let the caller deal with the update of the CFG.

* SliceToSink: Remove unused functionality

Now that the backward slice construction is context-sensitive, there is
no use for a function to add *all* predecessors without making any
distinction between them.

*Note*: As of now, the "consuming" code in not yet in `angr`'s codebase

* SliceToSink: Add a `slice_callgraph` function

  * to slice a callgraph from a slice_to_sink
  * useful for debuging

* Rename SliceToSink into CFGSliceToSink

  * sounds less like an action
  * is more accurate about what it represents

* Replace the `SliceVisitor` by a `CFGVisitor`

As when running a RDA on a `CFGSliceToSink`, the CFG to run on is
trimmed.

* My attempts to fix the broken test cases.

* Add a few missing functions.

* Cleanup some tests

  * stop using `nose` by favoring vanilla `unittest`
  * avoid globals

* Get rid of mock.patch function decorators because nose2 does not like them.

* More fixes.

* Lint the code.

* Hopefully this is the last fix.

Co-authored-by: Fish <fishw@asu.edu>
2020-06-13 01:32:21 -07:00

0 lines
Python