updated plugin Jetpack Protect version 3.0.2
This commit is contained in:
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* Model class for extensions.
|
||||
*
|
||||
* @package automattic/jetpack-protect-models
|
||||
*/
|
||||
|
||||
namespace Automattic\Jetpack\Protect_Models;
|
||||
|
||||
/**
|
||||
* Model class for extension data.
|
||||
*/
|
||||
class Extension_Model {
|
||||
|
||||
/**
|
||||
* The extension name.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* The extension slug.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $slug;
|
||||
|
||||
/**
|
||||
* The extension version.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $version;
|
||||
|
||||
/**
|
||||
* A collection of threats related to this version of the extension.
|
||||
*
|
||||
* @var array<Threat_Model>
|
||||
*/
|
||||
public $threats = array();
|
||||
|
||||
/**
|
||||
* Whether the extension has been checked for threats.
|
||||
*
|
||||
* @var null|bool
|
||||
*/
|
||||
public $checked;
|
||||
|
||||
/**
|
||||
* The type of extension ("plugins", "themes", or "core").
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Extension Model Constructor
|
||||
*
|
||||
* @param array|object $extension Extension data to load into the model instance.
|
||||
*/
|
||||
public function __construct( $extension = array() ) {
|
||||
if ( is_object( $extension ) ) {
|
||||
$extension = (array) $extension;
|
||||
}
|
||||
|
||||
foreach ( $extension as $property => $value ) {
|
||||
if ( property_exists( $this, $property ) ) {
|
||||
// use the property's setter method when possible
|
||||
if ( method_exists( $this, "set_$property" ) ) {
|
||||
$this->{ "set_$property" }( $value );
|
||||
continue;
|
||||
}
|
||||
|
||||
// otherwise, map the value directly into the class property
|
||||
$this->$property = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Threats
|
||||
*
|
||||
* @param array<Threat_Model|array|object> $threats An array of threat data to add to the extension.
|
||||
*/
|
||||
public function set_threats( $threats ) {
|
||||
if ( ! is_array( $threats ) ) {
|
||||
$this->threats = array();
|
||||
return;
|
||||
}
|
||||
|
||||
// convert each provided threat item into an instance of Threat_Model
|
||||
$threats = array_map(
|
||||
function ( $threat ) {
|
||||
if ( is_a( $threat, 'Threat_Model' ) ) {
|
||||
return $threat;
|
||||
}
|
||||
|
||||
if ( is_object( $threat ) ) {
|
||||
$threat = (array) $threat;
|
||||
}
|
||||
|
||||
return new Threat_Model( $threat );
|
||||
},
|
||||
$threats
|
||||
);
|
||||
|
||||
$this->threats = $threats;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* Model class for Protect history report data.
|
||||
*
|
||||
* @package automattic/jetpack-protect-models
|
||||
*/
|
||||
|
||||
namespace Automattic\Jetpack\Protect_Models;
|
||||
|
||||
/**
|
||||
* Model class for the Protect history report data.
|
||||
*/
|
||||
class History_Model {
|
||||
/**
|
||||
* The date and time when the history was generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $last_checked;
|
||||
|
||||
/**
|
||||
* The number of threats.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_threats;
|
||||
|
||||
/**
|
||||
* The number of core threats.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_core_threats;
|
||||
|
||||
/**
|
||||
* The number of plugin threats.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_plugins_threats;
|
||||
|
||||
/**
|
||||
* The number of theme threats.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_themes_threats;
|
||||
|
||||
/**
|
||||
* WordPress core.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $core = array();
|
||||
|
||||
/**
|
||||
* Status themes.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $themes = array();
|
||||
|
||||
/**
|
||||
* Status plugins.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $plugins = array();
|
||||
|
||||
/**
|
||||
* File threats.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $files = array();
|
||||
|
||||
/**
|
||||
* Database threats.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $database = array();
|
||||
|
||||
/**
|
||||
* Whether there was an error loading the history.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $error = false;
|
||||
|
||||
/**
|
||||
* The error code thrown when loading the history.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $error_code;
|
||||
|
||||
/**
|
||||
* The error message thrown when loading the history.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $error_message;
|
||||
|
||||
/**
|
||||
* Status constructor.
|
||||
*
|
||||
* @param array $history The history data to load into the class instance.
|
||||
*/
|
||||
public function __construct( $history = array() ) {
|
||||
foreach ( $history as $property => $value ) {
|
||||
if ( property_exists( $this, $property ) ) {
|
||||
$this->$property = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* This package contains the models used in the Protect plugin.
|
||||
*
|
||||
* @package automattic/jetpack-protect-models
|
||||
*/
|
||||
|
||||
namespace Automattic\Jetpack;
|
||||
|
||||
/**
|
||||
* Class description.
|
||||
*/
|
||||
class Protect_Models {
|
||||
|
||||
const PACKAGE_VERSION = '0.2.1';
|
||||
}
|
||||
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* Model class for Protect status report data.
|
||||
*
|
||||
* @package automattic/jetpack-protect-models
|
||||
*/
|
||||
|
||||
namespace Automattic\Jetpack\Protect_Models;
|
||||
|
||||
/**
|
||||
* Model class for the Protect status report data.
|
||||
*/
|
||||
class Status_Model {
|
||||
/**
|
||||
* Data source.
|
||||
*
|
||||
* @var string protect_report|scan_api
|
||||
*/
|
||||
public $data_source;
|
||||
|
||||
/**
|
||||
* The date and time when the status was generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $last_checked;
|
||||
|
||||
/**
|
||||
* The number of threats.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_threats;
|
||||
|
||||
/**
|
||||
* The number of plugin threats.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_plugins_threats;
|
||||
|
||||
/**
|
||||
* The number of theme threats.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_themes_threats;
|
||||
|
||||
/**
|
||||
* The current report status.
|
||||
*
|
||||
* @var string in_progress|scheduled|idle|scanning|provisioning|unavailable
|
||||
*/
|
||||
public $status;
|
||||
|
||||
/**
|
||||
* WordPress core status.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $core;
|
||||
|
||||
/**
|
||||
* Status themes.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $themes = array();
|
||||
|
||||
/**
|
||||
* Status plugins.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $plugins = array();
|
||||
|
||||
/**
|
||||
* File threats.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $files = array();
|
||||
|
||||
/**
|
||||
* Database threats.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $database = array();
|
||||
|
||||
/**
|
||||
* Whether the site includes items that have not been checked.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $has_unchecked_items;
|
||||
|
||||
/**
|
||||
* The estimated percentage of the current scan.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $current_progress;
|
||||
|
||||
/**
|
||||
* Whether there was an error loading the status.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $error = false;
|
||||
|
||||
/**
|
||||
* The error code thrown when loading the status.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $error_code;
|
||||
|
||||
/**
|
||||
* The error message thrown when loading the status.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $error_message;
|
||||
|
||||
/**
|
||||
* Status constructor.
|
||||
*
|
||||
* @param array $status The status data to load into the class instance.
|
||||
*/
|
||||
public function __construct( $status = array() ) {
|
||||
// set status defaults
|
||||
$this->core = new \stdClass();
|
||||
|
||||
foreach ( $status as $property => $value ) {
|
||||
if ( property_exists( $this, $property ) ) {
|
||||
$this->$property = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* Model class for threat data.
|
||||
*
|
||||
* @package automattic/jetpack-protect-models
|
||||
*/
|
||||
|
||||
namespace Automattic\Jetpack\Protect_Models;
|
||||
|
||||
/**
|
||||
* Model class for threat data.
|
||||
*/
|
||||
class Threat_Model {
|
||||
|
||||
/**
|
||||
* Threat ID.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Threat Signature.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $signature;
|
||||
|
||||
/**
|
||||
* Threat Title.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* Threat Description.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* The data the threat was first detected.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $first_detected;
|
||||
|
||||
/**
|
||||
* The version the threat is fixed in.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $fixed_in;
|
||||
|
||||
/**
|
||||
* The date the threat is fixed on.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $fixed_on;
|
||||
|
||||
/**
|
||||
* The severity of the threat between 1-5.
|
||||
*
|
||||
* @var null|int
|
||||
*/
|
||||
public $severity;
|
||||
|
||||
/**
|
||||
* Information about the auto-fix available for this threat. False when not auto-fixable.
|
||||
*
|
||||
* @var null|bool|object
|
||||
*/
|
||||
public $fixable;
|
||||
|
||||
/**
|
||||
* The current status of the threat.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $status;
|
||||
|
||||
/**
|
||||
* The filename of the threat.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $filename;
|
||||
|
||||
/**
|
||||
* The context of the threat.
|
||||
*
|
||||
* @var null|object
|
||||
*/
|
||||
public $context;
|
||||
|
||||
/**
|
||||
* The source URL of the threat.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $source;
|
||||
|
||||
/**
|
||||
* Threat Constructor
|
||||
*
|
||||
* @param array|object $threat Threat data to load into the class instance.
|
||||
*/
|
||||
public function __construct( $threat ) {
|
||||
if ( is_object( $threat ) ) {
|
||||
$threat = (array) $threat;
|
||||
}
|
||||
|
||||
foreach ( $threat as $property => $value ) {
|
||||
if ( property_exists( $this, $property ) ) {
|
||||
$this->$property = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user