1 | <?php |
||
23 | trait DriverBaseTrait |
||
24 | { |
||
25 | use ExtendedCacheItemPoolTrait; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | public $extension_dir = '_extensions'; |
||
31 | |||
32 | /** |
||
33 | * @var array default options, this will be merge to Driver's Options |
||
34 | */ |
||
35 | public $config = []; |
||
36 | |||
37 | /** |
||
38 | * @var bool |
||
39 | */ |
||
40 | public $fallback = false; |
||
41 | |||
42 | /** |
||
43 | * @var mixed Instance of driver service |
||
44 | */ |
||
45 | public $instance; |
||
46 | |||
47 | /** |
||
48 | * @param $keyword |
||
49 | * @return string |
||
50 | */ |
||
51 | protected function encodeFilename($keyword) |
||
55 | |||
56 | /** |
||
57 | * @param $config_name |
||
58 | * @param string $value |
||
59 | */ |
||
60 | public function setup($config_name, $value = '') |
||
71 | |||
72 | |||
73 | /** |
||
74 | * @param $file |
||
75 | * @return string |
||
76 | * @throws \Exception |
||
77 | */ |
||
78 | protected function readfile($file) |
||
99 | |||
100 | /** |
||
101 | * Encode data types such as object/array |
||
102 | * for driver that does not support |
||
103 | * non-scalar value |
||
104 | * @param $data |
||
105 | * @return string |
||
106 | */ |
||
107 | protected function encode($data) |
||
111 | |||
112 | /** |
||
113 | * Decode data types such as object/array |
||
114 | * for driver that does not support |
||
115 | * non-scalar value |
||
116 | * @param $value |
||
117 | * @return mixed |
||
118 | */ |
||
119 | protected function decode($value) |
||
128 | |||
129 | /** |
||
130 | * Check phpModules or CGI |
||
131 | * @return bool |
||
132 | */ |
||
133 | protected function isPHPModule() |
||
145 | |||
146 | |||
147 | /** |
||
148 | * @param $class |
||
149 | * @return bool |
||
150 | */ |
||
151 | protected function isExistingDriver($class) |
||
155 | |||
156 | |||
157 | /** |
||
158 | * @param $tag |
||
159 | * @return string |
||
160 | */ |
||
161 | protected function _getTagName($tag) |
||
165 | |||
166 | /** |
||
167 | * @param \phpFastCache\Cache\ExtendedCacheItemInterface $item |
||
168 | * @return array |
||
169 | */ |
||
170 | public function driverPreWrap(ExtendedCacheItemInterface $item) |
||
178 | |||
179 | /** |
||
180 | * @param array $wrapper |
||
181 | * @return mixed |
||
182 | */ |
||
183 | public function driverUnwrapData(array $wrapper) |
||
187 | |||
188 | /** |
||
189 | * @param array $wrapper |
||
190 | * @return mixed |
||
191 | */ |
||
192 | public function driverUnwrapTags(array $wrapper) |
||
196 | |||
197 | |||
198 | /** |
||
199 | * @param array $wrapper |
||
200 | * @return \DateTime |
||
201 | */ |
||
202 | public function driverUnwrapTime(array $wrapper) |
||
206 | |||
207 | /** |
||
208 | * @return string |
||
209 | */ |
||
210 | public function getDriverName() |
||
216 | |||
217 | /** |
||
218 | * @param \phpFastCache\Cache\ExtendedCacheItemInterface $item |
||
219 | * @return bool |
||
220 | */ |
||
221 | public function driverWriteTags(ExtendedCacheItemInterface $item) |
||
278 | |||
279 | /** |
||
280 | * @param $key |
||
281 | * @return string |
||
282 | */ |
||
283 | public function getTagKey($key) |
||
287 | |||
288 | /** |
||
289 | * @param $key |
||
290 | * @return string |
||
291 | */ |
||
292 | public function getTagKeys(array $keys) |
||
300 | |||
301 | /** |
||
302 | * @param string $optionName |
||
303 | * @param mixed $optionValue |
||
304 | * @return bool |
||
305 | * @throws \InvalidArgumentException |
||
306 | */ |
||
307 | public static function isValidOption($optionName, $optionValue) |
||
315 | |||
316 | /** |
||
317 | * @return array |
||
318 | */ |
||
319 | public static function getRequiredOptions() |
||
323 | |||
324 | /** |
||
325 | * @return array |
||
326 | */ |
||
327 | public static function getValidOptions() |
||
331 | } |
$file
can contain request data and is used in file inclusion context(s) leading to a potential security vulnerability.General Strategies to prevent injection
In general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:
For numeric data, we recommend to explicitly cast the data: