Custom Defined Steps

You can define your own custom steps and seamlessly make them of the CPG query language, using Scala’s enrich my library pattern. E.g. let’s say you want to define a step publicExampleOrg on method:

implicit class MyMethodTraversals(method: Traversal[Method]) {
  def publicExampleOrg = method.fullName(".*org.example.*").isPublic
}

To try it out, you can just paste this into the Joern REPL. Usage: cpg.method.publicExampleOrg

Note: tab completion works, i.e. if you type cpg.method.pu<TAB> it will auto-complete.