-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: filter every handled exceptions through a blacklist filter
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Jops\TYPO3\Sentry\Service; | ||
|
||
use Jops\TYPO3\Sentry\Domain\Configuration\Configuration; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class Blacklist | ||
{ | ||
/** | ||
* Check weather the given string gets matched by the configured blacklist regex. | ||
* If the blacklist regex is empty, this will always return false. | ||
*/ | ||
public static function isExcluded(string $className): bool | ||
{ | ||
$configuration = GeneralUtility::makeInstance(Configuration::class); | ||
$pattern = $configuration->getBlacklistPattern(); | ||
|
||
// When the pattern is empty (not set), nothing should be excluded, so we just return false. | ||
if ($pattern === "") { | ||
return false; | ||
} | ||
|
||
return preg_match($pattern, $className) > 0; | ||
} | ||
} |