Flag for disabling integrity check added

This commit is contained in:
Christoph Haas 2016-12-21 20:52:42 +01:00
parent c770b4f03a
commit ae0156d98b
1 changed files with 47 additions and 38 deletions

View File

@ -75,29 +75,35 @@ def download_joomla_version(version):
dst_path = ""
if version_match is not None:
if version_match.group(1) == 2:
if version_match.group(1) == "2":
version_path = "joomla25"
else:
version_path = "joomla3"
version_string = version_match.group(1) + "-" + version_match.group(2) + "-" + version_match.group(4)
# check if file has already been downloaded...
dst_path = tmp_dl_dir + "/" + version + ".zip"
dst_path = tmp_dl_dir + "/orig_joomla_" + version + ".zip"
dst_file = Path(dst_path)
if not dst_file.is_file():
url = "https://downloads.joomla.org/cms/" + version_path + "/" + version_string + "/joomla_" + version_string + "-stable-full_package-zip?format=zip"
try:
urllib.request.urlretrieve (url, dst_path)
except:
dst_path = ""
return dst_path
def extract_downloaded_joomla_version(version, path):
dst_path = tmp_dl_dir + "/" + version
dst_path = tmp_dl_dir + "/orig_joomla_" + version
# extract a fresh copy...
shutil.rmtree(dst_path, onerror=remove_readonly)
try:
with zipfile.ZipFile(path, "r") as zip_ref:
zip_ref.extractall(dst_path)
except:
dst_path = ""
return dst_path
@ -199,6 +205,7 @@ class bcolors:
parser = argparse.ArgumentParser(description='Check joomla installation state.')
parser.add_argument('-v', '--verbose', action='store_true', help='Print verbose output')
parser.add_argument('-n', '--nointegrity', action='store_true', help='Skip integrity check')
args = parser.parse_args()
@ -228,6 +235,7 @@ for file_path in Path(base_path).glob('**/version.php'):
print(bcolors.OKGREEN, "[OK] ", bcolors.ENDC, "Up to date Joomla version found!\t[", bcolors.OKGREEN + version + bcolors.ENDC, "] [", bcolors.WARNING + domain + bcolors.ENDC, "] \tin ", file_path)
version_status = "OKOK"
if not args.nointegrity:
print(bcolors.HEADER, " -> Checking file integrity: ", bcolors.ENDC, end=" ")
sys.stdout.flush()
dl_path = download_joomla_version(version)
@ -264,6 +272,7 @@ for file_path in Path(base_path).glob('**/version.php'):
integrity_status = "FAIL"
if args.verbose:
if len(result_list) > 0:
print('\tMissmatch: %s' % '\n\tMissmatch: '.join(map(str, result_list)))
fobj.write(version_status + ";" + integrity_status + ";" + version + ";" + newest_version + ";" + domain + ";" + str(file_path) + "\n")