You are here

public function PharExtensionInterceptor::assert in Drupal 8

Same name and namespace in other branches
  1. 7 misc/typo3/drupal-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

\TYPO3\PharStreamWrapper\Exception Thrown when the file is not allowed to execute.

File

core/lib/Drupal/Core/Security/PharExtensionInterceptor.php, line 34

Class

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

Namespace

Drupal\Core\Security

Code

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