updated plugin Jetpack Protect
version 4.0.0
This commit is contained in:
@ -5,6 +5,49 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.5.4] - 2025-03-21
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.5.3] - 2025-03-12
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.5.2] - 2025-03-05
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.5.1] - 2025-02-24
|
||||
### Changed
|
||||
- Update dependencies.
|
||||
|
||||
## [0.5.0] - 2025-02-10
|
||||
### Changed
|
||||
- Combine vulnerabilities for the same extension into single vulnerable extension threats. [#40863]
|
||||
|
||||
## [0.4.2] - 2025-02-03
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [0.4.1] - 2024-11-25
|
||||
### Changed
|
||||
- Updated dependencies. [#40286]
|
||||
|
||||
## [0.4.0] - 2024-11-14
|
||||
### Added
|
||||
- Added threats property to protect status. [#40097]
|
||||
|
||||
### Removed
|
||||
- General: Update minimum PHP version to 7.2. [#40147]
|
||||
|
||||
## [0.3.1] - 2024-11-04
|
||||
### Added
|
||||
- Enable test coverage. [#39961]
|
||||
|
||||
## [0.3.0] - 2024-09-23
|
||||
### Changed
|
||||
- Adds a fixable_threats status property [#39125]
|
||||
|
||||
## [0.2.1] - 2024-08-26
|
||||
### Changed
|
||||
- Updated package dependencies. [#39004]
|
||||
@ -17,5 +60,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Added
|
||||
- Initial version. [#37864]
|
||||
|
||||
[0.5.4]: https://github.com/Automattic/jetpack-protect-models/compare/v0.5.3...v0.5.4
|
||||
[0.5.3]: https://github.com/Automattic/jetpack-protect-models/compare/v0.5.2...v0.5.3
|
||||
[0.5.2]: https://github.com/Automattic/jetpack-protect-models/compare/v0.5.1...v0.5.2
|
||||
[0.5.1]: https://github.com/Automattic/jetpack-protect-models/compare/v0.5.0...v0.5.1
|
||||
[0.5.0]: https://github.com/Automattic/jetpack-protect-models/compare/v0.4.2...v0.5.0
|
||||
[0.4.2]: https://github.com/Automattic/jetpack-protect-models/compare/v0.4.1...v0.4.2
|
||||
[0.4.1]: https://github.com/Automattic/jetpack-protect-models/compare/v0.4.0...v0.4.1
|
||||
[0.4.0]: https://github.com/Automattic/jetpack-protect-models/compare/v0.3.1...v0.4.0
|
||||
[0.3.1]: https://github.com/Automattic/jetpack-protect-models/compare/v0.3.0...v0.3.1
|
||||
[0.3.0]: https://github.com/Automattic/jetpack-protect-models/compare/v0.2.1...v0.3.0
|
||||
[0.2.1]: https://github.com/Automattic/jetpack-protect-models/compare/v0.2.0...v0.2.1
|
||||
[0.2.0]: https://github.com/Automattic/jetpack-protect-models/compare/v0.1.0...v0.2.0
|
||||
|
@ -4,12 +4,14 @@
|
||||
"type": "jetpack-library",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"require": {
|
||||
"php": ">=7.0"
|
||||
"php": ">=7.2",
|
||||
"automattic/jetpack-redirect": "^3.0.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"yoast/phpunit-polyfills": "^1.1.1",
|
||||
"automattic/jetpack-changelogger": "^4.2.6",
|
||||
"automattic/wordbless": "0.4.2"
|
||||
"yoast/phpunit-polyfills": "^3.0.0",
|
||||
"automattic/jetpack-changelogger": "^6.0.2",
|
||||
"automattic/jetpack-test-environment": "@dev",
|
||||
"automattic/phpunit-select-config": "^1.0.1"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
@ -20,20 +22,21 @@
|
||||
"build-development": "echo 'Add your build step to composer.json, please!'",
|
||||
"build-production": "echo 'Add your build step to composer.json, please!'",
|
||||
"phpunit": [
|
||||
"./vendor/phpunit/phpunit/phpunit --colors=always"
|
||||
"phpunit-select-config phpunit.#.xml.dist --colors=always"
|
||||
],
|
||||
"test-coverage": [
|
||||
"php -dpcov.directory=. ./vendor/bin/phpunit-select-config phpunit.#.xml.dist --coverage-php \"$COVERAGE_DIR/php.cov\""
|
||||
],
|
||||
"test-php": [
|
||||
"@composer phpunit"
|
||||
],
|
||||
"post-install-cmd": "WorDBless\\Composer\\InstallDropin::copy",
|
||||
"post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"extra": {
|
||||
"autotagger": true,
|
||||
"branch-alias": {
|
||||
"dev-trunk": "0.2.x-dev"
|
||||
"dev-trunk": "0.5.x-dev"
|
||||
},
|
||||
"changelogger": {
|
||||
"link-template": "https://github.com/Automattic/jetpack-protect-models/compare/v${old}...v${new}"
|
||||
|
@ -36,6 +36,8 @@ class Extension_Model {
|
||||
/**
|
||||
* A collection of threats related to this version of the extension.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Use Threat_Model::$extension instead.
|
||||
*
|
||||
* @var array<Threat_Model>
|
||||
*/
|
||||
public $threats = array();
|
||||
@ -81,10 +83,13 @@ class Extension_Model {
|
||||
/**
|
||||
* Set Threats
|
||||
*
|
||||
* @deprecated 0.4.0 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;
|
||||
}
|
||||
@ -105,6 +110,7 @@ class Extension_Model {
|
||||
$threats
|
||||
);
|
||||
|
||||
// @phan-suppress-next-line PhanDeprecatedProperty -- Maintaining backwards compatibility.
|
||||
$this->threats = $threats;
|
||||
}
|
||||
}
|
||||
|
@ -19,67 +19,13 @@ class History_Model {
|
||||
public $last_checked;
|
||||
|
||||
/**
|
||||
* The number of threats.
|
||||
* Threats.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_threats;
|
||||
|
||||
/**
|
||||
* The number of core threats.
|
||||
* @since 0.4.0
|
||||
*
|
||||
* @var int
|
||||
* @var array<Threat_Model>
|
||||
*/
|
||||
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();
|
||||
public $threats = array();
|
||||
|
||||
/**
|
||||
* Whether there was an error loading the history.
|
||||
@ -102,6 +48,87 @@ class History_Model {
|
||||
*/
|
||||
public $error_message;
|
||||
|
||||
/**
|
||||
* The number of threats.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Count History_Model::$threats instead.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_threats;
|
||||
|
||||
/**
|
||||
* The number of core threats.
|
||||
*
|
||||
* @deprecated 0.4.0 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 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 This property is deprecated. Filter and count History_Model::$threats instead.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_themes_threats;
|
||||
|
||||
/**
|
||||
* WordPress core.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Use History_Model::$threats instead.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $core = array();
|
||||
|
||||
/**
|
||||
* Status themes.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Filter and use History_Model::$threats instead.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $themes = array();
|
||||
|
||||
/**
|
||||
* Status plugins.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Filter and use History_Model::$threats instead.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $plugins = array();
|
||||
|
||||
/**
|
||||
* File threats.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Filter and use History_Model::$threats instead.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $files = array();
|
||||
|
||||
/**
|
||||
* Database threats.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Filter and use History_Model::$threats instead.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $database = array();
|
||||
|
||||
/**
|
||||
* Status constructor.
|
||||
*
|
||||
|
@ -12,5 +12,5 @@ namespace Automattic\Jetpack;
|
||||
*/
|
||||
class Protect_Models {
|
||||
|
||||
const PACKAGE_VERSION = '0.2.1';
|
||||
const PACKAGE_VERSION = '0.5.4';
|
||||
}
|
||||
|
@ -25,27 +25,6 @@ class Status_Model {
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@ -54,39 +33,20 @@ class Status_Model {
|
||||
public $status;
|
||||
|
||||
/**
|
||||
* WordPress core status.
|
||||
* The current reported security threats.
|
||||
*
|
||||
* @var object
|
||||
* @since 0.4.0
|
||||
*
|
||||
* @var array<Threat_Model>
|
||||
*/
|
||||
public $core;
|
||||
public $threats = array();
|
||||
|
||||
/**
|
||||
* Status themes.
|
||||
* List of fixable threat IDs.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
* @var string[]
|
||||
*/
|
||||
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();
|
||||
public $fixable_threat_ids = array();
|
||||
|
||||
/**
|
||||
* Whether the site includes items that have not been checked.
|
||||
@ -123,6 +83,78 @@ class Status_Model {
|
||||
*/
|
||||
public $error_message;
|
||||
|
||||
/**
|
||||
* The number of threats.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Count Status_Model::$threats instead.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_threats;
|
||||
|
||||
/**
|
||||
* The number of plugin threats.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Filter and count Status_Model::$threats instead.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_plugins_threats;
|
||||
|
||||
/**
|
||||
* The number of theme threats.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Filter and count Status_Model::$threats instead.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_themes_threats;
|
||||
|
||||
/**
|
||||
* WordPress core status.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Filter and use Status_Model::$threats instead.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $core;
|
||||
|
||||
/**
|
||||
* Status themes.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Filter and use Status_Model::$threats instead.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $themes = array();
|
||||
|
||||
/**
|
||||
* Status plugins.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Filter and use Status_Model::$threats instead.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $plugins = array();
|
||||
|
||||
/**
|
||||
* File threats.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Filter and use Status_Model::$threats instead.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $files = array();
|
||||
|
||||
/**
|
||||
* Database threats.
|
||||
*
|
||||
* @deprecated 0.4.0 This property is deprecated. Filter and use Status_Model::$threats instead.
|
||||
*
|
||||
* @var array<Extension_Model>
|
||||
*/
|
||||
public $database = array();
|
||||
|
||||
/**
|
||||
* Status constructor.
|
||||
*
|
||||
@ -130,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 ) {
|
||||
|
@ -96,6 +96,13 @@ class Threat_Model {
|
||||
*/
|
||||
public $context;
|
||||
|
||||
/**
|
||||
* The database table of the threat.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $table;
|
||||
|
||||
/**
|
||||
* The source URL of the threat.
|
||||
*
|
||||
@ -103,6 +110,24 @@ class Threat_Model {
|
||||
*/
|
||||
public $source;
|
||||
|
||||
/**
|
||||
* The threat's extension information.
|
||||
*
|
||||
* @since 0.4.0
|
||||
*
|
||||
* @var null|Extension_Model
|
||||
*/
|
||||
public $extension;
|
||||
|
||||
/**
|
||||
* The threat's related vulnerabilities.
|
||||
*
|
||||
* @since 0.5.0
|
||||
*
|
||||
* @var null|Vulnerability_Model[]
|
||||
*/
|
||||
public $vulnerabilities;
|
||||
|
||||
/**
|
||||
* Threat Constructor
|
||||
*
|
||||
@ -114,9 +139,127 @@ class Threat_Model {
|
||||
}
|
||||
|
||||
foreach ( $threat as $property => $value ) {
|
||||
if ( 'extension' === $property && ! empty( $value ) ) {
|
||||
$this->extension = new Extension_Model( $value );
|
||||
continue;
|
||||
}
|
||||
if ( property_exists( $this, $property ) ) {
|
||||
$this->$property = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID value of the threat based on its related extension and vulnerabilities.
|
||||
*
|
||||
* @since 0.5.0
|
||||
*
|
||||
* @param Extension_Model $extension The extension to get the ID from.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function get_id_from_vulnerable_extension( Extension_Model $extension ) {
|
||||
return "$extension->type-$extension->slug-$extension->version";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title from a vulnerable extension.
|
||||
*
|
||||
* @since 0.5.0
|
||||
*
|
||||
* @param Extension_Model $extension The extension to get the title from.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private static function get_title_from_vulnerable_extension( Extension_Model $extension ) {
|
||||
$titles = array(
|
||||
'plugins' => sprintf(
|
||||
/* translators: placeholders are the theme name and version number. Example: "Vulnerable theme: Jetpack (version 1.2.3)" */
|
||||
__( 'Vulnerable plugin: %1$s (version %2$s)', 'jetpack-protect-models' ),
|
||||
$extension->name,
|
||||
$extension->version
|
||||
),
|
||||
'themes' => sprintf(
|
||||
/* translators: placeholders are the theme name and version number. Example: "Vulnerable theme: Jetpack (version 1.2.3)" */
|
||||
__( 'Vulnerable theme: %1$s (version %2$s)', 'jetpack-protect-models' ),
|
||||
$extension->name,
|
||||
$extension->version
|
||||
),
|
||||
'core' => sprintf(
|
||||
/* translators: placeholder is the version number. Example: "Vulnerable WordPress (version 1.2.3)" */
|
||||
__( 'Vulnerable WordPress (version %s)', 'jetpack-protect-models' ),
|
||||
$extension->version
|
||||
),
|
||||
);
|
||||
|
||||
return $titles[ $extension->type ] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description from a vulnerable extension.
|
||||
*
|
||||
* @since 0.5.0
|
||||
*
|
||||
* @param Extension_Model $extension The extension to get the description from.
|
||||
* @param array $vulnerabilities The vulnerabilities to get the description from.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function get_description_from_vulnerable_extension( Extension_Model $extension, array $vulnerabilities ) {
|
||||
return sprintf(
|
||||
/* translators: placeholders are the theme name and version number. Example: "The installed version of Jetpack (1.2.3) has a known security vulnerability." */
|
||||
_n( 'The installed version of %1$s (%2$s) has a known security vulnerability.', 'The installed version of %1$s (%2$s) has known security vulnerabilities.', count( $vulnerabilities ), 'jetpack-protect-models' ),
|
||||
$extension->name,
|
||||
$extension->version
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest fixed_in version from a list of vulnerabilities.
|
||||
*
|
||||
* @since 0.5.0
|
||||
*
|
||||
* @param array $vulnerabilities The vulnerabilities to get the fixed_in version from.
|
||||
*
|
||||
* @return string|bool|null The latest fixed_in version, or false if any of the vulnerabilities are not fixed.
|
||||
*/
|
||||
private static function get_fixed_in_from_vulnerabilities( array $vulnerabilities ) {
|
||||
$fixed_in = null;
|
||||
|
||||
foreach ( $vulnerabilities as $vulnerability ) {
|
||||
// If any of the vulnerabilities are not fixed, the threat is not fixed.
|
||||
if ( ! $vulnerability->fixed_in ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Use the latest available fixed_in version.
|
||||
if ( ! $fixed_in || ( $fixed_in && version_compare( $vulnerability->fixed_in, $fixed_in, '>' ) ) ) {
|
||||
$fixed_in = $vulnerability->fixed_in;
|
||||
}
|
||||
}
|
||||
|
||||
return $fixed_in;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a threat from extension vulnerabilities.
|
||||
*
|
||||
* @since 0.5.0
|
||||
*
|
||||
* @param Extension_Model $extension The extension to generate the threat for.
|
||||
* @param Vulnerability_Model[] $vulnerabilities The vulnerabilities to generate the threat from.
|
||||
*
|
||||
* @return Threat_Model
|
||||
*/
|
||||
public static function generate_from_extension_vulnerabilities( Extension_Model $extension, array $vulnerabilities ) {
|
||||
return new Threat_Model(
|
||||
array(
|
||||
'id' => self::get_id_from_vulnerable_extension( $extension ),
|
||||
'title' => self::get_title_from_vulnerable_extension( $extension ),
|
||||
'description' => self::get_description_from_vulnerable_extension( $extension, $vulnerabilities ),
|
||||
'fixed_in' => self::get_fixed_in_from_vulnerabilities( $vulnerabilities ),
|
||||
'vulnerabilities' => $vulnerabilities,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Model class for vulnerability data.
|
||||
*
|
||||
* @package automattic/jetpack-protect-models
|
||||
*/
|
||||
|
||||
namespace Automattic\Jetpack\Protect_Models;
|
||||
|
||||
use Automattic\Jetpack\Redirect;
|
||||
|
||||
/**
|
||||
* Model class for vulnerability data.
|
||||
*/
|
||||
class Vulnerability_Model {
|
||||
/**
|
||||
* Vulnerability ID.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Vulnerability Title.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* Vulnerability Description.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* The version the vulnerability is fixed in.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $fixed_in;
|
||||
|
||||
/**
|
||||
* The version the vulnerability was introduced.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $introduced_in;
|
||||
|
||||
/**
|
||||
* The type of vulnerability.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* The source URL for the vulnerability.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
public $source;
|
||||
|
||||
/**
|
||||
* Vulnerability Constructor
|
||||
*
|
||||
* @param array|object $vulnerability Vulnerability data to load into the class instance.
|
||||
*/
|
||||
public function __construct( $vulnerability ) {
|
||||
// Initialize the vulnerability data.
|
||||
foreach ( $vulnerability as $property => $value ) {
|
||||
if ( property_exists( $this, $property ) ) {
|
||||
$this->$property = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the source URL is set.
|
||||
$this->get_source();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source URL for the vulnerability.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_source() {
|
||||
if ( empty( $this->source ) && $this->id ) {
|
||||
$this->source = Redirect::get_url( 'jetpack-protect-vul-info', array( 'path' => $this->id ) );
|
||||
}
|
||||
|
||||
return $this->source;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user