feat: analyze expressions for safety#127
Conversation
Wait, aren't strings unsafe? Or am I misunderstanding what you mean by a primitive string here? |
I mean something like this: That will expand to In other words, this PR removes positives like the following: ...since I could be convinced that this is a bad idea however, and instead consider string literals unsafe 🙂 |
should be the actual website, not just the repo
TBH I think erring on the side of false positives to minimize the possibility of false negatives at this stage is the better move. If you're certain that this doesn't increase the likelihood of false negatives, then it should be fine -- but I'd suspect one would want a large corpus of test data available to ensure this first. |
I think it'll be fine, but yeah, I'll be adding a lot of tests to support this. (There's a fine line here, but |
WIP, needs tests.This will improve
template-injection's precision by allowing it to filter expressions that are "safe," i.e. can't produce arbitrary input-derived code regardless of how they're executed.For now, as "safe" expression is defined as:
!{expr}{expr} == {expr}and{expr} != {expr}Notably, this means that some expressions that contain code or can be evaluated to code will be considered safe, since that code will effectively be static within those expressions and not derived from user input (i.e. context accesses).