moloch-- / RootTheBox

A Game of Hackers (CTF Scoreboard & Game Manager)
http://root-the-box.com/
Apache License 2.0
915 stars 292 forks source link

3.12.3 - Issue Resetting Game #531

Closed PJNorrisS1 closed 1 year ago

PJNorrisS1 commented 1 year ago

Hi, I appear to be having the same problem as before. Once a game has finished, we hit the reset game and choose the option to delete players. It just hangs there, and then gives a page error. I have ran it verbose and I don't see anything in the logs. I think we had this issue before. I am up to date on commits... please could you take a look?

Thanks

eljeffeg commented 1 year ago

It could be just a matter of database size. Your browser can timeout before the operation completes on larger sizes. I guess the question is that after giving it time, do the accounts still exist? Is it failing to delete given time?

With regard to performance of the operation, there are a couple things that could be done. The tables that cause the size and performance issue are the snapshot tables. I'd like to remove them and approach it differently, but 1) I didn't develop this piece and I need to learn what is going on 2) it's going to break games that are just trying to update unless I can write a nice SQL migration script. So it would be a 3.x bump for sure, maybe even a 4.0.

eljeffeg commented 1 year ago

The other option would be to create a polling of the status instead of a wait. That would prevent the timeout at least but doesn't address the underlying issue that the snapshots are inefficient and can take a long time to delete.

PJNorrisS1 commented 1 year ago

Thanks for replying and looking at options. The container hangs basically. I see no errors and will stay there until I kill and restart the container. Left it hours as well and never recovers.  Something killing it…On 24 Jan 2023, at 23:13, ElJeffe @.***> wrote: It could be just a matter of database size. Your browser can timeout before the operation completes on larger sizes. I guess the question is that after giving it time, do the accounts still exist? Is it failing to delete given time? With regard to performance of the operation, there are a couple things that could be done. The tables that cause the size and performance issue are the snapshot tables. I'd like to remove them and approach it differently, but 1) I didn't develop this piece and I need to learn what is going on 2) it's going to break games that are just trying to update unless I can write a nice SQL migration script. So it would be a 3.x bump for sure.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

eljeffeg commented 1 year ago

Give the https://github.com/moloch--/RootTheBox/tree/Truncate_snaps branch a try and let me know if that helps.

PJNorrisS1 commented 1 year ago

Noticed when starting up one of the games, i get a lot of this:

rtb-uk-webapp-1     | [I 230127 21:33:52 GameHistory:54] Loading game history from database ...
rtb-uk-webapp-1     | [I 230127 21:33:52 GameHistory:67] Cached snapshot (12963 of 12972)
rtb-uk-webapp-1     | [I 230127 21:34:03 GameHistory:67] Cached snapshot (12964 of 12972)
rtb-uk-webapp-1     | [I 230127 21:34:14 GameHistory:67] Cached snapshot (12965 of 12972)
rtb-uk-webapp-1     | [I 230127 21:34:25 GameHistory:67] Cached snapshot (12966 of 12972)
rtb-uk-webapp-1     | [I 230127 21:34:35 GameHistory:67] Cached snapshot (12967 of 12972)
rtb-uk-webapp-1     | [I 230127 21:34:46 GameHistory:67] Cached snapshot (12968 of 12972)
rtb-uk-webapp-1     | [I 230127 21:34:57 GameHistory:67] Cached snapshot (12969 of 12972)
rtb-uk-webapp-1     | [I 230127 21:35:08 GameHistory:67] Cached snapshot (12970 of 12972)
rtb-uk-webapp-1     | [I 230127 21:35:18 GameHistory:67] Cached snapshot (12971 of 12972)
rtb-uk-webapp-1     | [I 230127 21:35:29 GameHistory:67] Cached snapshot (12972 of 12972)

Do you think this could be part of the problem? I'll try that branch too.

PJNorrisS1 commented 1 year ago

Truncate_snaps branch:

rtb-eu-central-webapp-1     | [E 230127 22:11:26 AdminGameHandlers:810] (sqlite3.OperationalError) near "TRUNCATE": syntax error
rtb-eu-central-webapp-1     |     [SQL: TRUNCATE TABLE snapshot_team_to_flag]
rtb-eu-central-webapp-1     |     (Background on this error at: https://sqlalche.me/e/14/e3q8)

image

eljeffeg commented 1 year ago

Thanks, I've pushed another update to that branch that I hope will fix sqlite.

PJNorrisS1 commented 1 year ago
rtb-eu-central-webapp-1     | [I 230128 18:54:50 web:2271] 101 GET /connect/notifications/updates (xxx) 0.58ms
rtb-eu-central-webapp-1     | [E 230128 18:54:55 AdminGameHandlers:810] 'str' object has no attribute 'includes'
rtb-eu-central-webapp-1     | [I 230128 18:54:55 web:2271] 200 POST /admin/resetdelete (xxx) 7.24ms
rtb-eu-central-webapp-1     | [I 230128 18:54:55 web:2271] 101 GET /connect/notifications/updates (xxx) 0.55ms

My current workaround was to export and import to a new DB. Delete players work. Will the cache get full again though?

eljeffeg commented 1 year ago

Ah dangit - brain wrote javascript instead of python. Fixed

PJNorrisS1 commented 1 year ago

Tried the latest update... just hangs there as before.

I wonder if this will be an issue going forward? I have a clear cache on my new DB now, and as long as the delete works, will it get in the state it's currently in again?

PJNorrisS1 commented 1 year ago

Oh scratch that, it did come back with something:

rtb-eu-central-webapp-1     | [I 230130 15:48:15 web:2271] 101 GET /connect/notifications/updates (xxx) 0.66ms
rtb-eu-central-webapp-1     | [E 230130 15:48:38 AdminGameHandlers:810] (sqlite3.OperationalError) no such table: SQLITE_SEQUENCE
rtb-eu-central-webapp-1     |     [SQL: UPDATE SQLITE_SEQUENCE SET seq = 0 WHERE name = snapshot_team_to_flag]
rtb-eu-central-webapp-1     |     (Background on this error at: https://sqlalche.me/e/14/e3q8)
rtb-eu-central-webapp-1     | [I 230130 15:48:38 web:2271] 200 POST /admin/resetdelete (xxx) 19205.41ms
rtb-eu-central-webapp-1     | [I 230130 15:48:38 web:2271] 101 GET /connect/notifications/updates (xxx) 0.76ms

And the status is image

eljeffeg commented 1 year ago

Ok, I've removed that line as it was unnecessary.

PJNorrisS1 commented 1 year ago
rtb-eu-central-webapp-1     | [I 230130 17:04:05 web:2271] 101 GET /connect/notifications/updates (xxx) 0.68ms
rtb-eu-central-webapp-1     | [E 230130 17:04:10 AdminGameHandlers:810] (sqlite3.OperationalError) cannot commit - no transaction is active
rtb-eu-central-webapp-1     |     [SQL: COMMIT]
rtb-eu-central-webapp-1     |     (Background on this error at: https://sqlalche.me/e/14/e3q8)
rtb-eu-central-webapp-1     | [I 230130 17:04:10 web:2271] 200 POST /admin/resetdelete (xxx) 11.48ms
eljeffeg commented 1 year ago

Alrighty.. guess I need to install a sqlite instance as I can't seem to get this right with that db. lol

PJNorrisS1 commented 1 year ago

I’m happy to share with you the DB if that helps. But need to do it privately.

eljeffeg commented 1 year ago

I pushed another update on this. Fingers crossed.

PJNorrisS1 commented 1 year ago

Hi - sorry for the delay in getting back to you - was off. I have just done a git pull origin Truncate_snaps to get the latest changes. I have tried the reset game remove players and it's still crashing. When starting, there is a large cache that is loading - is this all related:

image
eljeffeg commented 1 year ago

Yes, related. The issue is deleting the snapshot data as its large and has foreign dependencies. In the above case its trying to load that data. RootTheBox was designed to run an "event" - actually the CTF at CactusCon I think. The snapshots reflect that time limited event. It needs to be redesigned to plot timestamped actions like the flag capture and not a point in time of the current gamestate every x minutes. I just haven't had the time to do it.

PJNorrisS1 commented 1 year ago

Ok understood. To get around this, could export the XML, create a new empty instance and import it? Would it eventually fill up again? I have other instances of this running on a weekly basis in US and EMEA (about 15) will I eventually run in to same problem? Any workarounds you can suggest?On 23 Feb 2023, at 21:57, ElJeffe @.***> wrote: Yes, related. The issue is deleting the snapshot data as its large and has foreign dependencies. In the above case its trying to load that data. RootTheBox was designed to run an "event" - actually the CTF at CactusCon I think. The snapshots reflect that time limited event. It needs to be redesigned to plot timestamped actions like the flag capture and not a point in time of the current gamestate every x minutes. I just haven't had the time to do it.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

eljeffeg commented 1 year ago

I'll try to work on it next week. If we can get the graphs to work with existing data, we could potentially drop those tables.

eljeffeg commented 1 year ago

I created a new branch for testing the removal of Snapshots from RTB. https://github.com/moloch--/RootTheBox/tree/Remove_snapshots

This was a first run to remove snapshots without breaking anything aside from the history chart, which I'll work on. Needs testing to validate it didn't break anything else.

PJNorrisS1 commented 1 year ago

Pulled Remove_snapshots and rebulit it. Upon start up, it wasn't doing the cached snapshots, so far so good:

image

I reset the game with players... it took about 30 seconds, but the page loaded with a success:

image

I looked at the terminal and noted down the messages:

image

So far so good... I re-logged back in, browsed around, all the flags were there, and all the configuration i had was there. I haven't started a game or registered a player yet - do you want me to test that? Good work!

PJNorrisS1 commented 1 year ago

What's next? Do I update all my instances now with this branch, or is there more coding that needs to be done? Thanks again for your prompt action to this.

eljeffeg commented 1 year ago

More to come - sorry, just been slammed at work. There are some db updates to timestamp all events. The next step is to get the history graph working with the new data. Also not sure how I'm going to approach the update as all prior history will be lost. Not sure if it's worth the time to try and copy the old data into the new timestamps or just make a note in the release about prior history graph data.

PJNorrisS1 commented 1 year ago

When we reset a game, it's assumed anything is cleared out except the flags, org, levels - scores and usernames will go depending on the option. Therefore what is the history for?

eljeffeg commented 1 year ago

It would be for people that are not resetting the game. The reset problem is a symptom of the snapshots. But removing the snapshots will clear the graph history regardless of if your resetting your game or not. So if someone updates and they're not ready to reset, they'll lose the graph history. Not a problem for you.. just thinking about others.

eljeffeg commented 1 year ago

Pushed another update for this branch that should get the history graph working (all prior graph history will be lost for an existing game).

PJNorrisS1 commented 1 year ago

So, that branch worked for me as well. I loaded a DB that had known issues. Reset the game almost instantly. When running the log showed this: [I 230306 13:44:15 migration:619] Running upgrade de5d615ae090 -> fe5e615ae090, add relationship timestamp So assuming that's one of the changes. Anything else you want me to test, or is this for someone else with a different scenario that needs to test?

I'm going to run a game on this version on Weds, so hope it's all ok.

eljeffeg commented 1 year ago

Thanks - yeah, just need to run it through its paces as I'm not running a game at the moment to be thorough with testing. Things left to do.. I'm not sure the live updates for the chart is working, so I need to spend a little more time on that and figure out how it works. Need to make sure that a game reset also clears out this new chart data. I think it will be very difficult, but I'll look at how I might be able to extract the old graph data into the new format via SQLAlchemy. And lastly, drop the snapshot tables and free up that disk space.

PJNorrisS1 commented 1 year ago

Morning, I ran a workshop on 9th March, and it had your latest update from the branch above.

Most were able to play okay, but we had quite a few users inform me that they were getting 404 errors when trying to log in (glitch in matrix).

This is the error from the log:

[E 230310 01:26:23 web:1798] Uncaught exception POST /login (145.246.71.1)
     HTTPServerRequest(protocol='https', host='uk.emea-threatops.com', method='POST', uri='/login', version='HTTP/1.1', remote_ip='145.246.71.1')
     Traceback (most recent call last):
       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
         result = method(*self.path_args, **self.path_kwargs)
       File "/opt/rtb/libs/SecurityDecorators.py", line 108, in wrapper
         self.render("public/login.html", errors=None)
       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 865, in render
         html = self.render_string(template_name, **kwargs)
       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1014, in render_string
         return t.generate(**namespace)
       File "/usr/local/lib/python3.8/site-packages/tornado/template.py", line 362, in generate
         return execute()
       File "public/login_html.generated.py", line 53, in _tt_execute
         if info is not None and len(info) != 0:  # public/login.html:26 (via main.html:32)
     NameError: name 'info' is not defined
 [E 230310 01:26:23 BaseHandlers:195] Request from 145.246.71.1 resulted in an error code 500:
     Traceback (most recent call last):
       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
         result = method(*self.path_args, **self.path_kwargs)
       File "/opt/rtb/libs/SecurityDecorators.py", line 108, in wrapper
         self.render("public/login.html", errors=None)
       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 865, in render
         html = self.render_string(template_name, **kwargs)
       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1014, in render_string
         return t.generate(**namespace)
       File "/usr/local/lib/python3.8/site-packages/tornado/template.py", line 362, in generate
         return execute()
       File "public/login_html.generated.py", line 53, in _tt_execute
         if info is not None and len(info) != 0:  # public/login.html:26 (via main.html:32)
     NameError: name 'info' is not defined

Is this related to any of the patching you have done recently?

eljeffeg commented 1 year ago

It's not related. I found the bug and it's related to the rendering of the page if the IP is added to the blacklist. Looks like the IP got auto-banned. That should be in the logs, but not obvious when you got the errors for the page render. I'll fix that and commit it to both branches.

eljeffeg commented 1 year ago

How did the chart look, no issues?

PJNorrisS1 commented 1 year ago

Chart looks okay: image

PJNorrisS1 commented 1 year ago

It's not related. I found the bug and it's related to the rendering of the page if the IP is added to the blacklist. Looks like the IP got auto-banned. That should be in the logs, but not obvious when you got the errors for the page render. I'll fix that and commit it to both branches.

So will the user get a better page now informing them they are blocked? I see all the blocked addresses - be nice to clear them all with a 'clear all' button.

eljeffeg commented 1 year ago

Yes, the user will now receive an error telling them "Your IP address is currently banned - Contact Admin" and you'll see a message in the logs that a login attempt was made from a banned IP address. I'll take a look at adding the clear button. Can you create a new feature request issue for it so I don't forget? I'll try to work on it after we get this branch merged into master.

eljeffeg commented 1 year ago

Ok, I've pushed up the last changes to this branch. Includes updates to the live graph, tries to import old history data into the new format if exists (no guarantees), then drops the old snapshot tables.

The SQL history import was only tested on MySQL, but "should" also work on SQLite.

PJNorrisS1 commented 1 year ago

Now the game is over, I backed up the DB of the game I ran last week under the previous update from this branch.

I pulled the latest and built the container. Upon start up this appeared:

rtb-uk-webapp-1     | [I 230312 13:01:37 rootthebox:260] Environment Configuration (SQL_DIALECT): sqlite
rtb-uk-webapp-1     | [I 230312 13:01:37 rootthebox:1122] Running Docker Setup
rtb-uk-webapp-1     | [I 230312 13:01:37 ConfigHelpers:15] Saving current config to: files/rootthebox.cfg
rtb-uk-webapp-1     | [*] Switching CWD to '/opt/rtb'
rtb-uk-webapp-1     | [*] 13:01:37 : Creating the database ...
rtb-uk-webapp-1     | [I 230312 13:01:37 rootthebox:260] Environment Configuration (SQL_DIALECT): sqlite
rtb-uk-webapp-1     | [I 230312 13:01:38 __init__:263] Checking for Database Updates...
rtb-uk-webapp-1     | [I 230312 13:01:38 migration:205] Context impl SQLiteImpl.
rtb-uk-webapp-1     | [I 230312 13:01:38 migration:208] Will assume non-transactional DDL.
rtb-uk-webapp-1     | [I 230312 13:01:38 migration:619] Running upgrade fe5e615ae090 -> ffe623ae412, delete snapshot table
rtb-uk-webapp-1     | [*] It looks like database has already been set up.
rtb-uk-webapp-1     | Failed to import prior snapshot data into game history
rtb-uk-webapp-1     | Continuing...
rtb-uk-webapp-1     | Failed to import prior flag count into game history
rtb-uk-webapp-1     | Continuing...
rtb-uk-webapp-1     | [*] Starting RTB on http://localhost:80
rtb-uk-webapp-1     | [I 230312 13:02:18 __init__:324] Building Scoreboard Gamestate...
rtb-uk-webapp-1     | [I 230312 13:02:20 web:2271] 304 GET / (86.10.128.58) 7.16ms

Logged in fine, charts loading, scoreboard loading all okay.

I did a full reset of the game. I loaded the charts, and the main chart was empty, but these were populated with the previous players still:

image
PJNorrisS1 commented 1 year ago

I clicked around - I clicked Players under scoreboard menu, and got the 404 error. After that the other data was not appearing. Checking the logs here are some errors:

rtb-uk-webapp-1     |     HTTPServerRequest(protocol='https', host='uk.emea-threatops.com', method='GET', uri='/scoreboard/ajax/history?top=10', version='HTTP/1.1', remote_ip='86.10.128.58')
rtb-uk-webapp-1     |     Traceback (most recent call last):
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
rtb-uk-webapp-1     |         result = method(*self.path_args, **self.path_kwargs)
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 136, in get
rtb-uk-webapp-1     |         uri[args[0]]()
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 278, in history_data
rtb-uk-webapp-1     |         history["history"]["flag_count"][team.name] = team.get_history("flags")
rtb-uk-webapp-1     |     AttributeError: 'NoneType' object has no attribute 'get_history'
rtb-uk-webapp-1     | [E 230312 13:08:04 BaseHandlers:195] Request from 86.10.128.58 resulted in an error code 500:
rtb-uk-webapp-1     |     Traceback (most recent call last):
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
rtb-uk-webapp-1     |         result = method(*self.path_args, **self.path_kwargs)
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 136, in get
rtb-uk-webapp-1     |         uri[args[0]]()
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 278, in history_data
rtb-uk-webapp-1     |         history["history"]["flag_count"][team.name] = team.get_history("flags")
rtb-uk-webapp-1     |     AttributeError: 'NoneType' object has no attribute 'get_history'

and...

rtb-uk-webapp-1     | [E 230312 13:08:07 web:1798] Uncaught exception GET /scoreboard/ajax/history?top=10 (86.10.128.58)
rtb-uk-webapp-1     |     HTTPServerRequest(protocol='https', host='uk.emea-threatops.com', method='GET', uri='/scoreboard/ajax/history?top=10', version='HTTP/1.1', remote_ip='86.10.128.58')
rtb-uk-webapp-1     |     Traceback (most recent call last):
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
rtb-uk-webapp-1     |         result = method(*self.path_args, **self.path_kwargs)
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 136, in get
rtb-uk-webapp-1     |         uri[args[0]]()
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 278, in history_data
rtb-uk-webapp-1     |         history["history"]["flag_count"][team.name] = team.get_history("flags")
rtb-uk-webapp-1     |     AttributeError: 'NoneType' object has no attribute 'get_history'
rtb-uk-webapp-1     | [E 230312 13:08:07 BaseHandlers:195] Request from 86.10.128.58 resulted in an error code 500:
rtb-uk-webapp-1     |     Traceback (most recent call last):
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
rtb-uk-webapp-1     |         result = method(*self.path_args, **self.path_kwargs)
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 136, in get
rtb-uk-webapp-1     |         uri[args[0]]()
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 278, in history_data
rtb-uk-webapp-1     |         history["history"]["flag_count"][team.name] = team.get_history("flags")
rtb-uk-webapp-1     |     AttributeError: 'NoneType' object has no attribute 'get_history'
rtb-uk-webapp-1     |     
rtb-uk-webapp-1     | [E 230312 13:08:07 web:2271] 500 GET /scoreboard/ajax/history?top=10 (86.10.128.58) 7.58ms
rtb-uk-webapp-1     | [I 230312 13:08:07 web:2271] 101 GET /scoreboard/wsocket/game_data (86.10.128.58) 0.56ms
rtb-uk-webapp-1     | [I 230312 13:08:17 web:2271] 200 GET / (86.10.128.58) 0.94ms
rtb-uk-webapp-1     | [E 230312 13:08:33 web:1798] Uncaught exception GET /scoreboard/ajax/history?top=25 (86.10.128.58)
rtb-uk-webapp-1     |     HTTPServerRequest(protocol='https', host='uk.emea-threatops.com', method='GET', uri='/scoreboard/ajax/history?top=25', version='HTTP/1.1', remote_ip='86.10.128.58')
rtb-uk-webapp-1     |     Traceback (most recent call last):
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
rtb-uk-webapp-1     |         result = method(*self.path_args, **self.path_kwargs)
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 136, in get
rtb-uk-webapp-1     |         uri[args[0]]()
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 278, in history_data
rtb-uk-webapp-1     |         history["history"]["flag_count"][team.name] = team.get_history("flags")
rtb-uk-webapp-1     |     AttributeError: 'NoneType' object has no attribute 'get_history'
rtb-uk-webapp-1     | [E 230312 13:08:33 BaseHandlers:195] Request from 86.10.128.58 resulted in an error code 500:
rtb-uk-webapp-1     |     Traceback (most recent call last):
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
rtb-uk-webapp-1     |         result = method(*self.path_args, **self.path_kwargs)
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 136, in get
rtb-uk-webapp-1     |         uri[args[0]]()
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 278, in history_data
rtb-uk-webapp-1     |         history["history"]["flag_count"][team.name] = team.get_history("flags")
rtb-uk-webapp-1     |     AttributeError: 'NoneType' object has no attribute 'get_history'
rtb-uk-webapp-1     |     
rtb-uk-webapp-1     | [E 230312 13:08:33 web:2271] 500 GET /scoreboard/ajax/history?top=25 (86.10.128.58) 9.04ms
rtb-uk-webapp-1     | [I 230312 13:08:38 web:2271] 200 GET / (86.10.128.58) 0.99ms
rtb-uk-webapp-1     | [E 230312 13:08:45 web:1798] Uncaught exception GET /teams (86.10.128.58)
rtb-uk-webapp-1     |     HTTPServerRequest(protocol='https', host='uk.emea-threatops.com', method='GET', uri='/teams', version='HTTP/1.1', remote_ip='86.10.128.58')
rtb-uk-webapp-1     |     Traceback (most recent call last):
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
rtb-uk-webapp-1     |         result = method(*self.path_args, **self.path_kwargs)
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 405, in get
rtb-uk-webapp-1     |         self.render(
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 865, in render
rtb-uk-webapp-1     |         html = self.render_string(template_name, **kwargs)
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1014, in render_string
rtb-uk-webapp-1     |         return t.generate(**namespace)
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/template.py", line 362, in generate
rtb-uk-webapp-1     |         return execute()
rtb-uk-webapp-1     |       File "scoreboard/teams_html.generated.py", line 65, in _tt_execute
rtb-uk-webapp-1     |         _tt_tmp = team.uuid  # scoreboard/teams.html:33 (via main.html:32)
rtb-uk-webapp-1     |     AttributeError: 'NoneType' object has no attribute 'uuid'
rtb-uk-webapp-1     | [E 230312 13:08:45 BaseHandlers:195] Request from 86.10.128.58 resulted in an error code 500:
rtb-uk-webapp-1     |     Traceback (most recent call last):
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
rtb-uk-webapp-1     |         result = method(*self.path_args, **self.path_kwargs)
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 405, in get
rtb-uk-webapp-1     |         self.render(
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 865, in render
rtb-uk-webapp-1     |         html = self.render_string(template_name, **kwargs)
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1014, in render_string
rtb-uk-webapp-1     |         return t.generate(**namespace)
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/template.py", line 362, in generate
rtb-uk-webapp-1     |         return execute()
rtb-uk-webapp-1     |       File "scoreboard/teams_html.generated.py", line 65, in _tt_execute
rtb-uk-webapp-1     |         _tt_tmp = team.uuid  # scoreboard/teams.html:33 (via main.html:32)
rtb-uk-webapp-1     |     AttributeError: 'NoneType' object has no attribute 'uuid'
rtb-uk-webapp-1     |     
rtb-uk-webapp-1     | [E 230312 13:08:45 web:2271] 500 GET /teams (86.10.128.58) 28.37ms
rtb-uk-webapp-1     | [I 230312 13:08:45 web:2271] 101 GET /connect/notifications/updates (86.10.128.58) 0.64ms
rtb-uk-webapp-1     | [E 230312 13:08:49 web:1798] Uncaught exception GET /teams (86.10.128.58)
rtb-uk-webapp-1     |     HTTPServerRequest(protocol='https', host='uk.emea-threatops.com', method='GET', uri='/teams', version='HTTP/1.1', remote_ip='86.10.128.58')
rtb-uk-webapp-1     |     Traceback (most recent call last):
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
rtb-uk-webapp-1     |         result = method(*self.path_args, **self.path_kwargs)
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 405, in get
rtb-uk-webapp-1     |         self.render(
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 865, in render
rtb-uk-webapp-1     |         html = self.render_string(template_name, **kwargs)
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1014, in render_string
rtb-uk-webapp-1     |         return t.generate(**namespace)
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/template.py", line 362, in generate
rtb-uk-webapp-1     |         return execute()
rtb-uk-webapp-1     |       File "scoreboard/teams_html.generated.py", line 65, in _tt_execute
rtb-uk-webapp-1     |         _tt_tmp = team.uuid  # scoreboard/teams.html:33 (via main.html:32)
rtb-uk-webapp-1     |     AttributeError: 'NoneType' object has no attribute 'uuid'
rtb-uk-webapp-1     | [E 230312 13:08:49 BaseHandlers:195] Request from 86.10.128.58 resulted in an error code 500:
rtb-uk-webapp-1     |     Traceback (most recent call last):
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1711, in _execute
rtb-uk-webapp-1     |         result = method(*self.path_args, **self.path_kwargs)
rtb-uk-webapp-1     |       File "/opt/rtb/handlers/ScoreboardHandlers.py", line 405, in get
rtb-uk-webapp-1     |         self.render(
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 865, in render
rtb-uk-webapp-1     |         html = self.render_string(template_name, **kwargs)
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1014, in render_string
rtb-uk-webapp-1     |         return t.generate(**namespace)
rtb-uk-webapp-1     |       File "/usr/local/lib/python3.8/site-packages/tornado/template.py", line 362, in generate
rtb-uk-webapp-1     |         return execute()
rtb-uk-webapp-1     |       File "scoreboard/teams_html.generated.py", line 65, in _tt_execute
rtb-uk-webapp-1     |         _tt_tmp = team.uuid  # scoreboard/teams.html:33 (via main.html:32)
rtb-uk-webapp-1     |     AttributeError: 'NoneType' object has no attribute 'uuid'
rtb-uk-webapp-1     |     
eljeffeg commented 1 year ago

Thanks for checking this! I'll work on it soon. I'll also include an exception note on the failed import - I'd like to know why those failed. What database you using?

PJNorrisS1 commented 1 year ago

If this gives you a clue -

[I 230312 13:14:37 rootthebox:260] Environment Configuration (SQL_DIALECT): sqlite
rtb-uk-webapp-1     | [I 230312 13:14:37 __init__:263] Checking for Database Updates...
rtb-uk-webapp-1     | [I 230312 13:14:37 migration:205] Context impl SQLiteImpl.

I run these from the docker instance so assuming it's SQLite.

PJNorrisS1 commented 1 year ago

I've restored the DB we used for the above test and ran again. Noticed this on startup:

rtb-uk-webapp-1     | [*] Switching CWD to '/opt/rtb'
rtb-uk-webapp-1     | [*] 13:14:36 : Creating the database ...
rtb-uk-webapp-1     | [I 230312 13:14:37 rootthebox:260] Environment Configuration (SQL_DIALECT): sqlite
rtb-uk-webapp-1     | [I 230312 13:14:37 __init__:263] Checking for Database Updates...
rtb-uk-webapp-1     | [I 230312 13:14:37 migration:205] Context impl SQLiteImpl.
rtb-uk-webapp-1     | [I 230312 13:14:37 migration:208] Will assume non-transactional DDL.
rtb-uk-webapp-1     | [I 230312 13:14:37 migration:619] Running upgrade fe5e615ae090 -> ffe623ae412, delete snapshot table
rtb-uk-webapp-1     | [*] It looks like database has already been set up.
rtb-uk-webapp-1     | Failed to import prior snapshot data into game history
rtb-uk-webapp-1     | Continuing...
rtb-uk-webapp-1     | Failed to import prior flag count into game history
rtb-uk-webapp-1     | Continuing...
rtb-uk-webapp-1     | [*] Starting RTB on http://localhost:80
eljeffeg commented 1 year ago

I've pushed updates to fix the prior issues and add additional error reporting to the failed import. If you can, restore the database and run through it again. :)

eljeffeg commented 1 year ago

I expect your import to fail again, but I'm looking to see what the error is.

PJNorrisS1 commented 1 year ago

I expect your import to fail again, but I'm looking to see what the error is.

Just pulled the latest - perhaps this will help you explore further:

rtb-uk-webapp-1     | [I 230312 14:38:12 migration:208] Will assume non-transactional DDL.
rtb-uk-webapp-1     | [I 230312 14:38:12 migration:619] Running upgrade fe5e615ae090 -> ffe623ae412, delete snapshot table
rtb-uk-webapp-1     | [*] It looks like database has already been set up.
rtb-uk-webapp-1     | Failed to import prior snapshot data into game history: You can only execute one statement at a time.
rtb-uk-webapp-1     | Continuing...
rtb-uk-webapp-1     | Failed to import prior flag count into game history: tuple index out of range
rtb-uk-webapp-1     | Continuing...
rtb-uk-webapp-1     | [*] Starting RTB on http://localhost:80
PJNorrisS1 commented 1 year ago

I've pushed updates to fix the prior issues and add additional error reporting to the failed import. If you can, restore the database and run through it again. :)

Looking good! I restored the DB. Drove around the interface, scoreboards all okay. Reset game and delete players, and all the history and chart data disappeared. No errors in the logs! (thank you for doing this Sunday too!)

eljeffeg commented 1 year ago

I resolved the database issue and merged this branch into master.

PJNorrisS1 commented 1 year ago
rtb-uk-webapp-1     | [I 230312 23:04:03 rootthebox:260] Environment Configuration (SQL_DIALECT): sqlite
rtb-uk-webapp-1     | [I 230312 23:04:03 __init__:263] Checking for Database Updates...
rtb-uk-webapp-1     | [I 230312 23:04:03 migration:205] Context impl SQLiteImpl.
rtb-uk-webapp-1     | [I 230312 23:04:03 migration:208] Will assume non-transactional DDL.
rtb-uk-webapp-1     | [I 230312 23:04:03 migration:619] Running upgrade fe5e615ae090 -> ffe623ae412, delete snapshot table
rtb-uk-webapp-1     | [*] It looks like database has already been set up.
rtb-uk-webapp-1     | [*] Starting RTB on http://localhost:80

Yep! This looks good! Nice one! Thank you for everything on this one!

Do you have a 'buy me a coffee' page or something similar?

eljeffeg commented 1 year ago

Lol.. just keep testing things for me. :) I don't actually get to use RootTheBox much anymore and when I do, it's not a huge game. So it's great to have others that can run it through and identify problems.

PJNorrisS1 commented 1 year ago

Well, it’s appreciated. Your platform is now being used globally in 6 different countries, for a leading Security vendor.

We have about 15 instances plus dev/master instances. It’s used weekly, and we have 100’s of players. Thanks to your webhooks we capture all stats from the platform.

Again, if you have a buymeacoffee link or something similar, it would be a worthwhile coffee 👍

eljeffeg commented 1 year ago

That's awesome! If you're going to BlackHat USA / Defcon or Shmoocon, I plan to attend those and I can take you up on the coffee. Perhaps @moloch-- will be at one.. I've yet to meet up with him.