Class SubgraphWalker

java.lang.Object
de.fraunhofer.aisec.cpg.helpers.SubgraphWalker

public class SubgraphWalker
extends java.lang.Object
Helper class for graph walking: Walking through ast-, cfg-, ...- edges
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  SubgraphWalker.Border
    For better readability: result.entries instead of result.get(0) when working with getEOGPathEdges.
    static class  SubgraphWalker.IterativeGraphWalker  
    static class  SubgraphWalker.ScopedWalker
    Handles declaration scope monitoring for iterative traversals.
  • Method Summary

    Modifier and Type Method Description
    static void activateTypes​(de.fraunhofer.aisec.cpg.graph.Node node, de.fraunhofer.aisec.cpg.passes.scopes.ScopeManager scopeManager)  
    static java.util.List<de.fraunhofer.aisec.cpg.graph.Node> flattenAST​(de.fraunhofer.aisec.cpg.graph.Node n)
    Flattens the tree, starting at Node n into a list.
    static java.util.List<de.fraunhofer.aisec.cpg.graph.Node> getAstChildren​(de.fraunhofer.aisec.cpg.graph.Node node)
    Retrieves a list of AST children of the specified node by iterating all fields that are annotated with the SubGraph annotation and its value "AST".
    static SubgraphWalker.Border getEOGPathEdges​(de.fraunhofer.aisec.cpg.graph.Node n)
    Function returns two lists in a list.
    static void refreshType​(de.fraunhofer.aisec.cpg.graph.Node node)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getAstChildren

      public static java.util.List<de.fraunhofer.aisec.cpg.graph.Node> getAstChildren​(de.fraunhofer.aisec.cpg.graph.Node node)
      Retrieves a list of AST children of the specified node by iterating all fields that are annotated with the SubGraph annotation and its value "AST".
      Parameters:
      node - the start node
      Returns:
      a list of children from the node's AST
    • flattenAST

      public static java.util.List<de.fraunhofer.aisec.cpg.graph.Node> flattenAST​(de.fraunhofer.aisec.cpg.graph.Node n)
      Flattens the tree, starting at Node n into a list.
      Parameters:
      n - the node which contains the ast children to flatten
      Returns:
      the flattened nodes
    • getEOGPathEdges

      public static SubgraphWalker.Border getEOGPathEdges​(de.fraunhofer.aisec.cpg.graph.Node n)
      Function returns two lists in a list. The first list contains all eog nodes with no predecesor in the subgraph with root 'n'. The second list contains eog edges that have no successor in the subgraph with root 'n'. The first List marks the entry and the second marks the exit nodes of the cfg in this subgraph.
      Parameters:
      n - - root of the subgraph.
      Returns:
      Two lists, list 1 contains all eog entries and list 2 contains all exits.
    • refreshType

      public static void refreshType​(de.fraunhofer.aisec.cpg.graph.Node node)
    • activateTypes

      public static void activateTypes​(de.fraunhofer.aisec.cpg.graph.Node node, de.fraunhofer.aisec.cpg.passes.scopes.ScopeManager scopeManager)