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

View File

@ -75,29 +75,35 @@ def download_joomla_version(version):
dst_path = "" dst_path = ""
if version_match is not None: if version_match is not None:
if version_match.group(1) == 2: if version_match.group(1) == "2":
version_path = "joomla25" version_path = "joomla25"
else: else:
version_path = "joomla3" version_path = "joomla3"
version_string = version_match.group(1) + "-" + version_match.group(2) + "-" + version_match.group(4) version_string = version_match.group(1) + "-" + version_match.group(2) + "-" + version_match.group(4)
# check if file has already been downloaded... # 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) dst_file = Path(dst_path)
if not dst_file.is_file(): 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" 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) urllib.request.urlretrieve (url, dst_path)
except:
dst_path = ""
return dst_path return dst_path
def extract_downloaded_joomla_version(version, 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... # extract a fresh copy...
shutil.rmtree(dst_path, onerror=remove_readonly) shutil.rmtree(dst_path, onerror=remove_readonly)
try:
with zipfile.ZipFile(path, "r") as zip_ref: with zipfile.ZipFile(path, "r") as zip_ref:
zip_ref.extractall(dst_path) zip_ref.extractall(dst_path)
except:
dst_path = ""
return dst_path return dst_path
@ -199,6 +205,7 @@ class bcolors:
parser = argparse.ArgumentParser(description='Check joomla installation state.') parser = argparse.ArgumentParser(description='Check joomla installation state.')
parser.add_argument('-v', '--verbose', action='store_true', help='Print verbose output') 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() 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) 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" version_status = "OKOK"
if not args.nointegrity:
print(bcolors.HEADER, " -> Checking file integrity: ", bcolors.ENDC, end=" ") print(bcolors.HEADER, " -> Checking file integrity: ", bcolors.ENDC, end=" ")
sys.stdout.flush() sys.stdout.flush()
dl_path = download_joomla_version(version) dl_path = download_joomla_version(version)
@ -264,6 +272,7 @@ for file_path in Path(base_path).glob('**/version.php'):
integrity_status = "FAIL" integrity_status = "FAIL"
if args.verbose: if args.verbose:
if len(result_list) > 0:
print('\tMissmatch: %s' % '\n\tMissmatch: '.join(map(str, result_list))) print('\tMissmatch: %s' % '\n\tMissmatch: '.join(map(str, result_list)))
fobj.write(version_status + ";" + integrity_status + ";" + version + ";" + newest_version + ";" + domain + ";" + str(file_path) + "\n") fobj.write(version_status + ";" + integrity_status + ";" + version + ";" + newest_version + ";" + domain + ";" + str(file_path) + "\n")