@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 +13 -0
- package/build/types/fixers.d.ts +20 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.js +1 -0
- package/build/types/status.d.ts +23 -0
- package/build/types/status.js +1 -0
- package/build/types/threats.d.ts +1 -1
- package/build/utils/index.d.ts +1 -1
- package/build/utils/index.js +6 -7
- package/package.json +8 -8
- package/src/types/fixers.ts +23 -0
- package/src/types/index.ts +1 -0
- package/src/types/status.ts +33 -0
- package/src/types/threats.ts +1 -1
- package/src/utils/index.ts +6 -7
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
|
package/build/types/fixers.d.ts
CHANGED
|
@@ -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 {};
|
package/build/types/index.d.ts
CHANGED
package/build/types/index.js
CHANGED
|
@@ -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 {};
|
package/build/types/threats.d.ts
CHANGED
package/build/utils/index.d.ts
CHANGED
|
@@ -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) => "
|
|
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;
|
package/build/utils/index.js
CHANGED
|
@@ -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) === '
|
|
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) === '
|
|
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) === '
|
|
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) === '
|
|
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) === '
|
|
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) === '
|
|
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
|
+
"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.
|
|
49
|
-
"@automattic/jetpack-base-styles": "^0.6.
|
|
50
|
-
"@wordpress/api-fetch": "7.
|
|
51
|
-
"@wordpress/element": "6.
|
|
52
|
-
"@wordpress/i18n": "5.
|
|
53
|
-
"@wordpress/url": "4.
|
|
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.
|
|
59
|
+
"@wordpress/i18n": "5.13.0",
|
|
60
60
|
"react": "^18.2.0",
|
|
61
61
|
"react-dom": "^18.2.0"
|
|
62
62
|
}
|
package/src/types/fixers.ts
CHANGED
|
@@ -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;
|
package/src/types/index.ts
CHANGED
|
@@ -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
|
+
};
|
package/src/types/threats.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -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 === '
|
|
71
|
+
if ( threat.extension?.type === 'plugins' ) {
|
|
72
72
|
return __( 'Delete plugin from site', 'jetpack-scan' );
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
if ( threat.extension?.type === '
|
|
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 === '
|
|
80
|
+
if ( threat.extension?.type === 'plugins' ) {
|
|
81
81
|
return __( 'Update plugin to newer version', 'jetpack-scan' );
|
|
82
82
|
}
|
|
83
|
-
if ( threat.extension?.type === '
|
|
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 === '
|
|
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 === '
|
|
121
|
+
if ( threat.extension?.type === 'themes' ) {
|
|
123
122
|
return __( 'Delete the theme directory to fix the threat.', 'jetpack-scan' );
|
|
124
123
|
}
|
|
125
124
|
break;
|