@sfdxy/mule-lint 1.4.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 +413 -0
- package/dist/bin/mule-lint.d.ts +3 -0
- package/dist/bin/mule-lint.d.ts.map +1 -0
- package/dist/bin/mule-lint.js +123 -0
- package/dist/bin/mule-lint.js.map +1 -0
- package/dist/src/core/ComplexityCalculator.d.ts +42 -0
- package/dist/src/core/ComplexityCalculator.d.ts.map +1 -0
- package/dist/src/core/ComplexityCalculator.js +123 -0
- package/dist/src/core/ComplexityCalculator.js.map +1 -0
- package/dist/src/core/FileScanner.d.ts +58 -0
- package/dist/src/core/FileScanner.d.ts.map +1 -0
- package/dist/src/core/FileScanner.js +161 -0
- package/dist/src/core/FileScanner.js.map +1 -0
- package/dist/src/core/XPathHelper.d.ts +81 -0
- package/dist/src/core/XPathHelper.d.ts.map +1 -0
- package/dist/src/core/XPathHelper.js +229 -0
- package/dist/src/core/XPathHelper.js.map +1 -0
- package/dist/src/core/XmlParser.d.ts +38 -0
- package/dist/src/core/XmlParser.d.ts.map +1 -0
- package/dist/src/core/XmlParser.js +131 -0
- package/dist/src/core/XmlParser.js.map +1 -0
- package/dist/src/core/YamlParser.d.ts +30 -0
- package/dist/src/core/YamlParser.d.ts.map +1 -0
- package/dist/src/core/YamlParser.js +120 -0
- package/dist/src/core/YamlParser.js.map +1 -0
- package/dist/src/core/index.d.ts +4 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +21 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/engine/LintEngine.d.ts +60 -0
- package/dist/src/engine/LintEngine.d.ts.map +1 -0
- package/dist/src/engine/LintEngine.js +271 -0
- package/dist/src/engine/LintEngine.js.map +1 -0
- package/dist/src/engine/index.d.ts +2 -0
- package/dist/src/engine/index.d.ts.map +1 -0
- package/dist/src/engine/index.js +18 -0
- package/dist/src/engine/index.js.map +1 -0
- package/dist/src/formatters/JsonFormatter.d.ts +18 -0
- package/dist/src/formatters/JsonFormatter.d.ts.map +1 -0
- package/dist/src/formatters/JsonFormatter.js +45 -0
- package/dist/src/formatters/JsonFormatter.js.map +1 -0
- package/dist/src/formatters/SarifFormatter.d.ts +8 -0
- package/dist/src/formatters/SarifFormatter.d.ts.map +1 -0
- package/dist/src/formatters/SarifFormatter.js +115 -0
- package/dist/src/formatters/SarifFormatter.js.map +1 -0
- package/dist/src/formatters/TableFormatter.d.ts +10 -0
- package/dist/src/formatters/TableFormatter.d.ts.map +1 -0
- package/dist/src/formatters/TableFormatter.js +100 -0
- package/dist/src/formatters/TableFormatter.js.map +1 -0
- package/dist/src/formatters/index.d.ts +10 -0
- package/dist/src/formatters/index.d.ts.map +1 -0
- package/dist/src/formatters/index.js +42 -0
- package/dist/src/formatters/index.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +28 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/rules/api-led/ApiLedRules.d.ts +42 -0
- package/dist/src/rules/api-led/ApiLedRules.d.ts.map +1 -0
- package/dist/src/rules/api-led/ApiLedRules.js +95 -0
- package/dist/src/rules/api-led/ApiLedRules.js.map +1 -0
- package/dist/src/rules/base/BaseRule.d.ts +89 -0
- package/dist/src/rules/base/BaseRule.d.ts.map +1 -0
- package/dist/src/rules/base/BaseRule.js +137 -0
- package/dist/src/rules/base/BaseRule.js.map +1 -0
- package/dist/src/rules/complexity/FlowComplexityRule.d.ts +18 -0
- package/dist/src/rules/complexity/FlowComplexityRule.d.ts.map +1 -0
- package/dist/src/rules/complexity/FlowComplexityRule.js +58 -0
- package/dist/src/rules/complexity/FlowComplexityRule.js.map +1 -0
- package/dist/src/rules/dataweave/DataWeaveRules.d.ts +45 -0
- package/dist/src/rules/dataweave/DataWeaveRules.d.ts.map +1 -0
- package/dist/src/rules/dataweave/DataWeaveRules.js +168 -0
- package/dist/src/rules/dataweave/DataWeaveRules.js.map +1 -0
- package/dist/src/rules/documentation/FlowDescriptionRule.d.ts +16 -0
- package/dist/src/rules/documentation/FlowDescriptionRule.d.ts.map +1 -0
- package/dist/src/rules/documentation/FlowDescriptionRule.js +33 -0
- package/dist/src/rules/documentation/FlowDescriptionRule.js.map +1 -0
- package/dist/src/rules/documentation/MissingDocNameRule.d.ts +17 -0
- package/dist/src/rules/documentation/MissingDocNameRule.d.ts.map +1 -0
- package/dist/src/rules/documentation/MissingDocNameRule.js +44 -0
- package/dist/src/rules/documentation/MissingDocNameRule.js.map +1 -0
- package/dist/src/rules/error-handling/CorrelationIdRule.d.ts +26 -0
- package/dist/src/rules/error-handling/CorrelationIdRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/CorrelationIdRule.js +86 -0
- package/dist/src/rules/error-handling/CorrelationIdRule.js.map +1 -0
- package/dist/src/rules/error-handling/GenericErrorRule.d.ts +22 -0
- package/dist/src/rules/error-handling/GenericErrorRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/GenericErrorRule.js +51 -0
- package/dist/src/rules/error-handling/GenericErrorRule.js.map +1 -0
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.d.ts +17 -0
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js +77 -0
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js.map +1 -0
- package/dist/src/rules/error-handling/HttpStatusRule.d.ts +21 -0
- package/dist/src/rules/error-handling/HttpStatusRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/HttpStatusRule.js +57 -0
- package/dist/src/rules/error-handling/HttpStatusRule.js.map +1 -0
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.d.ts +17 -0
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.js +51 -0
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.js.map +1 -0
- package/dist/src/rules/experimental/ExperimentalRules.d.ts +43 -0
- package/dist/src/rules/experimental/ExperimentalRules.d.ts.map +1 -0
- package/dist/src/rules/experimental/ExperimentalRules.js +92 -0
- package/dist/src/rules/experimental/ExperimentalRules.js.map +1 -0
- package/dist/src/rules/http/HttpContentTypeRule.d.ts +17 -0
- package/dist/src/rules/http/HttpContentTypeRule.d.ts.map +1 -0
- package/dist/src/rules/http/HttpContentTypeRule.js +50 -0
- package/dist/src/rules/http/HttpContentTypeRule.js.map +1 -0
- package/dist/src/rules/http/HttpTimeoutRule.d.ts +16 -0
- package/dist/src/rules/http/HttpTimeoutRule.d.ts.map +1 -0
- package/dist/src/rules/http/HttpTimeoutRule.js +33 -0
- package/dist/src/rules/http/HttpTimeoutRule.js.map +1 -0
- package/dist/src/rules/http/HttpUserAgentRule.d.ts +17 -0
- package/dist/src/rules/http/HttpUserAgentRule.d.ts.map +1 -0
- package/dist/src/rules/http/HttpUserAgentRule.js +48 -0
- package/dist/src/rules/http/HttpUserAgentRule.js.map +1 -0
- package/dist/src/rules/index.d.ts +45 -0
- package/dist/src/rules/index.d.ts.map +1 -0
- package/dist/src/rules/index.js +205 -0
- package/dist/src/rules/index.js.map +1 -0
- package/dist/src/rules/logging/LoggerCategoryRule.d.ts +21 -0
- package/dist/src/rules/logging/LoggerCategoryRule.d.ts.map +1 -0
- package/dist/src/rules/logging/LoggerCategoryRule.js +61 -0
- package/dist/src/rules/logging/LoggerCategoryRule.js.map +1 -0
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.d.ts +16 -0
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.d.ts.map +1 -0
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.js +29 -0
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.js.map +1 -0
- package/dist/src/rules/logging/LoggerPayloadRule.d.ts +17 -0
- package/dist/src/rules/logging/LoggerPayloadRule.d.ts.map +1 -0
- package/dist/src/rules/logging/LoggerPayloadRule.js +39 -0
- package/dist/src/rules/logging/LoggerPayloadRule.js.map +1 -0
- package/dist/src/rules/naming/FlowCasingRule.d.ts +18 -0
- package/dist/src/rules/naming/FlowCasingRule.d.ts.map +1 -0
- package/dist/src/rules/naming/FlowCasingRule.js +40 -0
- package/dist/src/rules/naming/FlowCasingRule.js.map +1 -0
- package/dist/src/rules/naming/FlowNamingRule.d.ts +17 -0
- package/dist/src/rules/naming/FlowNamingRule.d.ts.map +1 -0
- package/dist/src/rules/naming/FlowNamingRule.js +60 -0
- package/dist/src/rules/naming/FlowNamingRule.js.map +1 -0
- package/dist/src/rules/naming/VariableNamingRule.d.ts +18 -0
- package/dist/src/rules/naming/VariableNamingRule.d.ts.map +1 -0
- package/dist/src/rules/naming/VariableNamingRule.js +39 -0
- package/dist/src/rules/naming/VariableNamingRule.js.map +1 -0
- package/dist/src/rules/performance/AsyncErrorHandlerRule.d.ts +16 -0
- package/dist/src/rules/performance/AsyncErrorHandlerRule.d.ts.map +1 -0
- package/dist/src/rules/performance/AsyncErrorHandlerRule.js +34 -0
- package/dist/src/rules/performance/AsyncErrorHandlerRule.js.map +1 -0
- package/dist/src/rules/performance/LargeChoiceBlockRule.d.ts +16 -0
- package/dist/src/rules/performance/LargeChoiceBlockRule.d.ts.map +1 -0
- package/dist/src/rules/performance/LargeChoiceBlockRule.js +32 -0
- package/dist/src/rules/performance/LargeChoiceBlockRule.js.map +1 -0
- package/dist/src/rules/performance/ScatterGatherRoutesRule.d.ts +16 -0
- package/dist/src/rules/performance/ScatterGatherRoutesRule.d.ts.map +1 -0
- package/dist/src/rules/performance/ScatterGatherRoutesRule.js +32 -0
- package/dist/src/rules/performance/ScatterGatherRoutesRule.js.map +1 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.d.ts +19 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.d.ts.map +1 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.js +66 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.js.map +1 -0
- package/dist/src/rules/security/HardcodedHttpRule.d.ts +33 -0
- package/dist/src/rules/security/HardcodedHttpRule.d.ts.map +1 -0
- package/dist/src/rules/security/HardcodedHttpRule.js +108 -0
- package/dist/src/rules/security/HardcodedHttpRule.js.map +1 -0
- package/dist/src/rules/security/InsecureTlsRule.d.ts +16 -0
- package/dist/src/rules/security/InsecureTlsRule.d.ts.map +1 -0
- package/dist/src/rules/security/InsecureTlsRule.js +36 -0
- package/dist/src/rules/security/InsecureTlsRule.js.map +1 -0
- package/dist/src/rules/standards/ChoiceAntiPatternRule.d.ts +17 -0
- package/dist/src/rules/standards/ChoiceAntiPatternRule.d.ts.map +1 -0
- package/dist/src/rules/standards/ChoiceAntiPatternRule.js +43 -0
- package/dist/src/rules/standards/ChoiceAntiPatternRule.js.map +1 -0
- package/dist/src/rules/standards/DeprecatedComponentRule.d.ts +17 -0
- package/dist/src/rules/standards/DeprecatedComponentRule.d.ts.map +1 -0
- package/dist/src/rules/standards/DeprecatedComponentRule.js +37 -0
- package/dist/src/rules/standards/DeprecatedComponentRule.js.map +1 -0
- package/dist/src/rules/standards/DwlStandardsRule.d.ts +22 -0
- package/dist/src/rules/standards/DwlStandardsRule.d.ts.map +1 -0
- package/dist/src/rules/standards/DwlStandardsRule.js +90 -0
- package/dist/src/rules/standards/DwlStandardsRule.js.map +1 -0
- package/dist/src/rules/structure/StructureRules.d.ts +45 -0
- package/dist/src/rules/structure/StructureRules.d.ts.map +1 -0
- package/dist/src/rules/structure/StructureRules.js +163 -0
- package/dist/src/rules/structure/StructureRules.js.map +1 -0
- package/dist/src/rules/yaml/YamlRules.d.ts +46 -0
- package/dist/src/rules/yaml/YamlRules.d.ts.map +1 -0
- package/dist/src/rules/yaml/YamlRules.js +226 -0
- package/dist/src/rules/yaml/YamlRules.js.map +1 -0
- package/dist/src/types/Config.d.ts +50 -0
- package/dist/src/types/Config.d.ts.map +1 -0
- package/dist/src/types/Config.js +18 -0
- package/dist/src/types/Config.js.map +1 -0
- package/dist/src/types/Report.d.ts +47 -0
- package/dist/src/types/Report.d.ts.map +1 -0
- package/dist/src/types/Report.js +3 -0
- package/dist/src/types/Report.js.map +1 -0
- package/dist/src/types/Rule.d.ts +76 -0
- package/dist/src/types/Rule.d.ts.map +1 -0
- package/dist/src/types/Rule.js +3 -0
- package/dist/src/types/Rule.js.map +1 -0
- package/dist/src/types/index.d.ts +4 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +21 -0
- package/dist/src/types/index.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeprecatedComponentRule = void 0;
|
|
4
|
+
const BaseRule_1 = require("../base/BaseRule");
|
|
5
|
+
/**
|
|
6
|
+
* MULE-701: Deprecated Component Usage
|
|
7
|
+
*
|
|
8
|
+
* Detect usage of deprecated Mule components.
|
|
9
|
+
*/
|
|
10
|
+
class DeprecatedComponentRule extends BaseRule_1.BaseRule {
|
|
11
|
+
id = 'MULE-701';
|
|
12
|
+
name = 'Deprecated Component Usage';
|
|
13
|
+
description = 'Detect usage of deprecated Mule components';
|
|
14
|
+
severity = 'warning';
|
|
15
|
+
category = 'standards';
|
|
16
|
+
DEPRECATED_ELEMENTS = [
|
|
17
|
+
{ element: 'component', replacement: 'Java module invoke' },
|
|
18
|
+
{ element: 'transactional', replacement: 'try scope with transactions' },
|
|
19
|
+
{ element: 'poll', replacement: 'scheduler component' },
|
|
20
|
+
{ element: 'inbound-endpoint', replacement: 'listener/trigger components' },
|
|
21
|
+
{ element: 'outbound-endpoint', replacement: 'requester components' },
|
|
22
|
+
];
|
|
23
|
+
validate(doc, _context) {
|
|
24
|
+
const issues = [];
|
|
25
|
+
for (const deprecated of this.DEPRECATED_ELEMENTS) {
|
|
26
|
+
const elements = this.select(`//mule:${deprecated.element}`, doc);
|
|
27
|
+
for (const element of elements) {
|
|
28
|
+
issues.push(this.createIssue(element, `Deprecated component "${deprecated.element}" found`, {
|
|
29
|
+
suggestion: `Use ${deprecated.replacement} instead`
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return issues;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.DeprecatedComponentRule = DeprecatedComponentRule;
|
|
37
|
+
//# sourceMappingURL=DeprecatedComponentRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeprecatedComponentRule.js","sourceRoot":"","sources":["../../../../src/rules/standards/DeprecatedComponentRule.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C;;;;GAIG;AACH,MAAa,uBAAwB,SAAQ,mBAAQ;IACjD,EAAE,GAAG,UAAU,CAAC;IAChB,IAAI,GAAG,4BAA4B,CAAC;IACpC,WAAW,GAAG,4CAA4C,CAAC;IAC3D,QAAQ,GAAG,SAAkB,CAAC;IAC9B,QAAQ,GAAG,WAAoB,CAAC;IAEf,mBAAmB,GAAG;QACnC,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE;QAC3D,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,6BAA6B,EAAE;QACxE,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE;QACvD,EAAE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,6BAA6B,EAAE;QAC3E,EAAE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,sBAAsB,EAAE;KACxE,CAAC;IAEF,QAAQ,CAAC,GAAa,EAAE,QAA2B;QAC/C,MAAM,MAAM,GAAY,EAAE,CAAC;QAE3B,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,UAAU,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;YAElE,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CACxB,OAAO,EACP,yBAAyB,UAAU,CAAC,OAAO,SAAS,EACpD;oBACI,UAAU,EAAE,OAAO,UAAU,CAAC,WAAW,UAAU;iBACtD,CACJ,CAAC,CAAC;YACP,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAlCD,0DAkCC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ValidationContext, Issue } from '../../types';
|
|
2
|
+
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
/**
|
|
4
|
+
* MULE-010: DWL Standards File
|
|
5
|
+
*
|
|
6
|
+
* Project should have standard DataWeave files for common operations
|
|
7
|
+
* like error responses, transformations, etc.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DwlStandardsRule extends BaseRule {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
severity: "info";
|
|
14
|
+
category: "standards";
|
|
15
|
+
private static checkedProjects;
|
|
16
|
+
validate(doc: Document, context: ValidationContext): Issue[];
|
|
17
|
+
/**
|
|
18
|
+
* Reset the checked projects cache (for testing)
|
|
19
|
+
*/
|
|
20
|
+
static reset(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=DwlStandardsRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DwlStandardsRule.d.ts","sourceRoot":"","sources":["../../../../src/rules/standards/DwlStandardsRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ;IAC1C,EAAE,SAAc;IAChB,IAAI,SAAwB;IAC5B,WAAW,SAAiF;IAC5F,QAAQ,EAAG,MAAM,CAAU;IAC3B,QAAQ,EAAG,WAAW,CAAU;IAGhC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAqB;IAEnD,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;IAsC5D;;OAEG;WACW,KAAK,IAAI,IAAI;CAG9B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DwlStandardsRule = void 0;
|
|
37
|
+
const BaseRule_1 = require("../base/BaseRule");
|
|
38
|
+
const FileScanner_1 = require("../../core/FileScanner");
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
/**
|
|
41
|
+
* MULE-010: DWL Standards File
|
|
42
|
+
*
|
|
43
|
+
* Project should have standard DataWeave files for common operations
|
|
44
|
+
* like error responses, transformations, etc.
|
|
45
|
+
*/
|
|
46
|
+
class DwlStandardsRule extends BaseRule_1.BaseRule {
|
|
47
|
+
id = 'MULE-010';
|
|
48
|
+
name = 'DWL Standards File';
|
|
49
|
+
description = 'Project should have standard DataWeave files for consistent error responses';
|
|
50
|
+
severity = 'info';
|
|
51
|
+
category = 'standards';
|
|
52
|
+
// Track if we've already checked (to avoid duplicate warnings)
|
|
53
|
+
static checkedProjects = new Set();
|
|
54
|
+
validate(doc, context) {
|
|
55
|
+
const issues = [];
|
|
56
|
+
// Only check once per project
|
|
57
|
+
if (DwlStandardsRule.checkedProjects.has(context.projectRoot)) {
|
|
58
|
+
return issues;
|
|
59
|
+
}
|
|
60
|
+
// Get expected DWL files from config
|
|
61
|
+
const expectedFiles = this.getOption(context, 'expectedFiles', [
|
|
62
|
+
'src/main/resources/dwl/standard-error.dwl',
|
|
63
|
+
'src/main/resources/dwl/common-functions.dwl',
|
|
64
|
+
]);
|
|
65
|
+
// Check if any expected files are missing
|
|
66
|
+
const missingFiles = [];
|
|
67
|
+
for (const expectedFile of expectedFiles) {
|
|
68
|
+
const fullPath = path.join(context.projectRoot, expectedFile);
|
|
69
|
+
if (!(0, FileScanner_1.fileExists)(fullPath)) {
|
|
70
|
+
missingFiles.push(expectedFile);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (missingFiles.length > 0) {
|
|
74
|
+
// Mark as checked to avoid duplicate warnings
|
|
75
|
+
DwlStandardsRule.checkedProjects.add(context.projectRoot);
|
|
76
|
+
issues.push(this.createFileIssue(`Recommended DataWeave standards files not found: ${missingFiles.join(', ')}`, {
|
|
77
|
+
suggestion: 'Create standard DWL files for consistent error responses and common functions'
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
return issues;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Reset the checked projects cache (for testing)
|
|
84
|
+
*/
|
|
85
|
+
static reset() {
|
|
86
|
+
DwlStandardsRule.checkedProjects.clear();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.DwlStandardsRule = DwlStandardsRule;
|
|
90
|
+
//# sourceMappingURL=DwlStandardsRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DwlStandardsRule.js","sourceRoot":"","sources":["../../../../src/rules/standards/DwlStandardsRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAA4C;AAC5C,wDAAoD;AACpD,2CAA6B;AAE7B;;;;;GAKG;AACH,MAAa,gBAAiB,SAAQ,mBAAQ;IAC1C,EAAE,GAAG,UAAU,CAAC;IAChB,IAAI,GAAG,oBAAoB,CAAC;IAC5B,WAAW,GAAG,6EAA6E,CAAC;IAC5F,QAAQ,GAAG,MAAe,CAAC;IAC3B,QAAQ,GAAG,WAAoB,CAAC;IAEhC,+DAA+D;IACvD,MAAM,CAAC,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAEnD,QAAQ,CAAC,GAAa,EAAE,OAA0B;QAC9C,MAAM,MAAM,GAAY,EAAE,CAAC;QAE3B,8BAA8B;QAC9B,IAAI,gBAAgB,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;YAC5D,OAAO,MAAM,CAAC;QAClB,CAAC;QAED,qCAAqC;QACrC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAW,OAAO,EAAE,eAAe,EAAE;YACrE,2CAA2C;YAC3C,6CAA6C;SAChD,CAAC,CAAC;QAEH,0CAA0C;QAC1C,MAAM,YAAY,GAAa,EAAE,CAAC;QAClC,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;YAC9D,IAAI,CAAC,IAAA,wBAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;gBACxB,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACpC,CAAC;QACL,CAAC;QAED,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,8CAA8C;YAC9C,gBAAgB,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAE1D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAC5B,oDAAoD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAC7E;gBACI,UAAU,EAAE,+EAA+E;aAC9F,CACJ,CAAC,CAAC;QACP,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,KAAK;QACf,gBAAgB,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC7C,CAAC;;AArDL,4CAsDC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ValidationContext, Issue } from '../../types';
|
|
2
|
+
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
/**
|
|
4
|
+
* MULE-802: Project Structure Validation
|
|
5
|
+
*
|
|
6
|
+
* Validates standard MuleSoft project folder structure.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ProjectStructureRule extends BaseRule {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
severity: "warning";
|
|
13
|
+
category: "structure";
|
|
14
|
+
private readonly REQUIRED_DIRS;
|
|
15
|
+
private readonly RECOMMENDED_DIRS;
|
|
16
|
+
validate(_doc: Document, context: ValidationContext): Issue[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* MULE-803: Global Config File
|
|
20
|
+
*
|
|
21
|
+
* Project should have global configuration file.
|
|
22
|
+
*/
|
|
23
|
+
export declare class GlobalConfigRule extends BaseRule {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
severity: "warning";
|
|
28
|
+
category: "structure";
|
|
29
|
+
validate(_doc: Document, context: ValidationContext): Issue[];
|
|
30
|
+
private findGlobalConfig;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* MULE-804: Monolithic XML File
|
|
34
|
+
*
|
|
35
|
+
* XML files should not be too large.
|
|
36
|
+
*/
|
|
37
|
+
export declare class MonolithicXmlRule extends BaseRule {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
severity: "warning";
|
|
42
|
+
category: "structure";
|
|
43
|
+
validate(doc: Document, context: ValidationContext): Issue[];
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=StructureRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StructureRules.d.ts","sourceRoot":"","sources":["../../../../src/rules/structure/StructureRules.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,QAAQ;IAC9C,EAAE,SAAc;IAChB,IAAI,SAAuB;IAC3B,WAAW,SAAyD;IACpE,QAAQ,EAAG,SAAS,CAAU;IAC9B,QAAQ,EAAG,WAAW,CAAU;IAEhC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAG5B;IAEF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAI/B;IAEF,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;CAkChE;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ;IAC1C,EAAE,SAAc;IAChB,IAAI,SAAwB;IAC5B,WAAW,SAA+D;IAC1E,QAAQ,EAAG,SAAS,CAAU;IAC9B,QAAQ,EAAG,WAAW,CAAU;IAEhC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;IAqB7D,OAAO,CAAC,gBAAgB;CAU3B;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;IAC3C,EAAE,SAAc;IAChB,IAAI,SAAyB;IAC7B,WAAW,SAAwD;IACnE,QAAQ,EAAG,SAAS,CAAU;IAC9B,QAAQ,EAAG,WAAW,CAAU;IAEhC,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;CAqB/D"}
|
|
@@ -0,0 +1,163 @@
|
|
|
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
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.MonolithicXmlRule = exports.GlobalConfigRule = exports.ProjectStructureRule = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const BaseRule_1 = require("../base/BaseRule");
|
|
40
|
+
/**
|
|
41
|
+
* MULE-802: Project Structure Validation
|
|
42
|
+
*
|
|
43
|
+
* Validates standard MuleSoft project folder structure.
|
|
44
|
+
*/
|
|
45
|
+
class ProjectStructureRule extends BaseRule_1.BaseRule {
|
|
46
|
+
id = 'MULE-802';
|
|
47
|
+
name = 'Project Structure';
|
|
48
|
+
description = 'Validate standard MuleSoft project folder structure';
|
|
49
|
+
severity = 'warning';
|
|
50
|
+
category = 'structure';
|
|
51
|
+
REQUIRED_DIRS = [
|
|
52
|
+
'src/main/mule',
|
|
53
|
+
'src/main/resources',
|
|
54
|
+
];
|
|
55
|
+
RECOMMENDED_DIRS = [
|
|
56
|
+
'src/main/resources/dwl',
|
|
57
|
+
'src/main/resources/api',
|
|
58
|
+
'src/test/munit',
|
|
59
|
+
];
|
|
60
|
+
validate(_doc, context) {
|
|
61
|
+
const issues = [];
|
|
62
|
+
const projectRoot = context.projectRoot;
|
|
63
|
+
// Check required directories
|
|
64
|
+
for (const dir of this.REQUIRED_DIRS) {
|
|
65
|
+
const fullPath = path.join(projectRoot, dir);
|
|
66
|
+
if (!fs.existsSync(fullPath)) {
|
|
67
|
+
issues.push({
|
|
68
|
+
line: 1,
|
|
69
|
+
message: `Missing required directory: ${dir}`,
|
|
70
|
+
ruleId: this.id,
|
|
71
|
+
severity: 'error',
|
|
72
|
+
suggestion: `Create directory: mkdir -p ${dir}`
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Check recommended directories
|
|
77
|
+
for (const dir of this.RECOMMENDED_DIRS) {
|
|
78
|
+
const fullPath = path.join(projectRoot, dir);
|
|
79
|
+
if (!fs.existsSync(fullPath)) {
|
|
80
|
+
issues.push({
|
|
81
|
+
line: 1,
|
|
82
|
+
message: `Missing recommended directory: ${dir}`,
|
|
83
|
+
ruleId: this.id,
|
|
84
|
+
severity: 'info',
|
|
85
|
+
suggestion: `Consider creating: ${dir}`
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return issues;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.ProjectStructureRule = ProjectStructureRule;
|
|
93
|
+
/**
|
|
94
|
+
* MULE-803: Global Config File
|
|
95
|
+
*
|
|
96
|
+
* Project should have global configuration file.
|
|
97
|
+
*/
|
|
98
|
+
class GlobalConfigRule extends BaseRule_1.BaseRule {
|
|
99
|
+
id = 'MULE-803';
|
|
100
|
+
name = 'Global Config File';
|
|
101
|
+
description = 'Project should have global.xml with shared configurations';
|
|
102
|
+
severity = 'warning';
|
|
103
|
+
category = 'structure';
|
|
104
|
+
validate(_doc, context) {
|
|
105
|
+
const issues = [];
|
|
106
|
+
const muleDir = path.join(context.projectRoot, 'src/main/mule');
|
|
107
|
+
if (!fs.existsSync(muleDir))
|
|
108
|
+
return issues;
|
|
109
|
+
const hasGlobalConfig = this.findGlobalConfig(muleDir);
|
|
110
|
+
if (!hasGlobalConfig) {
|
|
111
|
+
issues.push({
|
|
112
|
+
line: 1,
|
|
113
|
+
message: 'Missing global.xml configuration file',
|
|
114
|
+
ruleId: this.id,
|
|
115
|
+
severity: this.severity,
|
|
116
|
+
suggestion: 'Create src/main/mule/global.xml for shared configurations'
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return issues;
|
|
120
|
+
}
|
|
121
|
+
findGlobalConfig(dir) {
|
|
122
|
+
try {
|
|
123
|
+
const files = fs.readdirSync(dir);
|
|
124
|
+
return files.some(f => f.toLowerCase().includes('global') && f.endsWith('.xml'));
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.GlobalConfigRule = GlobalConfigRule;
|
|
132
|
+
/**
|
|
133
|
+
* MULE-804: Monolithic XML File
|
|
134
|
+
*
|
|
135
|
+
* XML files should not be too large.
|
|
136
|
+
*/
|
|
137
|
+
class MonolithicXmlRule extends BaseRule_1.BaseRule {
|
|
138
|
+
id = 'MULE-804';
|
|
139
|
+
name = 'Monolithic XML File';
|
|
140
|
+
description = 'XML files should not exceed recommended line count';
|
|
141
|
+
severity = 'warning';
|
|
142
|
+
category = 'structure';
|
|
143
|
+
validate(doc, context) {
|
|
144
|
+
const issues = [];
|
|
145
|
+
const maxLines = this.getOption(context, 'maxLines', 500);
|
|
146
|
+
// Count flows and sub-flows as proxy for complexity
|
|
147
|
+
const flows = this.select('//mule:flow', doc);
|
|
148
|
+
const subFlows = this.select('//mule:sub-flow', doc);
|
|
149
|
+
const totalFlows = flows.length + subFlows.length;
|
|
150
|
+
if (totalFlows > 10) {
|
|
151
|
+
issues.push({
|
|
152
|
+
line: 1,
|
|
153
|
+
message: `File has ${totalFlows} flows/sub-flows - consider splitting`,
|
|
154
|
+
ruleId: this.id,
|
|
155
|
+
severity: this.severity,
|
|
156
|
+
suggestion: 'Split into multiple XML files by domain or function'
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return issues;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.MonolithicXmlRule = MonolithicXmlRule;
|
|
163
|
+
//# sourceMappingURL=StructureRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StructureRules.js","sourceRoot":"","sources":["../../../../src/rules/structure/StructureRules.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ValidationContext, Issue } from '../../types';
|
|
2
|
+
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
/**
|
|
4
|
+
* YAML-001: Environment Properties Files
|
|
5
|
+
*
|
|
6
|
+
* Checks that environment-specific YAML files exist.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EnvironmentFilesRule extends BaseRule {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
severity: "warning";
|
|
13
|
+
category: "standards";
|
|
14
|
+
validate(_doc: Document, context: ValidationContext): Issue[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* YAML-003: Property Naming Convention
|
|
18
|
+
*
|
|
19
|
+
* Property keys should follow category.property format.
|
|
20
|
+
*/
|
|
21
|
+
export declare class PropertyNamingRule extends BaseRule {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
severity: "info";
|
|
26
|
+
category: "standards";
|
|
27
|
+
validate(_doc: Document, context: ValidationContext): Issue[];
|
|
28
|
+
private isValidPropertyName;
|
|
29
|
+
private findYamlFiles;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* YAML-004: No Plaintext Secrets
|
|
33
|
+
*
|
|
34
|
+
* Sensitive properties should be encrypted.
|
|
35
|
+
*/
|
|
36
|
+
export declare class PlaintextSecretsRule extends BaseRule {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
severity: "error";
|
|
41
|
+
category: "security";
|
|
42
|
+
validate(_doc: Document, context: ValidationContext): Issue[];
|
|
43
|
+
private checkForPlaintextSecrets;
|
|
44
|
+
private findYamlFiles;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=YamlRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YamlRules.d.ts","sourceRoot":"","sources":["../../../../src/rules/yaml/YamlRules.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAY,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,QAAQ;IAC9C,EAAE,SAAc;IAChB,IAAI,SAAkC;IACtC,WAAW,SAA2D;IACtE,QAAQ,EAAG,SAAS,CAAU;IAC9B,QAAQ,EAAG,WAAW,CAAU;IAEhC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;CA8ChE;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,QAAQ;IAC5C,EAAE,SAAc;IAChB,IAAI,SAAgC;IACpC,WAAW,SAA0D;IACrE,QAAQ,EAAG,MAAM,CAAU;IAC3B,QAAQ,EAAG,WAAW,CAAU;IAEhC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;IA2B7D,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,aAAa;CAqBxB;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,QAAQ;IAC9C,EAAE,SAAc;IAChB,IAAI,SAA0B;IAC9B,WAAW,SAA0D;IACrE,QAAQ,EAAG,OAAO,CAAU;IAC5B,QAAQ,EAAG,UAAU,CAAU;IAE/B,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;IAmB7D,OAAO,CAAC,wBAAwB;IA6BhC,OAAO,CAAC,aAAa;CAqBxB"}
|
|
@@ -0,0 +1,226 @@
|
|
|
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
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.PlaintextSecretsRule = exports.PropertyNamingRule = exports.EnvironmentFilesRule = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const BaseRule_1 = require("../base/BaseRule");
|
|
40
|
+
const YamlParser_1 = require("../../core/YamlParser");
|
|
41
|
+
/**
|
|
42
|
+
* YAML-001: Environment Properties Files
|
|
43
|
+
*
|
|
44
|
+
* Checks that environment-specific YAML files exist.
|
|
45
|
+
*/
|
|
46
|
+
class EnvironmentFilesRule extends BaseRule_1.BaseRule {
|
|
47
|
+
id = 'YAML-001';
|
|
48
|
+
name = 'Environment Properties Files';
|
|
49
|
+
description = 'Environment-specific YAML property files should exist';
|
|
50
|
+
severity = 'warning';
|
|
51
|
+
category = 'standards';
|
|
52
|
+
validate(_doc, context) {
|
|
53
|
+
const issues = [];
|
|
54
|
+
const configDir = path.join(context.projectRoot, 'src/main/resources');
|
|
55
|
+
const configSubDir = path.join(configDir, 'config');
|
|
56
|
+
// Check both possible locations
|
|
57
|
+
const searchDirs = [configDir, configSubDir].filter(d => fs.existsSync(d));
|
|
58
|
+
if (searchDirs.length === 0) {
|
|
59
|
+
return []; // No config directory found
|
|
60
|
+
}
|
|
61
|
+
const requiredEnvs = this.getOption(context, 'environments', ['dev', 'qa', 'prod']);
|
|
62
|
+
const existingFiles = new Set();
|
|
63
|
+
for (const dir of searchDirs) {
|
|
64
|
+
try {
|
|
65
|
+
const files = fs.readdirSync(dir);
|
|
66
|
+
files.forEach(f => existingFiles.add(f.toLowerCase()));
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Directory not readable
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const env of requiredEnvs) {
|
|
73
|
+
const hasEnvFile = existingFiles.has(`${env}.yaml`) ||
|
|
74
|
+
existingFiles.has(`${env}.yml`) ||
|
|
75
|
+
existingFiles.has(`config-${env}.yaml`) ||
|
|
76
|
+
existingFiles.has(`config-${env}.yml`) ||
|
|
77
|
+
existingFiles.has(`${env}-properties.yaml`);
|
|
78
|
+
if (!hasEnvFile) {
|
|
79
|
+
issues.push({
|
|
80
|
+
line: 1,
|
|
81
|
+
message: `Missing environment properties file for "${env}"`,
|
|
82
|
+
ruleId: this.id,
|
|
83
|
+
severity: this.severity,
|
|
84
|
+
suggestion: `Create ${env}.yaml or config-${env}.yaml in src/main/resources/`
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return issues;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.EnvironmentFilesRule = EnvironmentFilesRule;
|
|
92
|
+
/**
|
|
93
|
+
* YAML-003: Property Naming Convention
|
|
94
|
+
*
|
|
95
|
+
* Property keys should follow category.property format.
|
|
96
|
+
*/
|
|
97
|
+
class PropertyNamingRule extends BaseRule_1.BaseRule {
|
|
98
|
+
id = 'YAML-003';
|
|
99
|
+
name = 'Property Naming Convention';
|
|
100
|
+
description = 'Property keys should follow category.property format';
|
|
101
|
+
severity = 'info';
|
|
102
|
+
category = 'standards';
|
|
103
|
+
validate(_doc, context) {
|
|
104
|
+
const issues = [];
|
|
105
|
+
const configDir = path.join(context.projectRoot, 'src/main/resources');
|
|
106
|
+
const yamlFiles = this.findYamlFiles(configDir);
|
|
107
|
+
for (const yamlFile of yamlFiles) {
|
|
108
|
+
const content = YamlParser_1.YamlParser.parseFile(yamlFile);
|
|
109
|
+
if (!content)
|
|
110
|
+
continue;
|
|
111
|
+
const keys = YamlParser_1.YamlParser.getAllKeys(content);
|
|
112
|
+
const invalidKeys = keys.filter(key => !this.isValidPropertyName(key));
|
|
113
|
+
if (invalidKeys.length > 0) {
|
|
114
|
+
issues.push({
|
|
115
|
+
line: 1,
|
|
116
|
+
message: `Invalid property names in ${path.basename(yamlFile)}: ${invalidKeys.slice(0, 3).join(', ')}${invalidKeys.length > 3 ? '...' : ''}`,
|
|
117
|
+
ruleId: this.id,
|
|
118
|
+
severity: this.severity,
|
|
119
|
+
suggestion: 'Use category.property format (e.g., db.host, api.timeout)'
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return issues;
|
|
124
|
+
}
|
|
125
|
+
isValidPropertyName(key) {
|
|
126
|
+
// Valid: db.host, api.client.timeout, http.port
|
|
127
|
+
// Invalid: DBHOST, db-host, DbHost
|
|
128
|
+
return /^[a-z][a-z0-9]*(\.[a-z][a-z0-9]*)+$/.test(key) ||
|
|
129
|
+
/^[a-z][a-z0-9]*$/.test(key); // Single word keys OK too
|
|
130
|
+
}
|
|
131
|
+
findYamlFiles(dir) {
|
|
132
|
+
const files = [];
|
|
133
|
+
if (!fs.existsSync(dir))
|
|
134
|
+
return files;
|
|
135
|
+
try {
|
|
136
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
137
|
+
for (const entry of entries) {
|
|
138
|
+
const fullPath = path.join(dir, entry.name);
|
|
139
|
+
if (entry.isDirectory()) {
|
|
140
|
+
files.push(...this.findYamlFiles(fullPath));
|
|
141
|
+
}
|
|
142
|
+
else if (YamlParser_1.YamlParser.isYamlFile(entry.name)) {
|
|
143
|
+
files.push(fullPath);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// Directory not readable
|
|
149
|
+
}
|
|
150
|
+
return files;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.PropertyNamingRule = PropertyNamingRule;
|
|
154
|
+
/**
|
|
155
|
+
* YAML-004: No Plaintext Secrets
|
|
156
|
+
*
|
|
157
|
+
* Sensitive properties should be encrypted.
|
|
158
|
+
*/
|
|
159
|
+
class PlaintextSecretsRule extends BaseRule_1.BaseRule {
|
|
160
|
+
id = 'YAML-004';
|
|
161
|
+
name = 'No Plaintext Secrets';
|
|
162
|
+
description = 'Sensitive properties should be encrypted with ![...]';
|
|
163
|
+
severity = 'error';
|
|
164
|
+
category = 'security';
|
|
165
|
+
validate(_doc, context) {
|
|
166
|
+
const issues = [];
|
|
167
|
+
const configDir = path.join(context.projectRoot, 'src/main/resources');
|
|
168
|
+
const yamlFiles = this.findYamlFiles(configDir);
|
|
169
|
+
for (const yamlFile of yamlFiles) {
|
|
170
|
+
// Skip secure property files (they should be encrypted)
|
|
171
|
+
if (yamlFile.includes('-secure.'))
|
|
172
|
+
continue;
|
|
173
|
+
const content = YamlParser_1.YamlParser.parseFile(yamlFile);
|
|
174
|
+
if (!content)
|
|
175
|
+
continue;
|
|
176
|
+
this.checkForPlaintextSecrets(content, '', yamlFile, issues);
|
|
177
|
+
}
|
|
178
|
+
return issues;
|
|
179
|
+
}
|
|
180
|
+
checkForPlaintextSecrets(obj, prefix, filePath, issues) {
|
|
181
|
+
for (const key of Object.keys(obj)) {
|
|
182
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
183
|
+
const value = obj[key];
|
|
184
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
185
|
+
this.checkForPlaintextSecrets(value, fullKey, filePath, issues);
|
|
186
|
+
}
|
|
187
|
+
else if (typeof value === 'string') {
|
|
188
|
+
if (YamlParser_1.YamlParser.isSensitiveKey(fullKey) && !YamlParser_1.YamlParser.isEncryptedValue(value)) {
|
|
189
|
+
// Check if it's a placeholder (OK)
|
|
190
|
+
if (!value.includes('${') && value.length > 0) {
|
|
191
|
+
issues.push({
|
|
192
|
+
line: 1,
|
|
193
|
+
message: `Plaintext secret "${fullKey}" in ${path.basename(filePath)}`,
|
|
194
|
+
ruleId: this.id,
|
|
195
|
+
severity: this.severity,
|
|
196
|
+
suggestion: 'Encrypt value with ![...] or move to secure properties file'
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
findYamlFiles(dir) {
|
|
204
|
+
const files = [];
|
|
205
|
+
if (!fs.existsSync(dir))
|
|
206
|
+
return files;
|
|
207
|
+
try {
|
|
208
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
209
|
+
for (const entry of entries) {
|
|
210
|
+
const fullPath = path.join(dir, entry.name);
|
|
211
|
+
if (entry.isDirectory()) {
|
|
212
|
+
files.push(...this.findYamlFiles(fullPath));
|
|
213
|
+
}
|
|
214
|
+
else if (YamlParser_1.YamlParser.isYamlFile(entry.name)) {
|
|
215
|
+
files.push(fullPath);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
// Directory not readable
|
|
221
|
+
}
|
|
222
|
+
return files;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.PlaintextSecretsRule = PlaintextSecretsRule;
|
|
226
|
+
//# sourceMappingURL=YamlRules.js.map
|