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

can we add string with double quotes in treated function #629

Open
eankit opened this issue Nov 2, 2023 · 6 comments
Open

can we add string with double quotes in treated function #629

eankit opened this issue Nov 2, 2023 · 6 comments

Comments

@eankit
Copy link

eankit commented Nov 2, 2023

Can a string with double quotes be cleaned by polygot poranha, code snipped below, If yes, how ?

void demoMethod(ExperimentAPI experiment){
// Some code
if (experiment.isTreated("STALE_FLAG")) {
// Do something
} else {
// Do something else
}
// Do other things
}

@ketkarameya
Copy link
Collaborator

#630
I added a demo with your example.
Give it a try

@eankit
Copy link
Author

eankit commented Feb 16, 2024

@ketkarameya thanks this works.

can you also help me with this use case as well
// Some code
if (experiment.isTreated(someObject, "STALE_FLAG")) {
// Do something
} else {
// Do something else
}
// Do other things
}

@ketkarameya
Copy link
Collaborator

@eankit i will have to know more about your API to help you.
Can you please DM me ?

@eankit
Copy link
Author

eankit commented Mar 8, 2024

Hey @ketkarameya
My issue is this
if (experiment.isTreated(arg1, arg2, "STALE_FLAG")) {
// Do something
} else {
// Do something else
}
I want to run Piranha on this api. Here we have a simple feature flag string with a few arguments in the function.
I tried hardcoding the argument and it worked, but I want to understand how to work with a variable argument list.
Also, I saw in rules.toml file that you work on argument list for a simple example, something of a similar solution is expected for the String flag name.
arguments: ((argument_list
([
(field_access field: (
)@argument)
() @argument
])) )

@eankit
Copy link
Author

eankit commented Mar 8, 2024

Also, I want to understand how can I write my own query like the following, do you have any documentation for this?
query='cs :[e].isFeatureEnabled("@flag_name")',
For example, I want to skip the experiment. in experiment.isTreated("STALE_FLAG")
and work with only isTreated("STALE_FLAG") how can that be done

@ketkarameya
Copy link
Collaborator

Unfortunately there is no documentation for concrete syntax.

(
(method_invocation (argument_list (string_literal (_) @flag_name) @string_literal)) @mi
(#eq? @flag_name "@flag_name")
)

equivalent concrete syntax is
:[r].isTreated(:[a0], :[a1], ":[flag_name]")

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

2 participants