Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
Fix double-entry bug on the CSS leaderboard
Browse files Browse the repository at this point in the history
  • Loading branch information
sourque committed Apr 24, 2020
1 parent b22e316 commit 0a1c106
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ Start the engine with `service minos start`, or `service minos start logs` if yo
By default, the configuration and database don't reset when you start the engine, as long as there is a currently existing `running-config.cfg`. Set the `"reset=1"` option in the `[settings]` directive to reset every time the engine launches.

## Screenshot
## Screenshots

![Status Page](setup/imgs/status.png)

![CSS Reporting](setup/imgs/css.png)

## Features

- Uptime scoring engine
Expand All @@ -46,7 +48,7 @@ By default, the configuration and database don't reset when you start the engine
- Clock and competition time tracker
- Timing-based injects and scoring
- CyberPatriot-esque scoring graphics and pages :)
- (WIP) CSS Find-and-fix vulnerability leaderboard
- CSS Find-and-fix vulnerability leaderboard

## Scoring Engine Mechanics

Expand Down
23 changes: 10 additions & 13 deletions engine/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,18 @@ def get_css_scores(remote):
team_scores = []
try:
team_data = execute("SELECT team, image, points FROM css_results GROUP BY team, image ORDER BY time DESC")
team = team_data[0][0]
except:
return team_scores
else:
image_count = 0
team_sum = 0
team_score_dict = {}
for data in team_data:
if team != data[0]:
team_scores.append((team, image_count, get_css_elapsed_time(team), team_sum))
team = data[0]
image_count = 0
team_sum = 0
team_sum += data[2]
image_count += 1
team_scores.append((team, image_count, get_css_elapsed_time(team), team_sum))
if data[0] not in team_score_dict:
team_score_dict[data[0]] = [0, 0] # [image_count, team_score]
team_score_dict[data[0]][0] += 1
team_score_dict[data[0]][1] += data[2]

for team, team_data in team_score_dict.items():
team_scores.append((team, team_data[0], get_css_elapsed_time(team), team_data[1]))

# This can't possibly be efficient
team_scores.sort(key=lambda tup: tup[0])
Expand Down Expand Up @@ -446,12 +443,12 @@ def reset_engine():
execute("INSERT INTO users (team, username, password, is_admin) \
VALUES (?, ?, ?, ?)", (team, team_info['username'], pwhash, 0))
else:
print("[WARN] No teams found in configuration! Running into CCS mode.")
print("[WARN] No teams found in configuration! Running in CCS mode.")
config['settings']['css_mode'] = True
write_running_config(config)

if not 'systems' in config:
print("[WARN] No systems found in configuration! Running into CCS mode.")
print("[WARN] No systems found in configuration! Running in CCS mode.")
config['settings']['css_mode'] = True
write_running_config(config)

Expand Down
2 changes: 1 addition & 1 deletion engine/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def css_update():
print("[ERROR] Score update from image did not have all required fields, or had malformed fields.")
return("FAIL")
if not db.validate_alphanum(team) or not db.validate_alphanum(image):
print("[ERROR] Team or image contained illegal characters.")
print("[ERROR] Team or image contained illegal characters. team", image)
return("FAIL")
if "teams" in em.remote:
if team not in em.remote["teams"]:
Expand Down
Binary file added setup/imgs/css.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0a1c106

Please sign in to comment.