Help Directive

The Help Directive is a CPGQL Directive which returns textual descriptions of other directives.

If it is executed by itself, it shows an overview of Top-Level Commands:

joern> help
val res0: Helper = Welcome to the interactive help system. Below you find
a table of all available top-level commands. To get
more detailed help on a specific command, just type

`help.<command>`.

Try `help.importCode` to begin with.
┌────────────────┬────────────────────────────────────────────────┬─────────────────────────┐
command         description                                     example                  
├────────────────┼────────────────────────────────────────────────┼─────────────────────────┤
close           Close project by name                           close(projectName)       
cpg             CPG of the active project                       cpg.method.l             
delete          Close and remove project from disk              delete(projectName)      
exit            Exit the REPL                                                            
importCode      Create new project from code                    importCode("example.jar")
importCpg       Create new project from existing CPG            importCpg("cpg.bin.zip") 
open            Open project by name                            open("projectName")      
openForInputPathOpen project for input path                                              
project         Currently active project                        project                  
run             Run analyzer on active CPG                      run.securityprofile      
save            Write all changes to disk                       save                     
switchWorkspace Close current workspace and open a different one                         
workspace       Access to the workspace directory               workspace                
└────────────────┴────────────────────────────────────────────────┴─────────────────────────┘

If executed with a Top-Level Command CPGQL Component prefix, it describe that Top-Level Command:

joern> help.save 
res0: String = """
Close and reopen all loaded CPGs. This ensures that changes have been flushed to
disk.

Returns list of affected projects"""

If executed as part of a traversal, it prints available steps and their description at this point. Note that this list may not be complete - use <tab> completion for the full list.

joern> cpg.help
"Available starter steps:
┌─────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────┐
step             description                                                                                        
├─────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────┤
.all             All nodes of the graph                                                                             
.argument        All arguments (actual parameters)                                                                  
.arithmetic      All arithmetic operations, including shorthand assignments that perform arithmetic (e.g., '+=')    
.arrayAccess     All array accesses                                                                                 
.assignment      All assignments, including shorthand assignments that perform arithmetic (e.g., '+=')              
...


joern> cpg.method.help
Available steps for Method:
┌────────────────────┬─────────────────────────────────────────────────────────────┐
step                description                                                  
├────────────────────┼─────────────────────────────────────────────────────────────┤
.address            Address of the code (for binary code)                        
.ast                All nodes of the abstract syntax tree                        
.body               Alias for `block`                                            
.break              All breaks (`ControlStructure` nodes)                        
.cfgLast            Last control flow graph node                                 
...