You are here

public function PharExtensionInterceptor::assert in Drupal 7

Same name in this branch
  1. 7 misc/typo3/drupal-security/PharExtensionInterceptor.php \Drupal\Core\Security\PharExtensionInterceptor::assert()
  2. 7 misc/typo3/phar-stream-wrapper/src/Interceptor/PharExtensionInterceptor.php \TYPO3\PharStreamWrapper\Interceptor\PharExtensionInterceptor::assert()
Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Security/PharExtensionInterceptor.php \Drupal\Core\Security\PharExtensionInterceptor::assert()
  2. 9 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);
}