laziness, impatience, and hubris | |
PerlMonks |
Re: A minilanguage with the least effort?by jethro (Monsignor) |
on Feb 17, 2009 at 15:57 UTC ( [id://744461]=note: print w/replies, xml ) | Need Help?? |
Anecdotal evidence: I wrote a sort of "miniperl" interpreter that I believed (or lets say hoped) to be secure by transforming and filtering the miniperl into executable perl and using eval to execute it. It operated upon a hierarchical set of hashes and was crippled down to essentially mathematical operations, strings, control structures and calling of functions I allowed or provided. It was for a local management program for a play-by-mail space opera game, so security was not really necessary, just a bonus so that config files could be exchanged between player and game master without worries A typical example of what it did:
All the hashes were tied so that the %system-hash of a planet could be reached by simply saying system.something= .... This made it possible to do consitency checks or further actions when a variable was changed. Also if a variable like 'owned' was configured as hierarchical, not only was taurus.owned set to 1 in the example above but also the 'owned' of every planet in this system, i.e. 'taurus i'.owned would have been set too As you can see I had to exclude most of the special characters from my language, especially all the sigils. Since arrays or hashes couldn't be specified directly, looping was only possible through function calls. No regex was possible It was fun programming it, but you really have to cripple the language to put perl into a sandbox (and I still can't be completely sure I plugged all holes). While it fitted my needs in this case perfectly, I wouldn't really trust it on a public interface in the web for example By the way, I used Parse::RecDescent for the parsing of the language (actually it was really two languages that were parsed)
In Section
Seekers of Perl Wisdom
|
|