transip / tipctl

The command line interface for the TransIP API
https://api.transip.nl/rest/docs.html
Apache License 2.0
16 stars 4 forks source link

Discussion on how to securely handle tipctl within PHP open_basedir restrictions #3

Closed Broekman closed 3 years ago

Broekman commented 3 years ago

All files used by tipctl have to be available within the restrictions of PHPs open_basedir. The defaults used to e.g. run setup, adds files to /tmp and tries to create the configuration file under /home/user/.config/transip-api/cli-config.json. Running setup results in a series of PHP warnings and adding these folders to open_basedir or disabling open_basedir restrictions is a not really a good practice.

For now I managed by temporarily disabling the open_basedir restrictions to run the setup and after re-enabling, adding the configuration folder (/home/user/.config/transip-api/) to open_basedir

Anyhow, created this ticket see if a way of working was maybe already existent or of not, discuss on how to handle this securely. Thanks!

When running setup:

Checking API connection to endpoint 'https://api.transip.nl/v6'
PHP Warning:  is_dir(): open_basedir restriction in effect. File(/tmp/symfony-cache/@) is not within the allowed path(s): (/var/www/:/usr/share/webapps/) in phar:///usr/share/webapps/TransIP/tipctl.phar/vendor/symfony/cache/Traits/FilesystemCommonTrait.php on line 41
PHP Warning:  is_file(): open_basedir restriction in effect. File(/tmp/symfony-cache/@/L/J/NN8iPTNeZtJ7PibNDwnA) is not within the allowed path(s): (/var/www/:/usr/share/webapps/) in phar:///usr/share/webapps/TransIP/tipctl.phar/vendor/symfony/cache/Traits/FilesystemTrait.php on line 62
PHP Warning:  is_file(): open_basedir restriction in effect. File(/tmp/symfony-cache/@/J/H/FTp7JKavN6CBFmf-tlwA) is not within the allowed path(s): (/var/www/:/usr/share/webapps/) in phar:///usr/share/webapps/TransIP/tipctl.phar/vendor/symfony/cache/Traits/FilesystemTrait.php on line 62
PHP Warning:  is_file(): open_basedir restriction in effect. File(/tmp/symfony-cache/@/L/J/NN8iPTNeZtJ7PibNDwnA) is not within the allowed path(s): (/var/www/:/usr/share/webapps/) in phar:///usr/share/webapps/TransIP/tipctl.phar/vendor/symfony/cache/Traits/FilesystemTrait.php on line 62
PHP Warning:  is_dir(): open_basedir restriction in effect. File(/tmp/symfony-cache/@/L/J/) is not within the allowed path(s): (/var/www/:/usr/share/webapps/) in phar:///usr/share/webapps/TransIP/tipctl.phar/vendor/symfony/cache/Traits/FilesystemCommonTrait.php on line 116
PHP Warning:  is_file(): open_basedir restriction in effect. File(/tmp/symfony-cache/@/J/H/FTp7JKavN6CBFmf-tlwA) is not within the allowed path(s): (/var/www/:/usr/share/webapps/) in phar:///usr/share/webapps/TransIP/tipctl.phar/vendor/symfony/cache/Traits/FilesystemTrait.php on line 62
PHP Warning:  is_dir(): open_basedir restriction in effect. File(/tmp/symfony-cache/@/J/H/) is not within the allowed path(s): (/var/www/:/usr/share/webapps/) in phar:///usr/share/webapps/TransIP/tipctl.phar/vendor/symfony/cache/Traits/FilesystemCommonTrait.php on line 116

API connection successful
PHP Warning:  is_dir(): open_basedir restriction in effect. File(/user/.config/transip-api) is not within the allowed path(s): (/var/www/:/usr/share/webapps/) in phar:///usr/share/webapps/TransIP/tipctl.phar/vendor/symfony/filesystem/Filesystem.php on line 97
PHP Warning:  is_dir(): open_basedir restriction in effect. File(/user/.config/transip-api) is not within the allowed path(s): (/var/www/:/usr/share/webapps/) in phar:///usr/share/webapps/TransIP/tipctl.phar/vendor/symfony/filesystem/Filesystem.php on line 102

In Setup.php line 124:

  Config directory '/user/.config/transip-api' could not be created

setup [--apiUrl [APIURL]] [--loginName LOGINNAME] [--apiPrivateKey APIPRIVATEKEY] [--apiUseWhitelist [APIUSEWHITELIST]] [--format [FORMAT]]

PHP Warning:  is_file(): open_basedir restriction in effect. File(/tmp/symfony-cache/@/60037c08348023.48298829) is not within the allowed path(s): (/var/www/:/usr/share/webapps/) in phar:///usr/share/webapps/TransIP/tipctl.phar/vendor/symfony/cache/Traits/FilesystemCommonTrait.php on line 181