Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Git.php

function Git::maskCredentials

Parameters

string[] $credentials:

1 call to Git::maskCredentials()
Git::runCommand in vendor/composer/composer/src/Composer/Util/Git.php

File

vendor/composer/composer/src/Composer/Util/Git.php, line 610

Class

Git
@author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Util

Code

private function maskCredentials(string $error, array $credentials) : string {
    $maskedCredentials = [];
    foreach ($credentials as $credential) {
        if (in_array($credential, [
            'private-token',
            'x-token-auth',
            'oauth2',
            'gitlab-ci-token',
            'x-oauth-basic',
        ])) {
            $maskedCredentials[] = $credential;
        }
        elseif (strlen($credential) > 6) {
            $maskedCredentials[] = substr($credential, 0, 3) . '...' . substr($credential, -3);
        }
        elseif (strlen($credential) > 3) {
            $maskedCredentials[] = substr($credential, 0, 3) . '...';
        }
        else {
            $maskedCredentials[] = 'XXX';
        }
    }
    return str_replace($credentials, $maskedCredentials, $error);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal