Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add check for contractItemID validity to prevent 500 #14435

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion webapp/shop/cred/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def cred_schedule(
f"{data['date']}T{data['time']}", "%Y-%m-%dT%H:%M"
)
starts_at = tz_info.localize(scheduled_time)
contract_item_id = data["contract_item_id"]
contract_item_id = flask.request.args.get("contractItemID")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be used to get data from POST requests

first_name, last_name = get_user_first_last_name()
country_code = TIMEZONE_COUNTRIES[timezone]
assessment_reservation_uuid = None
Expand All @@ -280,6 +280,14 @@ def cred_schedule(
template_data["max_date"] = max_date
template_data["time_delay"] = time_delay

if not contract_item_id or not str(contract_item_id).isdigit():
error = "Invalid contract item ID"
return flask.render_template(
"/credentials/schedule.html",
error=error,
**template_data,
)

if flask.request.args.get("uuid", default=None, type=str):
assessment_reservation_uuid = flask.request.args.get("uuid")

Expand Down
Loading