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

Ignore wrong contest submissions in ProxyService #1142

Merged
merged 4 commits into from
Dec 17, 2021
Merged
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
28 changes: 28 additions & 0 deletions cms/service/ProxyService.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Copyright © 2015 Luca Versari <[email protected]>
# Copyright © 2015 William Di Luigi <[email protected]>
# Copyright © 2016 Amir Keivan Mohtashami <[email protected]>
# Copyright © 2019 Edoardo Morassutto <[email protected]>
#
edomora97 marked this conversation as resolved.
Show resolved Hide resolved
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -476,6 +477,15 @@ def submission_scored(self, submission_id):
"unexistent submission id %s.", submission_id)
raise KeyError("Submission not found.")

# ScoringService sent us a submission of another contest, they
# do not know about our contest_id in multicontest setup.
if submission.task.contest_id != self.contest_id:
logger.debug("Ignoring submission %d of contest %d "
"(this ProxyService considers contest %d only).",
submission.id, submission.task.contest_id,
self.contest_id)
return

if submission.participation.hidden:
logger.info("[submission_scored] Score for submission %d "
"not sent because the participation is hidden.",
Expand Down Expand Up @@ -511,6 +521,15 @@ def submission_tokened(self, submission_id):
"unexistent submission id %s.", submission_id)
raise KeyError("Submission not found.")

# ScoringService sent us a submission of another contest, they
# do not know about our contest_id in multicontest setup.
if submission.task.contest_id != self.contest_id:
logger.debug("Ignoring submission %d of contest %d "
"(this ProxyService considers contest %d only).",
submission.id, submission.task.contest_id,
self.contest_id)
return

if submission.participation.hidden:
logger.info("[submission_tokened] Token for submission %d "
"not sent because participation is hidden.",
Expand Down Expand Up @@ -545,6 +564,15 @@ def dataset_updated(self, task_id):
task = Task.get_from_id(task_id, session)
dataset = task.active_dataset

# This ProxyService may focus on a different contest, and it should
# ignore this update.
if task.contest_id != self.contest_id:
logger.debug("Ignoring dataset change for task %d of contest "
"%d (this ProxyService considers contest %d "
"only).", task_id, task.contest.id,
self.contest_id)
return

logger.info("Dataset update for task %d (dataset now is %d).",
task.id, dataset.id)

Expand Down