PluginProbe ʕ •ᴥ•ʔ
Wordfence Security – Firewall, Malware Scan, and Login Security / 7.2.4
Wordfence Security – Firewall, Malware Scan, and Login Security v7.2.4
8.2.2 8.2.1 8.2.0 3.7.1 3.7.2 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.9.1 4.0.1 4.0.2 4.0.3 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 5.1.1 5.1.2 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.2.1 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.1 5.3.10 5.3.11 5.3.12 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7 5.3.8 5.3.9 6.0.1 6.0.10 6.0.11 6.0.12 6.0.14 6.0.15 6.0.16 6.0.17 6.0.18 6.0.19 6.0.2 6.0.20 6.0.21 6.0.22 6.0.23 6.0.24 6.0.25 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.0.9 6.1.1 6.1.10 6.1.11 6.1.12 6.1.14 6.1.15 6.1.16 6.1.17 6.1.2 6.1.3 6.1.4 6.1.5 6.1.6 6.1.7 6.1.8 6.1.9 6.2.0 6.2.1 6.2.10 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.2.8 6.2.9 6.3.0 6.3.1 6.3.10 6.3.11 6.3.12 6.3.14 6.3.15 6.3.16 6.3.17 6.3.18 6.3.19 6.3.2 6.3.20 6.3.21 6.3.22 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.3.8 6.3.9 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1.0 7.1.1 7.1.10 7.1.11 7.1.12 7.1.14 7.1.15 7.1.16 7.1.17 7.1.18 7.1.19 7.1.2 7.1.20 7.1.3 7.1.4 7.1.5 7.1.6 7.1.7 7.1.8 7.1.9 7.10.0 7.10.1 7.10.2 7.10.3 7.10.4 7.10.5 7.10.6 7.10.7 7.11.0 7.11.1 7.11.2 7.11.3 7.11.4 7.11.5 7.11.6 7.11.7 7.2.1 7.2.2 7.2.3 7.2.4 7.2.5 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.4.0 7.4.1 7.4.10 7.4.11 7.4.12 7.4.14 7.4.2 7.4.3 trunk 7.4.4 1.1 7.4.5 1.2 7.4.6 1.3 7.4.7 1.3.1 7.4.8 1.3.2 7.4.9 1.3.3 7.5.0 1.4.2 7.5.1 1.4.3 7.5.10 1.4.4 7.5.11 1.4.5 7.5.2 1.4.6 7.5.3 1.4.7 7.5.4 1.4.8 7.5.5 1.5.1 7.5.6 1.5.2 7.5.7 1.5.3 7.5.8 1.5.4 7.5.9 1.5.5 7.6.0 1.5.6 7.6.1 2.0.1 7.6.2 2.0.2 7.7.0 2.0.3 7.7.1 2.0.5 7.8.0 2.0.6 7.8.1 2.0.7 7.8.2 2.1.0 7.9.0 2.1.1 7.9.1 2.1.2 7.9.2 2.1.3 7.9.3 2.1.4 8.0.0 2.1.5 8.0.1 3.0.2 8.0.2 3.0.3 8.0.3 3.0.4 8.0.4 3.0.5 8.0.5 3.0.6 8.1.0 3.0.7 8.1.1 3.0.8 8.1.2 3.0.9 8.1.3 3.1.0 8.1.4 3.1.1 v1.4.1 3.1.2 3.1.4 3.1.6 3.2.1 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.1 3.4.4 3.4.5 3.5.1 3.5.2 3.6.1 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9
wordfence / lib / wfUpdateCheck.php
wordfence / lib Last commit date
Diff 8 years ago dashboard 7 years ago rest-api 7 years ago .htaccess 7 years ago Diff.php 14 years ago GeoLite2-Country.mmdb 7 years ago IPTraf.php 8 years ago IPTrafList.php 7 years ago compat.php 8 years ago conntest.php 7 years ago cronview.php 8 years ago dbview.php 8 years ago diffResult.php 8 years ago email_genericAlert.php 7 years ago email_newIssues.php 7 years ago email_unlockRequest.php 8 years ago email_unsubscribeRequest.php 7 years ago flags.php 7 years ago live_activity.php 8 years ago menu_dashboard.php 7 years ago menu_dashboard_options.php 7 years ago menu_firewall.php 7 years ago menu_firewall_blocking.php 7 years ago menu_firewall_blocking_options.php 8 years ago menu_firewall_waf.php 7 years ago menu_firewall_waf_options.php 7 years ago menu_options.php 7 years ago menu_scanner.php 7 years ago menu_scanner_credentials.php 8 years ago menu_scanner_options.php 8 years ago menu_support.php 7 years ago menu_tools.php 7 years ago menu_tools_diagnostic.php 7 years ago menu_tools_importExport.php 7 years ago menu_tools_livetraffic.php 7 years ago menu_tools_twoFactor.php 8 years ago menu_tools_whois.php 8 years ago menu_wordfence_central.php 7 years ago sysinfo.php 8 years ago unknownFiles.php 8 years ago viewFullActivityLog.php 8 years ago wf503.php 7 years ago wfAPI.php 7 years ago wfActivityReport.php 7 years ago wfAdminNoticeQueue.php 8 years ago wfArray.php 7 years ago wfBrowscap.php 8 years ago wfBrowscapCache.php 7 years ago wfBulkCountries.php 7 years ago wfCache.php 9 years ago wfCentralAPI.php 7 years ago wfConfig.php 7 years ago wfCrawl.php 8 years ago wfCredentialsController.php 7 years ago wfCrypt.php 8 years ago wfDB.php 7 years ago wfDashboard.php 7 years ago wfDateLocalization.php 8 years ago wfDiagnostic.php 7 years ago wfDict.php 8 years ago wfDirectoryIterator.php 7 years ago wfHelperBin.php 11 years ago wfHelperString.php 11 years ago wfIPWhitelist.php 7 years ago wfImportExportController.php 7 years ago wfIssues.php 7 years ago wfJWT.php 7 years ago wfLockedOut.php 7 years ago wfLog.php 7 years ago wfMD5BloomFilter.php 8 years ago wfNotification.php 8 years ago wfOnboardingController.php 7 years ago wfPersistenceController.php 8 years ago wfRESTAPI.php 7 years ago wfScan.php 7 years ago wfScanEngine.php 7 years ago wfSchema.php 7 years ago wfStyle.php 8 years ago wfSupportController.php 7 years ago wfUnlockMsg.php 7 years ago wfUpdateCheck.php 8 years ago wfUtils.php 7 years ago wfVersionCheckController.php 8 years ago wfView.php 10 years ago wfViewResult.php 8 years ago wordfenceClass.php 7 years ago wordfenceConstants.php 7 years ago wordfenceHash.php 7 years ago wordfenceScanner.php 7 years ago wordfenceURLHoover.php 7 years ago
wfUpdateCheck.php
553 lines
1 <?php
2
3 class wfUpdateCheck {
4
5 private $needs_core_update = false;
6 private $core_update_version = 0;
7 private $plugin_updates = array();
8 private $all_plugins = array();
9 private $plugin_slugs = array();
10 private $theme_updates = array();
11 private $api = null;
12
13 public function __construct() {
14 $this->api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
15 }
16
17 public function __sleep() {
18 return array('needs_core_update', 'core_update_version', 'plugin_updates', 'all_plugins', 'plugin_slugs', 'theme_updates');
19 }
20
21 public function __wakeup() {
22 $this->api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
23 }
24
25 /**
26 * @return bool
27 */
28 public function needsAnyUpdates() {
29 return $this->needsCoreUpdate() || count($this->getPluginUpdates()) > 0 || count($this->getThemeUpdates()) > 0;
30 }
31
32 /**
33 * Check for any core, plugin or theme updates.
34 *
35 * @return $this
36 */
37 public function checkAllUpdates($useCachedValued = true) {
38 return $this->checkCoreUpdates($useCachedValued)
39 ->checkPluginUpdates($useCachedValued)
40 ->checkThemeUpdates($useCachedValued);
41 }
42
43 /**
44 * Check if there is an update to the WordPress core.
45 *
46 * @return $this
47 */
48 public function checkCoreUpdates($useCachedValued = true) {
49 $this->needs_core_update = false;
50
51 if (!function_exists('wp_version_check')) {
52 require_once(ABSPATH . WPINC . '/update.php');
53 }
54 if (!function_exists('get_preferred_from_update_core')) {
55 require_once(ABSPATH . 'wp-admin/includes/update.php');
56 }
57
58 include( ABSPATH . WPINC . '/version.php' ); //defines $wp_version
59
60 $update_core = get_preferred_from_update_core();
61 if ($useCachedValued && isset($update_core->last_checked) && isset($update_core->version_checked) && 12 * HOUR_IN_SECONDS > (time() - $update_core->last_checked) && $update_core->version_checked == $wp_version) { //Duplicate of _maybe_update_core, which is a private call
62 //Do nothing, use cached value
63 }
64 else {
65 wp_version_check();
66 $update_core = get_preferred_from_update_core();
67 }
68
69 if (isset($update_core->response) && $update_core->response == 'upgrade') {
70 $this->needs_core_update = true;
71 $this->core_update_version = $update_core->current;
72 }
73
74 return $this;
75 }
76
77 /**
78 * Check if any plugins need an update.
79 *
80 * @return $this
81 */
82 public function checkPluginUpdates($useCachedValued = true) {
83 $this->plugin_updates = array();
84
85 if (!function_exists('wp_update_plugins')) {
86 require_once(ABSPATH . WPINC . '/update.php');
87 }
88
89 if (!function_exists('plugins_api')) {
90 require_once(ABSPATH . '/wp-admin/includes/plugin-install.php');
91 }
92
93 $update_plugins = get_site_transient('update_plugins');
94 if ($useCachedValued && isset($update_plugins->last_checked) && 12 * HOUR_IN_SECONDS > (time() - $update_plugins->last_checked)) { //Duplicate of _maybe_update_plugins, which is a private call
95 //Do nothing, use cached value
96 }
97 else {
98 wp_update_plugins();
99 $update_plugins = get_site_transient('update_plugins');
100 }
101
102 //Get the full plugin list
103 if (!function_exists('get_plugins')) {
104 require_once(ABSPATH . '/wp-admin/includes/plugin.php');
105 }
106 $installedPlugins = get_plugins();
107
108 if ($update_plugins && !empty($update_plugins->response)) {
109 foreach ($update_plugins->response as $plugin => $vals) {
110 if (!function_exists('get_plugin_data')) {
111 require_once ABSPATH . '/wp-admin/includes/plugin.php';
112 }
113
114 $pluginFile = wfUtils::getPluginBaseDir() . $plugin;
115 if (!file_exists($pluginFile)) { //Plugin has been removed since the update status was pulled
116 unset($installedPlugins[$plugin]);
117 continue;
118 }
119
120 $valsArray = (array) $vals;
121
122 $slug = (isset($valsArray['slug']) ? $valsArray['slug'] : null);
123 if ($slug === null) { //Plugin may have been removed from the repo or was never in it so guess
124 if (preg_match('/^([^\/]+)\//', $pluginFile, $matches)) {
125 $slug = $matches[1];
126 }
127 else if (preg_match('/^([^\/.]+)\.php$/', $pluginFile, $matches)) {
128 $slug = $matches[1];
129 }
130 }
131
132 $data = get_plugin_data($pluginFile);
133 $data['pluginFile'] = $pluginFile;
134 $data['newVersion'] = (isset($valsArray['new_version']) ? $valsArray['new_version'] : 'Unknown');
135 $data['slug'] = $slug;
136 $data['wpURL'] = (isset($valsArray['url']) ? rtrim($valsArray['url'], '/') : null);
137
138 //Check the vulnerability database
139 if ($slug !== null && isset($data['Version'])) {
140 $status = $this->isPluginVulnerable($slug, $data['Version']);
141 $data['vulnerable'] = !!$status;
142 if (is_string($status)) {
143 $data['vulnerabilityLink'] = $status;
144 }
145 }
146 else {
147 $data['vulnerable'] = false;
148 }
149
150 if ($slug !== null) {
151 $this->plugin_slugs[] = $slug;
152 $this->all_plugins[$slug] = $data;
153 }
154
155 $this->plugin_updates[] = $data;
156 unset($installedPlugins[$plugin]);
157 }
158 }
159
160 //We have to grab the slugs from the update response because no built-in function exists to return the true slug from the local files
161 if ($update_plugins && !empty($update_plugins->no_update)) {
162 foreach ($update_plugins->no_update as $plugin => $vals) {
163 if (!function_exists('get_plugin_data')) {
164 require_once ABSPATH . '/wp-admin/includes/plugin.php';
165 }
166
167 $pluginFile = wfUtils::getPluginBaseDir() . $plugin;
168 if (!file_exists($pluginFile)) { //Plugin has been removed since the update status was pulled
169 unset($installedPlugins[$plugin]);
170 continue;
171 }
172
173 $valsArray = (array) $vals;
174
175 $data = get_plugin_data($pluginFile);
176 $data['pluginFile'] = $pluginFile;
177 $data['slug'] = (isset($valsArray['slug']) ? $valsArray['slug'] : null);
178 $data['wpURL'] = (isset($valsArray['url']) ? rtrim($valsArray['url'], '/') : null);
179
180 //Check the vulnerability database
181 if (isset($valsArray['slug']) && isset($data['Version'])) {
182 $status = $this->isPluginVulnerable($valsArray['slug'], $data['Version']);
183 $data['vulnerable'] = !!$status;
184 if (is_string($status)) {
185 $data['vulnerabilityLink'] = $status;
186 }
187 }
188 else {
189 $data['vulnerable'] = false;
190 }
191
192 if (isset($valsArray['slug'])) {
193 $this->plugin_slugs[] = $valsArray['slug'];
194 $this->all_plugins[$valsArray['slug']] = $data;
195 }
196
197 unset($installedPlugins[$plugin]);
198 }
199 }
200
201 //Get the remaining plugins (not in the wordpress.org repo for whatever reason)
202 foreach ($installedPlugins as $plugin => $data) {
203 $pluginFile = wfUtils::getPluginBaseDir() . $plugin;
204 if (!file_exists($pluginFile)) { //Plugin has been removed since the list was generated
205 continue;
206 }
207
208 $data = get_plugin_data($pluginFile);
209
210 $slug = null;
211 if (preg_match('/^([^\/]+)\//', $plugin, $matches)) {
212 $slug = $matches[1];
213 }
214 else if (preg_match('/^([^\/.]+)\.php$/', $plugin, $matches)) {
215 $slug = $matches[1];
216 }
217
218 if ($slug !== null) {
219 $this->plugin_slugs[] = $slug;
220 $this->all_plugins[$slug] = $data;
221 }
222 }
223
224 return $this;
225 }
226
227 /**
228 * Check if any themes need an update.
229 *
230 * @return $this
231 */
232 public function checkThemeUpdates($useCachedValued = true) {
233 $this->theme_updates = array();
234
235 if (!function_exists('wp_update_themes')) {
236 require_once(ABSPATH . WPINC . '/update.php');
237 }
238
239 $update_themes = get_site_transient('update_themes');
240 if ($useCachedValued && isset($update_themes->last_checked) && 12 * HOUR_IN_SECONDS > (time() - $update_themes->last_checked)) { //Duplicate of _maybe_update_themes, which is a private call
241 //Do nothing, use cached value
242 }
243 else {
244 wp_update_themes();
245 $update_themes = get_site_transient('update_themes');
246 }
247
248 if ($update_themes && (!empty($update_themes->response))) {
249 if (!function_exists('wp_get_themes')) {
250 require_once ABSPATH . '/wp-includes/theme.php';
251 }
252 $themes = wp_get_themes();
253 foreach ($update_themes->response as $theme => $vals) {
254 foreach ($themes as $name => $themeData) {
255 if (strtolower($name) == $theme) {
256 $vulnerable = false;
257 if (isset($themeData['Version'])) {
258 $vulnerable = $this->isThemeVulnerable($theme, $themeData['Version']);
259 }
260
261 $this->theme_updates[] = array(
262 'newVersion' => (isset($vals['new_version']) ? $vals['new_version'] : 'Unknown'),
263 'package' => (isset($vals['package']) ? $vals['package'] : null),
264 'URL' => (isset($vals['url']) ? $vals['url'] : null),
265 'Name' => $themeData['Name'],
266 'name' => $themeData['Name'],
267 'version' => $themeData['Version'],
268 'vulnerable' => $vulnerable
269 );
270 }
271 }
272 }
273 }
274 return $this;
275 }
276
277 public function checkAllVulnerabilities() {
278 $this->checkPluginVulnerabilities();
279 $this->checkThemeVulnerabilities();
280 }
281
282 public function checkPluginVulnerabilities() {
283 if (!function_exists('wp_update_plugins')) {
284 require_once(ABSPATH . WPINC . '/update.php');
285 }
286
287 if (!function_exists('plugins_api')) {
288 require_once(ABSPATH . '/wp-admin/includes/plugin-install.php');
289 }
290
291 $vulnerabilities = array();
292
293 //Get the full plugin list
294 if (!function_exists('get_plugins')) {
295 require_once(ABSPATH . '/wp-admin/includes/plugin.php');
296 }
297 $installedPlugins = get_plugins();
298
299 //Get the info for plugins on wordpress.org
300 $this->checkPluginUpdates();
301 $update_plugins = get_site_transient('update_plugins');
302 if ($update_plugins) {
303 if (!function_exists('get_plugin_data'))
304 {
305 require_once ABSPATH . '/wp-admin/includes/plugin.php';
306 }
307
308 if (!empty($update_plugins->response)) {
309 foreach ($update_plugins->response as $plugin => $vals) {
310 $pluginFile = wfUtils::getPluginBaseDir() . $plugin;
311 if (!file_exists($pluginFile)) { //Plugin has been removed since the update status was pulled
312 unset($installedPlugins[$plugin]);
313 continue;
314 }
315
316 $valsArray = (array) $vals;
317 $data = get_plugin_data($pluginFile);
318
319 $slug = (isset($valsArray['slug']) ? $valsArray['slug'] : null);
320 if ($slug === null) { //Plugin may have been removed from the repo or was never in it so guess
321 if (preg_match('/^([^\/]+)\//', $plugin, $matches)) {
322 $slug = $matches[1];
323 }
324 else if (preg_match('/^([^\/.]+)\.php$/', $plugin, $matches)) {
325 $slug = $matches[1];
326 }
327 }
328
329 $record = array();
330 $record['slug'] = $slug;
331 $record['toVersion'] = (isset($valsArray['new_version']) ? $valsArray['new_version'] : 'Unknown');
332 $record['fromVersion'] = (isset($data['Version']) ? $data['Version'] : 'Unknown');
333 $record['vulnerable'] = false;
334 $vulnerabilities[] = $record;
335
336 unset($installedPlugins[$plugin]);
337 }
338 }
339
340 if (!empty($update_plugins->no_update)) {
341 foreach ($update_plugins->no_update as $plugin => $vals) {
342 $pluginFile = wfUtils::getPluginBaseDir() . $plugin;
343 if (!file_exists($pluginFile)) { //Plugin has been removed since the update status was pulled
344 unset($installedPlugins[$plugin]);
345 continue;
346 }
347
348 $valsArray = (array) $vals;
349 $data = get_plugin_data($pluginFile);
350
351 $slug = (isset($valsArray['slug']) ? $valsArray['slug'] : null);
352 if ($slug === null) { //Plugin may have been removed from the repo or was never in it so guess
353 if (preg_match('/^([^\/]+)\//', $plugin, $matches)) {
354 $slug = $matches[1];
355 }
356 else if (preg_match('/^([^\/.]+)\.php$/', $plugin, $matches)) {
357 $slug = $matches[1];
358 }
359 }
360
361 $record = array();
362 $record['slug'] = $slug;
363 $record['fromVersion'] = (isset($data['Version']) ? $data['Version'] : 'Unknown');
364 $record['vulnerable'] = false;
365 $vulnerabilities[] = $record;
366
367 unset($installedPlugins[$plugin]);
368 }
369 }
370 }
371
372 //Get the remaining plugins (not in the wordpress.org repo for whatever reason)
373 foreach ($installedPlugins as $plugin => $data) {
374 $pluginFile = wfUtils::getPluginBaseDir() . $plugin;
375 if (!file_exists($pluginFile)) { //Plugin has been removed since the update status was pulled
376 continue;
377 }
378
379 $data = get_plugin_data($pluginFile);
380
381 $slug = null;
382 if (preg_match('/^([^\/]+)\//', $plugin, $matches)) {
383 $slug = $matches[1];
384 }
385 else if (preg_match('/^([^\/.]+)\.php$/', $plugin, $matches)) {
386 $slug = $matches[1];
387 }
388
389 $record = array();
390 $record['slug'] = $slug;
391 $record['fromVersion'] = (isset($data['Version']) ? $data['Version'] : 'Unknown');
392 $record['vulnerable'] = false;
393 $vulnerabilities[] = $record;
394 }
395
396 if (count($vulnerabilities) > 0) {
397 try {
398 $result = $this->api->call('plugin_vulnerability_check', array(), array(
399 'plugins' => json_encode($vulnerabilities),
400 ));
401
402 foreach ($vulnerabilities as &$v) {
403 $vulnerableList = $result['vulnerable'];
404 foreach ($vulnerableList as $r) {
405 if ($r['slug'] == $v['slug']) {
406 $v['vulnerable'] = !!$r['vulnerable'];
407 if (isset($r['link'])) {
408 $v['link'] = $r['link'];
409 }
410 break;
411 }
412 }
413 }
414 }
415 catch (Exception $e) {
416 //Do nothing
417 }
418
419 wfConfig::set_ser('vulnerabilities_plugin', $vulnerabilities);
420 }
421 }
422
423 public function checkThemeVulnerabilities() {
424 if (!function_exists('wp_update_themes')) {
425 require_once(ABSPATH . WPINC . '/update.php');
426 }
427
428 if (!function_exists('plugins_api')) {
429 require_once(ABSPATH . '/wp-admin/includes/plugin-install.php');
430 }
431
432 $this->checkThemeUpdates();
433 $update_themes = get_site_transient('update_themes');
434
435 $vulnerabilities = array();
436 if ($update_themes && !empty($update_themes->response)) {
437 if (!function_exists('get_plugin_data'))
438 {
439 require_once ABSPATH . '/wp-admin/includes/plugin.php';
440 }
441
442 foreach ($update_themes->response as $themeSlug => $vals) {
443
444 $valsArray = (array) $vals;
445 $theme = wp_get_theme($themeSlug);
446
447 $record = array();
448 $record['slug'] = $themeSlug;
449 $record['toVersion'] = (isset($valsArray['new_version']) ? $valsArray['new_version'] : 'Unknown');
450 $record['fromVersion'] = $theme->version;
451 $record['vulnerable'] = false;
452 $vulnerabilities[] = $record;
453 }
454
455 try {
456 $result = $this->api->call('theme_vulnerability_check', array(), array(
457 'themes' => json_encode($vulnerabilities),
458 ));
459
460 foreach ($vulnerabilities as &$v) {
461 $vulnerableList = $result['vulnerable'];
462 foreach ($vulnerableList as $r) {
463 if ($r['slug'] == $v['slug']) {
464 $v['vulnerable'] = !!$r['vulnerable'];
465 break;
466 }
467 }
468 }
469 }
470 catch (Exception $e) {
471 //Do nothing
472 }
473
474 wfConfig::set_ser('vulnerabilities_theme', $vulnerabilities);
475 }
476 }
477
478 public function isPluginVulnerable($slug, $version) {
479 return $this->_isSlugVulnerable('vulnerabilities_plugin', $slug, $version);
480 }
481
482 public function isThemeVulnerable($slug, $version) {
483 return $this->_isSlugVulnerable('vulnerabilities_theme', $slug, $version);
484 }
485
486 private function _isSlugVulnerable($vulnerabilitiesKey, $slug, $version) {
487 $vulnerabilities = wfConfig::get_ser($vulnerabilitiesKey, array());
488 foreach ($vulnerabilities as $v) {
489 if ($v['slug'] == $slug) {
490 if ($v['fromVersion'] == 'Unknown' && $v['toVersion'] == 'Unknown') {
491 if ($v['vulnerable'] && isset($v['link']) && is_string($v['link'])) { return $v['link']; }
492 return $v['vulnerable'];
493 }
494 else if ((!isset($v['toVersion']) || $v['toVersion'] == 'Unknown') && version_compare($version, $v['fromVersion']) >= 0) {
495 if ($v['vulnerable'] && isset($v['link']) && is_string($v['link'])) { return $v['link']; }
496 return $v['vulnerable'];
497 }
498 else if ($v['fromVersion'] == 'Unknown' && isset($v['toVersion']) && version_compare($version, $v['toVersion']) < 0) {
499 if ($v['vulnerable'] && isset($v['link']) && is_string($v['link'])) { return $v['link']; }
500 return $v['vulnerable'];
501 }
502 else if (version_compare($version, $v['fromVersion']) >= 0 && isset($v['toVersion']) && version_compare($version, $v['toVersion']) < 0) {
503 if ($v['vulnerable'] && isset($v['link']) && is_string($v['link'])) { return $v['link']; }
504 return $v['vulnerable'];
505 }
506 }
507 }
508 return false;
509 }
510
511 /**
512 * @return boolean
513 */
514 public function needsCoreUpdate() {
515 return $this->needs_core_update;
516 }
517
518 /**
519 * @return int
520 */
521 public function getCoreUpdateVersion() {
522 return $this->core_update_version;
523 }
524
525 /**
526 * @return array
527 */
528 public function getPluginUpdates() {
529 return $this->plugin_updates;
530 }
531
532 /**
533 * @return array
534 */
535 public function getAllPlugins() {
536 return $this->all_plugins;
537 }
538
539 /**
540 * @return array
541 */
542 public function getPluginSlugs() {
543 return $this->plugin_slugs;
544 }
545
546 /**
547 * @return array
548 */
549 public function getThemeUpdates() {
550 return $this->theme_updates;
551 }
552 }
553