1 | <?php |
||
23 | class AvirWrapper extends Wrapper{ |
||
24 | |||
25 | const AV_EXCEPTION_MESSAGE = 'Either the ownCloud antivirus app is misconfigured or the external antivirus service is not accessible. %s'; |
||
26 | |||
27 | /** |
||
28 | * Modes that are used for writing |
||
29 | * @var array |
||
30 | */ |
||
31 | private $writingModes = array('r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'c', 'c+'); |
||
32 | |||
33 | /** |
||
34 | * @var AppConfig |
||
35 | */ |
||
36 | protected $appConfig; |
||
37 | |||
38 | /** |
||
39 | * @var \OCA\Files_Antivirus\ScannerFactory |
||
40 | */ |
||
41 | protected $scannerFactory; |
||
42 | |||
43 | /** |
||
44 | * @var IL10N |
||
45 | */ |
||
46 | protected $l10n; |
||
47 | |||
48 | /** |
||
49 | * @var ILogger; |
||
50 | */ |
||
51 | protected $logger; |
||
52 | |||
53 | /** @var RequestHelper */ |
||
54 | protected $requestHelper; |
||
55 | |||
56 | /** |
||
57 | * @param array $parameters |
||
58 | */ |
||
59 | 7 | public function __construct($parameters) { |
|
67 | |||
68 | /** |
||
69 | * @param string $path |
||
70 | * @param string $data |
||
71 | * @return bool |
||
72 | */ |
||
73 | 3 | public function file_put_contents($path, $data) { |
|
97 | |||
98 | /** |
||
99 | * Asynchronously scan data that are written to the file |
||
100 | * @param string $path |
||
101 | * @param string $mode |
||
102 | * @return resource | bool |
||
103 | */ |
||
104 | 4 | public function fopen($path, $mode){ |
|
105 | 4 | $stream = $this->storage->fopen($path, $mode); |
|
106 | |||
107 | if ( |
||
108 | 4 | is_resource($stream) |
|
109 | 4 | && $this->isWritingMode($mode) |
|
110 | 4 | && $this->isScannableSize($path) |
|
111 | ) { |
||
112 | try { |
||
113 | 2 | $scanner = $this->scannerFactory->getScanner(); |
|
114 | 2 | $scanner->initScanner(); |
|
115 | 2 | return CallBackWrapper::wrap( |
|
116 | 2 | $stream, |
|
117 | 2 | null, |
|
118 | function ($data) use ($scanner) { |
||
119 | 2 | $scanner->onAsyncData($data); |
|
120 | 2 | }, |
|
121 | 2 | function () use ($scanner, $path) { |
|
122 | 2 | $this->onScanComplete($scanner, $path, true); |
|
123 | 2 | } |
|
124 | ); |
||
125 | } catch (InitException $e) { |
||
126 | $message = sprintf(self::AV_EXCEPTION_MESSAGE, $e->getMessage()); |
||
127 | $this->logger->warning($message, ['app' => 'files_antivirus']); |
||
128 | throw new ForbiddenException($message, false, $e); |
||
129 | } catch (\Exception $e){ |
||
130 | $message = implode(' ', [ __CLASS__, __METHOD__, $e->getMessage()]); |
||
131 | $this->logger->warning($message, ['app' => 'files_antivirus']); |
||
132 | } |
||
133 | } |
||
134 | 3 | return $stream; |
|
135 | } |
||
136 | |||
137 | /** |
||
138 | * @param AbstractScanner $scanner |
||
139 | * @param string $path |
||
140 | * @param bool $shouldDelete |
||
141 | * @throws InvalidContentException |
||
142 | */ |
||
143 | 5 | private function onScanComplete($scanner, $path, $shouldDelete){ |
|
190 | |||
191 | /** |
||
192 | * Checks whether passed mode is suitable for writing |
||
193 | * @param string $mode |
||
194 | * @return bool |
||
195 | */ |
||
196 | 4 | private function isWritingMode($mode){ |
|
205 | |||
206 | /** |
||
207 | * Checks upload size against the av_max_file_size config option |
||
208 | * |
||
209 | * @param string $path |
||
210 | * @return bool |
||
211 | */ |
||
212 | 4 | private function isScannableSize($path) { |
|
238 | } |
||
239 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.