@automattic/jetpack-scan 0.4.1 → 0.5.1

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,17 @@ 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.5.1] - 2024-12-09
9
+ ### Changed
10
+ - Internal updates.
11
+
12
+ ## [0.5.0] - 2024-12-04
13
+ ### Added
14
+ - Added more types for working with scan results. [#40399]
15
+
16
+ ### Changed
17
+ - Updated package dependencies. [#40363]
18
+
8
19
  ## [0.4.1] - 2024-11-28
9
20
  ### Fixed
10
21
  - Fix package build. [#40299]
@@ -72,6 +83,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
72
83
  ### Removed
73
84
  - Updated dependencies. [#39754]
74
85
 
86
+ [0.5.1]: https://github.com/Automattic/jetpack-scan/compare/v0.5.0...v0.5.1
87
+ [0.5.0]: https://github.com/Automattic/jetpack-scan/compare/v0.4.1...v0.5.0
75
88
  [0.4.1]: https://github.com/Automattic/jetpack-scan/compare/v0.4.0...v0.4.1
76
89
  [0.4.0]: https://github.com/Automattic/jetpack-scan/compare/v0.3.0...v0.4.0
77
90
  [0.3.0]: https://github.com/Automattic/jetpack-scan/compare/v0.2.0...v0.3.0
@@ -12,3 +12,23 @@ export type ThreatFixStatusSuccess = {
12
12
  lastUpdated: string;
13
13
  };
14
14
  export type ThreatFixStatus = ThreatFixStatusError | ThreatFixStatusSuccess;
15
+ /**
16
+ * Fixers Status
17
+ *
18
+ * Overall status of all fixers.
19
+ */
20
+ type FixersStatusBase = {
21
+ ok: boolean;
22
+ };
23
+ export type FixersStatusError = FixersStatusBase & {
24
+ ok: false;
25
+ error: string;
26
+ };
27
+ export type FixersStatusSuccess = FixersStatusBase & {
28
+ ok: true;
29
+ threats: {
30
+ [key: number]: ThreatFixStatus;
31
+ };
32
+ };
33
+ export type FixersStatus = FixersStatusSuccess | FixersStatusError;
34
+ export {};
@@ -1,2 +1,3 @@
1
1
  export * from './fixers.js';
2
+ export * from './status.js';
2
3
  export * from './threats.js';
@@ -1,2 +1,3 @@
1
1
  export * from './fixers.js';
2
+ export * from './status.js';
2
3
  export * from './threats.js';
@@ -0,0 +1,23 @@
1
+ import { Threat } from './threats.js';
2
+ export type ScanStatus = {
3
+ /** The current status of the scanner. */
4
+ status: 'unavailable' | 'provisioning' | 'idle' | 'scanning' | 'scheduled';
5
+ /** The IDs of fixable threats. */
6
+ fixableThreatIds: number[];
7
+ /** The current scan progress, only available from the Scan API. */
8
+ currentProgress: number | null;
9
+ /** The data source for the scan status. */
10
+ dataSource: 'protect_report' | 'scan_api';
11
+ /** Whether the site currently has extensions not checked in the latest scan. */
12
+ hasUncheckedItems: boolean;
13
+ /** The time the last scan was checked, in YYYY-MM-DD HH:MM:SS format. */
14
+ lastChecked: string | null;
15
+ /** Whether there was an error in the scan results. */
16
+ error: boolean | null;
17
+ /** The error code. */
18
+ errorCode: string | null;
19
+ /** The error message. */
20
+ errorMessage: string | null;
21
+ /** The detected threats. */
22
+ threats: Threat[];
23
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -41,6 +41,6 @@ export type Threat = {
41
41
  slug: string;
42
42
  name: string;
43
43
  version: string;
44
- type: 'plugin' | 'theme' | 'core';
44
+ type: 'plugins' | 'themes' | 'core';
45
45
  };
46
46
  };
@@ -1,6 +1,6 @@
1
1
  import { type ThreatFixStatus } from '../types/fixers.js';
2
2
  import { type Threat } from '../types/threats.js';
3
- export declare const getThreatType: (threat: Threat) => "plugin" | "theme" | "core" | "file";
3
+ export declare const getThreatType: (threat: Threat) => "plugins" | "themes" | "core" | "file";
4
4
  export declare const fixerTimestampIsStale: (lastUpdatedTimestamp: string) => boolean;
5
5
  export declare const fixerIsInError: (fixerStatus: ThreatFixStatus) => boolean;
6
6
  export declare const fixerIsInProgress: (fixerStatus: ThreatFixStatus) => boolean;
@@ -55,22 +55,21 @@ export const getDetailedFixerAction = (threat) => {
55
55
  if (threat.filename) {
56
56
  return __('Delete file', 'jetpack-scan');
57
57
  }
58
- if (((_a = threat.extension) === null || _a === void 0 ? void 0 : _a.type) === 'plugin') {
58
+ if (((_a = threat.extension) === null || _a === void 0 ? void 0 : _a.type) === 'plugins') {
59
59
  return __('Delete plugin from site', 'jetpack-scan');
60
60
  }
61
- if (((_b = threat.extension) === null || _b === void 0 ? void 0 : _b.type) === 'theme') {
61
+ if (((_b = threat.extension) === null || _b === void 0 ? void 0 : _b.type) === 'themes') {
62
62
  return __('Delete theme from site', 'jetpack-scan');
63
63
  }
64
64
  break;
65
65
  case 'update':
66
- if (((_c = threat.extension) === null || _c === void 0 ? void 0 : _c.type) === 'plugin') {
66
+ if (((_c = threat.extension) === null || _c === void 0 ? void 0 : _c.type) === 'plugins') {
67
67
  return __('Update plugin to newer version', 'jetpack-scan');
68
68
  }
69
- if (((_d = threat.extension) === null || _d === void 0 ? void 0 : _d.type) === 'theme') {
69
+ if (((_d = threat.extension) === null || _d === void 0 ? void 0 : _d.type) === 'themes') {
70
70
  return __('Update theme to newer version', 'jetpack-scan');
71
71
  }
72
72
  return __('Update', 'jetpack-scan');
73
- break;
74
73
  case 'replace':
75
74
  case 'rollback':
76
75
  if (threat.filename) {
@@ -97,10 +96,10 @@ export const getFixerDescription = (threat) => {
97
96
  }
98
97
  return __('Delete the infected file.', 'jetpack-scan');
99
98
  }
100
- if (((_a = threat.extension) === null || _a === void 0 ? void 0 : _a.type) === 'plugin') {
99
+ if (((_a = threat.extension) === null || _a === void 0 ? void 0 : _a.type) === 'plugins') {
101
100
  return __('Delete the plugin directory to fix the threat.', 'jetpack-scan');
102
101
  }
103
- if (((_b = threat.extension) === null || _b === void 0 ? void 0 : _b.type) === 'theme') {
102
+ if (((_b = threat.extension) === null || _b === void 0 ? void 0 : _b.type) === 'themes') {
104
103
  return __('Delete the theme directory to fix the threat.', 'jetpack-scan');
105
104
  }
106
105
  break;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@automattic/jetpack-scan",
4
- "version": "0.4.1",
4
+ "version": "0.5.1",
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": {
@@ -45,18 +45,18 @@
45
45
  "main": "./build/index.js",
46
46
  "types": "./build/index.d.ts",
47
47
  "dependencies": {
48
- "@automattic/jetpack-api": "^0.17.19",
49
- "@automattic/jetpack-base-styles": "^0.6.37",
50
- "@wordpress/api-fetch": "7.12.0",
51
- "@wordpress/element": "6.12.0",
52
- "@wordpress/i18n": "5.12.0",
53
- "@wordpress/url": "4.12.0",
48
+ "@automattic/jetpack-api": "^0.17.20",
49
+ "@automattic/jetpack-base-styles": "^0.6.38",
50
+ "@wordpress/api-fetch": "7.13.0",
51
+ "@wordpress/element": "6.13.0",
52
+ "@wordpress/i18n": "5.13.0",
53
+ "@wordpress/url": "4.13.0",
54
54
  "debug": "4.3.4",
55
55
  "react": "^18.2.0",
56
56
  "react-dom": "^18.2.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "@wordpress/i18n": "5.12.0",
59
+ "@wordpress/i18n": "5.13.0",
60
60
  "react": "^18.2.0",
61
61
  "react-dom": "^18.2.0"
62
62
  }
@@ -15,3 +15,26 @@ export type ThreatFixStatusSuccess = {
15
15
  };
16
16
 
17
17
  export type ThreatFixStatus = ThreatFixStatusError | ThreatFixStatusSuccess;
18
+
19
+ /**
20
+ * Fixers Status
21
+ *
22
+ * Overall status of all fixers.
23
+ */
24
+ type FixersStatusBase = {
25
+ ok: boolean; // Discriminator for overall success
26
+ };
27
+
28
+ export type FixersStatusError = FixersStatusBase & {
29
+ ok: false;
30
+ error: string;
31
+ };
32
+
33
+ export type FixersStatusSuccess = FixersStatusBase & {
34
+ ok: true;
35
+ threats: {
36
+ [ key: number ]: ThreatFixStatus;
37
+ };
38
+ };
39
+
40
+ export type FixersStatus = FixersStatusSuccess | FixersStatusError;
@@ -1,2 +1,3 @@
1
1
  export * from './fixers.js';
2
+ export * from './status.js';
2
3
  export * from './threats.js';
@@ -0,0 +1,33 @@
1
+ import { Threat } from './threats.js';
2
+
3
+ export type ScanStatus = {
4
+ /** The current status of the scanner. */
5
+ status: 'unavailable' | 'provisioning' | 'idle' | 'scanning' | 'scheduled';
6
+
7
+ /** The IDs of fixable threats. */
8
+ fixableThreatIds: number[];
9
+
10
+ /** The current scan progress, only available from the Scan API. */
11
+ currentProgress: number | null;
12
+
13
+ /** The data source for the scan status. */
14
+ dataSource: 'protect_report' | 'scan_api';
15
+
16
+ /** Whether the site currently has extensions not checked in the latest scan. */
17
+ hasUncheckedItems: boolean;
18
+
19
+ /** The time the last scan was checked, in YYYY-MM-DD HH:MM:SS format. */
20
+ lastChecked: string | null;
21
+
22
+ /** Whether there was an error in the scan results. */
23
+ error: boolean | null;
24
+
25
+ /** The error code. */
26
+ errorCode: string | null;
27
+
28
+ /** The error message. */
29
+ errorMessage: string | null;
30
+
31
+ /** The detected threats. */
32
+ threats: Threat[];
33
+ };
@@ -61,6 +61,6 @@ export type Threat = {
61
61
  slug: string;
62
62
  name: string;
63
63
  version: string;
64
- type: 'plugin' | 'theme' | 'core';
64
+ type: 'plugins' | 'themes' | 'core';
65
65
  };
66
66
  };
@@ -68,23 +68,22 @@ export const getDetailedFixerAction = ( threat: Threat ) => {
68
68
  return __( 'Delete file', 'jetpack-scan' );
69
69
  }
70
70
 
71
- if ( threat.extension?.type === 'plugin' ) {
71
+ if ( threat.extension?.type === 'plugins' ) {
72
72
  return __( 'Delete plugin from site', 'jetpack-scan' );
73
73
  }
74
74
 
75
- if ( threat.extension?.type === 'theme' ) {
75
+ if ( threat.extension?.type === 'themes' ) {
76
76
  return __( 'Delete theme from site', 'jetpack-scan' );
77
77
  }
78
78
  break;
79
79
  case 'update':
80
- if ( threat.extension?.type === 'plugin' ) {
80
+ if ( threat.extension?.type === 'plugins' ) {
81
81
  return __( 'Update plugin to newer version', 'jetpack-scan' );
82
82
  }
83
- if ( threat.extension?.type === 'theme' ) {
83
+ if ( threat.extension?.type === 'themes' ) {
84
84
  return __( 'Update theme to newer version', 'jetpack-scan' );
85
85
  }
86
86
  return __( 'Update', 'jetpack-scan' );
87
- break;
88
87
  case 'replace':
89
88
  case 'rollback':
90
89
  if ( threat.filename ) {
@@ -115,11 +114,11 @@ export const getFixerDescription = ( threat: Threat ) => {
115
114
  return __( 'Delete the infected file.', 'jetpack-scan' );
116
115
  }
117
116
 
118
- if ( threat.extension?.type === 'plugin' ) {
117
+ if ( threat.extension?.type === 'plugins' ) {
119
118
  return __( 'Delete the plugin directory to fix the threat.', 'jetpack-scan' );
120
119
  }
121
120
 
122
- if ( threat.extension?.type === 'theme' ) {
121
+ if ( threat.extension?.type === 'themes' ) {
123
122
  return __( 'Delete the theme directory to fix the threat.', 'jetpack-scan' );
124
123
  }
125
124
  break;