fuzzyc2cpg icon indicating copy to clipboard operation
fuzzyc2cpg copied to clipboard

Escape characters in function names

Open itsacoderepo opened this issue 6 years ago • 5 comments

Description

The CPG contains function names with escape sequences, eg. CHAT_PROTOCOL(server)->\\n\\t\\t\\tquery_create. It seems to be a parsing error of:

		query = CHAT_PROTOCOL(server)->
			query_create(server->tag, nick, TRUE);

See: https://github.com/irssi/irssi/blob/master/src/fe-common/core/fe-queries.c#L53-L54

Reproduction steps

  1. CPG creation:
$ git clone https://github.com/irssi/irssi
$ ./fuzzyc2cpg.sh irssi/src/ --out irssi.bin.zip 
  1. Load the CPG and search the function
ocular> loadCpg("irssi.bin.zip") 
ocular> cpg.method.fullName("CHAT.*query_create.*").fullName.p 
res5: List[String] = List("CHAT_PROTOCOL(server)->\\n\\t\\t\\tquery_create")

itsacoderepo avatar Jan 23 '19 17:01 itsacoderepo

"The first one an parsing error"?

fabsx00 avatar May 07 '19 17:05 fabsx00

You are right it sounds weird. I have updated the issue.

itsacoderepo avatar May 07 '19 22:05 itsacoderepo

This seems to crop up after running the Cpg2Scpg enhancements.

Running irssi through ./joern-parse with --noenhance and running the above query results in:

joern> cpg.method.fullName("CHAT.*query_create.*").fullName.p  
res1: List[String] = List()

Running with the enhancements enabled, we get:

joern> cpg.method.fullName("CHAT.*query_create.*").fullName.p  
res2: List[String] = List("CHAT_PROTOCOL(server)->\\n\\t\\t\\tquery_create")

GlassAndOneHalf avatar Nov 07 '19 10:11 GlassAndOneHalf

Ok, I believe this line is causing the issue: https://github.com/ShiftLeftSecurity/fuzzyc2cpg/blob/master/src/main/scala/io/shiftleft/fuzzyc2cpg/astnew/AstToCpgConverter.scala#L347

Is this something we'd want to remove? Everything else is also escaped

CC @fabsx00

GlassAndOneHalf avatar Nov 07 '19 11:11 GlassAndOneHalf

Can you try and see what happens? I think it may be removable.

fabsx00 avatar Nov 07 '19 12:11 fabsx00