(array $context)
| 785 | } |
| 786 | |
| 787 | private static function isVirusScanExcluded(array $context): bool |
| 788 | { |
| 789 | $rules = self::getVirusScanExcludeRules(); |
| 790 | if (empty($rules)) { |
| 791 | return false; |
| 792 | } |
| 793 | |
| 794 | $folder = trim((string)($context['folder'] ?? '')); |
| 795 | if ($folder === '') { |
| 796 | return false; |
| 797 | } |
| 798 | $folder = self::normalizeVirusScanExcludePath($folder); |
| 799 | if ($folder === '') { |
| 800 | return false; |
| 801 | } |
| 802 | |
| 803 | $activeSource = class_exists('SourceContext') ? SourceContext::getActiveId() : 'local'; |
| 804 | |
| 805 | foreach ($rules as $rule) { |
| 806 | $ruleSource = (string)($rule['source'] ?? ''); |
| 807 | if ($ruleSource !== '' && $ruleSource !== $activeSource) { |
| 808 | continue; |
| 809 | } |
| 810 | $path = (string)($rule['path'] ?? ''); |
| 811 | if ($path === '') { |
| 812 | continue; |
| 813 | } |
| 814 | if ($folder === $path || str_starts_with($folder, $path . '/')) { |
| 815 | return true; |
| 816 | } |
| 817 | } |
| 818 | |
| 819 | return false; |
| 820 | } |
| 821 | |
| 822 | /** |
| 823 | * Public helper: scan a single $_FILES-style upload array, if ClamAV is enabled. |
no test coverage detected