A free, self-hostable news aggregator…
Use PHP SensitiveParameter (#9322)
Alexandre Alapetite8067fd994b47
diff --git a/app/Controllers/apiController.php b/app/Controllers/apiController.phpindex 139e2734e..9d63a449a 100644--- a/app/Controllers/apiController.php+++ b/app/Controllers/apiController.php@@ -10,7 +10,7 @@ class FreshRSS_api_Controller extends FreshRSS_ActionController {* Update the user API password.* Return an error message, or `false` if no error.*/- public static function updatePassword(string $apiPasswordPlain): string|false {+ public static function updatePassword(#[\SensitiveParameter] string $apiPasswordPlain): string|false {$username = Minz_User::name();if ($username == null) {return _t('feedback.api.password.failed');diff --git a/app/Controllers/userController.php b/app/Controllers/userController.phpindex c823e2a40..6857b03ae 100644--- a/app/Controllers/userController.php+++ b/app/Controllers/userController.php@@ -74,7 +74,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {}/** @param array<string,mixed> $userConfigUpdated */- public static function updateUser(string $user, ?string $email, string $passwordPlain, array $userConfigUpdated = []): bool {+ public static function updateUser(string $user, ?string $email, #[\SensitiveParameter] string $passwordPlain, array $userConfigUpdated = []): bool {$userConfig = FreshRSS_UserConfiguration::getForUser($user);if ($userConfig === null) {return false;@@ -349,7 +349,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {* @throws Minz_ConfigurationNamespaceException* @throws Minz_PDOConnectionException*/- public static function createUser(string $new_user_name, ?string $email, string $passwordPlain,+ public static function createUser(string $new_user_name, ?string $email, #[\SensitiveParameter] string $passwordPlain,array $userConfigOverride = [], bool $insertDefaultFeeds = true): bool {$userConfig = [];diff --git a/app/Models/Feed.php b/app/Models/Feed.phpindex 670f0170b..c7b0b4111 100644--- a/app/Models/Feed.php+++ b/app/Models/Feed.php@@ -560,7 +560,7 @@ class FreshRSS_Feed extends Minz_Model {public function _pathEntries(string $value): void {$this->pathEntries = $value;}- public function _httpAuth(string $value): void {+ public function _httpAuth(#[\SensitiveParameter] string $value): void {$this->httpAuth = $value;}diff --git a/app/Models/FormAuth.php b/app/Models/FormAuth.phpindex 2c8f8afa8..8b8611e03 100644--- a/app/Models/FormAuth.php+++ b/app/Models/FormAuth.php@@ -2,7 +2,8 @@declare(strict_types=1);class FreshRSS_FormAuth {- public static function checkCredentials(string $username, string $hash, string $nonce, string $challenge): bool {+ public static function checkCredentials(string $username, #[\SensitiveParameter] string $hash,+ string $nonce, #[\SensitiveParameter] string $challenge): bool {if (!FreshRSS_user_Controller::checkUsername($username) ||!ctype_graph($hash) ||!ctype_graph($challenge) ||@@ -56,7 +57,7 @@ class FreshRSS_FormAuth {return false;}- public static function makeCookie(string $username, string $password_hash): string|false {+ public static function makeCookie(string $username, #[\SensitiveParameter] string $password_hash): string|false {do {$token = hash('sha256', FreshRSS_Context::systemConf()->salt . $username . random_bytes(32));$token_file = DATA_PATH . '/tokens/' . $token . '.txt';diff --git a/app/Utils/feverUtil.php b/app/Utils/feverUtil.phpindex ff6c4f14f..9cf6cf9f7 100644--- a/app/Utils/feverUtil.php+++ b/app/Utils/feverUtil.php@@ -38,7 +38,7 @@ class FreshRSS_fever_Util {* @return string|false the Fever key, or false if the update failed* @throws FreshRSS_Context_Exception*/- public static function updateKey(string $username, string $passwordPlain): string|false {+ public static function updateKey(string $username, #[\SensitiveParameter] string $passwordPlain): string|false {if (!self::checkFeverPath()) {return false;}diff --git a/app/Utils/passwordUtil.php b/app/Utils/passwordUtil.phpindex d522abac0..4f13a57fe 100644--- a/app/Utils/passwordUtil.php+++ b/app/Utils/passwordUtil.php@@ -9,7 +9,7 @@ class FreshRSS_password_Util {/*** Return a hash of a plain password, using BCRYPT*/- public static function hash(string $passwordPlain): string {+ public static function hash(#[\SensitiveParameter] string $passwordPlain): string {$passwordHash = password_hash($passwordPlain,PASSWORD_BCRYPT,@@ -25,7 +25,7 @@ class FreshRSS_password_Util {** @return bool True if the password is valid, false otherwise*/- public static function check(string $password): bool {+ public static function check(#[\SensitiveParameter] string $password): bool {return strlen($password) >= 7;}diff --git a/lib/Minz/Pdo.php b/lib/Minz/Pdo.phpindex bfa5cda52..b8fe3a4c6 100644--- a/lib/Minz/Pdo.php+++ b/lib/Minz/Pdo.php@@ -11,7 +11,7 @@ abstract class Minz_Pdo extends PDO {* @param array<int,int|string|bool>|null $options* @throws PDOException*/- public function __construct(string $dsn, ?string $username = null, ?string $passwd = null, ?array $options = null) {+ public function __construct(string $dsn, ?string $username = null, #[\SensitiveParameter] ?string $passwd = null, ?array $options = null) {parent::__construct($dsn, $username, $passwd, $options);$this->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);}diff --git a/lib/Minz/PdoMysql.php b/lib/Minz/PdoMysql.phpindex a072166ea..b7fdd08f6 100644--- a/lib/Minz/PdoMysql.php+++ b/lib/Minz/PdoMysql.php@@ -11,7 +11,7 @@ class Minz_PdoMysql extends Minz_Pdo {* @param array<int,int|string|bool>|null $options* @throws PDOException*/- public function __construct(string $dsn, ?string $username = null, ?string $passwd = null, ?array $options = null) {+ public function __construct(string $dsn, ?string $username = null, #[\SensitiveParameter] ?string $passwd = null, ?array $options = null) {parent::__construct($dsn, $username, $passwd, $options);if (class_exists('Pdo\Mysql')) {assert(is_int(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY)); // For PHPStan with PHP 8.4+diff --git a/lib/Minz/PdoPgsql.php b/lib/Minz/PdoPgsql.phpindex 6eda610d8..4209791c5 100644--- a/lib/Minz/PdoPgsql.php+++ b/lib/Minz/PdoPgsql.php@@ -11,7 +11,7 @@ class Minz_PdoPgsql extends Minz_Pdo {* @param array<int,int|string|bool>|null $options* @throws PDOException*/- public function __construct(string $dsn, ?string $username = null, ?string $passwd = null, ?array $options = null) {+ public function __construct(string $dsn, ?string $username = null, #[\SensitiveParameter] ?string $passwd = null, ?array $options = null) {parent::__construct($dsn, $username, $passwd, $options);$this->exec("SET NAMES 'UTF8';");}diff --git a/lib/Minz/PdoSqlite.php b/lib/Minz/PdoSqlite.phpindex 0c31ff95b..73c8ab3eb 100644--- a/lib/Minz/PdoSqlite.php+++ b/lib/Minz/PdoSqlite.php@@ -11,7 +11,7 @@ class Minz_PdoSqlite extends Minz_Pdo {* @param array<int,int|string|bool>|null $options* @throws PDOException*/- public function __construct(string $dsn, ?string $username = null, ?string $passwd = null, ?array $options = null) {+ public function __construct(string $dsn, ?string $username = null, #[\SensitiveParameter] ?string $passwd = null, ?array $options = null) {parent::__construct($dsn, $username, $passwd, $options);$this->exec('PRAGMA foreign_keys = ON;');}diff --git a/p/api/greader.php b/p/api/greader.phpindex 21f348f89..df9132d76 100644--- a/p/api/greader.php+++ b/p/api/greader.php@@ -206,7 +206,7 @@ final class GReaderAPI {return '';}- private static function clientLogin(string $email, string $pass): never {+ private static function clientLogin(string $email, #[\SensitiveParameter] string $pass): never {//https://web.archive.org/web/20130604091042/http://undoc.in/clientLogin.htmlif (FreshRSS_user_Controller::checkUsername($email)) {FreshRSS_Context::initUser($email);