| @@ -234,9 +234,11 @@ | ||
| 234 | 234 | ), |
| 235 | 235 | 'new_structure' => '3.4.0', |
| 236 | 236 | ); |
| 237 | 237 | |
| 238 | - $model->add_item( Scan_Item::TYPE_VULNERABILITY, $raw_data ); | |
| 238 | + if ( array() !== $raw_data['bugs'] ) { | |
| 239 | + $model->add_item( Scan_Item::TYPE_VULNERABILITY, $raw_data ); | |
| 240 | + } | |
| 239 | 241 | } |
| 240 | 242 | } elseif ( 'plugin' === $type || 'theme' === $type ) { |
| 241 | 243 | if ( ! isset( $info[ $base_slug ] ) || ! is_array( $info[ $base_slug ] ) ) { |
| 242 | 244 | continue; |
| @@ -242,16 +244,14 @@ | ||
| 242 | 244 | continue; |
| 243 | 245 | } |
| 244 | 246 | |
| 245 | 247 | if ( isset( $bugs['confirmed'] ) && ( is_array( $bugs['confirmed'] ) || $bugs['confirmed'] instanceof Countable ? count( $bugs['confirmed'] ) : 0 ) ) { |
| 248 | + // Default conditions for wp.org and Pro plugins. | |
| 246 | 249 | $wp_org_plugin_details = array( |
| 247 | 250 | 'is_existed' => false, |
| 248 | 251 | 'last_version' => '0', |
| 249 | 252 | ); |
| 250 | - if ( 'plugin' === $type ) { | |
| 251 | - if ( ! $this->is_likely_wporg_slug( $base_slug ) ) { | |
| 252 | - continue; | |
| 253 | - } | |
| 253 | + if ( 'plugin' === $type && $this->is_likely_wporg_slug( $base_slug ) ) { | |
| 254 | 254 | // Additional conditions for wp.org plugin. |
| 255 | 255 | $results = $this->handle_wp_org_response_by( $base_slug ); |
| 256 | 256 | if ( $results['success'] && isset( $results['body']['version'] ) ) { |
| 257 | 257 | $wp_org_plugin_details = array( |
| @@ -292,9 +292,11 @@ | ||
| 292 | 292 | 'cvss_score' => $bug['cvss']['score'] ?? '', |
| 293 | 293 | ); |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - $model->add_item( Scan_Item::TYPE_VULNERABILITY, $raw_data ); | |
| 296 | + if ( array() !== $raw_data['bugs'] ) { | |
| 297 | + $model->add_item( Scan_Item::TYPE_VULNERABILITY, $raw_data ); | |
| 298 | + } | |
| 297 | 299 | } |
| 298 | 300 | } |
| 299 | 301 | } |
| 300 | 302 | } |
| @@ -304,11 +306,26 @@ | ||
| 304 | 306 | * |
| 305 | 307 | * @param array $ignored_issues The array of ignored vulnerability issues to add. |
| 306 | 308 | */ |
| 307 | 309 | private function add_ignored_issues( $ignored_issues ) { |
| 308 | - if ( is_array( $ignored_issues ) && array() !== $ignored_issues ) { | |
| 309 | - foreach ( $ignored_issues as $issue ) { | |
| 310 | - $this->scan->add_item( Scan_Item::TYPE_VULNERABILITY, $issue->raw_data, Scan_Item::STATUS_IGNORE ); | |
| 310 | + if ( ! is_array( $ignored_issues ) || array() === $ignored_issues ) { | |
| 311 | + return; | |
| 312 | + } | |
| 313 | + | |
| 314 | + // wp_core issues have no slug, so carry them forward as-is. | |
| 315 | + $wp_core_issues = array(); | |
| 316 | + $other_issues = array(); | |
| 317 | + foreach ( $ignored_issues as $issue ) { | |
| 318 | + if ( 'wp_core' === ( $issue->raw_data['type'] ?? '' ) ) { | |
| 319 | + $wp_core_issues[] = $issue; | |
| 320 | + } else { | |
| 321 | + $other_issues[] = $issue; | |
| 311 | 322 | } |
| 312 | 323 | } |
| 324 | + | |
| 325 | + foreach ( $wp_core_issues as $issue ) { | |
| 326 | + $this->scan->add_item( Scan_Item::TYPE_VULNERABILITY, $issue->raw_data, Scan_Item::STATUS_IGNORE ); | |
| 327 | + } | |
| 328 | + | |
| 329 | + $this->scan->carry_forward_ignored_issues( Scan_Item::TYPE_VULNERABILITY, $other_issues, 'slug' ); | |
| 313 | 330 | } |
| 314 | 331 | } |