Verified Commit 90c51b90 authored by Dave Long's avatar Dave Long
Browse files

Issue #3296293 by andypost, amjad1233, mfb, smustgrave, _utsavsharma,...

Issue #3296293 by andypost, amjad1233, mfb, smustgrave, _utsavsharma, jordanpagewhite, longwave, geek-merlin: Apply SensitiveParameter attribute
parent 0da5ef42
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ abstract class FTP extends FileTransfer {
  /**
   * {@inheritdoc}
   */
  public function __construct($jail, $username, $password, $hostname, $port) {
  public function __construct($jail, $username, #[\SensitiveParameter] $password, $hostname, $port) {
    $this->username = $username;
    $this->password = $password;
    $this->hostname = $hostname;
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ class SSH extends FileTransfer implements ChmodInterface {
  /**
   * {@inheritdoc}
   */
  public function __construct($jail, $username, $password, $hostname = "localhost", $port = 22) {
  public function __construct($jail, $username, #[\SensitiveParameter] $password, $hostname = "localhost", $port = 22) {
    $this->username = $username;
    $this->password = $password;
    $this->hostname = $hostname;
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ interface PasswordInterface {
   * @return string
   *   A string containing the hashed password, or FALSE on failure.
   */
  public function hash($password);
  public function hash(#[\SensitiveParameter] $password);

  /**
   * Check whether a plain text password matches a hashed password.
@@ -34,7 +34,7 @@ public function hash($password);
   * @return bool
   *   TRUE if the password is valid, FALSE if not.
   */
  public function check($password, $hash);
  public function check(#[\SensitiveParameter] $password, #[\SensitiveParameter] $hash);

  /**
   * Check whether a hashed password needs to be replaced with a new hash.
+4 −4
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ protected function enforceLog2Boundaries($count_log2) {
   *   A string containing the hashed password (and salt) or FALSE on failure.
   *   The return string will be truncated at HASH_LENGTH characters max.
   */
  protected function crypt($algo, $password, $setting) {
  protected function crypt($algo, #[\SensitiveParameter] $password, $setting) {
    // Prevent DoS attacks by refusing to hash large passwords.
    if (strlen($password) > PasswordInterface::PASSWORD_MAX_LENGTH) {
      return FALSE;
@@ -213,14 +213,14 @@ public function getCountLog2($setting) {
  /**
   * {@inheritdoc}
   */
  public function hash($password) {
  public function hash(#[\SensitiveParameter] $password) {
    return $this->crypt('sha512', $password, $this->generateSalt());
  }

  /**
   * {@inheritdoc}
   */
  public function check($password, $hash) {
  public function check(#[\SensitiveParameter] $password, #[\SensitiveParameter] $hash) {
    if (substr($hash, 0, 2) == 'U$') {
      // This may be an updated password from user_update_7000(). Such hashes
      // have 'U' added as the first character and need an extra md5() (see the
@@ -258,7 +258,7 @@ public function check($password, $hash) {
  /**
   * {@inheritdoc}
   */
  public function needsRehash($hash) {
  public function needsRehash(#[\SensitiveParameter] $hash) {
    // Check whether this was an updated password.
    if ((substr($hash, 0, 3) != '$S$') || (strlen($hash) != static::HASH_LENGTH)) {
      return TRUE;
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public function get() {
   * @param string $key
   *   The private key to set.
   */
  public function set($key) {
  public function set(#[\SensitiveParameter] $key) {
    return $this->state->set('system.private_key', $key);
  }

Loading