ThiaudioTT / hoi4-presence

Hearts of Iron IV presence for Discord!
MIT License
13 stars 10 forks source link

Adds auto updater #31

Closed Wolfmyths closed 10 months ago

Wolfmyths commented 11 months ago

For issue #11

Implemented an auto updater.

Each time hoi4-presence starts it will check for an update like normal, if an update is found, download in user's %TEMP% and run setup.exe to install. There is a new argument to pass into setup.exe to signal that there is an update. When this new argument is passed, setup.exe will re-open hoi4-presence when it's finished installing.

I did some testing everything should work. If you don't want the requests module being used I can replace it with urllib.request

ThiaudioTT commented 11 months ago

Nice, bump the version to 1.2.0 and I will test it.

Wolfmyths commented 11 months ago

Should the auto-updater value be true in version.json? And if yes, I should probably add in an if statement checking it.

ThiaudioTT commented 11 months ago

Should the auto-updater value be true in version.json?

Yes

Wolfmyths commented 11 months ago

Just noticed security concerns, if it bothers you I'll try my best to look into it. I'm not too keen on code security yet as I'm self-taught, but I'll see what I can do.

ThiaudioTT commented 11 months ago

Just noticed security concerns, if it bothers you I'll try my best to look into it.

Yeah, this is indeed a security issue just to import suprocess due greatly to command injection attacks. But we don't need to solve it for now. A good aproach to solve it is just avoiding use or using preconditions and postconditions (A good code quality). But this issue is an especial case, the only main problem I see is when you call

subprocess.Popen([installerPath, "-update"], start_new_session=True)

But I think that installerPath came from the other module and is treated there. No worries, I will merge bypassing and we can treat/refactor this later.

I'm not too keen on code security yet as I'm self-taught, but I'll see what I can do.

Don't worry, the best programmers are self-taught.