hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

PHPUnit Phar signature not being correctly verified

Open simonwelsh opened this issue 11 years ago • 5 comments

I downloaded the 4.7.7 phar for PHPUnit (https://phar.phpunit.de/phpunit-4.7.7.phar) and HHVM is failing to run it. It runs fine with php 5.6.

PHP:

vagrant@homestead:~/projects$ php --version
PHP 5.6.7-1+deb.sury.org~utopic+1 (cli) (built: Mar 24 2015 11:23:10) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
    with blackfire v0.23.0, https://blackfire.io/, by SensioLabs
vagrant@homestead:~/projects$ php ./phpunit.phar --version
PHPUnit 4.7.7 by Sebastian Bergman and contributors.
vagrant@homestead:~/projects$ 

HHVM 3.8.1:

vagrant@homestead:~/projects$ hhvm --version
HipHop VM 3.8.1 (rel)
Compiler: tags/HHVM-3.8.1-0-g3006bc45691762b5409fc3a510a43093968e9660
Repo schema: 253b3802ce1bcd19e378634342fc9c245ac76c33
vagrant@homestead:~/projects$ hhvm ./phpunit.phar --version

Fatal error: Uncaught exception 'PharException' with message 'phar has a broken signature' in :
Stack trace:
#0 (): Phar->parsePhar()
#1 (): Phar->__construct()
#2 /home/vagrant/projects/phpunit.phar(15): Phar::mapPhar()
#3 {main}
vagrant@homestead:~/projects$ 

HHVM nightly (2015.08.03):

vagrant@homestead:~/projects$ hhvm --version
HipHop VM 3.9.0-dev (rel)
Compiler: heads/master-0-g71e7b1d166877fc68b9843e5aebcf5d175005a7e
Repo schema: 198b332a71922557779226df56fa055dc7dd6130
vagrant@homestead:~/projects$ hhvm ./phpunit.phar --version

Fatal error: Uncaught exception 'PharException' with message 'phar has a broken signature' in /home/vagrant/projects/phpunit.phar:15
Stack trace:
#0 /home/vagrant/projects/phpunit.phar(15): Phar::mapPhar()
#1 {main}
vagrant@homestead:~/projects$ 

simonwelsh avatar Aug 04 '15 08:08 simonwelsh

I did a bit of digging on this, and the specific place this exception is being thrown is in the system library in Phar.php:1061. My initial attempt at outputting the values of $actualHash and $this->signature failed due to actualHash containing a null byte, and that's as far as I'm going to dig on this for tonight.

Orvid avatar Aug 04 '15 12:08 Orvid

Well, after a bit more digging, it appears that only MD5 and SHA1 signatures were actually working. SHA512, which PHPUnit uses, and SHA256 signatures did not work correctly. OpenSSL signatures were being ignored completely and would fail quite badly due to $digestName and $digestSize not being set.

PR #5858 should fix this issue.

Orvid avatar Aug 04 '15 23:08 Orvid

Closed in f1e4062

Github doesn't recognize Fixes issue [xxx]

SiebelsTim avatar Aug 05 '15 18:08 SiebelsTim

This is preventing phpunit from running, right? So we should make sure this ends up in 3.9?

jwatzman avatar Aug 05 '15 18:08 jwatzman

Yeah, I was going to poke you to make sure it got into 3.9 once it got merged.

sebastianbergmann/phpunit#1752 is the first occurrence I saw of this happening, so it wasn't just me ;)

HRMsimon avatar Aug 05 '15 22:08 HRMsimon