Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get AST, CFG graph #129

Closed
shangqing-liu opened this issue Apr 24, 2019 · 5 comments
Closed

How to get AST, CFG graph #129

shangqing-liu opened this issue Apr 24, 2019 · 5 comments

Comments

@shangqing-liu
Copy link

Hi, may I ask how can I get AST, CFG graph with this tool. We can just use the simple interfaces supplied by queryprimitives.

@fabsx00
Copy link
Contributor

fabsx00 commented Apr 24, 2019

Hi! Take a look at https://github.com/ShiftLeftSecurity/joern and follow the instructions there to get access to a code property graph for C/C++ programs. It contains a control flow graph and all statements are decomposed into their expressions to yield an AST-like structure.

@shangqing-liu
Copy link
Author

Hi! Take a look at https://github.com/ShiftLeftSecurity/joern and follow the instructions there to get access to a code property graph for C/C++ programs. It contains a control flow graph and all statements are decomposed into their expressions to yield an AST-like structure.

thanks for the reply, but I have checked the documentation, it seems there is no interface about outputting ast or cfg on this https://ocular.shiftleft.io/api/io/shiftleft/queryprimitives/index.html. The documentation only provides some high level functions such as cfg.methods. If I want to get the raw ast or cfg graph with Joern, what can I do?

@jinho10
Copy link

jinho10 commented Apr 26, 2019

@fabsx00 do you have an instruction to generate the java cpg?

@fabsx00
Copy link
Contributor

fabsx00 commented Apr 28, 2019

@shangqing-liu the methods for traversing the CFG are called cfgPrev and cfgNext, and they follow incoming and outcoming CFG edges respectively. I think it might make sense if you tell us more about what you want to achieve. Do you want to have a CFG in some standard format like json? Do you want to plot the CFG?

@fabsx00
Copy link
Contributor

fabsx00 commented Apr 28, 2019

@jinho10 currently, an open-source input module only exists for C/C++ but not for Java. Ocular at https://ocular.shiftleft.io/ has a commercial Java language frontend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants