Skip to content

Commit

Permalink
Protect Status: Add a threats list property to the status, and deprec…
Browse files Browse the repository at this point in the history
…ate properties it replaces (#40097)

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11824413335

Upstream-Ref: Automattic/jetpack@a24a5f6
  • Loading branch information
nateweller authored and matticbot committed Nov 13, 2024
1 parent 87a19f0 commit 7acb400
Show file tree
Hide file tree
Showing 13 changed files with 310 additions and 169 deletions.
3 changes: 3 additions & 0 deletions jetpack_vendor/automattic/jetpack-protect-models/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

This is an alpha version! The changes listed here are not final.

### Added
- Added threats property to protect status.

### Removed
- General: Update minimum PHP version to 7.2.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Extension_Model {
/**
* A collection of threats related to this version of the extension.
*
* @deprecated 0.4.0-alpha This property is deprecated. Use Threat_Model::$extension instead.
*
* @var array<Threat_Model>
*/
public $threats = array();
Expand Down Expand Up @@ -81,10 +83,13 @@ public function __construct( $extension = array() ) {
/**
* Set Threats
*
* @deprecated 0.4.0-alpha This method is deprecated. Use Threat_Model::$extension instead.
*
* @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 ) ) {
// @phan-suppress-next-line PhanDeprecatedProperty -- Maintaining backwards compatibility.
$this->threats = array();
return;
}
Expand All @@ -105,6 +110,7 @@ function ( $threat ) {
$threats
);

// @phan-suppress-next-line PhanDeprecatedProperty -- Maintaining backwards compatibility.
$this->threats = $threats;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,90 +18,117 @@ class History_Model {
*/
public $last_checked;

/**
* Threats.
*
* @since 0.4.0-alpha
*
* @var array<Threat_Model>
*/
public $threats = 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;

/**
* The number of threats.
*
* @deprecated 0.4.0-alpha This property is deprecated. Count History_Model::$threats instead.
*
* @var int
*/
public $num_threats;

/**
* The number of core threats.
*
* @deprecated 0.4.0-alpha This property is deprecated. Filter and count History_Model::$threats instead.
*
* @var int
*/
public $num_core_threats;

/**
* The number of plugin threats.
*
* @deprecated 0.4.0-alpha This property is deprecated. Filter and count History_Model::$threats instead.
*
* @var int
*/
public $num_plugins_threats;

/**
* The number of theme threats.
*
* @deprecated 0.4.0-alpha This property is deprecated. Filter and count History_Model::$threats instead.
*
* @var int
*/
public $num_themes_threats;

/**
* WordPress core.
*
* @deprecated 0.4.0-alpha This property is deprecated. Use History_Model::$threats instead.
*
* @var array<Extension_Model>
*/
public $core = array();

/**
* Status themes.
*
* @deprecated 0.4.0-alpha This property is deprecated. Filter and use History_Model::$threats instead.
*
* @var array<Extension_Model>
*/
public $themes = array();

/**
* Status plugins.
*
* @deprecated 0.4.0-alpha This property is deprecated. Filter and use History_Model::$threats instead.
*
* @var array<Extension_Model>
*/
public $plugins = array();

/**
* File threats.
*
* @deprecated 0.4.0-alpha This property is deprecated. Filter and use History_Model::$threats instead.
*
* @var array<Extension_Model>
*/
public $files = array();

/**
* Database threats.
*
* @deprecated 0.4.0-alpha This property is deprecated. Filter and use History_Model::$threats instead.
*
* @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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,109 +26,134 @@ class Status_Model {
public $last_checked;

/**
* The number of threats.
* The current report status.
*
* @var int
* @var string in_progress|scheduled|idle|scanning|provisioning|unavailable
*/
public $num_threats;
public $status;

/**
* The number of plugin threats.
* The current reported security threats.
*
* @var int
* @since 0.4.0-alpha
*
* @var array<Threat_Model>
*/
public $num_plugins_threats;
public $threats = array();

/**
* The number of theme threats.
* List of fixable threat IDs.
*
* @var int
* @var string[]
*/
public $num_themes_threats;
public $fixable_threat_ids = array();

/**
* The current report status.
* Whether the site includes items that have not been checked.
*
* @var string in_progress|scheduled|idle|scanning|provisioning|unavailable
* @var boolean
*/
public $status;
public $has_unchecked_items;

/**
* List of fixable threat IDs.
* The estimated percentage of the current scan.
*
* @var string[]
* @var int
*/
public $fixable_threat_ids = array();
public $current_progress;

/**
* WordPress core status.
* Whether there was an error loading the status.
*
* @var object
* @var bool
*/
public $core;
public $error = false;

/**
* Status themes.
* The error code thrown when loading the status.
*
* @var array<Extension_Model>
* @var string
*/
public $themes = array();
public $error_code;

/**
* Status plugins.
* The error message thrown when loading the status.
*
* @var array<Extension_Model>
* @var string
*/
public $plugins = array();
public $error_message;

/**
* File threats.
* The number of threats.
*
* @var array<Extension_Model>
* @deprecated 0.4.0-alpha This property is deprecated. Count Status_Model::$threats instead.
*
* @var int
*/
public $files = array();
public $num_threats;

/**
* Database threats.
* The number of plugin threats.
*
* @var array<Extension_Model>
* @deprecated 0.4.0-alpha This property is deprecated. Filter and count Status_Model::$threats instead.
*
* @var int
*/
public $database = array();
public $num_plugins_threats;

/**
* Whether the site includes items that have not been checked.
* The number of theme threats.
*
* @var boolean
* @deprecated 0.4.0-alpha This property is deprecated. Filter and count Status_Model::$threats instead.
*
* @var int
*/
public $has_unchecked_items;
public $num_themes_threats;

/**
* The estimated percentage of the current scan.
* WordPress core status.
*
* @var int
* @deprecated 0.4.0-alpha This property is deprecated. Filter and use Status_Model::$threats instead.
*
* @var object
*/
public $current_progress;
public $core;

/**
* Whether there was an error loading the status.
* Status themes.
*
* @var bool
* @deprecated 0.4.0-alpha This property is deprecated. Filter and use Status_Model::$threats instead.
*
* @var array<Extension_Model>
*/
public $error = false;
public $themes = array();

/**
* The error code thrown when loading the status.
* Status plugins.
*
* @var string
* @deprecated 0.4.0-alpha This property is deprecated. Filter and use Status_Model::$threats instead.
*
* @var array<Extension_Model>
*/
public $error_code;
public $plugins = array();

/**
* The error message thrown when loading the status.
* File threats.
*
* @var string
* @deprecated 0.4.0-alpha This property is deprecated. Filter and use Status_Model::$threats instead.
*
* @var array<Extension_Model>
*/
public $error_message;
public $files = array();

/**
* Database threats.
*
* @deprecated 0.4.0-alpha This property is deprecated. Filter and use Status_Model::$threats instead.
*
* @var array<Extension_Model>
*/
public $database = array();

/**
* Status constructor.
Expand All @@ -137,6 +162,7 @@ class Status_Model {
*/
public function __construct( $status = array() ) {
// set status defaults
// @phan-suppress-next-line PhanDeprecatedProperty -- Maintaining backwards compatibility.
$this->core = new \stdClass();

foreach ( $status as $property => $value ) {
Expand Down
Loading

0 comments on commit 7acb400

Please sign in to comment.