-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Patterns] Test discovery rules for PHP #9
Comments
Some of my already review patterns have an
|
@mal-tee : the logger can be extended with some more info and I will try to do so. However that specific error:
You can try to run yourself on the branch refactoring (here done for pattern You will get a sub-folder within the results folder that will contain the generated cpg in case you want to run it manually. |
Seems like some discovery rules end with |
Hmm, some nodes in the php cpg don't have a @pr0me what's a smart way to fix this here? My current solution is to fix this via .repeat(_.astParent)(_.until(_.filter(x => x.lineNumber.getOrElse(-1) != -1))).location.toJson
// sometimes the generator might assign Some(-1) for unknown numbers. That's why I use the .getOrElse(-1) != -1 construct, to cover None and Some(-1). instead of .location.toJson Is there a smarter way? This would make the discovery rules quite bulky. |
FYI, When working on issue #10, I am facing the same problem for pattern 76 in JS. The query is as below and joern is not returning the line number. cpg.assignment.where(n=> n.code("^(?!(function|_tmp)).*\\..*=.*$")).method.callIn.location.toJson If anyone has some hints on why that happens, it is really appreciated! @mal-tee I tried your solution of traversing the AST upwards (as above), and it seem to not work in my case, returning empty results like below. Have you also encountered this issue?
|
Interesting!
No, haven't seen that so far. |
|
@compaluca As discussed in our last meeting, I manually tried this workaround on a few instances (58, 19_1, 56,3_1,and 3_2). The fix didn't change the outcome of the discovery rules for the instances that were ok beforehand (58, 19_1). But it also fixed 56, 3_1, and 3_2 which had missing linenos before. Speaking from this data integrating this into the framework should be ok until we fix linenumbers in the php-cpg. |
After implementing the work-around in the framework, we will repeat the test |
Problem statement
Discovery rules (when avaliable) were tested for PHP patterns via the tpframework new functionality:
Here a summary of the results:
This means that:
Here the raw data in a zip comprising:
20230202-PHP-discovery_rules.zip
Proposed changes
Check the issues reported and fix the patterns that can be fixed
The text was updated successfully, but these errors were encountered: