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

[Bug] Dot exporting of CPG generates an invalid dot file #5044

Open
ssierral opened this issue Oct 31, 2024 · 0 comments
Open

[Bug] Dot exporting of CPG generates an invalid dot file #5044

ssierral opened this issue Oct 31, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ssierral
Copy link

Describe the bug

When using joern-export to export a CPG in dot format, it fails to escape special characters (e.g., %d) or double quotes inside the CODE attribute of each node. Thus the generated dot file is not valid.

To Reproduce
I used exactly the same x42.c file which is provided in the quickstart guide.

  1. joern-parse x42.c
  2. joern-export --repr=cpg --format=dot cpg.bin
  3. Using pydot in python: graph = pydot.graph_from_dot_file("out/x42.c/main.dot")[0]
  4. See error:
30064771079[label=CALL ARGUMENT_INDEX="-1" CODE="printf("What is the meaning of life?\n")" COLUMN_NUMBER="3" DISPATCH_TYPE="STATIC_DISPATCH" LINE_NUMBER="10" METHOD_FULL_NAME="printf" NAME="printf" ORDER="2" SIGNATURE="" TYPE_FULL_NAME="ANY"]
             ^
Expected '}', found '['  (at char 23), (line:2, col:14)
  1. After escaping (\") all double quotes and special chars inside CODE attribute, the dot file can be read correctly.

Expected behavior
joern-export should automatically escape invalid characters inside node attribute fields.

Screenshots

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Joern Version: 4.0.87
  • Java version: 21.0.4

Additional context

@ssierral ssierral added the bug Something isn't working label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant