Skip to content

Commit

Permalink
minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
nateweller committed Jan 15, 2025
1 parent 92a84c5 commit bc4aefa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 7 additions & 2 deletions projects/packages/protect-models/src/class-threat-model.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function ( $carry, $vulnerability ) {
*
* @param Extension_Model $extension The extension to get the title from.
*
* @return string
* @return string|null
*/
private static function get_title_from_vulnerable_extension( Extension_Model $extension ) {
$titles = array(
Expand All @@ -191,9 +191,14 @@ private static function get_title_from_vulnerable_extension( Extension_Model $ex
$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 ];
return $titles[ $extension->type ] ?? null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,20 @@ public function __construct( $threat ) {
}
}

// Generate the source URL if it's not provided.
// Ensure the source URL is set.
$this->get_source();
}

/**
* Get the source URL for the threat.
*
* @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 ) );

Check failure on line 89 in projects/packages/protect-models/src/class-vulnerability-model.php

View workflow job for this annotation

GitHub Actions / Static analysis

UndefError PhanUndeclaredClassMethod Call to method get_url from undeclared class \Automattic\Jetpack\Redirect
}

return $this->source;
}
}

0 comments on commit bc4aefa

Please sign in to comment.