A function f() uses eval() (or something as dangerous) with  data which I created and stored in local_file on the machine running my program:import local_filedef f(str_to_eval):    # code....    # ....     eval(str_to_eval)        # ....    # ....        return Nonea = f(local_file.some_str)f() is safe to run since the strings I provide to it are my own. However, if I ever decide to use it for something unsafe (e.g. user input) things could go terribly wrong. Also, if the local_file stops being local then it would create a vulnerability since I would need to trust the machine that provides that file as well. How should I ensure that I never forget that this function is unsafe to use (unless specific criteria are met)?Note: eval() is dangerous and can usually be replaced by something safe. 
Ensure unsafe code is not used accidentally
python;vulnerabilities
Define a type to decorate safe inputs. In your function f(), assert that the argument has this type or throw an error. Be smart enough to never define a shortcut def g(x): return f(SafeInput(x)).Example:class SafeInput(object):  def __init__(self, value):    self._value = value  def value(self):    return self._valuedef f(safe_string_to_eval):  assert type(safe_string_to_eval) is SafeInput, safe_string_to_eval must have type SafeInput, but was {}.format(type(safe_string_to_eval))  ...  eval(safe_string_to_eval.value())  ...a = f(SafeInput(local_file.some_str))While this can be easily circumvented, it makes it harder to do so by accident. People might criticize such a draconian type check, but they would miss the point. Since the SafeInput type is just a datatype and not an object-oriented class that could be subclassed, checking for type identity with type(x) is SafeInput is safer than checking for type compatibility with isinstance(x, SafeInput). Since we do want to enforce a specific type, ignoring the explicit type and just doing implicit duck typing is also not satisfactory here. Python has a type system, so let's use it to catch possible mistakes!