Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Jan 15, 2021
2 parents f637aea + eef9742 commit 4aee7b6
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
tools: flex
env:
fail-fast: false # disabled as old PHP version cannot run flex
update: ${{ matrix.php-version == '8.0' }} # force update to 8.0.1+, ref https://github.com/shivammathur/setup-php/issues/394#issuecomment-760461251

- name: Get Composer cache directory
id: composer-cache
Expand Down
8 changes: 8 additions & 0 deletions php-cs-fixer
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ if (defined('HHVM_VERSION_ID')) {
}
} elseif (!defined('PHP_VERSION_ID') || \PHP_VERSION_ID < 50600 || \PHP_VERSION_ID >= 70500) {
fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.6.0 and maximum version of PHP 7.4.*.\n");
fwrite(STDERR, 'Current PHP version: '.PHP_VERSION.".\n");

if (defined('PHP_VERSION_ID') && \PHP_VERSION_ID === 80000) {
fwrite(STDERR, "PHP CS Fixer is not able run on PHP 8.0.0 due to bug in PHP tokenizer (https://bugs.php.net/bug.php?id=80462).\n");
fwrite(STDERR, "Update PHP version to unblock execution.\n");

exit(1);
}

if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");
Expand Down
20 changes: 20 additions & 0 deletions src/Cache/FileCacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,26 @@ public function __destruct()
$this->writeCache();
}

/**
* This class is not intended to be serialized,
* and cannot be deserialized (see __wakeup method).
*/
public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* Disable the deserialization of the class to prevent attacker executing
* code by leveraging the __destruct method.
*
* @see https://owasp.org/www-community/vulnerabilities/PHP_Object_Injection
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

public function needFixing($file, $fileContent)
{
$file = $this->cacheDirectory->getRelativePathTo($file);
Expand Down
20 changes: 20 additions & 0 deletions src/Console/Output/ProcessOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ public function __destruct()
$this->eventDispatcher->removeListener(FixerFileProcessedEvent::NAME, [$this, 'onFixerFileProcessed']);
}

/**
* This class is not intended to be serialized,
* and cannot be deserialized (see __wakeup method).
*/
public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* Disable the deserialization of the class to prevent attacker executing
* code by leveraging the __destruct method.
*
* @see https://owasp.org/www-community/vulnerabilities/PHP_Object_Injection
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

public function onFixerFileProcessed(FixerFileProcessedEvent $event)
{
if (
Expand Down
20 changes: 20 additions & 0 deletions src/FileRemoval.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ public function __destruct()
$this->clean();
}

/**
* This class is not intended to be serialized,
* and cannot be deserialized (see __wakeup method).
*/
public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* Disable the deserialization of the class to prevent attacker executing
* code by leveraging the __destruct method.
*
* @see https://owasp.org/www-community/vulnerabilities/PHP_Object_Injection
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

/**
* Adds a file to be removed.
*
Expand Down
20 changes: 20 additions & 0 deletions src/Linter/ProcessLinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ public function __destruct()
}
}

/**
* This class is not intended to be serialized,
* and cannot be deserialized (see __wakeup method).
*/
public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* Disable the deserialization of the class to prevent attacker executing
* code by leveraging the __destruct method.
*
* @see https://owasp.org/www-community/vulnerabilities/PHP_Object_Injection
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 4aee7b6

Please sign in to comment.