d6b3e8cff0
Joomla: Extension CI / Tests (PHP 8.2) (pull_request) Blocked by required conditions
Joomla: Extension CI / Tests (PHP 8.3) (pull_request) Blocked by required conditions
Joomla: Extension CI / PHPStan Analysis (pull_request) Blocked by required conditions
Joomla: Extension CI / Build RC Pre-Release (pull_request) Blocked by required conditions
Universal: PR Check / Build RC Package (pull_request) Blocked by required conditions
Universal: PR Check / Report Issues (pull_request) Blocked by required conditions
Generic: Repo Health / Scripts governance (pull_request) Blocked by required conditions
Generic: Repo Health / Repository health (pull_request) Blocked by required conditions
Generic: Repo Health / Report Issues (pull_request) Blocked by required conditions
Universal: PR Check / Branch Policy (pull_request) Failing after 2s
Generic: Repo Health / Access control (pull_request) Successful in 2s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Joomla: Extension CI / Release Readiness Check (pull_request) Failing after 6s
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 23s
Universal: PR Check / Validate PR (pull_request) Failing after 7s
Universal: PR Check / Secret Scan (pull_request) Successful in 9s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 13s
Universal: Build & Release / Promote to RC (pull_request) Failing after 11s
Universal: Build & Release / Build & Release Pipeline (pull_request) Has been skipped
Joomla: Extension CI / Lint & Validate (pull_request) Failing after 34s
SFTP UX improvements: - SshKeyField: file upload button (FileReader → base64 → hidden field), key never displayed as readable text, __KEEP_EXISTING__ sentinel preserves DB value on re-save without re-uploading - Auth type dropdown: password / key file / key file + passphrase with conditional field visibility via showon - Required field markers on host, username, path, password - Remove insecure FTP option from remote storage dropdown Security: - Private key stored base64-encoded in database - SftpUploader decodes base64 before writing temp file - ProfileTable::store() handles sentinel to prevent key leakage - Key content never rendered in HTML form output
97 lines
2.4 KiB
PHP
97 lines
2.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @package MokoSuiteBackup
|
|
* @subpackage com_mokosuitebackup
|
|
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
* @license GNU General Public License version 3 or later; see LICENSE
|
|
*/
|
|
|
|
namespace Joomla\Component\MokoSuiteBackup\Administrator\Table;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\Table\Table;
|
|
use Joomla\Component\MokoSuiteBackup\Administrator\Utility\BackupDirectory;
|
|
use Joomla\Database\DatabaseDriver;
|
|
|
|
class ProfileTable extends Table
|
|
{
|
|
public function __construct(DatabaseDriver $db)
|
|
{
|
|
parent::__construct('#__mokosuitebackup_profiles', 'id', $db);
|
|
}
|
|
|
|
public function store($updateNulls = true): bool
|
|
{
|
|
/* Handle SSH key sentinel — when __KEEP_EXISTING__ is submitted,
|
|
preserve the current DB value instead of overwriting with the sentinel.
|
|
This prevents the key from being exposed in the form HTML. */
|
|
if (isset($this->sftp_key_data) && $this->sftp_key_data === '__KEEP_EXISTING__') {
|
|
if ($this->id) {
|
|
$db = $this->getDbo();
|
|
$query = $db->getQuery(true)
|
|
->select($db->quoteName('sftp_key_data'))
|
|
->from($db->quoteName($this->_tbl))
|
|
->where($db->quoteName('id') . ' = ' . (int) $this->id);
|
|
$db->setQuery($query);
|
|
$this->sftp_key_data = $db->loadResult() ?: '';
|
|
} else {
|
|
$this->sftp_key_data = '';
|
|
}
|
|
}
|
|
|
|
$result = parent::store($updateNulls);
|
|
|
|
if ($result && !empty($this->backup_dir)) {
|
|
$this->protectWebAccessibleDir($this->backup_dir);
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
private function protectWebAccessibleDir(string $dir): void
|
|
{
|
|
$resolved = BackupDirectory::resolve($dir);
|
|
|
|
if (BackupDirectory::hasPlaceholders($resolved)) {
|
|
return;
|
|
}
|
|
|
|
if (!BackupDirectory::isWebAccessible($resolved)) {
|
|
return;
|
|
}
|
|
|
|
BackupDirectory::ensureReady($resolved);
|
|
}
|
|
|
|
public function check(): bool
|
|
{
|
|
if (empty($this->title)) {
|
|
$this->setError('Profile title is required.');
|
|
|
|
return false;
|
|
}
|
|
|
|
if (empty($this->backup_type)) {
|
|
$this->backup_type = 'full';
|
|
}
|
|
|
|
// Normalize backup_dir to portable placeholder form
|
|
if (!empty($this->backup_dir)) {
|
|
$this->backup_dir = BackupDirectory::portablize($this->backup_dir);
|
|
}
|
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
|
if (empty($this->created) || $this->created === '0000-00-00 00:00:00') {
|
|
$this->created = $now;
|
|
}
|
|
|
|
$this->modified = $now;
|
|
|
|
return true;
|
|
}
|
|
}
|