- { threat.title }
+ { getLabel( threat ) }
{ !! threat.severity && }
diff --git a/projects/js-packages/scan/src/types/threats.ts b/projects/js-packages/scan/src/types/threats.ts
index 22f6b06477163..9eb732e80a98c 100644
--- a/projects/js-packages/scan/src/types/threats.ts
+++ b/projects/js-packages/scan/src/types/threats.ts
@@ -75,4 +75,7 @@ export type Threat = {
/** The affected extension. */
extension?: Extension;
+
+ /** The affected version */
+ version?: string;
};
diff --git a/projects/js-packages/scan/src/utils/index.ts b/projects/js-packages/scan/src/utils/index.ts
index 30a96cbd132d5..1704481053581 100644
--- a/projects/js-packages/scan/src/utils/index.ts
+++ b/projects/js-packages/scan/src/utils/index.ts
@@ -156,7 +156,7 @@ export const getFixerDescription = ( threat: Threat ) => {
if ( threat.fixedIn && threat.extension?.name ) {
return sprintf(
/* translators: Translates to Updates to version. %1$s: Name. %2$s: Fixed version */
- __( 'Update %1$s to version %2$s', 'jetpack-scan' ),
+ __( 'Update %1$s to version %2$s.', 'jetpack-scan' ),
threat.extension.name,
threat.fixedIn
);
@@ -187,3 +187,20 @@ export const getFixerDescription = ( threat: Threat ) => {
return __( 'Jetpack will auto-fix the threat.', 'jetpack-scan' );
}
};
+
+export const getLabel = ( threat: Threat ) => {
+ if ( threat.signature === 'Vulnerable.WP.Core' ) {
+ // Core threat i.e. "WordPress (5.8)"
+ return `WordPress (${ threat.version })`;
+ }
+
+ if ( threat.extension?.name && threat.extension?.version ) {
+ // Extension threat i.e. "Woocommerce (3.0.0)"
+ return `${ threat.extension.name } (${ threat.extension.version })`;
+ }
+
+ if ( threat.filename ) {
+ // File threat i.e. "index.php"
+ return threat.filename.split( '/' ).pop();
+ }
+};