Skip to content
Snippets Groups Projects
Commit e99229e9 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Update template verifier

parent 9d714981
No related branches found
No related tags found
No related merge requests found
76acfefb6e94d49d562e67e0a871be7c123e9f4c8be36cbb0c7a3359da7b8a96e24bc3a2fb033d1f866eeefe7eca3791f9da52b9f7aa5b0d594799a0ba3399ae
\ No newline at end of file
dddb11f7e45f1779ff536819f36a20e63d572ba8
\ No newline at end of file
......@@ -240,7 +240,7 @@ def run(sysargs):
default=False, help="""Set to true to attempt use local cached copy of the master template.""")
parser.add_option(
'-f', '--force', action='store_true', dest='force_verification',
default=False, help="""Set to true to skip the sha_256 check and force template verification.""")
default=False, help="""Set to true to skip the blake2 check and force template verification.""")
options, args = parser.parse_args(sysargs)
......@@ -279,13 +279,13 @@ def run(sysargs):
# retrieve the contents of the local template
current = fetch(current_url)
hexdigest = hashlib.sha256(current).hexdigest()
hexdigest = hashlib.blake2b(current).hexdigest()
if not options.force_verification:
# Early exist if the template hasn't changed.
sha_url = "%s.sha256" % current_url
current_sha = fetch(sha_url)
if hexdigest == current_sha:
print("Message template SHA_256 has not changed.")
b2_url = "%s.b2" % current_url
current_b2b = fetch(b2_url)
if hexdigest == current_b2b:
print("Message template BLAKE2 has not changed.")
sys.exit(0)
# and check for syntax
......@@ -320,10 +320,10 @@ def explain(header, compat):
if acceptable:
explain("--- PASS ---", compat)
if options.force_verification == False:
print("Updating sha256 to %s" % hexdigest)
sha_filename = "%s.sha256" % current_filename
with open(sha_filename, 'w') as sha_file:
sha_file.write(hexdigest)
print("Updating blake2 hash to %s" % hexdigest)
b2_filename = "%s.b2" % current_filename
with open(b2_filename, 'w') as b2_file:
b2_file.write(hexdigest)
else:
explain("*** FAIL ***", compat)
return 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment