def _get_trigger_func(name, trigger_name): """ Given a valid vulnerability name, get the trigger function corresponding to the vulnerability name and trigger name. If the trigger function isn't found, raise NotFound. """ try: return get_trigger(name, trigger_name) except AttributeError: raise NotFound()
def _root_view(): user_input = _get_user_input(request) trigger_func = get_trigger(name, trigger) if trigger_func: trigger_func(user_input) template = get_template("{}.html".format(name)) if name == "xss" and trigger == "raw": template += "<p>XSS: " + user_input + "</p>" return template
def trigger(self, command): trigger_func = get_trigger(name, trigger) if trigger_func: trigger_func(command)
def test_get_trigger_does_not_exist(): with pytest.raises(AttributeError) as exc: get_trigger("cmdi", "nope") assert "do_nope" in str(exc)