diff --git a/README.md b/README.md index 449a943..7aad5bf 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/engine/db.py b/engine/db.py index cd08432..a9ed985 100644 --- a/engine/db.py +++ b/engine/db.py @@ -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]) @@ -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) diff --git a/engine/server.py b/engine/server.py index 8678fe9..a8f78a6 100644 --- a/engine/server.py +++ b/engine/server.py @@ -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"]: diff --git a/setup/imgs/css.png b/setup/imgs/css.png new file mode 100644 index 0000000..8fc3f53 Binary files /dev/null and b/setup/imgs/css.png differ