@sfdxy/mule-lint 1.19.0 → 1.21.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 +128 -73
- package/dist/package.json +1 -1
- package/dist/src/core/XPathHelper.d.ts.map +1 -1
- package/dist/src/core/XPathHelper.js +8 -0
- package/dist/src/core/XPathHelper.js.map +1 -1
- package/dist/src/engine/LintEngine.d.ts +32 -0
- package/dist/src/engine/LintEngine.d.ts.map +1 -1
- package/dist/src/engine/LintEngine.js +166 -15
- package/dist/src/engine/LintEngine.js.map +1 -1
- package/dist/src/rules/api-led/ApikitConsoleProductionRule.d.ts +22 -0
- package/dist/src/rules/api-led/ApikitConsoleProductionRule.d.ts.map +1 -0
- package/dist/src/rules/api-led/ApikitConsoleProductionRule.js +43 -0
- package/dist/src/rules/api-led/ApikitConsoleProductionRule.js.map +1 -0
- package/dist/src/rules/api-led/ApikitMainFlowStructureRule.d.ts +24 -0
- package/dist/src/rules/api-led/ApikitMainFlowStructureRule.d.ts.map +1 -0
- package/dist/src/rules/api-led/ApikitMainFlowStructureRule.js +53 -0
- package/dist/src/rules/api-led/ApikitMainFlowStructureRule.js.map +1 -0
- package/dist/src/rules/api-led/ApikitStatusCodeVariableRule.d.ts +25 -0
- package/dist/src/rules/api-led/ApikitStatusCodeVariableRule.d.ts.map +1 -0
- package/dist/src/rules/api-led/ApikitStatusCodeVariableRule.js +59 -0
- package/dist/src/rules/api-led/ApikitStatusCodeVariableRule.js.map +1 -0
- package/dist/src/rules/connector/EventListenerNullGuardRule.d.ts +24 -0
- package/dist/src/rules/connector/EventListenerNullGuardRule.d.ts.map +1 -0
- package/dist/src/rules/connector/EventListenerNullGuardRule.js +58 -0
- package/dist/src/rules/connector/EventListenerNullGuardRule.js.map +1 -0
- package/dist/src/rules/connector/ReplayChannelConfigRule.d.ts +23 -0
- package/dist/src/rules/connector/ReplayChannelConfigRule.d.ts.map +1 -0
- package/dist/src/rules/connector/ReplayChannelConfigRule.js +52 -0
- package/dist/src/rules/connector/ReplayChannelConfigRule.js.map +1 -0
- package/dist/src/rules/dataweave/DataWeaveRules.d.ts +17 -4
- package/dist/src/rules/dataweave/DataWeaveRules.d.ts.map +1 -1
- package/dist/src/rules/dataweave/DataWeaveRules.js +36 -20
- package/dist/src/rules/dataweave/DataWeaveRules.js.map +1 -1
- package/dist/src/rules/dataweave/DuplicateTransformLogicRule.d.ts +25 -0
- package/dist/src/rules/dataweave/DuplicateTransformLogicRule.d.ts.map +1 -0
- package/dist/src/rules/dataweave/DuplicateTransformLogicRule.js +63 -0
- package/dist/src/rules/dataweave/DuplicateTransformLogicRule.js.map +1 -0
- package/dist/src/rules/error-handling/CatchAllLastRule.d.ts +24 -0
- package/dist/src/rules/error-handling/CatchAllLastRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/CatchAllLastRule.js +65 -0
- package/dist/src/rules/error-handling/CatchAllLastRule.js.map +1 -0
- package/dist/src/rules/error-handling/CorrelationIdRule.d.ts +22 -1
- package/dist/src/rules/error-handling/CorrelationIdRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/CorrelationIdRule.js +107 -6
- package/dist/src/rules/error-handling/CorrelationIdRule.js.map +1 -1
- package/dist/src/rules/error-handling/ErrorHandlerTypeCoverageRule.d.ts +28 -0
- package/dist/src/rules/error-handling/ErrorHandlerTypeCoverageRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/ErrorHandlerTypeCoverageRule.js +70 -0
- package/dist/src/rules/error-handling/ErrorHandlerTypeCoverageRule.js.map +1 -0
- package/dist/src/rules/error-handling/ErrorResponseStructureRule.d.ts +23 -0
- package/dist/src/rules/error-handling/ErrorResponseStructureRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/ErrorResponseStructureRule.js +73 -0
- package/dist/src/rules/error-handling/ErrorResponseStructureRule.js.map +1 -0
- package/dist/src/rules/error-handling/GenericErrorRule.d.ts +15 -3
- package/dist/src/rules/error-handling/GenericErrorRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/GenericErrorRule.js +58 -18
- package/dist/src/rules/error-handling/GenericErrorRule.js.map +1 -1
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.d.ts +16 -5
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js +64 -21
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js.map +1 -1
- package/dist/src/rules/error-handling/HttpStatusRule.d.ts +5 -0
- package/dist/src/rules/error-handling/HttpStatusRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/HttpStatusRule.js +15 -0
- package/dist/src/rules/error-handling/HttpStatusRule.js.map +1 -1
- package/dist/src/rules/error-handling/TryScopeRule.d.ts +5 -0
- package/dist/src/rules/error-handling/TryScopeRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/TryScopeRule.js +30 -7
- package/dist/src/rules/error-handling/TryScopeRule.js.map +1 -1
- package/dist/src/rules/http/ConnectionIdleTimeoutRule.d.ts +27 -0
- package/dist/src/rules/http/ConnectionIdleTimeoutRule.d.ts.map +1 -0
- package/dist/src/rules/http/ConnectionIdleTimeoutRule.js +46 -0
- package/dist/src/rules/http/ConnectionIdleTimeoutRule.js.map +1 -0
- package/dist/src/rules/http/HttpContentTypeRule.d.ts +28 -1
- package/dist/src/rules/http/HttpContentTypeRule.d.ts.map +1 -1
- package/dist/src/rules/http/HttpContentTypeRule.js +68 -7
- package/dist/src/rules/http/HttpContentTypeRule.js.map +1 -1
- package/dist/src/rules/index.d.ts +1 -1
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +50 -8
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/logging/LoggerPayloadRule.d.ts +15 -0
- package/dist/src/rules/logging/LoggerPayloadRule.d.ts.map +1 -1
- package/dist/src/rules/logging/LoggerPayloadRule.js +48 -4
- package/dist/src/rules/logging/LoggerPayloadRule.js.map +1 -1
- package/dist/src/rules/operations/FlowRefTargetExistsRule.d.ts +23 -0
- package/dist/src/rules/operations/FlowRefTargetExistsRule.d.ts.map +1 -0
- package/dist/src/rules/operations/FlowRefTargetExistsRule.js +58 -0
- package/dist/src/rules/operations/FlowRefTargetExistsRule.js.map +1 -0
- package/dist/src/rules/operations/UnusedFlowRule.d.ts +26 -1
- package/dist/src/rules/operations/UnusedFlowRule.d.ts.map +1 -1
- package/dist/src/rules/operations/UnusedFlowRule.js +96 -16
- package/dist/src/rules/operations/UnusedFlowRule.js.map +1 -1
- package/dist/src/rules/operations/UnusedVariableRule.d.ts +31 -0
- package/dist/src/rules/operations/UnusedVariableRule.d.ts.map +1 -0
- package/dist/src/rules/operations/UnusedVariableRule.js +103 -0
- package/dist/src/rules/operations/UnusedVariableRule.js.map +1 -0
- package/dist/src/rules/performance/ConnectionPoolingRule.d.ts +5 -0
- package/dist/src/rules/performance/ConnectionPoolingRule.d.ts.map +1 -1
- package/dist/src/rules/performance/ConnectionPoolingRule.js +18 -5
- package/dist/src/rules/performance/ConnectionPoolingRule.js.map +1 -1
- package/dist/src/rules/performance/ListenerReconnectForeverRule.d.ts +28 -0
- package/dist/src/rules/performance/ListenerReconnectForeverRule.d.ts.map +1 -0
- package/dist/src/rules/performance/ListenerReconnectForeverRule.js +56 -0
- package/dist/src/rules/performance/ListenerReconnectForeverRule.js.map +1 -0
- package/dist/src/rules/performance/ReconnectionStrategyRule.d.ts +10 -0
- package/dist/src/rules/performance/ReconnectionStrategyRule.d.ts.map +1 -1
- package/dist/src/rules/performance/ReconnectionStrategyRule.js +47 -14
- package/dist/src/rules/performance/ReconnectionStrategyRule.js.map +1 -1
- package/dist/src/rules/security/ConnectorCredentialsSecuredRule.d.ts +36 -0
- package/dist/src/rules/security/ConnectorCredentialsSecuredRule.d.ts.map +1 -0
- package/dist/src/rules/security/ConnectorCredentialsSecuredRule.js +124 -0
- package/dist/src/rules/security/ConnectorCredentialsSecuredRule.js.map +1 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.d.ts +4 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.d.ts.map +1 -1
- package/dist/src/rules/security/HardcodedCredentialsRule.js +15 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.js.map +1 -1
- package/dist/src/rules/security/SecurePropertiesEncryptionRule.d.ts +25 -0
- package/dist/src/rules/security/SecurePropertiesEncryptionRule.d.ts.map +1 -0
- package/dist/src/rules/security/SecurePropertiesEncryptionRule.js +59 -0
- package/dist/src/rules/security/SecurePropertiesEncryptionRule.js.map +1 -0
- package/dist/src/rules/security/SecurePropertiesKeyRule.d.ts +23 -0
- package/dist/src/rules/security/SecurePropertiesKeyRule.d.ts.map +1 -0
- package/dist/src/rules/security/SecurePropertiesKeyRule.js +45 -0
- package/dist/src/rules/security/SecurePropertiesKeyRule.js.map +1 -0
- package/dist/src/rules/security/TlsKeystorePasswordRule.d.ts +25 -0
- package/dist/src/rules/security/TlsKeystorePasswordRule.d.ts.map +1 -0
- package/dist/src/rules/security/TlsKeystorePasswordRule.js +63 -0
- package/dist/src/rules/security/TlsKeystorePasswordRule.js.map +1 -0
- package/dist/src/rules/standards/ApikitRouteVariableConsistencyRule.d.ts +26 -0
- package/dist/src/rules/standards/ApikitRouteVariableConsistencyRule.d.ts.map +1 -0
- package/dist/src/rules/standards/ApikitRouteVariableConsistencyRule.js +61 -0
- package/dist/src/rules/standards/ApikitRouteVariableConsistencyRule.js.map +1 -0
- package/dist/src/rules/standards/ConfigPropertiesOrderingRule.d.ts +34 -0
- package/dist/src/rules/standards/ConfigPropertiesOrderingRule.d.ts.map +1 -0
- package/dist/src/rules/standards/ConfigPropertiesOrderingRule.js +76 -0
- package/dist/src/rules/standards/ConfigPropertiesOrderingRule.js.map +1 -0
- package/dist/src/rules/standards/MissingEnvPropertiesDeclarationRule.d.ts +25 -0
- package/dist/src/rules/standards/MissingEnvPropertiesDeclarationRule.d.ts.map +1 -0
- package/dist/src/rules/standards/MissingEnvPropertiesDeclarationRule.js +111 -0
- package/dist/src/rules/standards/MissingEnvPropertiesDeclarationRule.js.map +1 -0
- package/dist/src/rules/structure/StructureRules.d.ts +8 -1
- package/dist/src/rules/structure/StructureRules.d.ts.map +1 -1
- package/dist/src/rules/structure/StructureRules.js +11 -7
- package/dist/src/rules/structure/StructureRules.js.map +1 -1
- package/dist/src/rules/yaml/YamlRules.d.ts +6 -2
- package/dist/src/rules/yaml/YamlRules.d.ts.map +1 -1
- package/dist/src/rules/yaml/YamlRules.js +15 -11
- package/dist/src/rules/yaml/YamlRules.js.map +1 -1
- package/dist/src/types/Rule.d.ts +35 -0
- package/dist/src/types/Rule.d.ts.map +1 -1
- package/docs/best-practices/rules-catalog.md +444 -42
- package/docs/linter/architecture.md +119 -64
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ exports.DwlModulesRule = exports.DwlNamingRule = exports.ExternalDwlRule = void
|
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const BaseRule_1 = require("../base/BaseRule");
|
|
40
|
+
const ProjectRule_1 = require("../base/ProjectRule");
|
|
40
41
|
/**
|
|
41
42
|
* DW-001: External DWL for Complex Transforms
|
|
42
43
|
*
|
|
@@ -75,14 +76,23 @@ exports.ExternalDwlRule = ExternalDwlRule;
|
|
|
75
76
|
*
|
|
76
77
|
* DataWeave files should follow naming conventions for consistency.
|
|
77
78
|
* Supports configurable conventions: 'kebab-case' (default), 'camelCase', or 'any'.
|
|
79
|
+
*
|
|
80
|
+
* IMPORTANT: DataWeave module files (imported via `import X from dwl::path::X`)
|
|
81
|
+
* MUST use camelCase because the module identifier in the import statement must
|
|
82
|
+
* exactly match the filename, and hyphens are not valid in DataWeave identifiers.
|
|
83
|
+
* Use the `exemptPaths` option to exclude module directories from this rule, or
|
|
84
|
+
* set `convention: "camelCase"` for projects that use DW modules extensively.
|
|
85
|
+
*
|
|
86
|
+
* This is a ProjectRule — it runs once per scan to avoid producing
|
|
87
|
+
* N identical issues (one per XML file).
|
|
78
88
|
*/
|
|
79
|
-
class DwlNamingRule extends
|
|
89
|
+
class DwlNamingRule extends ProjectRule_1.ProjectRule {
|
|
80
90
|
id = 'DW-002';
|
|
81
91
|
name = 'DWL File Naming';
|
|
82
92
|
description = 'DataWeave files should follow consistent naming conventions (kebab-case recommended)';
|
|
83
93
|
severity = 'info';
|
|
84
94
|
category = 'dataweave';
|
|
85
|
-
|
|
95
|
+
validateProject(context) {
|
|
86
96
|
const issues = [];
|
|
87
97
|
const dwlDir = path.join(context.projectRoot, 'src/main/resources/dwl');
|
|
88
98
|
if (!fs.existsSync(dwlDir)) {
|
|
@@ -94,18 +104,24 @@ class DwlNamingRule extends BaseRule_1.BaseRule {
|
|
|
94
104
|
if (convention === 'any') {
|
|
95
105
|
return issues;
|
|
96
106
|
}
|
|
107
|
+
// Get configurable exempt paths (glob-style patterns relative to projectRoot).
|
|
108
|
+
// Files matching any exempt pattern are skipped entirely regardless of convention.
|
|
109
|
+
// Use this for DataWeave module directories where camelCase is required by the
|
|
110
|
+
// DataWeave runtime import system (e.g., "src/main/resources/dwl/lookups/**").
|
|
111
|
+
const exemptPaths = this.getOption(context, 'exemptPaths', []);
|
|
97
112
|
const dwlFiles = this.findDwlFiles(dwlDir);
|
|
98
113
|
for (const file of dwlFiles) {
|
|
99
114
|
const basename = path.basename(file, '.dwl');
|
|
115
|
+
// Check if this file matches any exempt path pattern
|
|
116
|
+
const relativeToDwlDir = path.relative(context.projectRoot, file);
|
|
117
|
+
if (exemptPaths.length > 0 && this.isExcluded(relativeToDwlDir, exemptPaths)) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
100
120
|
if (!this.isValidDwlName(basename, convention)) {
|
|
101
121
|
const suggestedName = this.toConvention(basename, convention);
|
|
102
|
-
issues.push({
|
|
103
|
-
line: 1,
|
|
104
|
-
message: `DWL file "${basename}.dwl" should use ${convention} naming`,
|
|
105
|
-
ruleId: this.id,
|
|
106
|
-
severity: this.severity,
|
|
122
|
+
issues.push(this.createProjectIssue(`DWL file "${basename}.dwl" should use ${convention} naming`, {
|
|
107
123
|
suggestion: `Rename to: ${suggestedName}.dwl`,
|
|
108
|
-
});
|
|
124
|
+
}));
|
|
109
125
|
}
|
|
110
126
|
}
|
|
111
127
|
return issues;
|
|
@@ -160,31 +176,31 @@ exports.DwlNamingRule = DwlNamingRule;
|
|
|
160
176
|
* DW-003: DWL Modules Usage
|
|
161
177
|
*
|
|
162
178
|
* Common DataWeave functions should be in reusable modules.
|
|
179
|
+
*
|
|
180
|
+
* This is a ProjectRule — it runs once per scan to avoid producing
|
|
181
|
+
* N identical issues (one per XML file).
|
|
163
182
|
*/
|
|
164
|
-
class DwlModulesRule extends
|
|
183
|
+
class DwlModulesRule extends ProjectRule_1.ProjectRule {
|
|
165
184
|
id = 'DW-003';
|
|
166
185
|
name = 'DWL Modules';
|
|
167
186
|
description = 'Project should have common DataWeave modules';
|
|
168
187
|
severity = 'info';
|
|
169
188
|
category = 'dataweave';
|
|
170
|
-
|
|
171
|
-
const issues = [];
|
|
189
|
+
validateProject(context) {
|
|
172
190
|
const dwlDir = path.join(context.projectRoot, 'src/main/resources/dwl');
|
|
173
191
|
if (!fs.existsSync(dwlDir)) {
|
|
174
|
-
return
|
|
192
|
+
return [];
|
|
175
193
|
}
|
|
176
194
|
const hasCommonModule = this.hasFile(dwlDir, 'common');
|
|
177
195
|
const hasUtilsModule = this.hasFile(dwlDir, 'utils');
|
|
178
196
|
if (!hasCommonModule && !hasUtilsModule) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
suggestion: 'Create common.dwl or utils.dwl for reusable functions',
|
|
185
|
-
});
|
|
197
|
+
return [
|
|
198
|
+
this.createProjectIssue('No common/utils DWL module found', {
|
|
199
|
+
suggestion: 'Create common.dwl or utils.dwl for reusable functions',
|
|
200
|
+
}),
|
|
201
|
+
];
|
|
186
202
|
}
|
|
187
|
-
return
|
|
203
|
+
return [];
|
|
188
204
|
}
|
|
189
205
|
hasFile(dir, pattern) {
|
|
190
206
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataWeaveRules.js","sourceRoot":"","sources":["../../../../src/rules/dataweave/DataWeaveRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,+CAA4C;
|
|
1
|
+
{"version":3,"file":"DataWeaveRules.js","sourceRoot":"","sources":["../../../../src/rules/dataweave/DataWeaveRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,+CAA4C;AAC5C,qDAAkD;AAElD;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,mBAAQ;IAC3C,EAAE,GAAG,QAAQ,CAAC;IACd,IAAI,GAAG,qCAAqC,CAAC;IAC7C,WAAW,GAAG,wDAAwD,CAAC;IACvE,QAAQ,GAAG,SAAkB,CAAC;IAC9B,QAAQ,GAAG,WAAoB,CAAC;IAEhC,QAAQ,CAAC,GAAa,EAAE,OAA0B;QAChD,MAAM,MAAM,GAAY,EAAE,CAAC;QAC3B,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAErE,gCAAgC;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAC;QAErE,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,kCAAkC,EAAE,SAAqB,CAAC,CAAC;YAE1F,KAAK,MAAM,OAAO,IAAI,UAAU,EAAE,CAAC;gBACjC,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;gBAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAA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@@
|
|
|
1
|
+
import { ValidationContext, Issue, IssueType } from '../../types';
|
|
2
|
+
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
/**
|
|
4
|
+
* DW-005: Duplicate Transform Logic
|
|
5
|
+
*
|
|
6
|
+
* Flags flows that contain multiple DataWeave transform-message blocks
|
|
7
|
+
* with identical or near-identical body content. Duplicated transforms
|
|
8
|
+
* should be extracted into reusable .dwl modules under src/main/resources/dw/.
|
|
9
|
+
*
|
|
10
|
+
* This rule checks for duplicate ee:transform → ee:message → ee:set-payload
|
|
11
|
+
* content within the same file. It compares the text content of set-payload
|
|
12
|
+
* elements and flags exact duplicates.
|
|
13
|
+
*/
|
|
14
|
+
export declare class DuplicateTransformLogicRule extends BaseRule {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
severity: "info";
|
|
19
|
+
category: "dataweave";
|
|
20
|
+
issueType: IssueType;
|
|
21
|
+
/** Minimum length of transform content to consider for duplication check */
|
|
22
|
+
private readonly MIN_CONTENT_LENGTH;
|
|
23
|
+
validate(doc: Document, _context: ValidationContext): Issue[];
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=DuplicateTransformLogicRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DuplicateTransformLogicRule.d.ts","sourceRoot":"","sources":["../../../../src/rules/dataweave/DuplicateTransformLogicRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,qBAAa,2BAA4B,SAAQ,QAAQ;IACvD,EAAE,SAAY;IACd,IAAI,SAA+B;IACnC,WAAW,SAC6E;IACxF,QAAQ,EAAG,MAAM,CAAU;IAC3B,QAAQ,EAAG,WAAW,CAAU;IAChC,SAAS,EAAE,SAAS,CAAgB;IAEpC,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAM;IAEzC,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,KAAK,EAAE;CA0D9D"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DuplicateTransformLogicRule = void 0;
|
|
4
|
+
const BaseRule_1 = require("../base/BaseRule");
|
|
5
|
+
/**
|
|
6
|
+
* DW-005: Duplicate Transform Logic
|
|
7
|
+
*
|
|
8
|
+
* Flags flows that contain multiple DataWeave transform-message blocks
|
|
9
|
+
* with identical or near-identical body content. Duplicated transforms
|
|
10
|
+
* should be extracted into reusable .dwl modules under src/main/resources/dw/.
|
|
11
|
+
*
|
|
12
|
+
* This rule checks for duplicate ee:transform → ee:message → ee:set-payload
|
|
13
|
+
* content within the same file. It compares the text content of set-payload
|
|
14
|
+
* elements and flags exact duplicates.
|
|
15
|
+
*/
|
|
16
|
+
class DuplicateTransformLogicRule extends BaseRule_1.BaseRule {
|
|
17
|
+
id = 'DW-005';
|
|
18
|
+
name = 'Duplicate Transform Logic';
|
|
19
|
+
description = 'Duplicate DataWeave transform blocks should be extracted into reusable .dwl modules';
|
|
20
|
+
severity = 'info';
|
|
21
|
+
category = 'dataweave';
|
|
22
|
+
issueType = 'code-smell';
|
|
23
|
+
/** Minimum length of transform content to consider for duplication check */
|
|
24
|
+
MIN_CONTENT_LENGTH = 20;
|
|
25
|
+
validate(doc, _context) {
|
|
26
|
+
const issues = [];
|
|
27
|
+
// Find all ee:transform → ee:set-payload elements
|
|
28
|
+
const transforms = this.select('//*[local-name()="transform"]/*[local-name()="message"]/*[local-name()="set-payload"]', doc);
|
|
29
|
+
// Also check top-level set-payload in transforms without message wrapper
|
|
30
|
+
const directTransforms = this.select('//*[local-name()="transform"]/*[local-name()="set-payload"]', doc);
|
|
31
|
+
const allPayloads = [...transforms, ...directTransforms];
|
|
32
|
+
// Collect transform content for duplication detection
|
|
33
|
+
const contentMap = new Map();
|
|
34
|
+
for (const payload of allPayloads) {
|
|
35
|
+
const content = (payload.textContent ?? '').trim();
|
|
36
|
+
// Skip short/trivial transforms and resource references
|
|
37
|
+
if (content.length < this.MIN_CONTENT_LENGTH) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (content.startsWith('${') || content.includes('readUrl')) {
|
|
41
|
+
continue; // Already using externalized DWL
|
|
42
|
+
}
|
|
43
|
+
const normalized = content.replace(/\s+/g, ' ');
|
|
44
|
+
const nodes = contentMap.get(normalized) ?? [];
|
|
45
|
+
nodes.push(payload);
|
|
46
|
+
contentMap.set(normalized, nodes);
|
|
47
|
+
}
|
|
48
|
+
// Flag duplicates
|
|
49
|
+
for (const [, nodes] of contentMap) {
|
|
50
|
+
if (nodes.length > 1) {
|
|
51
|
+
// Only flag the second and subsequent occurrences
|
|
52
|
+
for (let i = 1; i < nodes.length; i++) {
|
|
53
|
+
issues.push(this.createIssue(nodes[i], `Duplicate DataWeave transform logic found (${nodes.length} identical blocks in file)`, {
|
|
54
|
+
suggestion: 'Extract the shared DataWeave logic into a reusable .dwl file under src/main/resources/dw/ and reference it with readUrl("classpath://dw/transform.dwl")',
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return issues;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.DuplicateTransformLogicRule = DuplicateTransformLogicRule;
|
|
63
|
+
//# sourceMappingURL=DuplicateTransformLogicRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DuplicateTransformLogicRule.js","sourceRoot":"","sources":["../../../../src/rules/dataweave/DuplicateTransformLogicRule.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C;;;;;;;;;;GAUG;AACH,MAAa,2BAA4B,SAAQ,mBAAQ;IACvD,EAA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CAAC;YACpB,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC;QAED,kBAAkB;QAClB,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,UAAU,EAAE,CAAC;YACnC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,kDAAkD;gBAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACtC,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,WAAW,CACd,KAAK,CAAC,CAAC,CAAC,EACR,8CAA8C,KAAK,CAAC,MAAM,4BAA4B,EACtF;wBACE,UAAU,EACR,yJAAyJ;qBAC5J,CACF,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAtED,kEAsEC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ValidationContext, Issue, IssueType } from '../../types';
|
|
2
|
+
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
/**
|
|
4
|
+
* ERR-004: Catch-All Must Be Last
|
|
5
|
+
*
|
|
6
|
+
* When type="ANY" (or no type attribute — implicit catch-all) is used in
|
|
7
|
+
* an error handler, it must be the last on-error block. Placing a catch-all
|
|
8
|
+
* before specific error types makes those specific handlers unreachable.
|
|
9
|
+
*
|
|
10
|
+
* Real-world pattern from accelerators: type="ANY" is always the final
|
|
11
|
+
* on-error-propagate, typically mapping to HTTP 500.
|
|
12
|
+
*/
|
|
13
|
+
export declare class CatchAllLastRule extends BaseRule {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
severity: "error";
|
|
18
|
+
category: "error-handling";
|
|
19
|
+
issueType: IssueType;
|
|
20
|
+
private readonly CATCH_ALL_TYPES;
|
|
21
|
+
validate(doc: Document, _context: ValidationContext): Issue[];
|
|
22
|
+
private findParentFlowName;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=CatchAllLastRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CatchAllLastRule.d.ts","sourceRoot":"","sources":["../../../../src/rules/error-handling/CatchAllLastRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;;;;;GASG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ;IAC5C,EAAE,SAAa;IACf,IAAI,SAA4B;IAChC,WAAW,SAC8E;IACzF,QAAQ,EAAG,OAAO,CAAU;IAC5B,QAAQ,EAAG,gBAAgB,CAAU;IACrC,SAAS,EAAE,SAAS,CAAS;IAE7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuB;IAEvD,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,KAAK,EAAE;IAkD7D,OAAO,CAAC,kBAAkB;CAU3B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CatchAllLastRule = void 0;
|
|
4
|
+
const BaseRule_1 = require("../base/BaseRule");
|
|
5
|
+
/**
|
|
6
|
+
* ERR-004: Catch-All Must Be Last
|
|
7
|
+
*
|
|
8
|
+
* When type="ANY" (or no type attribute — implicit catch-all) is used in
|
|
9
|
+
* an error handler, it must be the last on-error block. Placing a catch-all
|
|
10
|
+
* before specific error types makes those specific handlers unreachable.
|
|
11
|
+
*
|
|
12
|
+
* Real-world pattern from accelerators: type="ANY" is always the final
|
|
13
|
+
* on-error-propagate, typically mapping to HTTP 500.
|
|
14
|
+
*/
|
|
15
|
+
class CatchAllLastRule extends BaseRule_1.BaseRule {
|
|
16
|
+
id = 'ERR-004';
|
|
17
|
+
name = 'Catch-All Must Be Last';
|
|
18
|
+
description = 'type="ANY" or implicit catch-all must be the last on-error block in an error handler';
|
|
19
|
+
severity = 'error';
|
|
20
|
+
category = 'error-handling';
|
|
21
|
+
issueType = 'bug';
|
|
22
|
+
CATCH_ALL_TYPES = ['ANY', 'MULE:ANY'];
|
|
23
|
+
validate(doc, _context) {
|
|
24
|
+
const issues = [];
|
|
25
|
+
const errorHandlers = this.select('//mule:error-handler', doc);
|
|
26
|
+
for (const handler of errorHandlers) {
|
|
27
|
+
// Collect all on-error-* children in document order
|
|
28
|
+
const children = this.select('./*[local-name()="on-error-continue" or local-name()="on-error-propagate"]', handler);
|
|
29
|
+
if (children.length <= 1) {
|
|
30
|
+
continue; // Single handler — nothing to check
|
|
31
|
+
}
|
|
32
|
+
// Check each child except the last
|
|
33
|
+
for (let i = 0; i < children.length - 1; i++) {
|
|
34
|
+
const child = children[i];
|
|
35
|
+
const typeAttr = this.getAttribute(child, 'type');
|
|
36
|
+
const isCatchAll = typeAttr === null ||
|
|
37
|
+
typeAttr === undefined ||
|
|
38
|
+
typeAttr.trim() === '' ||
|
|
39
|
+
this.CATCH_ALL_TYPES.includes(typeAttr.trim().toUpperCase());
|
|
40
|
+
if (isCatchAll) {
|
|
41
|
+
const handlerName = this.getAttribute(handler, 'name') ?? this.findParentFlowName(handler) ?? 'unnamed';
|
|
42
|
+
const blockType = child.nodeName.includes('continue')
|
|
43
|
+
? 'on-error-continue'
|
|
44
|
+
: 'on-error-propagate';
|
|
45
|
+
issues.push(this.createIssue(child, `Catch-all ${blockType}${typeAttr ? ` (type="${typeAttr}")` : ''} is not the last handler in "${handlerName}" — subsequent handlers are unreachable`, {
|
|
46
|
+
suggestion: 'Move the catch-all (type="ANY") block to be the last on-error handler',
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return issues;
|
|
52
|
+
}
|
|
53
|
+
findParentFlowName(node) {
|
|
54
|
+
let current = node.parentNode;
|
|
55
|
+
while (current) {
|
|
56
|
+
if (current.nodeName === 'flow' || current.nodeName === 'mule:flow') {
|
|
57
|
+
return current.getAttribute('name');
|
|
58
|
+
}
|
|
59
|
+
current = current.parentNode;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.CatchAllLastRule = CatchAllLastRule;
|
|
65
|
+
//# sourceMappingURL=CatchAllLastRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CatchAllLastRule.js","sourceRoot":"","sources":["../../../../src/rules/error-handling/CatchAllLastRule.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C;;;;;;;;;GASG;AACH,MAAa,gBAAiB,SAAQ,mBAAQ;IAC5C,EAAE,GAAG,SAAS,CAAC;IACf,IAAI,GAAG,wBAAwB,CAAC;IAChC,WAAW,GACT,sFAAsF,CAAC;IACzF,QAAQ,GAAG,OAAgB,CAAC;IAC5B,QAAQ,GAAG,gBAAyB,CAAC;IACrC,SAAS,GAAc,KAAK,CAAC;IAEZ,eAAe,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAEvD,QAAQ,CAAC,GAAa,EAAE,QAA2B;QACjD,MAAM,MAAM,GAAY,EAAE,CAAC;QAE3B,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;QAE/D,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE,CAAC;YACpC,oDAAoD;YACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAC1B,4EAA4E,EAC5E,OAAmB,CACpB,CAAC;YAEF,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBACzB,SAAS,CAAC,oCAAoC;YAChD,CAAC;YAED,mCAAmC;YACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,C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AAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACnD,CAAC;YACD,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAvED,4CAuEC"}
|
|
@@ -5,6 +5,13 @@ import { BaseRule } from '../base/BaseRule';
|
|
|
5
5
|
*
|
|
6
6
|
* Error handlers should include correlation ID for traceability.
|
|
7
7
|
* This helps track errors across distributed systems.
|
|
8
|
+
*
|
|
9
|
+
* The rule checks three patterns:
|
|
10
|
+
* 1. Inline correlationId reference in the error handler XML text/attributes
|
|
11
|
+
* 2. External DWL file referenced via resource="..." attribute on ee:set-payload
|
|
12
|
+
* (the DWL file content is read from disk and inspected)
|
|
13
|
+
* 3. If a resource reference exists but the file cannot be read, the issue is
|
|
14
|
+
* downgraded to 'info' to avoid false positives on valid code
|
|
8
15
|
*/
|
|
9
16
|
export declare class CorrelationIdRule extends BaseRule {
|
|
10
17
|
id: string;
|
|
@@ -14,11 +21,25 @@ export declare class CorrelationIdRule extends BaseRule {
|
|
|
14
21
|
category: "error-handling";
|
|
15
22
|
issueType: IssueType;
|
|
16
23
|
private readonly CORRELATION_PATTERNS;
|
|
17
|
-
validate(doc: Document,
|
|
24
|
+
validate(doc: Document, context: ValidationContext): Issue[];
|
|
25
|
+
/**
|
|
26
|
+
* Inspect resource="..." attributes on ee:set-payload (and similar) elements
|
|
27
|
+
* within the error handler.
|
|
28
|
+
*
|
|
29
|
+
* @returns
|
|
30
|
+
* 'found' — correlationId pattern detected in a referenced DWL file
|
|
31
|
+
* 'unresolvable' — resource reference exists but could not be read
|
|
32
|
+
* 'not-found' — no resource references present or none contain correlationId
|
|
33
|
+
*/
|
|
34
|
+
private checkResourceReferences;
|
|
18
35
|
/**
|
|
19
36
|
* Check if a node or its descendants contain correlation ID reference
|
|
20
37
|
*/
|
|
21
38
|
private containsCorrelationId;
|
|
39
|
+
/**
|
|
40
|
+
* Check whether a raw file content string contains a correlationId pattern
|
|
41
|
+
*/
|
|
42
|
+
private contentContainsCorrelationId;
|
|
22
43
|
/**
|
|
23
44
|
* Find the parent flow element for context
|
|
24
45
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CorrelationIdRule.d.ts","sourceRoot":"","sources":["../../../../src/rules/error-handling/CorrelationIdRule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CorrelationIdRule.d.ts","sourceRoot":"","sources":["../../../../src/rules/error-handling/CorrelationIdRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C;;;;;;;;;;;;GAYG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,EAAE,SAAc;IAChB,IAAI,SAAqC;IACzC,WAAW,SAA2E;IACtF,QAAQ,EAAG,SAAS,CAAU;IAC9B,QAAQ,EAAG,gBAAgB,CAAU;IACrC,SAAS,EAAE,SAAS,CAAS;IAG7B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CASnC;IAEF,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;IAwD5D;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB;IAqC/B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAyB7B;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAKpC;;OAEG;IACH,OAAO,CAAC,cAAc;CAUvB"}
|
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.CorrelationIdRule = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
4
39
|
const BaseRule_1 = require("../base/BaseRule");
|
|
5
40
|
const XPathHelper_1 = require("../../core/XPathHelper");
|
|
6
41
|
/**
|
|
@@ -8,6 +43,13 @@ const XPathHelper_1 = require("../../core/XPathHelper");
|
|
|
8
43
|
*
|
|
9
44
|
* Error handlers should include correlation ID for traceability.
|
|
10
45
|
* This helps track errors across distributed systems.
|
|
46
|
+
*
|
|
47
|
+
* The rule checks three patterns:
|
|
48
|
+
* 1. Inline correlationId reference in the error handler XML text/attributes
|
|
49
|
+
* 2. External DWL file referenced via resource="..." attribute on ee:set-payload
|
|
50
|
+
* (the DWL file content is read from disk and inspected)
|
|
51
|
+
* 3. If a resource reference exists but the file cannot be read, the issue is
|
|
52
|
+
* downgraded to 'info' to avoid false positives on valid code
|
|
11
53
|
*/
|
|
12
54
|
class CorrelationIdRule extends BaseRule_1.BaseRule {
|
|
13
55
|
id = 'MULE-007';
|
|
@@ -27,7 +69,7 @@ class CorrelationIdRule extends BaseRule_1.BaseRule {
|
|
|
27
69
|
'requestId',
|
|
28
70
|
'request-id',
|
|
29
71
|
];
|
|
30
|
-
validate(doc,
|
|
72
|
+
validate(doc, context) {
|
|
31
73
|
const issues = [];
|
|
32
74
|
// Find error handlers
|
|
33
75
|
const errorHandlers = this.select('//mule:error-handler', doc);
|
|
@@ -35,16 +77,68 @@ class CorrelationIdRule extends BaseRule_1.BaseRule {
|
|
|
35
77
|
const handlerName = this.getNameAttribute(handler);
|
|
36
78
|
const parentFlow = this.findParentFlow(handler);
|
|
37
79
|
const contextName = handlerName ?? parentFlow ?? 'unnamed';
|
|
38
|
-
// Check
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
80
|
+
// Check inline text/attribute content first
|
|
81
|
+
if (this.containsCorrelationId(handler)) {
|
|
82
|
+
continue; // Found inline — pass
|
|
83
|
+
}
|
|
84
|
+
// Check resource= references to external DWL files
|
|
85
|
+
const resourceResult = this.checkResourceReferences(handler, context.projectRoot);
|
|
86
|
+
if (resourceResult === 'found') {
|
|
87
|
+
continue; // Found in referenced DWL file — pass
|
|
88
|
+
}
|
|
89
|
+
if (resourceResult === 'unresolvable') {
|
|
90
|
+
// Resource reference exists but file cannot be read; cannot determine
|
|
91
|
+
// whether correlationId is present. Downgrade to info to avoid false positive.
|
|
92
|
+
issues.push(this.createIssue(handler, `Error handler in "${contextName}" delegates to an external DWL file — verify correlationId is included`, {
|
|
93
|
+
severity: 'info',
|
|
94
|
+
suggestion: 'Ensure the referenced DWL resource file includes correlationId in its output',
|
|
43
95
|
}));
|
|
96
|
+
continue;
|
|
44
97
|
}
|
|
98
|
+
// No correlationId found anywhere
|
|
99
|
+
issues.push(this.createIssue(handler, `Error handler in "${contextName}" should include correlationId for traceability`, {
|
|
100
|
+
suggestion: 'Include correlationId in error response or logging for distributed tracing',
|
|
101
|
+
}));
|
|
45
102
|
}
|
|
46
103
|
return issues;
|
|
47
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Inspect resource="..." attributes on ee:set-payload (and similar) elements
|
|
107
|
+
* within the error handler.
|
|
108
|
+
*
|
|
109
|
+
* @returns
|
|
110
|
+
* 'found' — correlationId pattern detected in a referenced DWL file
|
|
111
|
+
* 'unresolvable' — resource reference exists but could not be read
|
|
112
|
+
* 'not-found' — no resource references present or none contain correlationId
|
|
113
|
+
*/
|
|
114
|
+
checkResourceReferences(handler, projectRoot) {
|
|
115
|
+
// Look for any element with a resource= attribute (covers ee:set-payload, ee:set-variable, etc.)
|
|
116
|
+
const elementsWithResource = this.select('.//*[@resource]', handler);
|
|
117
|
+
if (elementsWithResource.length === 0) {
|
|
118
|
+
return 'not-found';
|
|
119
|
+
}
|
|
120
|
+
let hasUnresolvable = false;
|
|
121
|
+
for (const el of elementsWithResource) {
|
|
122
|
+
const resourceAttr = this.getAttribute(el, 'resource') ?? '';
|
|
123
|
+
if (!resourceAttr) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
// Resolve relative to src/main/resources/ (standard Mule resource path)
|
|
127
|
+
const fullPath = path.join(projectRoot, 'src', 'main', 'resources', resourceAttr);
|
|
128
|
+
try {
|
|
129
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
130
|
+
if (this.contentContainsCorrelationId(content)) {
|
|
131
|
+
return 'found';
|
|
132
|
+
}
|
|
133
|
+
// File read successfully but no correlationId found — continue checking others
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// File not readable — mark as unresolvable but keep checking other resources
|
|
137
|
+
hasUnresolvable = true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return hasUnresolvable ? 'unresolvable' : 'not-found';
|
|
141
|
+
}
|
|
48
142
|
/**
|
|
49
143
|
* Check if a node or its descendants contain correlation ID reference
|
|
50
144
|
*/
|
|
@@ -69,6 +163,13 @@ class CorrelationIdRule extends BaseRule_1.BaseRule {
|
|
|
69
163
|
}
|
|
70
164
|
return false;
|
|
71
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Check whether a raw file content string contains a correlationId pattern
|
|
168
|
+
*/
|
|
169
|
+
contentContainsCorrelationId(content) {
|
|
170
|
+
const lower = content.toLowerCase();
|
|
171
|
+
return this.CORRELATION_PATTERNS.some((p) => lower.includes(p.toLowerCase()));
|
|
172
|
+
}
|
|
72
173
|
/**
|
|
73
174
|
* Find the parent flow element for context
|
|
74
175
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CorrelationIdRule.js","sourceRoot":"","sources":["../../../../src/rules/error-handling/CorrelationIdRule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CorrelationIdRule.js","sourceRoot":"","sources":["../../../../src/rules/error-handling/CorrelationIdRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,+CAA4C;AAC5C,wDAAwD;AAExD;;;;;;;;;;;;GAYG;AACH,MAAa,iBAAkB,SAAQ,mBAAQ;IAC7C,EAAE,GAAG,UAAU,CAAC;IAChB,IAAI,GAAG,iCAAiC,CAAC;IACzC,WAAW,GAAG,uEAAuE,CAAC;IACtF,QAAQ,GAAG,SAAkB,CAAC;IAC9B,QAAQ,GAAG,gBAAyB,CAAC;IACrC,SAAS,GAAc,KAAK,CAAC;IAE7B,sDAAsD;IACrC,oBAAoB,GAA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C,CAAC;YAC5C,CAAC;YACD,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA3KD,8CA2KC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ValidationContext, Issue, IssueType } from '../../types';
|
|
2
|
+
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
/**
|
|
4
|
+
* ERR-002: Error Handler Type Coverage
|
|
5
|
+
*
|
|
6
|
+
* SAPI error handlers should cover the standard APIKit error types
|
|
7
|
+
* (BAD_REQUEST, NOT_FOUND, METHOD_NOT_ALLOWED, NOT_ACCEPTABLE,
|
|
8
|
+
* UNSUPPORTED_MEDIA_TYPE) when an APIKit router is present.
|
|
9
|
+
*
|
|
10
|
+
* Inspired by real-world accelerator patterns where both Salesforce and
|
|
11
|
+
* NetSuite SAPIs consistently cover these types for proper HTTP status
|
|
12
|
+
* code mapping.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ErrorHandlerTypeCoverageRule extends BaseRule {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
severity: "warning";
|
|
19
|
+
category: "error-handling";
|
|
20
|
+
issueType: IssueType;
|
|
21
|
+
/**
|
|
22
|
+
* Minimum set of APIKit error types that a well-structured SAPI should handle.
|
|
23
|
+
* These correspond to standard HTTP status codes that APIKit can generate.
|
|
24
|
+
*/
|
|
25
|
+
private readonly REQUIRED_APIKIT_TYPES;
|
|
26
|
+
validate(doc: Document, context: ValidationContext): Issue[];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ErrorHandlerTypeCoverageRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorHandlerTypeCoverageRule.d.ts","sourceRoot":"","sources":["../../../../src/rules/error-handling/ErrorHandlerTypeCoverageRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,qBAAa,4BAA6B,SAAQ,QAAQ;IACxD,EAAE,SAAa;IACf,IAAI,SAAiC;IACrC,WAAW,SAAgF;IAC3F,QAAQ,EAAG,SAAS,CAAU;IAC9B,QAAQ,EAAG,gBAAgB,CAAU;IACrC,SAAS,EAAE,SAAS,CAAS;IAE7B;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAMpC;IAEF,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;CAkD7D"}
|