Validate bedrock url before download with urllib

Even though there will be an incredibly small chance of tampering
this is to make bandit happy
"Bandit Test ID B310"
https://stackoverflow.com/a/53040523/18355876
This commit is contained in:
Zedifus 2022-08-31 20:04:39 +01:00
parent 0c9e10f18a
commit 96c4fa3bdd

View File

@ -1115,10 +1115,13 @@ class ServerInstance:
)
else:
# downloads zip from remote url
urllib.request.urlretrieve(
Helpers.get_latest_bedrock_url(),
os.path.join(self.settings["path"], "bedrock_server.zip"),
)
bedrock_url = Helpers.get_latest_bedrock_url()
if bedrock_url.lower().startswith("https"):
urllib.request.urlretrieve(
bedrock_url,
os.path.join(self.settings["path"], "bedrock_server.zip"),
)
unzip_path = os.path.join(self.settings["path"], "bedrock_server.zip")
unzip_path = self.helper.wtol_path(unzip_path)
# unzips archive that was downloaded.