@automattic/jetpack-scan 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.4.0] - 2024-11-26
9
+ ### Added
10
+ - Adds utility for retrieving a detailed action description [#40214]
11
+
8
12
  ## [0.3.0] - 2024-11-25
9
13
  ### Added
10
14
  - Adds utilities for retrieving fixer messaging [#40197]
@@ -64,5 +68,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
64
68
  ### Removed
65
69
  - Updated dependencies. [#39754]
66
70
 
71
+ [0.4.0]: https://github.com/Automattic/jetpack-scan/compare/v0.3.0...v0.4.0
67
72
  [0.3.0]: https://github.com/Automattic/jetpack-scan/compare/v0.2.0...v0.3.0
68
73
  [0.2.0]: https://github.com/Automattic/jetpack-scan/compare/v0.1.0...v0.2.0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@automattic/jetpack-scan",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "description": "A JS client for consuming Jetpack Scan services",
6
6
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/scan/#readme",
7
7
  "bugs": {
@@ -55,60 +55,99 @@ export const getFixerAction = ( threat: Threat ) => {
55
55
  case 'rollback':
56
56
  return __( 'Replace', 'jetpack-scan' );
57
57
  default:
58
- return __( 'Fix', 'jetpack-scan' );
58
+ return __( 'Auto-fix', 'jetpack-scan' );
59
59
  }
60
60
  };
61
61
 
62
- export const getFixerMessage = ( threat: Threat ) => {
62
+ export const getDetailedFixerAction = ( threat: Threat ) => {
63
+ switch ( threat.fixable && threat.fixable.fixer ) {
64
+ case 'delete':
65
+ if ( threat.filename ) {
66
+ return __( 'Delete file', 'jetpack-scan' );
67
+ }
68
+
69
+ if ( threat.extension?.type === 'plugin' ) {
70
+ return __( 'Delete plugin from site', 'jetpack-scan' );
71
+ }
72
+
73
+ if ( threat.extension?.type === 'theme' ) {
74
+ return __( 'Delete theme from site', 'jetpack-scan' );
75
+ }
76
+ break;
77
+ case 'update':
78
+ if ( threat.extension?.type === 'plugin' ) {
79
+ return __( 'Update plugin to newer version', 'jetpack-scan' );
80
+ }
81
+ if ( threat.extension?.type === 'theme' ) {
82
+ return __( 'Update theme to newer version', 'jetpack-scan' );
83
+ }
84
+ return __( 'Update', 'jetpack-scan' );
85
+ break;
86
+ case 'replace':
87
+ case 'rollback':
88
+ if ( threat.filename ) {
89
+ return __( 'Replace from backup', 'jetpack-scan' );
90
+ }
91
+
92
+ if ( threat.signature === 'php_hardening_WP_Config_NoSalts_001' ) {
93
+ return __( 'Replace default salts', 'jetpack-scan' );
94
+ }
95
+ break;
96
+ default:
97
+ return __( 'Auto-fix', 'jetpack-scan' );
98
+ }
99
+ };
100
+
101
+ export const getFixerDescription = ( threat: Threat ) => {
63
102
  switch ( threat.fixable && threat.fixable.fixer ) {
64
103
  case 'delete':
65
104
  if ( threat.filename ) {
66
105
  if ( threat.filename.endsWith( '/' ) ) {
67
- return __( 'Deletes the directory that the infected file is in.', 'jetpack-scan' );
106
+ return __( 'Delete the directory that the infected file is in.', 'jetpack-scan' );
68
107
  }
69
108
 
70
109
  if ( threat.signature === 'Core.File.Modification' ) {
71
- return __( 'Deletes the unexpected file in a core WordPress directory.', 'jetpack-scan' );
110
+ return __( 'Delete the unexpected file in a core WordPress directory.', 'jetpack-scan' );
72
111
  }
73
112
 
74
- return __( 'Deletes the infected file.', 'jetpack-scan' );
113
+ return __( 'Delete the infected file.', 'jetpack-scan' );
75
114
  }
76
115
 
77
116
  if ( threat.extension?.type === 'plugin' ) {
78
- return __( 'Deletes the plugin directory to fix the threat.', 'jetpack-scan' );
117
+ return __( 'Delete the plugin directory to fix the threat.', 'jetpack-scan' );
79
118
  }
80
119
 
81
120
  if ( threat.extension?.type === 'theme' ) {
82
- return __( 'Deletes the theme directory to fix the threat.', 'jetpack-scan' );
121
+ return __( 'Delete the theme directory to fix the threat.', 'jetpack-scan' );
83
122
  }
84
123
  break;
85
124
  case 'update':
86
125
  if ( threat.fixedIn && threat.extension.name ) {
87
126
  return sprintf(
88
127
  /* translators: Translates to Updates to version. %1$s: Name. %2$s: Fixed version */
89
- __( 'Updates %1$s to version %2$s', 'jetpack-scan' ),
128
+ __( 'Update %1$s to version %2$s', 'jetpack-scan' ),
90
129
  threat.extension.name,
91
130
  threat.fixedIn
92
131
  );
93
132
  }
94
- return __( 'Upgrades the plugin or theme to a newer version.', 'jetpack-scan' );
133
+ return __( 'Upgrade the plugin or theme to a newer version.', 'jetpack-scan' );
95
134
  case 'replace':
96
135
  case 'rollback':
97
136
  if ( threat.filename ) {
98
137
  return threat.signature === 'Core.File.Modification'
99
138
  ? __(
100
- 'Replaces the modified core WordPress file with the original clean version from the WordPress source code.',
139
+ 'Replace the modified core WordPress file with the original clean version from the WordPress source code.',
101
140
  'jetpack-scan'
102
141
  )
103
142
  : __(
104
- 'Replaces the infected file with a previously backed up version that is clean.',
143
+ 'Replace the infected file with a previously backed up version that is clean.',
105
144
  'jetpack-scan'
106
145
  );
107
146
  }
108
147
 
109
148
  if ( threat.signature === 'php_hardening_WP_Config_NoSalts_001' ) {
110
149
  return __(
111
- 'Replaces the default salt keys in wp-config.php with unique ones.',
150
+ 'Replace the default salt keys in wp-config.php with unique ones.',
112
151
  'jetpack-scan'
113
152
  );
114
153
  }