-
Notifications
You must be signed in to change notification settings - Fork 325
[ruby] Add Support for ERB files #5447
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
base: master
Are you sure you want to change the base?
Conversation
* Added tests for ERB processing * update test expectation * Add isLineFeed func * removed erb config file test * Fixed new line issues with ERB files, updated test expectations
… operators. Included explicit return for ERB file processing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
...s/rubysrc2cpg/src/main/scala/io/joern/rubysrc2cpg/astcreation/AstForExpressionsCreator.scala
Outdated
Show resolved
Hide resolved
...s/rubysrc2cpg/src/main/scala/io/joern/rubysrc2cpg/astcreation/AstForExpressionsCreator.scala
Outdated
Show resolved
Hide resolved
...s/rubysrc2cpg/src/main/scala/io/joern/rubysrc2cpg/astcreation/AstForExpressionsCreator.scala
Outdated
Show resolved
Hide resolved
I'm still missing a lot of .erb files. E.g. for https://github.com/chatwoot/chatwoot:
The frontend spits out some warnings for the project, e.g. |
@maltek these are the new results on chatwoot with all of the changes made for ERB handling.
|
joern-cli/frontends/rubysrc2cpg/src/test/scala/io/joern/rubysrc2cpg/querying/ErbTests.scala
Show resolved
Hide resolved
joern-cli/frontends/rubysrc2cpg/src/test/scala/io/joern/rubysrc2cpg/querying/ErbTests.scala
Outdated
Show resolved
Hide resolved
import io.shiftleft.codepropertygraph.generated.nodes.{Block, Call, FieldIdentifier, Identifier, Literal, TypeRef} | ||
import io.shiftleft.semanticcpg.language.* | ||
|
||
class ErbTests extends RubyCode2CpgFixture { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you writing tests that include the lowering of a ruby AST into CPG?
The ERB support takes input ERB files and emits ruby code that is then fed into rubyAstGen. For the later part we already have plenty of tests. Here it would be much better readable if you test the first step ( ERB -> ruby code) the added benefit would be much better readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ERB -> Ruby code is tested on the ruby_ast_gen
project e.g., https://github.com/joernio/ruby_ast_gen/blob/main/spec/ruby_ast_gen_spec.rb#L155
Albeit, one could argue for more tests there perhaps, but we haven't designed the RubyAstGen hook to give us the lowered ERB code as-is, only via AST
templateOutRaw
(<%== %>
) andtemplateOutEscape
(<%= %>
) operator callsRETURN
for thejoern__buffer
which holds all of the appended strings from the ERB lowering.html.erb
files as config files