Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

The compared phars are altered #6

Closed
theofidry opened this issue May 31, 2018 · 5 comments
Closed

The compared phars are altered #6

theofidry opened this issue May 31, 2018 · 5 comments

Comments

@theofidry
Copy link
Contributor

When executing a diff between two PHAR files, their contents are altered. This can be seen with Box for example:

$ git@github.com:humbug/box.git && cd box
$ composer install
$ bin/phpunit tests/Console/Command/DiffTest.php
$ git st
On branch acme/foo
Your branch is up to date with 'upstream/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   fixtures/diff/simple-phar-bar.phar
	modified:   fixtures/diff/simple-phar-foo.phar

The issue seems to come from setting the alias which alters the original PHAR.

I'm not sure why setting the alias is necessary, but restoring the alias after usage does not seem to help, so maybe Pharaoh should manipulate a copied PHAR instead.

@paragonie-scott
Copy link
Member

I'm not sure why setting the alias is necessary

Try opening two identical PHP archives with the same filename (and thus, the same alias) from different directories.

@theofidry
Copy link
Contributor Author

I see, so maybe we should copy the PHARs before comparing them?

@theofidry
Copy link
Contributor Author

@paragonie-scott what's your opinion here? Willing to go that way or you would prefer tackling the issue from another angle?

@paragonie-scott
Copy link
Member

I don't really have any strong opinions on the best way forward.

If you think copying the PHARs before comparing them will solve the problem, please feel free to give it a shot. I just recall having two PHARs with the same alias (which IIRC defaults to the filename) caused a conflict issue.

theofidry added a commit to theofidry/pharaoh that referenced this issue Jun 10, 2018
The PHARs requires to have a different alias hence Pharaoh set a unique alias. It however alters the
orignal PHAR which is not desirable. This patch copies the PHAR to a temporary directory first and
compare this copy instead.

Closes paragonie#6
@theofidry
Copy link
Contributor Author

The problem persist indeed, but this means two identical PHARs will always show as different (because the alias, hence the signature, will differ).

I've decided to not compare the signatures & aliases in Box since I really don't know how to handle this either.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants