Be stricter about meaning of severe query param

`severe` can mean one of three things:
- `yes` – user has told us this is an emergency
- `no` – user has told us this isn’t an emergency
- Anything else – user hasn’t been asked the question or has
  hacked/mangled the URL

This commit adds some stricter sanitisation of the `severe` query
parameter and does so up front, rather than spreading it across multiple
functions.
This commit is contained in:
Chris Hill-Scott
2017-02-02 10:42:17 +00:00
parent f3e52d310b
commit ef1bbb5692
2 changed files with 64 additions and 19 deletions

View File

@@ -48,11 +48,14 @@ def feedback(ticket_type):
if not form.feedback.data:
form.feedback.data = session.pop('feedback_message', '')
severe = request.args.get('severe')
if request.args.get('severe') in ['yes', 'no']:
severe = convert_to_boolean(request.args.get('severe'))
else:
severe = None
urgent = (
in_business_hours() or
(ticket_type == 'problem' and convert_to_boolean(severe))
(ticket_type == 'problem' and severe)
)
anonymous = (
@@ -208,7 +211,7 @@ def needs_triage(ticket_type, severe):
def needs_escalation(ticket_type, severe):
return all((
ticket_type == 'problem',
convert_to_boolean(severe),
severe,
not current_user.is_authenticated,
not in_business_hours(),
))