joern> help val res12: 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") │ │openForInputPath│Open 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 │ └────────────────┴────────────────────────────────────────────────┴─────────────────────────┘
使用cpg.+Tab来查看cpg相关 API 操作:
1 2
joern> cpg. != close hashCode ne ## closureBinding help nn #> comment helpVerbose notify #>> configFile id notifyAll #| continue identifier parameter #|^ controlStructure ids ret -> cpg ifBlock runtimeChecked == declaration imports switchBlock all dependency isInstanceOf synchronized annotation doBlock jumpLabel tag annotationLiteral dotCallGraph jumpTarget tagNodePair annotationParameter dotTypeHierarchy keyValuePair templateDom annotationParameterAssign elseBlock literal throws argument ensuring local toString arithmetic eq member tryBlock arrayAccess equals metaData typ arrayInitializer expression method typeArgument asInstanceOf fieldAccess methodParameterIn typeDecl assignment fieldIdentifier methodParameterOut typeParameter astNode file methodRef typeRef binding finding methodRefWithName unknown block forBlock methodReturn wait break formatted modifier whileBlock call getClass moduleVariables wrappedCpg callRepr goto namespace → cfgNode graph namespaceBlock
joern> val cpg=importCode("/mnt/e/test-project/test_1/") Using generator for language: NEWC: CCpgGenerator Creating project `test_11` for code at `/mnt/e/test-project/test_1/` ======================================================================================================= Invoking CPG generator in a separate process. Note that the new process will consume additional memory. If you are importing a large codebase (and/or running into memory issues), please try the following: 1) exit joern 2) invoke the frontend: /home/richard_11_02_06/joern/joern-cli/c2cpg.sh -J-Xmx3970m /mnt/e/test-project/test_1/ --output /home/richard_11_02_06/joern/joern-cli/workspace/test_11/cpg.bin.zip 3) start joern, import the cpg: `importCpg("path/to/cpg")` =======================================================================================================
moving cpg.bin.zip to cpg.bin because it is already a database file Creating working copy of CPG to be safe Loading base CPG from: /home/richard_11_02_06/joern/joern-cli/workspace/test_11/cpg.bin.tmp Code successfully imported. You can now query it using `cpg`. For an overview of all imported code, type `workspace`. Adding default overlays to base CPG The graph has been modified. You may want to use the `save` command to persist changes to disk. All changes will also be saved collectively on exit The graph has been modified. You may want to use the `save` command to persist changes to disk. All changes will also be saved collectively on exit val cpg: io.shiftleft.codepropertygraph.generated.Cpg = Cpg[Graph[463 nodes]]