paketo-buildpacks / php-composer

Apache License 2.0
5 stars 3 forks source link

Buildpack does not detect that openssl is a required extension #190

Open dmikusa opened 3 years ago

dmikusa commented 3 years ago

What happened?

Create and run the sample app as described in this issue. When deployed, it will not have the openssl extension enabled.

https://github.com/paketo-buildpacks/php/issues/366#issue-866600764

Based on this, it seems like the auto detection is run but it's missing OpenSSL. It should have been though as when I run composer check-platform-reqs locally, it shows openssl as required.

The php.ini snippet generated by the buildpack only has:

extension = fileinfo.so
extension = mbstring.so

My theory is that because openssl is a required extension to run Composer, we enable it in the php.ini that's used to execute composer. Thus when composer check-platform-reqs executes, it sees openssl as already available. This isn't correct though because it's only available in the limited environment where we execute Composer.

I think there's a couple ways that we could fix this:

  1. Always enable the openssl extension. It is quite widely used at this point. I think the risk here is that if we enable it, and there's a security vulnerability then an app that doesn't use it could potentially be vulnerable when it otherwise wouldn't be.
  2. When we check for extensions with composer check-platform-reqs, we normally filter by extensions listed missing. We need to look for both missing or the name openssl. If openssl is listed, it'll never be missing, so we just need to add it to the list of extensions to enable.

Run an app where openssl is a extension required through Composer.

The composer extension to be available.

Other extensions were detected correctly, but not openssl.

Build Configuration

Pack.

full

https://github.com/paketo-buildpacks/php/issues/366#issue-866600764

Checklist

arjun024 commented 3 years ago

When we check for extensions with composer check-platform-reqs, we normally filter by extensions listed missing. We need to look for both missing or the name openssl. If openssl is listed, it'll never be missing, so we just need to add it to the list of extensions to enable.

This sounds reasonable to me. In the meantime as a workaround for anyone running into this issue, you should be able to follow the steps here to manually enable the openssl extension https://paketo.io/docs/buildpacks/language-family-buildpacks/php/#configuring-custom-ini-files.

Create a .php.ini.d directory at the root of the app and create an .ini file inside it declaring the openssl extension.

So it should looks look something like this:

$ cat .php.ini.d/extension.ini
extension=openssl.so
TisVictress commented 2 years ago

@arjun024 Is there an update on how we should prioritize this issue? Is the current workaround still sufficient?