From d8c5fa04c4c0d98e29f615cd46816ee979de5909 Mon Sep 17 00:00:00 2001 From: Franck DAKIA Date: Sat, 14 Dec 2024 00:42:57 +0000 Subject: [PATCH] fix(ci): remove network setting on the ftp server --- .github/workflows/tests.yml | 4 ++-- src/Storage/Service/FTPService.php | 11 ++--------- tests/Config/stubs/storage.php | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2b9975e5..b2bec46d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ env: FTP_USER: username FTP_PASSWORD: password FTP_PORT: 21 - FTP_ROOT: /home/vsftpd/username + FTP_ROOT: /tmp jobs: lunix-tests: @@ -42,7 +42,7 @@ jobs: extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysql, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, redis coverage: none - - run: docker run --net=host -p 21:21 -p 20:20 -p 12020:12020 -p 12021:12021 -p 12022:12022 -p 12023:12023 -p 12024:12024 -p 12025:12025 -e USER=$FTP_USER -e PASS=$FTP_PASSWORD -d --name ftp -v $(pwd)/:/ftp/$FTP_USER papacdev/vsftpd + - run: docker run -p 21:21 -p 20:20 -e USER=$FTP_USER -e PASS=$FTP_PASSWORD -d --name ftp papacdev/vsftpd - run: docker run -p 1080:1080 -p 1025:1025 -d --name maildev soulteary/maildev - run: docker run -p 6379:6379 -d --name redis redis - run: docker run -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres -e POSTGRES_PASSWORD=postgres -d postgis/postgis diff --git a/src/Storage/Service/FTPService.php b/src/Storage/Service/FTPService.php index 7fc5026b..0d3c44d6 100644 --- a/src/Storage/Service/FTPService.php +++ b/src/Storage/Service/FTPService.php @@ -112,7 +112,7 @@ public function connect() $this->login(); $this->changePath(); - $this->setConnectionPassiveMode(); + $this->activePassiveMode(); } /** @@ -139,15 +139,8 @@ private function login(): bool { ['username' => $username, 'password' => $password] = $this->config; - // We disable error handling to avoid credentials leak :+1: - set_error_handler( - fn () => error_log("set_error_handler muted for hidden the ftp credential to user") - ); - $is_logged_in = ftp_login($this->connection, $username, $password); - restore_error_handler(); - if ($is_logged_in) { return true; } @@ -642,7 +635,7 @@ private function readStream(string $path): mixed * * @throws RuntimeException */ - private function setConnectionPassiveMode() + private function activePassiveMode() { if (!ftp_pasv($this->connection, $this->use_passive_mode)) { throw new RuntimeException( diff --git a/tests/Config/stubs/storage.php b/tests/Config/stubs/storage.php index 4fcc382a..81857865 100644 --- a/tests/Config/stubs/storage.php +++ b/tests/Config/stubs/storage.php @@ -27,7 +27,7 @@ 'password' => app_env('FTP_PASSWORD', 'password'), 'username' => app_env('FTP_USERNAME', 'username'), 'port' => app_env('FTP_PORT', 21), - 'root' => app_env('FTP_ROOT', sys_get_temp_dir()), // Start directory + 'root' => app_env('FTP_ROOT', '/tmp'), // Start directory 'tls' => app_env('FTP_SSL', false), // `true` enable the secure connexion. 'timeout' => app_env('FTP_TIMEOUT', 90) // Temps d'attente de connection ],