| @@ -75,12 +75,12 @@ | ||
| 75 | 75 | * Analytics data for scan completed event. |
| 76 | 76 | * |
| 77 | 77 | * @param Scan_Model $scan_model Scan model object. |
| 78 | 78 | * |
| 79 | - * @return array[ | |
| 79 | + * @return array{ | |
| 80 | 80 | * 'event' => string, |
| 81 | 81 | * 'data' => array |
| 82 | - * ] | |
| 82 | + * } | |
| 83 | 83 | */ |
| 84 | 84 | public function scan_completed( Scan_Model $scan_model ): array { |
| 85 | 85 | $last_scan = $scan_model::get_last(); |
| 86 | 86 | if ( ! $last_scan instanceof Scan_Model ) { |
| @@ -97,19 +97,32 @@ | ||
| 97 | 97 | |
| 98 | 98 | if ( isset( $scan_item_group_total[ Scan_Item::TYPE_INTEGRITY ] ) ) { |
| 99 | 99 | $data['WP core issue count'] = $scan_item_group_total[ Scan_Item::TYPE_INTEGRITY ]; |
| 100 | 100 | } |
| 101 | - | |
| 102 | 101 | if ( isset( $scan_item_group_total[ Scan_Item::TYPE_SUSPICIOUS ] ) ) { |
| 103 | 102 | $data['Suspicious Code'] = $scan_item_group_total[ Scan_Item::TYPE_SUSPICIOUS ]; |
| 103 | + // Additional JS file count if found. | |
| 104 | + $items = $last_scan->get_issues( Scan_Item::TYPE_SUSPICIOUS, Scan_Item::STATUS_ACTIVE ); | |
| 105 | + $count_js_files = 0; | |
| 106 | + foreach ( $items as $item ) { | |
| 107 | + if ( | |
| 108 | + isset( $item->raw_data['file'] ) && is_file( $item->raw_data['file'] ) && | |
| 109 | + 'js' === strtolower( pathinfo( $item->raw_data['file'], PATHINFO_EXTENSION ) ) | |
| 110 | + ) { | |
| 111 | + ++$count_js_files; | |
| 112 | + } | |
| 113 | + } | |
| 114 | + if ( $count_js_files > 0 ) { | |
| 115 | + $data['JS file Detection'] = $count_js_files; | |
| 116 | + } | |
| 104 | 117 | } |
| 105 | 118 | |
| 119 | + if ( isset( $scan_item_group_total[ Scan_Item::TYPE_VULNERABILITY ] ) ) { | |
| 120 | + $data['Vulnerability'] = $scan_item_group_total[ Scan_Item::TYPE_VULNERABILITY ]; | |
| 121 | + } | |
| 122 | + | |
| 106 | 123 | if ( isset( $scan_item_group_total[ Scan_Item::TYPE_PLUGIN_CHECK ] ) ) { |
| 107 | 124 | $data['Plugin file modified'] = $scan_item_group_total[ Scan_Item::TYPE_PLUGIN_CHECK ]; |
| 108 | - } | |
| 109 | - | |
| 110 | - if ( isset( $scan_item_group_total[ Scan_Item::TYPE_VULNERABILITY ] ) ) { | |
| 111 | - $data['Vulnerability'] = $scan_item_group_total[ Scan_Item::TYPE_VULNERABILITY ]; | |
| 112 | 125 | } |
| 113 | 126 | |
| 114 | 127 | $is_closed = false; |
| 115 | 128 | $is_outdated = false; |