Programatically modifying Datalog query

Hi All,

I am receiving the stringified datalog query as one of the values inside a JSON request. Before executing the query, I need to modify it in my Clojure code to add some more conditions. I was unsure about the approach that I should take - should I proceed with string concatenations or should I convert the query into Clojure data structure and then proceed with modifying that data structure. I tried to search for some examples but wasn’t able to find any. Could you please suggest me what would be the better approach.

Thanks,
Mayank

Personally, I’d convert it into a Clojure data structure as soon as possible. Once it’s in that format, you can use spec or other tools to validate it, manipulate the structure, etc.

You should also think about the security implications of allowing the client to send datalog over directly, as it can open you up to similar problems as SQL injection attacks. One alternative approach is that you can store the actual query on your server and then just have the client send the name of the query and any parameters over.

I agree that I would tend toward converting it into data prior to manipulation.

Also, Tim’s warnings regarding security are quite right - be sure you know what is in the code before you allow it to be executed.

Thanks for the suggestions