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,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Report Generator
|
|
3
|
+
* Handles generation of security reports and statistics
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
PipelineSecurityReport,
|
|
8
|
+
GateResult,
|
|
9
|
+
PipelineContext,
|
|
10
|
+
ReportSummary,
|
|
11
|
+
PipelineStatistics,
|
|
12
|
+
ReportFilterOptions,
|
|
13
|
+
} from "./SecurityTypes.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Security Report Generator
|
|
17
|
+
* Responsible for generating and managing security reports
|
|
18
|
+
*/
|
|
19
|
+
export class SecurityReportGenerator {
|
|
20
|
+
private reports: PipelineSecurityReport[] = [];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Generate a pipeline security report
|
|
24
|
+
*/
|
|
25
|
+
generateReport(
|
|
26
|
+
reportId: string,
|
|
27
|
+
stage: string,
|
|
28
|
+
startTime: number,
|
|
29
|
+
status: "passed" | "failed" | "warning",
|
|
30
|
+
gateResults: GateResult[],
|
|
31
|
+
context: PipelineContext,
|
|
32
|
+
): PipelineSecurityReport {
|
|
33
|
+
const allFindings = gateResults.flatMap((gate) => gate.checks.flatMap((check) => check.findings));
|
|
34
|
+
|
|
35
|
+
const summary: ReportSummary = {
|
|
36
|
+
totalIssues: allFindings.length,
|
|
37
|
+
criticalIssues: allFindings.filter((f) => f.severity === "critical").length,
|
|
38
|
+
highIssues: allFindings.filter((f) => f.severity === "high").length,
|
|
39
|
+
mediumIssues: allFindings.filter((f) => f.severity === "medium").length,
|
|
40
|
+
lowIssues: allFindings.filter((f) => f.severity === "low").length,
|
|
41
|
+
securityScore: this.calculateOverallSecurityScore(gateResults),
|
|
42
|
+
compliance: status === "passed",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const recommendations = this.generateRecommendations(gateResults, summary);
|
|
46
|
+
|
|
47
|
+
const report: PipelineSecurityReport = {
|
|
48
|
+
reportId,
|
|
49
|
+
timestamp: new Date(),
|
|
50
|
+
stage,
|
|
51
|
+
status,
|
|
52
|
+
duration: Date.now() - startTime,
|
|
53
|
+
gates: gateResults,
|
|
54
|
+
summary,
|
|
55
|
+
recommendations,
|
|
56
|
+
artifacts: this.generateArtifacts(reportId, gateResults),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return report;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Create empty report for stages with no gates
|
|
64
|
+
*/
|
|
65
|
+
createEmptyReport(reportId: string, stage: string, startTime: number): PipelineSecurityReport {
|
|
66
|
+
return {
|
|
67
|
+
reportId,
|
|
68
|
+
timestamp: new Date(),
|
|
69
|
+
stage,
|
|
70
|
+
status: "passed",
|
|
71
|
+
duration: Date.now() - startTime,
|
|
72
|
+
gates: [],
|
|
73
|
+
summary: {
|
|
74
|
+
totalIssues: 0,
|
|
75
|
+
criticalIssues: 0,
|
|
76
|
+
highIssues: 0,
|
|
77
|
+
mediumIssues: 0,
|
|
78
|
+
lowIssues: 0,
|
|
79
|
+
securityScore: 100,
|
|
80
|
+
compliance: true,
|
|
81
|
+
},
|
|
82
|
+
recommendations: [],
|
|
83
|
+
artifacts: [],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Store a report
|
|
89
|
+
*/
|
|
90
|
+
storeReport(report: PipelineSecurityReport): void {
|
|
91
|
+
this.reports.push(report);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get the latest report
|
|
96
|
+
*/
|
|
97
|
+
getLatestReport(): PipelineSecurityReport | undefined {
|
|
98
|
+
return this.reports.length > 0 ? this.reports[this.reports.length - 1] : undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get all reports
|
|
103
|
+
*/
|
|
104
|
+
getAllReports(): PipelineSecurityReport[] {
|
|
105
|
+
return [...this.reports];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Get filtered reports
|
|
110
|
+
*/
|
|
111
|
+
getReports(options: ReportFilterOptions = {}): PipelineSecurityReport[] {
|
|
112
|
+
let reports = [...this.reports];
|
|
113
|
+
|
|
114
|
+
if (options.stage) {
|
|
115
|
+
reports = reports.filter((r) => r.stage === options.stage);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (options.status) {
|
|
119
|
+
reports = reports.filter((r) => r.status === options.status);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (options.since) {
|
|
123
|
+
reports = reports.filter((r) => r.timestamp >= options.since!);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Sort by timestamp (newest first)
|
|
127
|
+
reports.sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime());
|
|
128
|
+
|
|
129
|
+
if (options.limit) {
|
|
130
|
+
reports = reports.slice(0, options.limit);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return reports;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Export report in various formats
|
|
138
|
+
*/
|
|
139
|
+
exportReport(report: PipelineSecurityReport, format: string): string {
|
|
140
|
+
if (format === "html") {
|
|
141
|
+
return `<html><body>${JSON.stringify(report)}</body></html>`;
|
|
142
|
+
}
|
|
143
|
+
if (format === "xml") {
|
|
144
|
+
return `<report>${JSON.stringify(report)}</report>`;
|
|
145
|
+
}
|
|
146
|
+
return JSON.stringify(report);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Calculate security metrics from a report
|
|
151
|
+
*/
|
|
152
|
+
calculateSecurityMetrics(report: PipelineSecurityReport): {
|
|
153
|
+
overallScore: number;
|
|
154
|
+
riskLevel: string;
|
|
155
|
+
complianceStatus: boolean;
|
|
156
|
+
} {
|
|
157
|
+
const overallScore = report.summary.securityScore ?? 100;
|
|
158
|
+
const riskLevel = overallScore > 80 ? "low" : overallScore > 50 ? "medium" : "high";
|
|
159
|
+
return { overallScore, riskLevel, complianceStatus: report.summary.compliance };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Calculate overall security score from gate results
|
|
164
|
+
*/
|
|
165
|
+
calculateOverallSecurityScore(gateResults: GateResult[]): number {
|
|
166
|
+
const allChecks = gateResults.flatMap((gate) => gate.checks);
|
|
167
|
+
|
|
168
|
+
if (allChecks.length === 0) {
|
|
169
|
+
return 100;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const totalScore = allChecks.reduce((sum, check) => sum + check.score, 0);
|
|
173
|
+
return totalScore / allChecks.length;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Generate recommendations based on results
|
|
178
|
+
*/
|
|
179
|
+
generateRecommendations(
|
|
180
|
+
gateResults: GateResult[],
|
|
181
|
+
summary: ReportSummary,
|
|
182
|
+
): string[] {
|
|
183
|
+
const recommendations: string[] = [];
|
|
184
|
+
|
|
185
|
+
if (summary.criticalIssues > 0) {
|
|
186
|
+
recommendations.push("Address critical security vulnerabilities immediately before deployment");
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (summary.highIssues > 5) {
|
|
190
|
+
recommendations.push("Review and remediate high-severity security issues");
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (summary.securityScore < 80) {
|
|
194
|
+
recommendations.push("Improve overall security posture through code review and security training");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const failedGates = gateResults.filter((gate) => gate.status === "failed");
|
|
198
|
+
if (failedGates.length > 0) {
|
|
199
|
+
recommendations.push(`Review failed security gates: ${failedGates.map((g) => g.gateName).join(", ")}`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return recommendations;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Generate artifacts for the security report
|
|
207
|
+
*/
|
|
208
|
+
generateArtifacts(reportId: string, gateResults: GateResult[]): string[] {
|
|
209
|
+
return [`security-report-${reportId}.json`, `security-findings-${reportId}.sarif`];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Get pipeline statistics
|
|
214
|
+
*/
|
|
215
|
+
getStatistics(): PipelineStatistics {
|
|
216
|
+
const totalReports = this.reports.length;
|
|
217
|
+
const passedReports = this.reports.filter((r) => r.status === "passed").length;
|
|
218
|
+
const passRate = totalReports > 0 ? passedReports / totalReports : 1;
|
|
219
|
+
|
|
220
|
+
const averageSecurityScore =
|
|
221
|
+
totalReports > 0 ? this.reports.reduce((sum, r) => sum + r.summary.securityScore, 0) / totalReports : 100;
|
|
222
|
+
|
|
223
|
+
// Count issue types
|
|
224
|
+
const issueTypes: Record<string, number> = {};
|
|
225
|
+
this.reports.forEach((report) => {
|
|
226
|
+
report.gates.forEach((gate) => {
|
|
227
|
+
gate.checks.forEach((check) => {
|
|
228
|
+
check.findings.forEach((finding) => {
|
|
229
|
+
issueTypes[finding.type] = (issueTypes[finding.type] || 0) + 1;
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
const mostCommonIssues = Object.entries(issueTypes)
|
|
236
|
+
.map(([type, count]) => ({ type, count }))
|
|
237
|
+
.sort((a, b) => b.count - a.count)
|
|
238
|
+
.slice(0, 5);
|
|
239
|
+
|
|
240
|
+
// Calculate gate performance
|
|
241
|
+
const gateStats: Record<string, { total: number; passed: number; totalDuration: number }> = {};
|
|
242
|
+
|
|
243
|
+
this.reports.forEach((report) => {
|
|
244
|
+
report.gates.forEach((gate) => {
|
|
245
|
+
if (!gateStats[gate.gateId]) {
|
|
246
|
+
gateStats[gate.gateId] = { total: 0, passed: 0, totalDuration: 0 };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
gateStats[gate.gateId].total++;
|
|
250
|
+
gateStats[gate.gateId].totalDuration += gate.duration;
|
|
251
|
+
|
|
252
|
+
if (gate.status === "passed") {
|
|
253
|
+
gateStats[gate.gateId].passed++;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const gatePerformance = Object.entries(gateStats).map(([gateId, stats]) => ({
|
|
259
|
+
gateId,
|
|
260
|
+
successRate: stats.total > 0 ? stats.passed / stats.total : 0,
|
|
261
|
+
averageDuration: stats.total > 0 ? stats.totalDuration / stats.total : 0,
|
|
262
|
+
}));
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
totalReports,
|
|
266
|
+
passRate,
|
|
267
|
+
averageSecurityScore,
|
|
268
|
+
mostCommonIssues,
|
|
269
|
+
gatePerformance,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -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
|
interface SecurityReviewRule {
|
|
13
13
|
id: string;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Types and Interfaces
|
|
3
|
+
* Shared type definitions for the security CI/CD pipeline
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Security gate configuration
|
|
8
|
+
*/
|
|
9
|
+
export interface SecurityGate {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
stage: "pre-commit" | "pre-build" | "pre-deploy" | "post-deploy";
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
blocking: boolean;
|
|
15
|
+
checks: SecurityCheck[];
|
|
16
|
+
thresholds: SecurityThresholds;
|
|
17
|
+
exceptions: string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Security thresholds for gate evaluation
|
|
22
|
+
*/
|
|
23
|
+
export interface SecurityThresholds {
|
|
24
|
+
maxCritical: number;
|
|
25
|
+
maxHigh: number;
|
|
26
|
+
maxMedium: number;
|
|
27
|
+
minSecurityScore: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Security check configuration
|
|
32
|
+
*/
|
|
33
|
+
export interface SecurityCheck {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
type: SecurityCheckType;
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
timeout: number;
|
|
39
|
+
retries: number;
|
|
40
|
+
parameters: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Types of security checks
|
|
45
|
+
*/
|
|
46
|
+
export type SecurityCheckType = "scan" | "review" | "dependency" | "configuration" | "secrets" | "compliance";
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Pipeline security report
|
|
50
|
+
*/
|
|
51
|
+
export interface PipelineSecurityReport {
|
|
52
|
+
reportId: string;
|
|
53
|
+
timestamp: Date;
|
|
54
|
+
stage: string;
|
|
55
|
+
status: ReportStatus;
|
|
56
|
+
duration: number;
|
|
57
|
+
gates: GateResult[];
|
|
58
|
+
summary: ReportSummary;
|
|
59
|
+
recommendations: string[];
|
|
60
|
+
artifacts: string[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Report status
|
|
65
|
+
*/
|
|
66
|
+
export type ReportStatus = "passed" | "failed" | "warning";
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Report summary
|
|
70
|
+
*/
|
|
71
|
+
export interface ReportSummary {
|
|
72
|
+
totalIssues: number;
|
|
73
|
+
criticalIssues: number;
|
|
74
|
+
highIssues: number;
|
|
75
|
+
mediumIssues: number;
|
|
76
|
+
lowIssues: number;
|
|
77
|
+
securityScore: number;
|
|
78
|
+
compliance: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Gate execution result
|
|
83
|
+
*/
|
|
84
|
+
export interface GateResult {
|
|
85
|
+
gateId: string;
|
|
86
|
+
gateName: string;
|
|
87
|
+
status: GateStatus;
|
|
88
|
+
duration: number;
|
|
89
|
+
checks: CheckResult[];
|
|
90
|
+
blocking: boolean;
|
|
91
|
+
message: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Gate status
|
|
96
|
+
*/
|
|
97
|
+
export type GateStatus = "passed" | "failed" | "warning" | "skipped";
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Check execution result
|
|
101
|
+
*/
|
|
102
|
+
export interface CheckResult {
|
|
103
|
+
checkId: string;
|
|
104
|
+
checkName: string;
|
|
105
|
+
status: CheckStatus;
|
|
106
|
+
duration: number;
|
|
107
|
+
findings: SecurityFinding[];
|
|
108
|
+
details: string;
|
|
109
|
+
score: number;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Check status
|
|
114
|
+
*/
|
|
115
|
+
export type CheckStatus = "passed" | "failed" | "warning" | "error";
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Security finding
|
|
119
|
+
*/
|
|
120
|
+
export interface SecurityFinding {
|
|
121
|
+
id: string;
|
|
122
|
+
severity: FindingSeverity;
|
|
123
|
+
type: string;
|
|
124
|
+
description: string;
|
|
125
|
+
file?: string | undefined;
|
|
126
|
+
line?: number | undefined;
|
|
127
|
+
remediation?: string | undefined;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Finding severity levels
|
|
132
|
+
*/
|
|
133
|
+
export type FindingSeverity = "critical" | "high" | "medium" | "low" | "info";
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Pipeline execution context
|
|
137
|
+
*/
|
|
138
|
+
export interface PipelineContext {
|
|
139
|
+
repositoryUrl: string;
|
|
140
|
+
branch: string;
|
|
141
|
+
commit: string;
|
|
142
|
+
author: string;
|
|
143
|
+
pullRequest?: {
|
|
144
|
+
id: string;
|
|
145
|
+
title: string;
|
|
146
|
+
source: string;
|
|
147
|
+
target: string;
|
|
148
|
+
};
|
|
149
|
+
environment: string;
|
|
150
|
+
buildNumber: string;
|
|
151
|
+
artifacts: string[];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Gate execution options
|
|
156
|
+
*/
|
|
157
|
+
export interface GateExecutionOptions {
|
|
158
|
+
skipNonBlocking?: boolean;
|
|
159
|
+
continueOnFailure?: boolean;
|
|
160
|
+
dryRun?: boolean;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Check execution result (internal)
|
|
165
|
+
*/
|
|
166
|
+
export interface CheckExecutionResult {
|
|
167
|
+
findings: SecurityFinding[];
|
|
168
|
+
score: number;
|
|
169
|
+
details: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Gate status evaluation result
|
|
174
|
+
*/
|
|
175
|
+
export interface GateStatusResult {
|
|
176
|
+
status: "passed" | "failed" | "warning";
|
|
177
|
+
message: string;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Pipeline statistics
|
|
182
|
+
*/
|
|
183
|
+
export interface PipelineStatistics {
|
|
184
|
+
totalReports: number;
|
|
185
|
+
passRate: number;
|
|
186
|
+
averageSecurityScore: number;
|
|
187
|
+
mostCommonIssues: { type: string; count: number }[];
|
|
188
|
+
gatePerformance: { gateId: string; successRate: number; averageDuration: number }[];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Report filter options
|
|
193
|
+
*/
|
|
194
|
+
export interface ReportFilterOptions {
|
|
195
|
+
stage?: string;
|
|
196
|
+
status?: string;
|
|
197
|
+
since?: Date;
|
|
198
|
+
limit?: number;
|
|
199
|
+
}
|
package/src/security/index.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Core Security Components
|
|
7
7
|
export { SecurityConfig, SecurityUtils, createSecureError, getEnvironmentSecurity } from "./SecurityConfig.js";
|
|
8
8
|
import { SecurityValidationError } from "./InputValidator.js";
|
|
9
|
-
import { LoggerFactory } from "
|
|
9
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
10
10
|
export {
|
|
11
11
|
InputSanitizer,
|
|
12
12
|
SecuritySchemas,
|
|
@@ -41,6 +41,11 @@ export { SecurityMonitor, SecurityEvent } from "./SecurityMonitoring.js";
|
|
|
41
41
|
import { SecurityCIPipeline, PipelineSecurityReport as _PipelineSecurityReport } from "./SecurityCIPipeline.js";
|
|
42
42
|
export { SecurityCIPipeline, PipelineSecurityReport } from "./SecurityCIPipeline.js";
|
|
43
43
|
|
|
44
|
+
// Security Types (new modular exports)
|
|
45
|
+
export * from "./SecurityTypes.js";
|
|
46
|
+
export { SecurityGateExecutor } from "./SecurityGateExecutor.js";
|
|
47
|
+
export { SecurityReportGenerator } from "./SecurityReportGenerator.js";
|
|
48
|
+
|
|
44
49
|
// Type definitions for external use
|
|
45
50
|
export interface SecurityScanOptions {
|
|
46
51
|
targets?: string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WordPressClient } from "
|
|
2
|
-
import { getErrorMessage } from "
|
|
3
|
-
import { LoggerFactory } from "
|
|
4
|
-
import { ConfigHelpers } from "
|
|
1
|
+
import { WordPressClient } from "@/client/api.js";
|
|
2
|
+
import { getErrorMessage } from "@/utils/error.js";
|
|
3
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
4
|
+
import { ConfigHelpers } from "@/config/Config.js";
|
|
5
5
|
|
|
6
6
|
interface ErrorWithResponse {
|
|
7
7
|
response?: {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { WordPressClient } from "
|
|
3
|
-
import { getErrorMessage } from "
|
|
4
|
-
import { EnhancedError, ErrorHandlers } from "
|
|
5
|
-
import { config } from "
|
|
6
|
-
import * as Tools from "
|
|
2
|
+
import { WordPressClient } from "@/client/api.js";
|
|
3
|
+
import { getErrorMessage } from "@/utils/error.js";
|
|
4
|
+
import { EnhancedError, ErrorHandlers } from "@/utils/enhancedError.js";
|
|
5
|
+
import { config } from "@/config/Config.js";
|
|
6
|
+
import * as Tools from "@/tools/index.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import type { MCPToolSchema, JSONSchemaProperty } from "
|
|
8
|
+
import type { MCPToolSchema, JSONSchemaProperty } from "@/types/mcp.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Interface for tool definition
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Base utility class for tool managers with enhanced type safety
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { getErrorMessage } from "
|
|
6
|
-
import { WordPressId, createWordPressId, DeepReadonly, Result, createSuccess, createError } from "
|
|
5
|
+
import { getErrorMessage } from "@/utils/error.js";
|
|
6
|
+
import { WordPressId, createWordPressId, DeepReadonly, Result, createSuccess, createError } from "@/types/enhanced.js";
|
|
7
7
|
|
|
8
8
|
interface EnhancedError extends Error {
|
|
9
9
|
originalError?: unknown;
|
package/src/tools/auth.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { WordPressClient } from "
|
|
2
|
-
import { AuthMethod } from "
|
|
3
|
-
import { getErrorMessage } from "
|
|
1
|
+
import { WordPressClient } from "@/client/api.js";
|
|
2
|
+
import { AuthMethod } from "@/types/client.js";
|
|
3
|
+
import { getErrorMessage } from "@/utils/error.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Provides authentication-related tools for WordPress sites.
|
package/src/tools/cache.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Provides cache inspection, clearing, and warming capabilities
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { WordPressClient } from "
|
|
7
|
-
import { CachedWordPressClient } from "
|
|
8
|
-
import { toolWrapper } from "
|
|
6
|
+
import type { WordPressClient } from "@/client/api.js";
|
|
7
|
+
import { CachedWordPressClient } from "@/client/CachedWordPressClient.js";
|
|
8
|
+
import { toolWrapper } from "@/utils/toolWrapper.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Cache management tools class
|
package/src/tools/comments.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { WordPressClient } from "
|
|
2
|
-
import { CommentQueryParams, CreateCommentRequest, UpdateCommentRequest } from "
|
|
3
|
-
import { getErrorMessage } from "
|
|
1
|
+
import { WordPressClient } from "@/client/api.js";
|
|
2
|
+
import { CommentQueryParams, CreateCommentRequest, UpdateCommentRequest } from "@/types/wordpress.js";
|
|
3
|
+
import { getErrorMessage } from "@/utils/error.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Provides tools for managing comments on a WordPress site.
|
package/src/tools/media.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
|
-
import { WordPressClient } from "
|
|
3
|
-
import { MediaQueryParams, UpdateMediaRequest, UploadMediaRequest } from "
|
|
4
|
-
import { getErrorMessage } from "
|
|
2
|
+
import { WordPressClient } from "@/client/api.js";
|
|
3
|
+
import { MediaQueryParams, UpdateMediaRequest, UploadMediaRequest } from "@/types/wordpress.js";
|
|
4
|
+
import { getErrorMessage } from "@/utils/error.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Comprehensive media management tools for WordPress sites.
|
package/src/tools/pages.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { WordPressClient } from "
|
|
2
|
-
import { CreatePageRequest, PostQueryParams as PageQueryParams, UpdatePageRequest } from "
|
|
3
|
-
import { getErrorMessage } from "
|
|
1
|
+
import { WordPressClient } from "@/client/api.js";
|
|
2
|
+
import { CreatePageRequest, PostQueryParams as PageQueryParams, UpdatePageRequest } from "@/types/wordpress.js";
|
|
3
|
+
import { getErrorMessage } from "@/utils/error.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Provides tools for managing pages on a WordPress site.
|