Skip to content

Commit 7e0f866

Browse files
authored
Merge pull request #2838 from jmoraleda/md5_to_sha256_validation
Replace md5 with sha256 when validating downloaded waf and doxygen build tools
2 parents 3353d0e + d0dc79a commit 7e0f866

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

build.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@
8484
wxICON = 'packaging/docset/mondrian.png'
8585

8686
# Some tools will be downloaded for the builds. These are the versions and
87-
# MD5s of the tool binaries currently in use.
87+
# SHA256s of the tool binaries currently in use.
8888
wafCurrentVersion = '2.1.8'
89-
wafMD5 = 'adefb38faba08f87bbbc585dcf74bf3f'
89+
wafSHA256 = 'd45bbd147d4d22c01ffb59ce6ea230b64c202a90d5447e7a53a2b440b86a42f3'
9090

9191
doxygenCurrentVersion = '1.9.1'
92-
doxygenMD5 = {
93-
'darwin' : '6912d41cef5971fb07573190849a8a84',
94-
'win32' : '90439896025dc8ddcd5d767ab2c2c489',
95-
'linux' : 'ed2c35099165fce0d07d9a1809935928',
92+
doxygenSHA256 = {
93+
'darwin' : '01bc02017b83369a75d9f52c687217395c772382ee5e9157d0afbc2e2929ce5e',
94+
'win32' : '3ef1084566b8c9bf33706d47b974ad07ddb4d2e26037eb199ff406c62f4c693e',
95+
'linux' : '5b8171931bc2b83bb4d19ab1b9ffc423d82df6ebaedc053364ef9543fb6b82e8',
9696
}
9797

9898
# And the location where they can be downloaded from
@@ -603,10 +603,10 @@ def downloadTool(cmd, cmdname, envvar):
603603

604604
os.chmod(cmd, 0o755)
605605

606-
def getTool(cmdName, version, MD5, envVar, platformBinary, linuxBits=False):
606+
def getTool(cmdName, version, SHA256, envVar, platformBinary, linuxBits=False):
607607
# Check in the bin dir for the specified version of the tool command. If
608608
# it's not there then attempt to download it. Validity of the binary is
609-
# checked with an MD5 hash.
609+
# checked with an SHA256 hash.
610610
if os.environ.get(envVar):
611611
# Setting a value in the environment overrides other options
612612
return os.environ.get(envVar)
@@ -618,10 +618,10 @@ def getTool(cmdName, version, MD5, envVar, platformBinary, linuxBits=False):
618618
if platform == 'win32':
619619
ext = '.exe'
620620
cmd = opj(phoenixDir(), 'bin', '%s-%s-%s%s' % (cmdName, version, platform, ext))
621-
md5 = MD5[platform]
621+
sha256 = SHA256[platform]
622622
else:
623623
cmd = opj(phoenixDir(), 'bin', '%s-%s' % (cmdName, version))
624-
md5 = MD5
624+
sha256 = SHA256
625625

626626
msg('Checking for %s...' % cmd)
627627
if os.path.exists(cmd):
@@ -633,13 +633,13 @@ def getTool(cmdName, version, MD5, envVar, platformBinary, linuxBits=False):
633633
cmdName, envVar)
634634
sys.exit(1)
635635

636-
# now check the MD5 if not in dev mode and it's set to None
637-
if not (devMode and md5 is None):
638-
m = hashlib.md5()
636+
# now check the SHA256 if not in dev mode and it's set to None
637+
if not (devMode and sha256 is None):
638+
m = hashlib.sha256()
639639
m.update(Path(cmd).read_bytes())
640-
if m.hexdigest() != md5:
641-
errorMsg('MD5 mismatch, got "%s"\n '
642-
'expected "%s"' % (m.hexdigest(), md5),
640+
if m.hexdigest() != sha256:
641+
errorMsg('SHA256 mismatch, got "%s"\n '
642+
'expected "%s"' % (m.hexdigest(), sha256),
643643
cmdName, envVar)
644644
sys.exit(1)
645645

@@ -668,26 +668,26 @@ def getTool(cmdName, version, MD5, envVar, platformBinary, linuxBits=False):
668668

669669
downloadTool(cmd, cmdName, envVar)
670670

671-
# Recursive call so the MD5 value will be double-checked on what was
671+
# Recursive call so the SHA256 value will be double-checked on what was
672672
# just downloaded
673-
return getTool(cmdName, version, MD5, envVar, platformBinary, linuxBits)
673+
return getTool(cmdName, version, SHA256, envVar, platformBinary, linuxBits)
674674

675675

676-
# The download and MD5 check only needs to happen once per run, cache the sip
676+
# The download and SHA256 check only needs to happen once per run, cache the sip
677677
# cmd value here the first time through.
678678
_wafCmd = None
679679
def getWafCmd():
680680
global _wafCmd
681681
if _wafCmd is None:
682-
_wafCmd = getTool('waf', wafCurrentVersion, wafMD5, 'WAF', False)
682+
_wafCmd = getTool('waf', wafCurrentVersion, wafSHA256, 'WAF', False)
683683
return _wafCmd
684684

685685
# and Doxygen
686686
_doxCmd = None
687687
def getDoxCmd():
688688
global _doxCmd
689689
if _doxCmd is None:
690-
_doxCmd = getTool('doxygen', doxygenCurrentVersion, doxygenMD5, 'DOXYGEN', True)
690+
_doxCmd = getTool('doxygen', doxygenCurrentVersion, doxygenSHA256, 'DOXYGEN', True)
691691
return _doxCmd
692692

693693

0 commit comments

Comments
 (0)