1092 fix solve count leak during freeze (#1095)

* Challenges properly get solve count during freeze time
* Closes #1092
This commit is contained in:
Kevin Chung
2019-08-29 23:22:24 -04:00
committed by GitHub
parent 941ca8f506
commit c88e0556eb
2 changed files with 22 additions and 5 deletions

View File

@@ -38,7 +38,7 @@ from CTFd.utils import user as current_user
from CTFd.utils.user import get_current_team
from CTFd.utils.user import get_current_user
from CTFd.plugins.challenges import get_chal_class
from CTFd.utils.dates import ctf_ended, ctf_paused, ctftime
from CTFd.utils.dates import ctf_ended, ctf_paused, ctftime, unix_time_to_utc
from CTFd.utils.logging import log
from CTFd.utils.security.signing import serialize
from sqlalchemy.sql import and_
@@ -267,8 +267,14 @@ class Challenge(Resource):
Model.banned == False,
Model.hidden == False,
)
.count()
)
# Only show solves that happened before freeze time if configured
freeze = get_config("freeze")
if not is_admin() and freeze:
solves = solves.filter(Solves.date < unix_time_to_utc(freeze))
solves = solves.count()
response["solves"] = solves
else:
response["solves"] = None