function PharExtensionInterceptor::assert

Same name in this branch
  1. 7.x misc/typo3/phar-stream-wrapper/src/Interceptor/PharExtensionInterceptor.php \TYPO3\PharStreamWrapper\Interceptor\PharExtensionInterceptor::assert()
Same name in other branches
  1. 9 core/lib/Drupal/Core/Security/PharExtensionInterceptor.php \Drupal\Core\Security\PharExtensionInterceptor::assert()
  2. 8.9.x core/lib/Drupal/Core/Security/PharExtensionInterceptor.php \Drupal\Core\Security\PharExtensionInterceptor::assert()

Determines whether phar file is allowed to execute.

The phar file is allowed to execute if:

  • the base file name has a ".phar" suffix.
  • it is the CLI tool that has invoked the interceptor.

Parameters

string $path: The path of the phar file to check.

string $command: The command being carried out.

Return value

bool TRUE if the phar file is allowed to execute.

Throws

Exception Thrown when the file is not allowed to execute.

Overrides Assertable::assert

File

misc/typo3/drupal-security/PharExtensionInterceptor.php, line 34

Class

PharExtensionInterceptor
An alternate PharExtensionInterceptor to support phar-based CLI tools.

Namespace

Drupal\Core\Security

Code

public function assert($path, $command) {
    if ($this->baseFileContainsPharExtension($path)) {
        return TRUE;
    }
    throw new Exception(sprintf('Unexpected file extension in "%s"', $path), 1535198703);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.