mcp-wordpress 2.11.13 → 3.0.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/README.md +14 -29
- package/dist/cache/CacheInvalidation.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +7 -0
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +21 -7
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/HttpCacheWrapper.js.map +1 -1
- package/dist/cache/SEOCacheManager.d.ts.map +1 -1
- package/dist/cache/SEOCacheManager.js +6 -1
- package/dist/cache/SEOCacheManager.js.map +1 -1
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js.map +1 -1
- package/dist/client/CachedWordPressClient.d.ts.map +1 -1
- package/dist/client/CachedWordPressClient.js.map +1 -1
- package/dist/client/MockWordPressClient.d.ts.map +1 -1
- package/dist/client/MockWordPressClient.js.map +1 -1
- package/dist/client/SEOWordPressClient.d.ts.map +1 -1
- package/dist/client/SEOWordPressClient.js.map +1 -1
- package/dist/client/api.d.ts +11 -26
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +111 -203
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/auth.js.map +1 -1
- package/dist/client/managers/AuthManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.js +6 -5
- package/dist/client/managers/RequestManager.js.map +1 -1
- package/dist/client/managers/composed/MigrationAdapter.d.ts +3 -3
- package/dist/client/managers/composed/MigrationAdapter.d.ts.map +1 -1
- package/dist/client/managers/composed/MigrationAdapter.js +2 -2
- package/dist/client/managers/composed/MigrationAdapter.js.map +1 -1
- package/dist/client/managers/composed/index.d.ts +7 -7
- package/dist/client/managers/composed/index.d.ts.map +1 -1
- package/dist/client/managers/composed/index.js +6 -6
- package/dist/client/managers/composed/index.js.map +1 -1
- package/dist/client/managers/implementations/ConfigurationProviderImpl.d.ts +1 -1
- package/dist/client/managers/implementations/ConfigurationProviderImpl.d.ts.map +1 -1
- package/dist/client/managers/implementations/ErrorHandlerImpl.d.ts +1 -1
- package/dist/client/managers/implementations/ErrorHandlerImpl.d.ts.map +1 -1
- package/dist/client/managers/implementations/ParameterValidatorImpl.d.ts +1 -1
- package/dist/client/managers/implementations/ParameterValidatorImpl.d.ts.map +1 -1
- package/dist/client/operations/comments.d.ts +58 -0
- package/dist/client/operations/comments.d.ts.map +1 -0
- package/dist/client/operations/comments.js +74 -0
- package/dist/client/operations/comments.js.map +1 -0
- package/dist/client/operations/index.d.ts +12 -0
- package/dist/client/operations/index.d.ts.map +1 -0
- package/dist/client/operations/index.js +12 -0
- package/dist/client/operations/index.js.map +1 -0
- package/dist/client/operations/media.d.ts +55 -0
- package/dist/client/operations/media.d.ts.map +1 -0
- package/dist/client/operations/media.js +132 -0
- package/dist/client/operations/media.js.map +1 -0
- package/dist/client/operations/pages.d.ts +50 -0
- package/dist/client/operations/pages.d.ts.map +1 -0
- package/dist/client/operations/pages.js +56 -0
- package/dist/client/operations/pages.js.map +1 -0
- package/dist/client/operations/posts.d.ts +50 -0
- package/dist/client/operations/posts.d.ts.map +1 -0
- package/dist/client/operations/posts.js +53 -0
- package/dist/client/operations/posts.js.map +1 -0
- package/dist/client/operations/site.d.ts +60 -0
- package/dist/client/operations/site.d.ts.map +1 -0
- package/dist/client/operations/site.js +83 -0
- package/dist/client/operations/site.js.map +1 -0
- package/dist/client/operations/taxonomies.d.ts +69 -0
- package/dist/client/operations/taxonomies.d.ts.map +1 -0
- package/dist/client/operations/taxonomies.js +87 -0
- package/dist/client/operations/taxonomies.js.map +1 -0
- package/dist/client/operations/users.d.ts +50 -0
- package/dist/client/operations/users.d.ts.map +1 -0
- package/dist/client/operations/users.js +57 -0
- package/dist/client/operations/users.js.map +1 -0
- package/dist/config/ServerConfiguration.d.ts.map +1 -1
- package/dist/config/ServerConfiguration.js.map +1 -1
- package/dist/docs/DocumentationGenerator.js.map +1 -1
- package/dist/performance/MetricsCollector.d.ts.map +1 -1
- package/dist/performance/MetricsCollector.js.map +1 -1
- package/dist/performance/PerformanceMonitor.js.map +1 -1
- package/dist/security/AISecurityScanner.d.ts.map +1 -1
- package/dist/security/AISecurityScanner.js +3 -2
- package/dist/security/AISecurityScanner.js.map +1 -1
- package/dist/security/AutomatedRemediation.js.map +1 -1
- package/dist/security/InputValidator.d.ts.map +1 -1
- package/dist/security/InputValidator.js +30 -18
- package/dist/security/InputValidator.js.map +1 -1
- package/dist/security/SecurityCIPipeline.d.ts +19 -196
- package/dist/security/SecurityCIPipeline.d.ts.map +1 -1
- package/dist/security/SecurityCIPipeline.js +95 -639
- package/dist/security/SecurityCIPipeline.js.map +1 -1
- package/dist/security/SecurityConfig.js.map +1 -1
- package/dist/security/SecurityConfigManager.js.map +1 -1
- package/dist/security/SecurityGateExecutor.d.ts +67 -0
- package/dist/security/SecurityGateExecutor.d.ts.map +1 -0
- package/dist/security/SecurityGateExecutor.js +363 -0
- package/dist/security/SecurityGateExecutor.js.map +1 -0
- package/dist/security/SecurityMonitoring.js.map +1 -1
- package/dist/security/SecurityReportGenerator.d.ts +65 -0
- package/dist/security/SecurityReportGenerator.d.ts.map +1 -0
- package/dist/security/SecurityReportGenerator.js +210 -0
- package/dist/security/SecurityReportGenerator.js.map +1 -0
- package/dist/security/SecurityReviewer.js.map +1 -1
- package/dist/security/SecurityTypes.d.ts +188 -0
- package/dist/security/SecurityTypes.d.ts.map +1 -0
- package/dist/security/SecurityTypes.js +6 -0
- package/dist/security/SecurityTypes.js.map +1 -0
- package/dist/security/index.d.ts +5 -28
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +4 -0
- package/dist/security/index.js.map +1 -1
- package/dist/server/ConnectionTester.d.ts.map +1 -1
- package/dist/server/ConnectionTester.js.map +1 -1
- package/dist/server/ToolRegistry.d.ts.map +1 -1
- package/dist/server/ToolRegistry.js.map +1 -1
- package/dist/tools/BaseToolManager.d.ts.map +1 -1
- package/dist/tools/BaseToolManager.js.map +1 -1
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/cache.d.ts.map +1 -1
- package/dist/tools/cache.js.map +1 -1
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/media.d.ts.map +1 -1
- package/dist/tools/media.js.map +1 -1
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/performance/PerformanceHelpers.d.ts +116 -0
- package/dist/tools/performance/PerformanceHelpers.d.ts.map +1 -0
- package/dist/tools/performance/PerformanceHelpers.js +298 -0
- package/dist/tools/performance/PerformanceHelpers.js.map +1 -0
- package/dist/tools/performance/PerformanceTools.d.ts +54 -0
- package/dist/tools/performance/PerformanceTools.d.ts.map +1 -0
- package/dist/tools/performance/PerformanceTools.js +687 -0
- package/dist/tools/performance/PerformanceTools.js.map +1 -0
- package/dist/tools/performance/index.d.ts +8 -0
- package/dist/tools/performance/index.d.ts.map +1 -0
- package/dist/tools/performance/index.js +8 -0
- package/dist/tools/performance/index.js.map +1 -0
- package/dist/tools/performance.d.ts +12 -69
- package/dist/tools/performance.d.ts.map +1 -1
- package/dist/tools/performance.js +12 -920
- package/dist/tools/performance.js.map +1 -1
- package/dist/tools/posts.d.ts.map +1 -1
- package/dist/tools/seo/analyzers/ContentAnalyzer.d.ts.map +1 -1
- package/dist/tools/seo/analyzers/ContentAnalyzer.js +14 -3
- package/dist/tools/seo/analyzers/ContentAnalyzer.js.map +1 -1
- package/dist/tools/seo/auditors/SiteAuditor.d.ts.map +1 -1
- package/dist/tools/seo/auditors/SiteAuditor.js +12 -3
- package/dist/tools/seo/auditors/SiteAuditor.js.map +1 -1
- package/dist/tools/seo/generators/MetaGenerator.d.ts.map +1 -1
- package/dist/tools/seo/generators/MetaGenerator.js +25 -8
- package/dist/tools/seo/generators/MetaGenerator.js.map +1 -1
- package/dist/tools/seo/generators/SchemaGenerator.d.ts.map +1 -1
- package/dist/tools/seo/generators/SchemaGenerator.js.map +1 -1
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.d.ts.map +1 -1
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.js.map +1 -1
- package/dist/tools/site.d.ts.map +1 -1
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts.map +1 -1
- package/dist/tools/taxonomies.js.map +1 -1
- package/dist/tools/users.d.ts.map +1 -1
- package/dist/tools/users.js.map +1 -1
- package/dist/utils/CircuitBreaker.d.ts +243 -0
- package/dist/utils/CircuitBreaker.d.ts.map +1 -0
- package/dist/utils/CircuitBreaker.js +456 -0
- package/dist/utils/CircuitBreaker.js.map +1 -0
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js.map +1 -1
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/toolWrapper.d.ts.map +1 -1
- package/docs/DEPRECATIONS.md +157 -0
- package/package.json +2 -3
- package/src/cache/CacheInvalidation.ts +1 -1
- package/src/cache/CacheManager.ts +25 -8
- package/src/cache/HttpCacheWrapper.ts +1 -1
- package/src/cache/SEOCacheManager.ts +9 -3
- package/src/cache/index.ts +1 -1
- package/src/client/CachedWordPressClient.ts +6 -6
- package/src/client/MockWordPressClient.ts +3 -3
- package/src/client/SEOWordPressClient.ts +6 -6
- package/src/client/api.ts +129 -215
- package/src/client/auth.ts +3 -3
- package/src/client/managers/AuthManager.ts +1 -1
- package/src/client/managers/RequestManager.ts +6 -7
- package/src/client/managers/composed/MigrationAdapter.ts +4 -4
- package/src/client/managers/composed/index.ts +7 -7
- package/src/client/managers/implementations/ConfigurationProviderImpl.ts +1 -1
- package/src/client/managers/implementations/ErrorHandlerImpl.ts +1 -1
- package/src/client/managers/implementations/ParameterValidatorImpl.ts +1 -1
- package/src/client/operations/comments.ts +96 -0
- package/src/client/operations/index.ts +12 -0
- package/src/client/operations/media.ts +162 -0
- package/src/client/operations/pages.ts +71 -0
- package/src/client/operations/posts.ts +68 -0
- package/src/client/operations/site.ts +106 -0
- package/src/client/operations/taxonomies.ts +115 -0
- package/src/client/operations/users.ts +72 -0
- package/src/config/ServerConfiguration.ts +6 -6
- package/src/docs/DocumentationGenerator.ts +3 -3
- package/src/performance/MetricsCollector.ts +4 -4
- package/src/performance/PerformanceMonitor.ts +1 -1
- package/src/security/AISecurityScanner.ts +4 -3
- package/src/security/AutomatedRemediation.ts +1 -1
- package/src/security/InputValidator.ts +36 -19
- package/src/security/SecurityCIPipeline.ts +130 -953
- package/src/security/SecurityConfig.ts +1 -1
- package/src/security/SecurityConfigManager.ts +1 -1
- package/src/security/SecurityGateExecutor.ts +485 -0
- package/src/security/SecurityMonitoring.ts +1 -1
- package/src/security/SecurityReportGenerator.ts +272 -0
- package/src/security/SecurityReviewer.ts +1 -1
- package/src/security/SecurityTypes.ts +199 -0
- package/src/security/index.ts +6 -1
- package/src/server/ConnectionTester.ts +4 -4
- package/src/server/ToolRegistry.ts +6 -6
- package/src/tools/BaseToolManager.ts +2 -2
- package/src/tools/auth.ts +3 -3
- package/src/tools/cache.ts +3 -3
- package/src/tools/comments.ts +3 -3
- package/src/tools/media.ts +3 -3
- package/src/tools/pages.ts +3 -3
- package/src/tools/performance/PerformanceHelpers.ts +330 -0
- package/src/tools/performance/PerformanceTools.ts +854 -0
- package/src/tools/performance/index.ts +8 -0
- package/src/tools/performance.ts +12 -1073
- package/src/tools/posts.ts +1 -1
- package/src/tools/seo/analyzers/ContentAnalyzer.ts +21 -7
- package/src/tools/seo/auditors/SiteAuditor.ts +18 -7
- package/src/tools/seo/generators/MetaGenerator.ts +33 -12
- package/src/tools/seo/generators/SchemaGenerator.ts +3 -3
- package/src/tools/seo/optimizers/InternalLinkingSuggester.ts +4 -4
- package/src/tools/site.ts +3 -3
- package/src/tools/taxonomies.ts +3 -3
- package/src/tools/users.ts +4 -4
- package/src/utils/CircuitBreaker.ts +572 -0
- package/src/utils/debug.ts +3 -3
- package/src/utils/error.ts +1 -1
- package/src/utils/index.ts +3 -0
- package/src/utils/logger.ts +1 -1
- package/src/utils/toolWrapper.ts +2 -2
- package/docs/BRANCH_PROTECTION.md +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Taxonomies Operations Module
|
|
3
|
+
* Handles all taxonomy-related WordPress REST API operations (categories, tags)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
WordPressCategory,
|
|
8
|
+
WordPressTag,
|
|
9
|
+
CreateCategoryRequest,
|
|
10
|
+
UpdateCategoryRequest,
|
|
11
|
+
CreateTagRequest,
|
|
12
|
+
UpdateTagRequest,
|
|
13
|
+
} from "@/types/wordpress.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Interface for the base client methods needed by taxonomies operations
|
|
17
|
+
*/
|
|
18
|
+
export interface TaxonomiesClientBase {
|
|
19
|
+
get<T>(endpoint: string): Promise<T>;
|
|
20
|
+
post<T>(endpoint: string, data?: unknown): Promise<T>;
|
|
21
|
+
put<T>(endpoint: string, data?: unknown): Promise<T>;
|
|
22
|
+
delete<T>(endpoint: string): Promise<T>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Taxonomies operations mixin
|
|
27
|
+
* Provides CRUD operations for WordPress categories and tags
|
|
28
|
+
*/
|
|
29
|
+
export class TaxonomiesOperations {
|
|
30
|
+
constructor(private client: TaxonomiesClientBase) {}
|
|
31
|
+
|
|
32
|
+
// Categories
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get a list of categories with optional filtering
|
|
36
|
+
*/
|
|
37
|
+
async getCategories(params?: Record<string, string | number | boolean>): Promise<WordPressCategory[]> {
|
|
38
|
+
const normalizedParams = params
|
|
39
|
+
? Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)]))
|
|
40
|
+
: undefined;
|
|
41
|
+
const queryString = normalizedParams ? "?" + new URLSearchParams(normalizedParams).toString() : "";
|
|
42
|
+
return this.client.get<WordPressCategory[]>(`categories${queryString}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get a single category by ID
|
|
47
|
+
*/
|
|
48
|
+
async getCategory(id: number): Promise<WordPressCategory> {
|
|
49
|
+
return this.client.get<WordPressCategory>(`categories/${id}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create a new category
|
|
54
|
+
*/
|
|
55
|
+
async createCategory(data: CreateCategoryRequest): Promise<WordPressCategory> {
|
|
56
|
+
return this.client.post<WordPressCategory>("categories", data);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Update an existing category
|
|
61
|
+
*/
|
|
62
|
+
async updateCategory(data: UpdateCategoryRequest): Promise<WordPressCategory> {
|
|
63
|
+
const { id, ...updateData } = data;
|
|
64
|
+
return this.client.put<WordPressCategory>(`categories/${id}`, updateData);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Delete a category
|
|
69
|
+
*/
|
|
70
|
+
async deleteCategory(id: number, force = false): Promise<{ deleted: boolean; previous?: WordPressCategory }> {
|
|
71
|
+
return this.client.delete(`categories/${id}?force=${force}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Tags
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get a list of tags with optional filtering
|
|
78
|
+
*/
|
|
79
|
+
async getTags(params?: Record<string, string | number | boolean>): Promise<WordPressTag[]> {
|
|
80
|
+
const normalizedParams = params
|
|
81
|
+
? Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)]))
|
|
82
|
+
: undefined;
|
|
83
|
+
const queryString = normalizedParams ? "?" + new URLSearchParams(normalizedParams).toString() : "";
|
|
84
|
+
return this.client.get<WordPressTag[]>(`tags${queryString}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get a single tag by ID
|
|
89
|
+
*/
|
|
90
|
+
async getTag(id: number): Promise<WordPressTag> {
|
|
91
|
+
return this.client.get<WordPressTag>(`tags/${id}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Create a new tag
|
|
96
|
+
*/
|
|
97
|
+
async createTag(data: CreateTagRequest): Promise<WordPressTag> {
|
|
98
|
+
return this.client.post<WordPressTag>("tags", data);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Update an existing tag
|
|
103
|
+
*/
|
|
104
|
+
async updateTag(data: UpdateTagRequest): Promise<WordPressTag> {
|
|
105
|
+
const { id, ...updateData } = data;
|
|
106
|
+
return this.client.put<WordPressTag>(`tags/${id}`, updateData);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Delete a tag
|
|
111
|
+
*/
|
|
112
|
+
async deleteTag(id: number, force = false): Promise<{ deleted: boolean; previous?: WordPressTag }> {
|
|
113
|
+
return this.client.delete(`tags/${id}?force=${force}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Users Operations Module
|
|
3
|
+
* Handles all user-related WordPress REST API operations
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { WordPressUser, UserQueryParams, CreateUserRequest, UpdateUserRequest } from "@/types/wordpress.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Interface for the base client methods needed by users operations
|
|
10
|
+
*/
|
|
11
|
+
export interface UsersClientBase {
|
|
12
|
+
get<T>(endpoint: string): Promise<T>;
|
|
13
|
+
post<T>(endpoint: string, data?: unknown): Promise<T>;
|
|
14
|
+
put<T>(endpoint: string, data?: unknown): Promise<T>;
|
|
15
|
+
delete<T>(endpoint: string): Promise<T>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Users operations mixin
|
|
20
|
+
* Provides CRUD operations for WordPress users
|
|
21
|
+
*/
|
|
22
|
+
export class UsersOperations {
|
|
23
|
+
constructor(private client: UsersClientBase) {}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get a list of users with optional filtering
|
|
27
|
+
*/
|
|
28
|
+
async getUsers(params?: UserQueryParams): Promise<WordPressUser[]> {
|
|
29
|
+
const normalizedParams = params
|
|
30
|
+
? Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)]))
|
|
31
|
+
: undefined;
|
|
32
|
+
const queryString = normalizedParams ? "?" + new URLSearchParams(normalizedParams).toString() : "";
|
|
33
|
+
return this.client.get<WordPressUser[]>(`users${queryString}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get a single user by ID or "me" for current user
|
|
38
|
+
*/
|
|
39
|
+
async getUser(id: number | "me", context: "view" | "embed" | "edit" = "view"): Promise<WordPressUser> {
|
|
40
|
+
return this.client.get<WordPressUser>(`users/${id}?context=${context}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Create a new user
|
|
45
|
+
*/
|
|
46
|
+
async createUser(data: CreateUserRequest): Promise<WordPressUser> {
|
|
47
|
+
return this.client.post<WordPressUser>("users", data);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Update an existing user
|
|
52
|
+
*/
|
|
53
|
+
async updateUser(data: UpdateUserRequest): Promise<WordPressUser> {
|
|
54
|
+
const { id, ...updateData } = data;
|
|
55
|
+
return this.client.put<WordPressUser>(`users/${id}`, updateData);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Delete a user
|
|
60
|
+
*/
|
|
61
|
+
async deleteUser(id: number, reassign?: number): Promise<{ deleted: boolean; previous?: WordPressUser }> {
|
|
62
|
+
const params = reassign ? `?reassign=${reassign}&force=true` : "?force=true";
|
|
63
|
+
return this.client.delete(`users/${id}${params}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Get the current authenticated user
|
|
68
|
+
*/
|
|
69
|
+
async getCurrentUser(): Promise<WordPressUser> {
|
|
70
|
+
return this.getUser("me", "edit");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -2,12 +2,12 @@ import dotenv from "dotenv";
|
|
|
2
2
|
import { promises as fsPromises } from "fs";
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
|
-
import { WordPressClient } from "
|
|
6
|
-
import { CachedWordPressClient } from "
|
|
7
|
-
import { MockWordPressClient } from "
|
|
8
|
-
import { WordPressClientConfig } from "
|
|
9
|
-
import { getErrorMessage } from "
|
|
10
|
-
import { LoggerFactory } from "
|
|
5
|
+
import { WordPressClient } from "@/client/api.js";
|
|
6
|
+
import { CachedWordPressClient } from "@/client/CachedWordPressClient.js";
|
|
7
|
+
import { MockWordPressClient } from "@/client/MockWordPressClient.js";
|
|
8
|
+
import { WordPressClientConfig } from "@/types/client.js";
|
|
9
|
+
import { getErrorMessage } from "@/utils/error.js";
|
|
10
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
11
11
|
import { ConfigHelpers } from "./Config.js";
|
|
12
12
|
import {
|
|
13
13
|
ConfigurationValidator,
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
import * as fs from "fs";
|
|
7
7
|
import * as path from "path";
|
|
8
|
-
import * as Tools from "
|
|
9
|
-
import type { ToolDefinition } from "
|
|
10
|
-
import { LoggerFactory } from "
|
|
8
|
+
import * as Tools from "@/tools/index.js";
|
|
9
|
+
import type { ToolDefinition } from "@/server/ToolRegistry.js";
|
|
10
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
11
11
|
|
|
12
12
|
export interface DocumentationConfig {
|
|
13
13
|
outputDir: string;
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { PerformanceMonitor, PerformanceMetrics } from "./PerformanceMonitor.js";
|
|
7
|
-
import type { CacheStats } from "
|
|
8
|
-
import type { ClientStats } from "
|
|
9
|
-
import { ConfigHelpers } from "
|
|
10
|
-
import { LoggerFactory } from "
|
|
7
|
+
import type { CacheStats } from "@/cache/CacheManager.js";
|
|
8
|
+
import type { ClientStats } from "@/types/client.js";
|
|
9
|
+
import { ConfigHelpers } from "@/config/Config.js";
|
|
10
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
11
11
|
|
|
12
12
|
export interface CollectorConfig {
|
|
13
13
|
enableRealTime: boolean;
|
|
@@ -7,7 +7,7 @@ import * as fs from "fs/promises";
|
|
|
7
7
|
import * as path from "path";
|
|
8
8
|
import { SecurityUtils } from "./SecurityConfig.js";
|
|
9
9
|
import { SecurityValidationError } from "./InputValidator.js";
|
|
10
|
-
import { LoggerFactory } from "
|
|
10
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
11
11
|
|
|
12
12
|
export interface SecurityVulnerability {
|
|
13
13
|
id: string;
|
|
@@ -67,7 +67,7 @@ export interface RemediationResult {
|
|
|
67
67
|
const SECURITY_PATTERNS = {
|
|
68
68
|
// SQL Injection patterns
|
|
69
69
|
sqlInjection: [
|
|
70
|
-
/['"
|
|
70
|
+
/['";\-]|\/\*|\*\/|--/g, // Match quotes, double hyphens, semicolons, and SQL comments
|
|
71
71
|
/(union|select|insert|update|delete|drop|create|alter)\s+/gi,
|
|
72
72
|
/\b(or|and)\s+['"]?\d+['"]?\s*=\s*['"]?\d+['"]?/gi,
|
|
73
73
|
/\b(char|ascii|substring|length|concat)\s*\(/gi,
|
|
@@ -75,7 +75,8 @@ const SECURITY_PATTERNS = {
|
|
|
75
75
|
|
|
76
76
|
// XSS patterns
|
|
77
77
|
xss: [
|
|
78
|
-
/<script
|
|
78
|
+
/<script/gi, // Detect script tag start
|
|
79
|
+
/<\/script/gi, // Detect script tag end
|
|
79
80
|
/javascript\s*:/gi,
|
|
80
81
|
/on\w+\s*=\s*['"][^'"]*['"]?/gi,
|
|
81
82
|
/eval\s*\(/gi,
|
|
@@ -8,7 +8,7 @@ import * as path from "path";
|
|
|
8
8
|
import { SecurityVulnerability, SecurityScanResult } from "./AISecurityScanner.js";
|
|
9
9
|
import { SecurityUtils } from "./SecurityConfig.js";
|
|
10
10
|
import { SecurityValidationError } from "./InputValidator.js";
|
|
11
|
-
import { LoggerFactory } from "
|
|
11
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
12
12
|
|
|
13
13
|
interface RemediationAction {
|
|
14
14
|
id: string;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
import { LoggerFactory } from "
|
|
7
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
8
8
|
|
|
9
9
|
const logger = LoggerFactory.security();
|
|
10
10
|
|
|
@@ -12,7 +12,9 @@ const logger = LoggerFactory.security();
|
|
|
12
12
|
const URL_PATTERN = /^https?:\/\/[^\s<>'"{}|\\^`\[\]]+$/;
|
|
13
13
|
const EMAIL_PATTERN = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
14
14
|
const SLUG_PATTERN = /^[a-z0-9-]+$/;
|
|
15
|
-
|
|
15
|
+
// Patterns for detecting dangerous content (used for validation, not sanitization)
|
|
16
|
+
const SCRIPT_TAG_PATTERN = /<script/gi;
|
|
17
|
+
const SCRIPT_END_PATTERN = /<\/script/gi;
|
|
16
18
|
const SQL_INJECTION_PATTERN = /('|(\\')|(;)|(\\x00)|(\\n)|(\\r)|(\\x1a)|(\\x22)|(\\x27)|(\\x5c)|(\\x60))/i;
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -23,9 +25,9 @@ export const SecuritySchemas = {
|
|
|
23
25
|
safeString: z
|
|
24
26
|
.string()
|
|
25
27
|
.max(10000, "String too long")
|
|
26
|
-
.refine((val) => !
|
|
27
|
-
.refine((val) =>
|
|
28
|
-
.refine((val) =>
|
|
28
|
+
.refine((val) => !SCRIPT_TAG_PATTERN.test(val) && !SCRIPT_END_PATTERN.test(val), "Script tags not allowed")
|
|
29
|
+
.refine((val) => !/javascript\s*:/i.test(val), "JavaScript URLs not allowed")
|
|
30
|
+
.refine((val) => !/data\s*:/i.test(val), "Data URLs not allowed")
|
|
29
31
|
.refine((val) => !val.includes("onerror="), "Event handlers not allowed")
|
|
30
32
|
.refine((val) => !val.includes("onload="), "Event handlers not allowed")
|
|
31
33
|
.refine((val) => !val.includes("onfocus="), "Event handlers not allowed"),
|
|
@@ -34,8 +36,8 @@ export const SecuritySchemas = {
|
|
|
34
36
|
htmlContent: z
|
|
35
37
|
.string()
|
|
36
38
|
.max(100000, "Content too long")
|
|
37
|
-
.refine((val) => !
|
|
38
|
-
.refine((val) =>
|
|
39
|
+
.refine((val) => !SCRIPT_TAG_PATTERN.test(val) && !SCRIPT_END_PATTERN.test(val), "Script tags not allowed")
|
|
40
|
+
.refine((val) => !/javascript\s*:/i.test(val), "JavaScript URLs not allowed")
|
|
39
41
|
.refine((val) => !val.includes("on[a-z]+="), "Event handlers not allowed"),
|
|
40
42
|
|
|
41
43
|
// URL validation
|
|
@@ -43,8 +45,8 @@ export const SecuritySchemas = {
|
|
|
43
45
|
.string()
|
|
44
46
|
.url("Invalid URL format")
|
|
45
47
|
.regex(URL_PATTERN, "URL contains invalid characters")
|
|
46
|
-
.refine((val) =>
|
|
47
|
-
.refine((val) =>
|
|
48
|
+
.refine((val) => !/javascript\s*:/i.test(val), "JavaScript URLs not allowed")
|
|
49
|
+
.refine((val) => !/data\s*:/i.test(val), "Data URLs not allowed"),
|
|
48
50
|
|
|
49
51
|
// Email validation
|
|
50
52
|
email: z
|
|
@@ -64,8 +66,11 @@ export const SecuritySchemas = {
|
|
|
64
66
|
wpContent: z
|
|
65
67
|
.string()
|
|
66
68
|
.max(1000000, "Content too long")
|
|
67
|
-
.refine(
|
|
68
|
-
|
|
69
|
+
.refine(
|
|
70
|
+
(val) => !SCRIPT_TAG_PATTERN.test(val) && !SCRIPT_END_PATTERN.test(val),
|
|
71
|
+
"Script tags not allowed in content",
|
|
72
|
+
)
|
|
73
|
+
.refine((val) => !/javascript\s*:/i.test(val), "JavaScript URLs not allowed"),
|
|
69
74
|
|
|
70
75
|
// Site ID validation
|
|
71
76
|
siteId: z
|
|
@@ -111,14 +116,26 @@ export class InputSanitizer {
|
|
|
111
116
|
* Sanitize HTML content by removing dangerous elements
|
|
112
117
|
*/
|
|
113
118
|
static sanitizeHtml(input: string): string {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
let result = input;
|
|
120
|
+
let previous = "";
|
|
121
|
+
|
|
122
|
+
// Apply sanitization repeatedly until no more changes occur
|
|
123
|
+
// This prevents bypass via nested dangerous patterns like "jajavascript:vascript:"
|
|
124
|
+
while (result !== previous) {
|
|
125
|
+
previous = result;
|
|
126
|
+
result = result
|
|
127
|
+
.replace(/<script[^>]*>/gi, "") // Remove script open tags
|
|
128
|
+
.replace(/<\/script[^>]*>/gi, "") // Remove script close tags
|
|
129
|
+
.replace(/javascript\s*:/gi, "") // Remove javascript: URLs (with optional whitespace)
|
|
130
|
+
.replace(/data\s*:/gi, "") // Remove data: URLs (with optional whitespace)
|
|
131
|
+
.replace(/vbscript\s*:/gi, "") // Remove vbscript: URLs
|
|
132
|
+
.replace(/on[a-z]+\s*=/gi, "") // Remove event handlers
|
|
133
|
+
.replace(/<iframe[^>]*>/gi, "") // Remove iframes
|
|
134
|
+
.replace(/<object[^>]*>/gi, "") // Remove objects
|
|
135
|
+
.replace(/<embed[^>]*>/gi, ""); // Remove embeds
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return result;
|
|
122
139
|
}
|
|
123
140
|
|
|
124
141
|
/**
|