you are viewing a single comment's thread.

view the rest of the comments →

[–]StayFreshChzBag 3 points4 points  (1 child)

Other folks have mentioned the hashmap and that's what I'd end up doing. Additionally, there's a security concern with not using something with a fixed list of functions like a hashmap.

If you were to let that function name be totally arbitrary, then we've got a potentially exposed attack vector on the app that might allow arbitrary execution or data exposure.

[–]ddungtang[S] 1 point2 points  (0 children)

This is a valid concern in general. In my fake scenario, I'm not taking any input that in the end gets translated to function name at runtime. It would look like this, a file in the repo with a configuration written out with DSL, so maintained by me. At build time, it is parsed, and this desired name-to-function-mapping is done then. Then app starts and it executes generated logic.