Skip to content

Commit

Permalink
fix(ci): remove network setting on the ftp server
Browse files Browse the repository at this point in the history
  • Loading branch information
papac committed Dec 14, 2024
1 parent 4ac97d2 commit 2f65022
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 -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 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
Expand Down
13 changes: 4 additions & 9 deletions src/Storage/Service/FTPService.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function connect()

$this->login();
$this->changePath();
$this->setConnectionPassiveMode();
$this->activePassiveMode();
}

/**
Expand All @@ -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;
}
Expand Down Expand Up @@ -642,8 +635,10 @@ private function readStream(string $path): mixed
*
* @throws RuntimeException
*/
private function setConnectionPassiveMode()
private function activePassiveMode()
{
ftp_set_option($this->connection, FTP_USEPASVADDRESS, false);

if (!ftp_pasv($this->connection, $this->use_passive_mode)) {
throw new RuntimeException(
'Could not set passive mode for connection: '
Expand Down
2 changes: 1 addition & 1 deletion tests/Config/stubs/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
Expand Down

0 comments on commit 2f65022

Please sign in to comment.