Skip to content

Add recommendations & warnings#282

Merged
theofidry merged 8 commits into
box-project:masterfrom
theofidry:feature/warnings
Sep 21, 2018
Merged

Add recommendations & warnings#282
theofidry merged 8 commits into
box-project:masterfrom
theofidry:feature/warnings

Conversation

@theofidry
Copy link
Copy Markdown
Member

@theofidry theofidry commented Sep 21, 2018

Related to #123.

The current implementation only adds the API at the Configuration level. Some TODOs have been changed as well in favour of that new system but I am certain there is more "recommendations" that could be added.

To completely close #123 more work needs to be done on the UI for the user to be able to read them.

Other notable changes:

  • Add the Symfony PHPUnit bridge in order to notice the deprecation notice messages when running the tests
  • Fail gracefully (i.e. with a meaningful message) when a wrong password has been provided to retrieve the private key necessary for OpenSSL signing
  • Rename isPrivateKeyPrompt() to promptPrivateKey(). The old method is kept for BC but is marked as deprecated.
  • Reworking the PHAR built-in signing part:
    • An error is thrown if no path is provided for the key but the OpenSSL algorithm is requested for signing
    • No longer allow any invalid signing algorithm (before the only condition was that it was a known constant from the Phar class)
    • Warnings and recommendations have been added for various algorithm, key and key-pass combinations
  • Migrated from datetime_format which is deprecated to datetime-format
  • Implemented various recommendations/warnings

@theofidry theofidry merged commit 0e87fa8 into box-project:master Sep 21, 2018
@theofidry theofidry deleted the feature/warnings branch September 21, 2018 13:59
Comment thread doc/configuration.md
prompted for the passphrase.
prompted for the passphrase unless you are not in an interactive environment.

This setting will be ignored if no [key][key] has been provided.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[key][key] ?
what this MD syntax stands for ?

Copy link
Copy Markdown
Member Author

@theofidry theofidry Sep 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing:

[link text](link)

You can do:

[link text][anchor]

[anchor]: link

Which allows you to group all the links in one place (here at the bot of the file) and re-use a given link in several places.

It looks funny here because coincidentally the anchor name is the same as the linked text

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome ;) TIL ;) thanks !

Comment thread src/Configuration.php
// TODO: no longer accept strings & document BC break
if (false === isset($raw->algorithm)) {
return Phar::SHA1;
return self::DEFAULT_SIGNING_ALGORITHM;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if this algorithms is not one available in get_phar_signing_algorithms ?

Copy link
Copy Markdown
Member Author

@theofidry theofidry Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_phar_signing_algorithms() would need to be updated - it takes all the algorithms allowed by Phar right now, (which is unlikely to happen often so maintaining that should be ok)

Comment thread src/Configuration.php
Assertion::true(
defined('Phar::'.$algorithm),
sprintf(
'The signing algorithm "%s" is not supported by your current PHAR version.',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, to be honest, I would not expect that, after we checked our algorithm is in get_phar_signing_algorithms :|

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me neither, but it would be possible for example that a new PHP version introduce a new signing algorithm, in which case get_phar_signing_algorithms () would have it, but the PHP version you are using does not allow it.

Just to be clear: there is no change of behaviour here in the sense it would just fail as before, the difference is the failure would happen with a more friendly error message

Comment thread src/Configuration.php
'finder',
];
private const PHP_SCOPER_CONFIG = 'scoper.inc.php';
private const DEFAULT_SIGNING_ALGORITHM = Phar::SHA1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure SHA1 is always available? asking, as for other algorithms, we check if it's available for our installation of Phar ext...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, worth checking even more so since I'd like to check if it's worth pushing for a better signing algorithm

Comment thread src/functions.php
*
* @return <string, int>
*/
function get_phar_signing_algorithms(): array
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, nothing like that as native PHP function ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind got it: no I wish that was par of the PHP phar extension as well as one or two of the functions above... but it's probably not gonna happen any time soon and didn't bother to try to push for it yet either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add build warnings

2 participants