joern 运行 scala 脚本

使用 joern-parse 在桌面生成 cpg.bin 文件

cd C:\Users\admin\Desktop
joern-parse C:\Users\admin\Desktop\project

编辑 test.sc 脚本,功能为:导入 cpg 文件、输出所有方法名

import io.shiftleft.semanticcpg.language._

@main def exec(cpgFile: String) = {
   importCpg(cpgFile)
   cpg.method.name.l 
}

使用 joern 运行,从命令行接收 exec 函数的参数

windows:
joern --script C:\Users\admin\Desktop\test.sc --params "cpgFile=cpg.bin"

linux:
./joern --script /opt/test.sc --params cpgFile=cpg.bin