Skip to content

Commit

Permalink
update content
Browse files Browse the repository at this point in the history
  • Loading branch information
b3ny4 committed Sep 8, 2023
2 parents a7d898d + 1fb947d commit b9e486b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/ctf_gameserver/checker/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def get_check_duration(db_conn, service_id, std_dev_count, prohibit_changes=Fals
"""

with transaction_cursor(db_conn, prohibit_changes) as cursor:
cursor.execute('SELECT avg(extract(epoch from (placement_end - placement_start))) + %s *'
' stddev_pop(extract(epoch from (placement_end - placement_start)))'
cursor.execute('SELECT (avg(extract(epoch from (placement_end - placement_start))) + %s *'
' stddev_pop(extract(epoch from (placement_end - placement_start))))::float'
' FROM scoring_flag, scoring_gamecontrol'
' WHERE service_id = %s AND tick < current_tick', (std_dev_count, service_id))
result = cursor.fetchone()
Expand Down
12 changes: 12 additions & 0 deletions src/ctf_gameserver/checkerlib/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def get_flag(tick: int) -> str:
current run. The returned flag can be used for both placement and checks.
"""

if not isinstance(tick, int):
raise TypeError('tick must be of type int')

# Return dummy flag when launched locally
if _launched_without_runner():
try:
Expand All @@ -140,6 +143,9 @@ def set_flagid(data: str) -> None:
Stores the Flag ID for the current team and tick.
"""

if not isinstance(data, str):
raise TypeError('data must be of type str')

if not _launched_without_runner():
_send_ctrl_message({'action': 'FLAGID', 'param': data})
# Wait for acknowledgement
Expand All @@ -154,6 +160,9 @@ def store_state(key: str, data: Any) -> None:
service and team with the given key as an additional identifier.
"""

if not isinstance(key, str):
raise TypeError('key must be of type str')

serialized_data = base64.b64encode(pickle.dumps(data)).decode('ascii')

if not _launched_without_runner():
Expand All @@ -178,6 +187,9 @@ def load_state(key: str) -> Any:
current service and team), None is returned.
"""

if not isinstance(key, str):
raise TypeError('key must be of type str')

if not _launched_without_runner():
_send_ctrl_message({'action': 'LOAD', 'param': key})
result = _recv_ctrl_message()
Expand Down
5 changes: 3 additions & 2 deletions src/ctf_gameserver/controller/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def get_control_info(db_conn, prohibit_changes=False):
def increase_tick(db_conn, prohibit_changes=False):

with transaction_cursor(db_conn, prohibit_changes) as cursor:
cursor.execute('UPDATE scoring_gamecontrol SET current_tick = current_tick + 1, cancel_checks = 0')
cursor.execute('UPDATE scoring_gamecontrol SET current_tick = current_tick + 1,'
' cancel_checks = false')
# Create flags for every service and team in the new tick
cursor.execute('INSERT INTO scoring_flag (service_id, protecting_team_id, tick)'
' SELECT service.id, team.user_id, control.current_tick'
Expand All @@ -39,7 +40,7 @@ def increase_tick(db_conn, prohibit_changes=False):
def cancel_checks(db_conn, prohibit_changes=False):

with transaction_cursor(db_conn, prohibit_changes) as cursor:
cursor.execute('UPDATE scoring_gamecontrol SET cancel_checks = 1')
cursor.execute('UPDATE scoring_gamecontrol SET cancel_checks = true')


def update_scoring(db_conn):
Expand Down
2 changes: 1 addition & 1 deletion src/ctf_gameserver/web/templates/base-common.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<title itemprop="name">{% block title %}{% endblock %} | {{ competition_name }}</title>

<meta name="description" itemprop="description" property="og:description" content="
FAUST CTF 2022 is an online attack-defense CTF competition run by FAUST, the CTF team of
FAUST CTF 2023 is an online attack-defense CTF competition run by FAUST, the CTF team of
Friedrich-Alexander University Erlangen-Nürnberg
" />
<meta name="keywords" content="
Expand Down
2 changes: 1 addition & 1 deletion tests/checker/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def test_cancel_checks(self, monotonic_mock, warning_mock):
os.kill(checkerscript_pid, 0)

with transaction_cursor(self.connection) as cursor:
cursor.execute('UPDATE scoring_gamecontrol SET cancel_checks=1')
cursor.execute('UPDATE scoring_gamecontrol SET cancel_checks=true')

master_loop.supervisor.queue_timeout = 0.01
monotonic_mock.return_value = 190
Expand Down
2 changes: 1 addition & 1 deletion tests/controller/test_main_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_next_tick_overdue(self, sleep_mock, _):
with transaction_cursor(self.connection) as cursor:
cursor.execute('UPDATE scoring_gamecontrol SET start=datetime("now", "-19 minutes"), '
' end=datetime("now", "+1421 minutes"), '
' current_tick=5, cancel_checks=1')
' current_tick=5, cancel_checks=true')

controller.main_loop_step(self.connection, self.metrics, False)

Expand Down

0 comments on commit b9e486b

Please sign in to comment.