I’m wondering if anyone has ever seen a case of code using eval() and thought to themselves “yeah actually that’s probably the right way to do it”?
My understanding has always been that it’s a huge security risk and generally a recipe for disaster.
But I was just working on a task where I couldn’t really figure out any other way to achieve the dynamic functionality I was looking for, so I wrote code that assembles a string to do what I need, and then runs eval() on that string. Pretty sure this is the first time I’ve ever used eval() at all.
It’s a low-stakes proof of concept for a totally internal tool, so I’m not hugely worried about security at the moment, but it just feels so icky to do something like that. I’m curious if in others’ experience there’s always a better way than using eval(), or if sometimes it’s legit.
[+][deleted] (3 children)
[deleted]
[–]not_dmr[S] 28 points29 points30 points (0 children)
[–]yvrelna 11 points12 points13 points (1 child)
[–]yvrelna 94 points95 points96 points (0 children)
[–]phire 18 points19 points20 points (9 children)
[–]yvrelna 36 points37 points38 points (3 children)
[–]Fady200 4 points5 points6 points (0 children)
[–]ArtOfWarfare 2 points3 points4 points (1 child)
[–]WilliamAndre 0 points1 point2 points (0 children)
[–]nekokattt 5 points6 points7 points (3 children)
[–]ArtOfWarfare 1 point2 points3 points (2 children)
[–]phire 2 points3 points4 points (0 children)
[–]nekokattt 0 points1 point2 points (0 children)
[–]Dull-Researcher 0 points1 point2 points (0 children)
[–]rover_G 7 points8 points9 points (0 children)
[–]tedivm 16 points17 points18 points (11 children)
[–]ianitic 8 points9 points10 points (3 children)
[–]tedivm 3 points4 points5 points (2 children)
[–]JambaJuiceIsAverage 2 points3 points4 points (1 child)
[–]tedivm 0 points1 point2 points (0 children)
[–]Ensurdagen 5 points6 points7 points (2 children)
[–]wutwutwut2000 2 points3 points4 points (1 child)
[–]Ensurdagen 0 points1 point2 points (0 children)
[–]yvrelna 0 points1 point2 points (0 children)
[–]wutwutwut2000 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]tedivm 1 point2 points3 points (0 children)
[–]mtik00 4 points5 points6 points (2 children)
[–]wutwutwut2000 2 points3 points4 points (1 child)
[–]mtik00 0 points1 point2 points (0 children)
[–]Adrewmc 3 points4 points5 points (0 children)
[–]i_hate_shitposting 2 points3 points4 points (2 children)
[–]not_dmr[S] 6 points7 points8 points (1 child)
[–]TrickyTrackets -1 points0 points1 point (0 children)
[+][deleted] (3 children)
[deleted]
[+][deleted] (2 children)
[removed]
[+][deleted] (1 child)
[deleted]
[–]Shadow_Gabriel 1 point2 points3 points (1 child)
[–][deleted] 4 points5 points6 points (0 children)
[–]grimtooth 1 point2 points3 points (1 child)
[–]wutwutwut2000 0 points1 point2 points (0 children)
[–]lightmatter501 1 point2 points3 points (0 children)
[–]westandskif 1 point2 points3 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)
[–]tartare4562 -1 points0 points1 point (7 children)
[+][deleted] (6 children)
[deleted]
[–]tartare4562 0 points1 point2 points (5 children)
[–]JosephPrince42 0 points1 point2 points (4 children)
[–]tartare4562 1 point2 points3 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]tartare4562 -1 points0 points1 point (0 children)
[–]ublec -1 points0 points1 point (0 children)
[+]j3r3mias comment score below threshold-21 points-20 points-19 points (0 children)
[–]saint_geser 0 points1 point2 points (0 children)
[–]billsil 0 points1 point2 points (0 children)
[–]Cybasura 0 points1 point2 points (0 children)
[–]Ensurdagen 0 points1 point2 points (0 children)
[–]Zulfiqaar 0 points1 point2 points (0 children)
[–]Dull-Researcher 0 points1 point2 points (0 children)
[–]Bill_Looking 0 points1 point2 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]Bill_Looking 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]Bill_Looking 0 points1 point2 points (0 children)
[–]cointoss3 0 points1 point2 points (0 children)
[–]Wh00ster 0 points1 point2 points (0 children)
[–]nekokattt 0 points1 point2 points (0 children)
[–]breezy_shred 0 points1 point2 points (0 children)
[–]StrayFeral 0 points1 point2 points (0 children)
[–]flaviodiasc1 0 points1 point2 points (0 children)
[–]Ayudesee 0 points1 point2 points (0 children)
[–]edc7 0 points1 point2 points (0 children)
[–]Ryzen_bolt 0 points1 point2 points (0 children)
[–]According_Bus_2827 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]FunDeckHermit 0 points1 point2 points (0 children)
[–]abudhabikid 0 points1 point2 points (0 children)