x-fidelity 2.17.2 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +143 -0
- package/CONTRIBUTING.md +1 -0
- package/PLUGIN_GUIDANCE.md +157 -0
- package/README.md +109 -15
- package/dist/core/cli.d.ts +3 -0
- package/dist/core/cli.js +65 -44
- package/dist/core/configManager.d.ts +14 -0
- package/dist/{utils → core}/configManager.js +62 -12
- package/dist/core/configManager.test.d.ts +1 -0
- package/dist/{utils → core}/configManager.test.js +27 -71
- package/dist/core/engine/analyzer.d.ts +3 -0
- package/dist/core/engine/analyzer.js +4 -2
- package/dist/core/engine/analyzer.test.d.ts +1 -0
- package/dist/core/engine/analyzer.test.js +14 -26
- package/dist/core/engine/engineRunner.d.ts +3 -0
- package/dist/core/engine/engineRunner.js +77 -14
- package/dist/core/engine/engineRunner.test.d.ts +1 -0
- package/dist/core/engine/engineRunner.test.js +25 -11
- package/dist/core/engine/engineSetup.d.ts +3 -0
- package/dist/core/engine/engineSetup.js +4 -4
- package/dist/core/engine/engineSetup.test.d.ts +1 -0
- package/dist/core/engine/engineSetup.test.js +13 -5
- package/dist/core/engine/errorActionExecutor.d.ts +10 -0
- package/dist/core/engine/errorActionExecutor.js +64 -0
- package/dist/core/engine/errorActionExecutor.test.d.ts +1 -0
- package/dist/core/engine/errorActionExecutor.test.js +66 -0
- package/dist/core/engine/telemetryCollector.d.ts +2 -0
- package/dist/core/engine/telemetryCollector.test.d.ts +1 -0
- package/dist/core/pluginRegistry.d.ts +14 -0
- package/dist/core/pluginRegistry.js +111 -0
- package/dist/core/validateConfig.d.ts +1 -0
- package/dist/core/validateConfig.js +105 -0
- package/dist/{archetypes → demoConfig}/node-fullstack.json +8 -4
- package/dist/demoConfig/rules/custom-rule.json +27 -0
- package/dist/demoConfig/rules/invalidSystemIdConfigured-iterative-rule.json +43 -0
- package/dist/{rules → demoConfig/rules}/openaiAnalysisA11y-global-rule.json +1 -1
- package/{src/archetypes → dist/demoConfig}/rules/outdatedFramework-global-rule.json +9 -1
- package/dist/facts/index.d.ts +3 -0
- package/dist/facts/index.js +40 -11
- package/dist/facts/openaiAnalysisFacts.d.ts +5 -0
- package/dist/facts/openaiAnalysisFacts.js +25 -11
- package/dist/facts/openaiAnalysisFacts.test.d.ts +1 -0
- package/dist/facts/repoDependencyFacts.d.ts +23 -0
- package/dist/facts/repoDependencyFacts.js +22 -17
- package/dist/facts/repoDependencyFacts.test.d.ts +1 -0
- package/dist/facts/repoFilesystemFacts.d.ts +7 -0
- package/dist/facts/repoFilesystemFacts.js +43 -20
- package/dist/facts/repoFilesystemFacts.test.d.ts +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +83 -32
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +3 -0
- package/dist/jest.setup.d.ts +1 -0
- package/dist/jest.setup.js +12 -1
- package/dist/operators/fileContains.d.ts +3 -0
- package/dist/operators/fileContains.test.d.ts +1 -0
- package/dist/operators/index.d.ts +3 -0
- package/dist/operators/index.js +10 -7
- package/dist/operators/index.test.d.ts +1 -0
- package/dist/operators/nonStandardDirectoryStructure.d.ts +3 -0
- package/dist/operators/nonStandardDirectoryStructure.js +15 -5
- package/dist/operators/nonStandardDirectoryStructure.test.d.ts +1 -0
- package/dist/operators/nonStandardDirectoryStructure.test.js +15 -1
- package/dist/operators/openaiAnalysisHighSeverity.d.ts +3 -0
- package/dist/operators/openaiAnalysisHighSeverity.js +5 -3
- package/dist/operators/openaiAnalysisHighSeverity.test.d.ts +1 -0
- package/dist/operators/openaiAnalysisHighSeverity.test.js +9 -4
- package/dist/operators/outdatedFramework.d.ts +3 -0
- package/dist/operators/outdatedFramework.test.d.ts +1 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/facts/remoteSubstringValidation.d.ts +16 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/facts/remoteSubstringValidation.js +136 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/facts/remoteSubstringValidation.test.d.ts +1 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/facts/remoteSubstringValidation.test.js +65 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/index.d.ts +1 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/index.js +5 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/operators/invalidRemoteValidation.d.ts +3 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/operators/invalidRemoteValidation.js +26 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/operators/invalidRemoteValidation.test.d.ts +1 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/operators/invalidRemoteValidation.test.js +26 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/xfiPluginRemoteStringValidator.d.ts +3 -0
- package/dist/plugins/xfiPluginRemoteStringValidator/xfiPluginRemoteStringValidator.js +17 -0
- package/dist/plugins/xfiPluginSimpleExample/facts/customFact.d.ts +2 -0
- package/dist/plugins/xfiPluginSimpleExample/facts/customFact.js +18 -0
- package/dist/plugins/xfiPluginSimpleExample/facts/customFact.test.d.ts +1 -0
- package/dist/plugins/xfiPluginSimpleExample/facts/customFact.test.js +21 -0
- package/dist/plugins/xfiPluginSimpleExample/index.d.ts +1 -0
- package/dist/plugins/xfiPluginSimpleExample/index.js +5 -0
- package/dist/plugins/xfiPluginSimpleExample/operators/customOperator.d.ts +2 -0
- package/dist/plugins/xfiPluginSimpleExample/operators/customOperator.js +9 -0
- package/dist/plugins/xfiPluginSimpleExample/operators/customOperator.test.d.ts +1 -0
- package/dist/plugins/xfiPluginSimpleExample/operators/customOperator.test.js +18 -0
- package/dist/plugins/xfiPluginSimpleExample/xfiPluginSimpleExample.d.ts +3 -0
- package/dist/plugins/xfiPluginSimpleExample/xfiPluginSimpleExample.js +12 -0
- package/dist/plugins/xfiPluginSimpleExample/xfiPluginSimpleExample.test.d.ts +1 -0
- package/dist/plugins/xfiPluginSimpleExample/xfiPluginSimpleExample.test.js +36 -0
- package/dist/server/cacheManager.d.ts +7 -0
- package/dist/server/cacheManager.js +4 -4
- package/dist/server/cacheManager.test.d.ts +1 -0
- package/dist/server/cacheManager.test.js +28 -0
- package/dist/server/configServer.d.ts +2 -0
- package/dist/server/configServer.js +4 -1
- package/dist/server/configServer.test.d.ts +1 -0
- package/dist/server/expressLogger.d.ts +2 -0
- package/dist/server/expressLogger.js +17 -22
- package/dist/server/middleware/checkSharedSecret.d.ts +2 -0
- package/dist/server/middleware/validateGithubWebhook.d.ts +2 -0
- package/dist/server/middleware/validateTelemetryData.d.ts +2 -0
- package/dist/server/middleware/validateUrlInput.d.ts +2 -0
- package/dist/server/routes/archetypeRoute.d.ts +2 -0
- package/dist/server/routes/archetypeRoute.js +1 -1
- package/dist/server/routes/archetypeRuleRoute.d.ts +2 -0
- package/dist/server/routes/archetypeRuleRoute.js +1 -1
- package/dist/server/routes/archetypeRulesRoute.d.ts +2 -0
- package/dist/server/routes/archetypeRulesRoute.js +1 -1
- package/dist/server/routes/clearCacheRoute.d.ts +2 -0
- package/dist/server/routes/clearCacheRoute.js +1 -1
- package/dist/server/routes/exemptionsRoute.d.ts +2 -0
- package/dist/server/routes/exemptionsRoute.js +1 -1
- package/dist/server/routes/githubWebhookConfigUpdateRoute.d.ts +2 -0
- package/dist/server/routes/githubWebhookConfigUpdateRoute.js +9 -3
- package/dist/server/routes/githubWebhookPullRequestCheckRoute.d.ts +2 -0
- package/dist/server/routes/githubWebhookPullRequestCheckRoute.js +8 -2
- package/dist/server/routes/telemetryRoute.d.ts +2 -0
- package/dist/server/routes/telemetryRoute.js +4 -1
- package/dist/server/routes/viewCacheRoute.d.ts +2 -0
- package/dist/server/routes/viewCacheRoute.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +17 -0
- package/dist/types/typeDefs.d.ts +285 -0
- package/dist/utils/axiosClient.d.ts +8 -0
- package/dist/utils/exemptionUtils.d.ts +6 -0
- package/dist/utils/{exemptionLoader.js → exemptionUtils.js} +6 -14
- package/dist/utils/exemptionUtils.test.d.ts +1 -0
- package/dist/utils/{exemptionLoader.test.js → exemptionUtils.test.js} +21 -21
- package/dist/utils/inputValidation.d.ts +5 -0
- package/dist/utils/inputValidation.js +6 -1
- package/dist/utils/inputValidation.test.d.ts +1 -0
- package/dist/utils/jsonSchemas.d.ts +9 -0
- package/dist/utils/jsonSchemas.js +138 -45
- package/dist/utils/logger.d.ts +9 -0
- package/dist/utils/logger.js +107 -34
- package/dist/utils/logger.test.d.ts +1 -0
- package/dist/utils/maskSensitiveData.d.ts +1 -0
- package/dist/utils/maskSensitiveData.js +86 -3
- package/dist/utils/maskSensitiveData.test.d.ts +1 -0
- package/dist/utils/maskSensitiveData.test.js +30 -7
- package/dist/utils/openaiUtils.d.ts +5 -0
- package/dist/utils/pathUtils.d.ts +1 -0
- package/dist/utils/pathUtils.js +2 -0
- package/dist/utils/pathUtils.test.d.ts +1 -0
- package/dist/utils/pathUtils.test.js +16 -0
- package/dist/utils/repoXFIConfigLoader.d.ts +2 -0
- package/dist/utils/repoXFIConfigLoader.js +6 -1
- package/dist/utils/ruleUtils.d.ts +3 -0
- package/dist/{rules/index.js → utils/ruleUtils.js} +5 -26
- package/dist/utils/ruleUtils.test.d.ts +1 -0
- package/dist/{rules/index.test.js → utils/ruleUtils.test.js} +13 -13
- package/dist/utils/telemetry.d.ts +2 -0
- package/dist/utils/telemetry.js +4 -1
- package/dist/utils/utils.d.ts +4 -0
- package/dist/utils/utils.js +4 -11
- package/dist/xfidelity +83 -32
- package/package.json +27 -12
- package/src/core/cli.ts +63 -43
- package/src/{utils → core}/configManager.test.ts +12 -59
- package/src/{utils → core}/configManager.ts +59 -10
- package/src/core/engine/analyzer.test.ts +14 -26
- package/src/core/engine/analyzer.ts +4 -2
- package/src/core/engine/engineRunner.test.ts +28 -12
- package/src/core/engine/engineRunner.ts +82 -15
- package/src/core/engine/engineSetup.test.ts +15 -5
- package/src/core/engine/engineSetup.ts +3 -3
- package/src/core/engine/errorActionExecutor.test.ts +62 -0
- package/src/core/engine/errorActionExecutor.ts +58 -0
- package/src/core/pluginRegistry.ts +126 -0
- package/src/core/validateConfig.ts +103 -0
- package/src/demoConfig/java-microservice-exemptions/team3-java-microservice-exemptions.json +15 -0
- package/src/demoConfig/node-fullstack-exemptions/project1-node-fullstack-exemptions.json +15 -0
- package/src/demoConfig/node-fullstack-exemptions/team1-node-fullstack-exemptions.json +15 -0
- package/src/{archetypes → demoConfig}/node-fullstack.json +8 -4
- package/src/demoConfig/rules/custom-rule.json +27 -0
- package/src/demoConfig/rules/invalidSystemIdConfigured-iterative-rule.json +43 -0
- package/src/{archetypes → demoConfig}/rules/openaiAnalysisA11y-global-rule.json +1 -1
- package/src/{rules → demoConfig/rules}/outdatedFramework-global-rule.json +9 -1
- package/src/facts/index.ts +48 -14
- package/src/facts/openaiAnalysisFacts.ts +29 -11
- package/src/facts/repoDependencyFacts.ts +22 -17
- package/src/facts/repoFilesystemFacts.ts +42 -20
- package/src/index.test.ts +3 -0
- package/src/index.ts +50 -34
- package/src/jest.setup.ts +15 -1
- package/src/operators/index.ts +15 -8
- package/src/operators/nonStandardDirectoryStructure.test.ts +15 -1
- package/src/operators/nonStandardDirectoryStructure.ts +15 -5
- package/src/operators/openaiAnalysisHighSeverity.test.ts +9 -4
- package/src/operators/openaiAnalysisHighSeverity.ts +7 -3
- package/src/plugins/xfiPluginRemoteStringValidator/facts/remoteSubstringValidation.test.ts +63 -0
- package/src/plugins/xfiPluginRemoteStringValidator/facts/remoteSubstringValidation.ts +160 -0
- package/src/plugins/xfiPluginRemoteStringValidator/index.ts +1 -0
- package/src/plugins/xfiPluginRemoteStringValidator/operators/invalidRemoteValidation.test.ts +28 -0
- package/src/plugins/xfiPluginRemoteStringValidator/operators/invalidRemoteValidation.ts +27 -0
- package/src/plugins/xfiPluginRemoteStringValidator/sampleRules/invalidSystemIdConfigured-iterative-rule.json +43 -0
- package/src/plugins/xfiPluginRemoteStringValidator/sampleRules/xfiTestMatch.json +14 -0
- package/src/plugins/xfiPluginRemoteStringValidator/sampleRules/xfiTestServerResponse.json +12 -0
- package/src/plugins/xfiPluginRemoteStringValidator/xfiPluginRemoteStringValidator.ts +17 -0
- package/src/plugins/xfiPluginSimpleExample/facts/customFact.test.ts +11 -0
- package/src/plugins/xfiPluginSimpleExample/facts/customFact.ts +8 -0
- package/src/plugins/xfiPluginSimpleExample/index.ts +1 -0
- package/src/plugins/xfiPluginSimpleExample/operators/customOperator.test.ts +18 -0
- package/src/plugins/xfiPluginSimpleExample/operators/customOperator.ts +8 -0
- package/src/plugins/xfiPluginSimpleExample/sampleRules/custom-rule.json +21 -0
- package/src/plugins/xfiPluginSimpleExample/xfiPluginSimpleExample.test.ts +40 -0
- package/src/plugins/xfiPluginSimpleExample/xfiPluginSimpleExample.ts +12 -0
- package/src/server/cacheManager.test.ts +31 -0
- package/src/server/cacheManager.ts +4 -4
- package/src/server/configServer.ts +6 -1
- package/src/server/expressLogger.ts +22 -25
- package/src/server/routes/archetypeRoute.ts +1 -1
- package/src/server/routes/archetypeRuleRoute.ts +1 -1
- package/src/server/routes/archetypeRulesRoute.ts +1 -1
- package/src/server/routes/clearCacheRoute.ts +1 -1
- package/src/server/routes/exemptionsRoute.ts +1 -1
- package/src/server/routes/githubWebhookConfigUpdateRoute.ts +9 -3
- package/src/server/routes/githubWebhookPullRequestCheckRoute.ts +8 -2
- package/src/server/routes/telemetryRoute.ts +4 -1
- package/src/server/routes/viewCacheRoute.ts +1 -1
- package/src/types/index.ts +1 -0
- package/src/types/typeDefs.ts +79 -4
- package/src/utils/{exemptionLoader.test.ts → exemptionUtils.test.ts} +2 -2
- package/src/utils/{exemptionLoader.ts → exemptionUtils.ts} +7 -13
- package/src/utils/inputValidation.ts +6 -1
- package/src/utils/jsonSchemas.ts +150 -50
- package/src/utils/logger.ts +109 -40
- package/src/utils/maskSensitiveData.test.ts +35 -7
- package/src/utils/maskSensitiveData.ts +92 -3
- package/src/utils/pathUtils.test.ts +17 -0
- package/src/utils/pathUtils.ts +1 -0
- package/src/utils/repoXFIConfigLoader.ts +6 -1
- package/src/{rules/index.test.ts → utils/ruleUtils.test.ts} +10 -10
- package/src/{rules/index.ts → utils/ruleUtils.ts} +6 -26
- package/src/utils/telemetry.ts +4 -1
- package/src/utils/utils.ts +8 -12
- package/tsconfig.json +10 -3
- package/dist/archetypes/index.js +0 -69
- package/dist/rules/outdatedFramework-global-rule.json +0 -30
- package/src/archetypes/index.ts +0 -37
- package/src/archetypes/rules/nonStandardDirectoryStructure-global-rule copy.json +0 -30
- package/src/archetypes/rules/sensitiveLogging-iterative-rule copy.json +0 -47
- package/src/rules/noDatabases-iterative-rule.json +0 -31
- package/src/rules/nonStandardDirectoryStructure-global-rule.json +0 -30
- package/src/rules/openaiAnalysisA11y-global-rule.json +0 -31
- package/src/rules/openaiAnalysisTop5-global-rule.json +0 -31
- package/src/rules/sensitiveLogging-iterative-rule.json +0 -47
- /package/{src/archetypes → dist/demoConfig}/java-microservice-exemptions/team3-java-microservice-exemptions.json +0 -0
- /package/dist/{archetypes → demoConfig}/java-microservice-exemptions.json +0 -0
- /package/dist/{archetypes → demoConfig}/java-microservice.json +0 -0
- /package/{src/archetypes → dist/demoConfig}/node-fullstack-exemptions/project1-node-fullstack-exemptions.json +0 -0
- /package/{src/archetypes → dist/demoConfig}/node-fullstack-exemptions/team1-node-fullstack-exemptions.json +0 -0
- /package/dist/{archetypes → demoConfig}/node-fullstack-exemptions.json +0 -0
- /package/dist/{rules → demoConfig/rules}/noDatabases-iterative-rule.json +0 -0
- /package/dist/{rules → demoConfig/rules}/nonStandardDirectoryStructure-global-rule.json +0 -0
- /package/dist/{rules → demoConfig/rules}/openaiAnalysisTop5-global-rule.json +0 -0
- /package/dist/{rules → demoConfig/rules}/sensitiveLogging-iterative-rule.json +0 -0
- /package/src/{archetypes → demoConfig}/java-microservice-exemptions.json +0 -0
- /package/src/{archetypes → demoConfig}/java-microservice.json +0 -0
- /package/src/{archetypes → demoConfig}/node-fullstack-exemptions.json +0 -0
- /package/src/{archetypes → demoConfig}/rules/noDatabases-iterative-rule.json +0 -0
- /package/src/{archetypes → demoConfig}/rules/nonStandardDirectoryStructure-global-rule.json +0 -0
- /package/src/{archetypes → demoConfig}/rules/openaiAnalysisTop5-global-rule.json +0 -0
- /package/src/{archetypes → demoConfig}/rules/sensitiveLogging-iterative-rule.json +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,146 @@
|
|
|
1
|
+
## [3.0.1](https://github.com/zotoio/x-fidelity/compare/v3.0.0...v3.0.1) (2025-02-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* package.json & yarn.lock to reduce vulnerabilities ([5dd70a3](https://github.com/zotoio/x-fidelity/commit/5dd70a3363b212d85147dbd18f56e0eaefcc1897))
|
|
7
|
+
|
|
8
|
+
# [3.0.0](https://github.com/zotoio/x-fidelity/compare/v2.17.2...v3.0.0) (2025-02-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* add event listener cleanup in engine test files ([705a39c](https://github.com/zotoio/x-fidelity/commit/705a39c8357c74cc2f7935a44da1bdb27bcb9e31))
|
|
14
|
+
* add interceptors mock to axios test client ([edb17b5](https://github.com/zotoio/x-fidelity/commit/edb17b54a45771c53eb44dd34763d93273d137bf))
|
|
15
|
+
* add isPathInside imports and handle missing file paths ([42b0207](https://github.com/zotoio/x-fidelity/commit/42b0207276827cb05aa10d4b6c5c9247c33bbb6f))
|
|
16
|
+
* add matchLength undefined checks in maskValue function ([2872ec5](https://github.com/zotoio/x-fidelity/commit/2872ec5323e4517f032f404cf6c50237af1d5e59))
|
|
17
|
+
* add missing Engine interface methods in test mock ([fa523d2](https://github.com/zotoio/x-fidelity/commit/fa523d217839e997713aa8527d95bf1b968c1c0d))
|
|
18
|
+
* add missing ErrorLevel type import in engineRunner ([bb8551c](https://github.com/zotoio/x-fidelity/commit/bb8551c9dbfc7282e39bf871f97696e2705d7686))
|
|
19
|
+
* add missing imports for path and pluginRegistry ([d98192b](https://github.com/zotoio/x-fidelity/commit/d98192b4eb8b540975ab351efa5e24aaab5fabd7))
|
|
20
|
+
* add missing interceptors to axios mock in test ([42a72eb](https://github.com/zotoio/x-fidelity/commit/42a72eb121fd28009ebdf91383e1a93d6cae7a4b))
|
|
21
|
+
* add missing logger import in facts/index.ts ([46d09c7](https://github.com/zotoio/x-fidelity/commit/46d09c70120a935a15d5c5cf070b27bf3d2cf0fb))
|
|
22
|
+
* add missing logger.info mock in test setup ([c1a3dba](https://github.com/zotoio/x-fidelity/commit/c1a3dbaa3bb4cf1d696244d274d8aed94ec897e1))
|
|
23
|
+
* add missing OperatorDefn type import in pluginRegistry ([51fcf15](https://github.com/zotoio/x-fidelity/commit/51fcf159fa6bd93f0f5081aee5dd87dc0a85a10a))
|
|
24
|
+
* add mock implementation for path.relative in tests ([f39ce89](https://github.com/zotoio/x-fidelity/commit/f39ce89f1db3ea0cfe6f222cf6cc7fcd78a94dca))
|
|
25
|
+
* add mock implementation for path.resolve in tests ([edd3388](https://github.com/zotoio/x-fidelity/commit/edd33884f61ae2a8a457b15a32478f949b8d7d96))
|
|
26
|
+
* add null check for childPath in isPathInside function ([c510bd4](https://github.com/zotoio/x-fidelity/commit/c510bd43fff43328ced1d5706f0969e630b4ed19))
|
|
27
|
+
* add proper type annotations to express logger functions ([7146f70](https://github.com/zotoio/x-fidelity/commit/7146f70f954021708cc79924727a7cd306596ada))
|
|
28
|
+
* add proper type annotations to express logger middleware ([c0868ce](https://github.com/zotoio/x-fidelity/commit/c0868ceb8f2aca2dcd91da06c3977154f4b12ef1))
|
|
29
|
+
* add type annotation for operators object to fix string indexing ([aa3ced1](https://github.com/zotoio/x-fidelity/commit/aa3ced1b494aa3c453d3d7231ef9c99e0a2603fa))
|
|
30
|
+
* add type annotation for rest parameter in mock implementation ([736fd36](https://github.com/zotoio/x-fidelity/commit/736fd36f4fbe9299cbc600f6700d1603d6337659))
|
|
31
|
+
* add type assertion for errorSource in engineRunner ([f17df2a](https://github.com/zotoio/x-fidelity/commit/f17df2a6982c79a31520141324d64281321138a8))
|
|
32
|
+
* add type cast for args spread in plugin function call ([f88f3f8](https://github.com/zotoio/x-fidelity/commit/f88f3f840318cc8eb1a404d6fe30efc58d178598))
|
|
33
|
+
* add type cast for rule name property in validate command ([5b811ad](https://github.com/zotoio/x-fidelity/commit/5b811ad00bcf50b76a8b96999ae36a758f2a286d))
|
|
34
|
+
* add type safety for engine removeAllListeners method in tests ([f1bd1c0](https://github.com/zotoio/x-fidelity/commit/f1bd1c056246918303d4b4fbda2702cc8f807e79))
|
|
35
|
+
* avoid reassigning to constant error variable in error handling ([5f04405](https://github.com/zotoio/x-fidelity/commit/5f04405a02693c53dc048d2c63ac1cb9827c24a2))
|
|
36
|
+
* cast event types to ErrorLevel enum for type safety ([f2cb3b5](https://github.com/zotoio/x-fidelity/commit/f2cb3b567d4061b57c5ca6c9b07cd628f9554c5c))
|
|
37
|
+
* change logPrefix from const to let for mutability ([2ce6b56](https://github.com/zotoio/x-fidelity/commit/2ce6b5615a9be93230e5278dcf5b3308e4c2b5aa))
|
|
38
|
+
* correct Engine type definition in engineRunner test ([e474084](https://github.com/zotoio/x-fidelity/commit/e474084ca0cc033a341cc983174b66161bdf0dbe))
|
|
39
|
+
* correct function type signature in plugin registry ([f5001df](https://github.com/zotoio/x-fidelity/commit/f5001df187496074b7d2be517bdb714c31b495e5))
|
|
40
|
+
* correct type casting for spread operator in plugin function call ([55e1894](https://github.com/zotoio/x-fidelity/commit/55e1894f099d3153699613e543d0163f9a0e00e5))
|
|
41
|
+
* correct type signature for pino-http customLogLevel function ([8d6cb76](https://github.com/zotoio/x-fidelity/commit/8d6cb7696c32aa26fbf97bc9bf0637f1e1ae0089))
|
|
42
|
+
* correct TypeScript errors in logger implementation ([8da1f9c](https://github.com/zotoio/x-fidelity/commit/8da1f9ca56cf054cd499df4d2da510ba6fdb8ab0))
|
|
43
|
+
* correct TypeScript errors in operator and error handling ([d2a1927](https://github.com/zotoio/x-fidelity/commit/d2a19270e047a903d1ef0a526f2bd193dab5a39f))
|
|
44
|
+
* declare handledError variable before usage in error handling ([34a95a9](https://github.com/zotoio/x-fidelity/commit/34a95a9ca2994db0bf8d03381e636b315e75ee37))
|
|
45
|
+
* declare handledError with proper scope in engineRunner ([65fc6b9](https://github.com/zotoio/x-fidelity/commit/65fc6b905ead2756462ac81eb7085189d06833ec))
|
|
46
|
+
* ensure error handling type safety and add onError schema ([b61c183](https://github.com/zotoio/x-fidelity/commit/b61c183565a15c18c665581df806a387792878a2))
|
|
47
|
+
* ensure type safety in engine runner error handling ([32a3007](https://github.com/zotoio/x-fidelity/commit/32a30076a2673ecc9f32e42a3a7e876133ce8a64))
|
|
48
|
+
* handle missing fs.promises.stat and fix directory structure check ([84ff132](https://github.com/zotoio/x-fidelity/commit/84ff132e63dfd88255a4e38b316399ff2c82abcd))
|
|
49
|
+
* handle symlink errors and improve directory structure validation ([b2847c9](https://github.com/zotoio/x-fidelity/commit/b2847c96f85a04f68033371fc5235255971a5e0d))
|
|
50
|
+
* handle undefined paths and use path.resolve for path normalization ([e814259](https://github.com/zotoio/x-fidelity/commit/e814259eef9372d3f79a890952a685d1086bd7a0))
|
|
51
|
+
* improve error handling in dependency collection ([ee003d2](https://github.com/zotoio/x-fidelity/commit/ee003d23713b7fcc465ec042e605518c8fb1a34f))
|
|
52
|
+
* improve event listener handling and type safety in tests ([32d6c3b](https://github.com/zotoio/x-fidelity/commit/32d6c3bdf2a4148a84969e8baa5ee647cfed57c6))
|
|
53
|
+
* improve logger prefix handling and configuration inheritance ([42f6d8c](https://github.com/zotoio/x-fidelity/commit/42f6d8ccfdc437e51d58be690ca1cd39b023dade))
|
|
54
|
+
* improve operator error detection in rule execution ([3590c50](https://github.com/zotoio/x-fidelity/commit/3590c5078bdefe90fefe98279eb52402446e8e4a))
|
|
55
|
+
* improve plugin error handling and propagation ([82315c6](https://github.com/zotoio/x-fidelity/commit/82315c6d02c025a2a022d3b59cd61070479c954f))
|
|
56
|
+
* improve TypeScript types for logger and pino middleware ([77bd9ac](https://github.com/zotoio/x-fidelity/commit/77bd9acf8a42dff164623f81fdac2b977cb9ff78))
|
|
57
|
+
* initialize logger immediately and update test expectations ([adc8d76](https://github.com/zotoio/x-fidelity/commit/adc8d7641ba42ae4f8e56440f8bea417c2cb8568))
|
|
58
|
+
* move operator loading inside function to capture latest plugins ([c1df0df](https://github.com/zotoio/x-fidelity/commit/c1df0dfe602adfea05b9db86a67c1e33f9915a96))
|
|
59
|
+
* prevent masking of string values in maskSensitiveData util ([f9abb11](https://github.com/zotoio/x-fidelity/commit/f9abb11929aa90c619f522f985b91572e603e7e9))
|
|
60
|
+
* remove duplicate export statements in types/index.ts ([b61504c](https://github.com/zotoio/x-fidelity/commit/b61504ce03f5cbd4d0ff4ba8dc99645e40be7310))
|
|
61
|
+
* remove duplicate function declarations in logger.ts ([fe68714](https://github.com/zotoio/x-fidelity/commit/fe68714618067ee5600a5e00048632b1c265f6d2))
|
|
62
|
+
* remove duplicate removeAllListeners property in mock Engine object ([f77bd1a](https://github.com/zotoio/x-fidelity/commit/f77bd1a05719c8c1598fec364febe5f835f24390))
|
|
63
|
+
* remove duplicate setLogLevel function declaration ([a6f892a](https://github.com/zotoio/x-fidelity/commit/a6f892a0f0de31d7e564ab9984364f30b29c01ec))
|
|
64
|
+
* remove unused plugin types import ([47e3bdc](https://github.com/zotoio/x-fidelity/commit/47e3bdcf8d3228ba90fc6c790bd67aa18497aff6))
|
|
65
|
+
* rename errorSource to source in ErrorActionParams interface ([d7f2c04](https://github.com/zotoio/x-fidelity/commit/d7f2c048922bb9a285cbe73482b8a3b8d0ce4634))
|
|
66
|
+
* rename reqCustomProps to customProps in express logger config ([22f380e](https://github.com/zotoio/x-fidelity/commit/22f380e4d80296b248ce472796af6890d1bd8639))
|
|
67
|
+
* replace Function.apply with Function.call for better type safety ([f0e8e2d](https://github.com/zotoio/x-fidelity/commit/f0e8e2d2c1ef7eb0acece223474f33e08e7cd478))
|
|
68
|
+
* resolve logger initialization circular dependency ([3d81e87](https://github.com/zotoio/x-fidelity/commit/3d81e87fc5cabd339c5173a92ec1b66d9377671a))
|
|
69
|
+
* resolve TypeScript error by avoiding reassignment to constant error ([e16fbd6](https://github.com/zotoio/x-fidelity/commit/e16fbd6c57ce98a12fb1e868c0a86f2998774b34))
|
|
70
|
+
* resolve TypeScript errors in engineRunner test file ([26cf0a5](https://github.com/zotoio/x-fidelity/commit/26cf0a5ad1e0fefe14c6e3697bebec2017a6cc72))
|
|
71
|
+
* resolve TypeScript errors in logger implementation ([5025c92](https://github.com/zotoio/x-fidelity/commit/5025c92f75d9a754ef38194e4495ada9bb8b50d2))
|
|
72
|
+
* resolve TypeScript interface inheritance for XFiLogger ([01c9069](https://github.com/zotoio/x-fidelity/commit/01c906978a2b9e034c953646489d28148a48598d))
|
|
73
|
+
* **test:** delete invalid tests ([6a3e449](https://github.com/zotoio/x-fidelity/commit/6a3e449d0c8673a70efc801cefc3a565678e5ecf))
|
|
74
|
+
* update axios client test module imports and error handling ([944d83c](https://github.com/zotoio/x-fidelity/commit/944d83c4d74a4aa6984351ad560737d00cee3f07))
|
|
75
|
+
* update axios mock implementation for 429 retry test ([469881c](https://github.com/zotoio/x-fidelity/commit/469881cc17bae169115c29fcaf0d8d4949f85250))
|
|
76
|
+
* update customContains operator to handle file analysis result object ([961a8cf](https://github.com/zotoio/x-fidelity/commit/961a8cf66384929b2af5e9fc8f647c22803d413f))
|
|
77
|
+
* update docusaurus config to use correct API paths ([749b04f](https://github.com/zotoio/x-fidelity/commit/749b04f14475849294420145101445f325608e85))
|
|
78
|
+
* update function type signatures for plugin facts ([7aaf633](https://github.com/zotoio/x-fidelity/commit/7aaf6335ec421d0f527eb3c9f65b7e4cc8cd104e))
|
|
79
|
+
* update logger implementation to use Pino instead of Winston ([78fa960](https://github.com/zotoio/x-fidelity/commit/78fa960ec2e339bbe3b1bc54d3188ef313287ac0))
|
|
80
|
+
* update logger types and fix pino-http integration ([6dbe72e](https://github.com/zotoio/x-fidelity/commit/6dbe72ef25df54d9faf8a6d41b7069a95a84c5b9))
|
|
81
|
+
* update pino logger types and middleware configuration ([bf3f0bf](https://github.com/zotoio/x-fidelity/commit/bf3f0bf64d1150d5c7bba6cdf47028f20c8b6ce3))
|
|
82
|
+
* update spread args type to tuple for TypeScript compatibility ([cf0579b](https://github.com/zotoio/x-fidelity/commit/cf0579bcdc38007e66d639f01e846fe3c35861b1))
|
|
83
|
+
* use call() instead of apply() for proper argument handling ([eedc5bf](https://github.com/zotoio/x-fidelity/commit/eedc5bfe9497c67fddd051dd4b59c99e3baeedb8))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
### Features
|
|
87
|
+
|
|
88
|
+
* add basic plugin example with custom operator and fact ([7af5f0f](https://github.com/zotoio/x-fidelity/commit/7af5f0fcf1cee2c02fb4c6c73999e99df0c01236))
|
|
89
|
+
* add custom error handling and action execution for rules ([4eb80a3](https://github.com/zotoio/x-fidelity/commit/4eb80a3d7e293588ad57fc34c26c792874f4c43f))
|
|
90
|
+
* add dynamic log level configuration and prefix management ([3bdf085](https://github.com/zotoio/x-fidelity/commit/3bdf08504e7b51c34d1eeef6860e7e88ce019663))
|
|
91
|
+
* add dynamic log level control and improve environment variable handling ([138f6d0](https://github.com/zotoio/x-fidelity/commit/138f6d0efadf5f52c9df560777be84baf63b41d9))
|
|
92
|
+
* add dynamic log level control and improve initialization logging ([0640350](https://github.com/zotoio/x-fidelity/commit/0640350dc947018b41028fd35453c2f1e5562bfa))
|
|
93
|
+
* add environment variable control for log level ([95197a5](https://github.com/zotoio/x-fidelity/commit/95197a502422052d8337f7fe96dd0de3d3aa8fed))
|
|
94
|
+
* add error behavior configuration for rule execution ([2380704](https://github.com/zotoio/x-fidelity/commit/2380704beb019ee72f4a054235ed6592e35f073e))
|
|
95
|
+
* add error count tracking to codebase analysis results ([c8e5847](https://github.com/zotoio/x-fidelity/commit/c8e5847a6fb3285769e2c3c83705bb8ffb88bd0a))
|
|
96
|
+
* add error demo plugin with comprehensive error handling ([336d24a](https://github.com/zotoio/x-fidelity/commit/336d24a3da91ba334951c7ced0271f19a3d6c637))
|
|
97
|
+
* add error handling and export utility modules ([ea41b07](https://github.com/zotoio/x-fidelity/commit/ea41b07b8f4cec57117a339ce60b2e7c147b77d2))
|
|
98
|
+
* add errorCount field to ResultMetadata interface ([24f8d84](https://github.com/zotoio/x-fidelity/commit/24f8d8472bcfccb69f9bcaab4e3d170c3b3e92ec))
|
|
99
|
+
* add ErrorLevel type for rule failure levels ([1523f9f](https://github.com/zotoio/x-fidelity/commit/1523f9fd96a6cd4f3312c171772f97cc5149bdd9))
|
|
100
|
+
* add explicit method signatures to XFiLogger interface ([af1684d](https://github.com/zotoio/x-fidelity/commit/af1684d1db71d0ccf2c047457239d5adba93ae12))
|
|
101
|
+
* add extensions file option to CLI and banner display ([3512f4f](https://github.com/zotoio/x-fidelity/commit/3512f4ffa5cde82a4500f199b8632f9436e99680))
|
|
102
|
+
* add external API integration with regex value extraction ([c019226](https://github.com/zotoio/x-fidelity/commit/c0192260a8ff0c6bc60afc28fc81f4ff48358c10))
|
|
103
|
+
* add external sample rules loading for basic plugin ([b63fb0a](https://github.com/zotoio/x-fidelity/commit/b63fb0aadda2bf9af4018267a2c672fdfe01ec87))
|
|
104
|
+
* add fallback to global modules for plugin loading ([52949fb](https://github.com/zotoio/x-fidelity/commit/52949fbc06d6dd9a1aefdfbf5e9086c2d83b6b5f))
|
|
105
|
+
* add operation field to dependency error logging ([457050b](https://github.com/zotoio/x-fidelity/commit/457050b5cbda10bdfbc22230d29569902eb6444f))
|
|
106
|
+
* add plugin error handling with result propagation ([8f0a78e](https://github.com/zotoio/x-fidelity/commit/8f0a78edba0b9352a7d485bc7ae87cd2b5064356))
|
|
107
|
+
* add plugin loading support to CLI mode ([7c23f01](https://github.com/zotoio/x-fidelity/commit/7c23f01e5ce7307391b42ae5e0f755ee6ef91d3f))
|
|
108
|
+
* add regex validator plugin with API validation support ([664cdb5](https://github.com/zotoio/x-fidelity/commit/664cdb595c925637042b4ce511681b012ba9ceec))
|
|
109
|
+
* add regex validator plugin with validation endpoint support ([0cc8b55](https://github.com/zotoio/x-fidelity/commit/0cc8b55183727c5f68c7493fff50e698df16e951))
|
|
110
|
+
* add routeBasePath to TypeDoc plugin for correct API docs routing ([255bbe5](https://github.com/zotoio/x-fidelity/commit/255bbe591d931b0c31877bbebaec7e32f9c4f175))
|
|
111
|
+
* add sample rule using customFact and customOperator ([27f864f](https://github.com/zotoio/x-fidelity/commit/27f864f196e2e3dbe49b831e3c3e739cef708a20))
|
|
112
|
+
* add sample rules loading to sample plugin ([c1ef6f4](https://github.com/zotoio/x-fidelity/commit/c1ef6f409a4e5e23f60c72c1e489c2f296664abe))
|
|
113
|
+
* add sample rules support to plugin interface ([e263728](https://github.com/zotoio/x-fidelity/commit/e263728de96835ab27188cecbb7f6729ce0d859b))
|
|
114
|
+
* add source map support and error location enhancement to logger ([f641a69](https://github.com/zotoio/x-fidelity/commit/f641a69f992100650ce32831cad9dd197f845914))
|
|
115
|
+
* add src/plugins as first lookup path for plugin loading ([bd2e8b5](https://github.com/zotoio/x-fidelity/commit/bd2e8b586a0b2402910dd301ac706247a2bb7e48))
|
|
116
|
+
* add subpath exports for logger and axios utilities ([21a9ff2](https://github.com/zotoio/x-fidelity/commit/21a9ff293cedfde5d9339516351f933b430d100b))
|
|
117
|
+
* add support for loading external plugins via extensions ([d044e02](https://github.com/zotoio/x-fidelity/commit/d044e020f727aec554ee7dcc4acd3e8bcb6a854b))
|
|
118
|
+
* add symlink support with cycle detection in file operations ([7862c52](https://github.com/zotoio/x-fidelity/commit/7862c526c9e5da4cba438e80d979b6a9c9b67a7b))
|
|
119
|
+
* add test command as default CLI action ([40ad784](https://github.com/zotoio/x-fidelity/commit/40ad7840220e37a2b901037185f09c3ed32ec260))
|
|
120
|
+
* add test server script for serving mock JSON responses ([e204196](https://github.com/zotoio/x-fidelity/commit/e2041960251b6f2c3e3089bc52e1b7673fd553ad))
|
|
121
|
+
* add validate command for archetype configuration validation ([31d489a](https://github.com/zotoio/x-fidelity/commit/31d489a2b7af6d591e257604c11449b612e7716a))
|
|
122
|
+
* enhance error handling with source classification and stack traces ([eaaf0e0](https://github.com/zotoio/x-fidelity/commit/eaaf0e0e3a4b85cd23a234bba12c9e3fefb48f15))
|
|
123
|
+
* enhance Pino logger with multistream and improved serialization ([3956a0b](https://github.com/zotoio/x-fidelity/commit/3956a0b4ac8cfd0944cc4fd3f5681694a865ffd2))
|
|
124
|
+
* enhance plugin loading logs with detailed facts and operators info ([96b49eb](https://github.com/zotoio/x-fidelity/commit/96b49eb69c046dfb7496bcf5d84112841a276d0c))
|
|
125
|
+
* enhance plugin registration with validation and module format support ([785445b](https://github.com/zotoio/x-fidelity/commit/785445b84d62b6a313a09a10dbbab223739daae1))
|
|
126
|
+
* enhance sensitive data protection in logging and env vars ([b7dc977](https://github.com/zotoio/x-fidelity/commit/b7dc977ebe059d760fccad9a66221042f5992a39))
|
|
127
|
+
* expose TypeScript type definitions in package exports ([8c0dd86](https://github.com/zotoio/x-fidelity/commit/8c0dd86ed27d86df36da1db34359a8ea2d4d6549))
|
|
128
|
+
* implement intermittent masking pattern for sensitive data ([18a5d84](https://github.com/zotoio/x-fidelity/commit/18a5d84ac6444897286dae472f66fadab8a766b5))
|
|
129
|
+
* implement partial masking for sensitive data with string support ([d8dc195](https://github.com/zotoio/x-fidelity/commit/d8dc19590710e763e8eb1e7f8002a449d5af3346))
|
|
130
|
+
* implement plugin system for custom facts and operators ([6a03a2c](https://github.com/zotoio/x-fidelity/commit/6a03a2c7a720ff98b85333be7c4073674b10133c))
|
|
131
|
+
* improve sensitive data masking to maintain original length ([b47cbca](https://github.com/zotoio/x-fidelity/commit/b47cbca1ddb772da28b23e5d58123a18e6bac709))
|
|
132
|
+
* integrate plugin facts into allFacts registry ([89504e4](https://github.com/zotoio/x-fidelity/commit/89504e43479af94c9121914e186d2db6e4a1d68a))
|
|
133
|
+
* **plugin framework:** refactor and improve extensibility ([d999ebc](https://github.com/zotoio/x-fidelity/commit/d999ebcfbf482a41d77e96393188d02cc0b2b0e2))
|
|
134
|
+
* support loading multiple npm modules as extensions directly ([e485c6b](https://github.com/zotoio/x-fidelity/commit/e485c6bf550547c43d5d2e9248477e16ff059d6b))
|
|
135
|
+
* update basic plugin to support external API calls and regex extraction ([c23941c](https://github.com/zotoio/x-fidelity/commit/c23941cc7dac4a67ada075970859e395a4369aec))
|
|
136
|
+
* update mask function to show 6 characters at each end ([9b8babe](https://github.com/zotoio/x-fidelity/commit/9b8babe6cfa4b41bcd3b70e476e4e23259d80a27))
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
### BREAKING CHANGES
|
|
140
|
+
|
|
141
|
+
* **plugin framework:** cli options extended to include -e loading plugins, and enhancements to AI
|
|
142
|
+
integration options
|
|
143
|
+
|
|
1
144
|
## [2.17.2](https://github.com/zotoio/x-fidelity/compare/v2.17.1...v2.17.2) (2025-01-16)
|
|
2
145
|
|
|
3
146
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -14,6 +14,7 @@ We welcome contributions to x-fidelity! This document provides guidelines for co
|
|
|
14
14
|
1. Make your changes in your feature branch.
|
|
15
15
|
2. Add or update tests as necessary.
|
|
16
16
|
3. Ensure all tests pass by running `yarn test`.
|
|
17
|
+
4. When modifying documentation to cover new functionality (such as remote validation, GitHub webhook integration, enhanced telemetry, or new plugins), please update both the README and PLUGIN_GUIDANCE accordingly.
|
|
17
18
|
4. Ensure the code lints properly by running `yarn lint`.
|
|
18
19
|
|
|
19
20
|
## Commit Messages
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Plugin Guidance
|
|
2
|
+
|
|
3
|
+
This document provides detailed guidance on how to use, install, and create external plugin extensions for x‑fidelity. External plugins allow you to extend x‑fidelity’s core functionality without modifying the main codebase.
|
|
4
|
+
|
|
5
|
+
## Introduction
|
|
6
|
+
|
|
7
|
+
x‑fidelity supports plugins that conform to the `XFiPlugin` interface. Plugins can add custom facts, operators, and error handlers. They can be installed either globally or locally—and x‑fidelity will load them at runtime as specified with the `-e` or `--extensions` option.
|
|
8
|
+
|
|
9
|
+
## Installation Options
|
|
10
|
+
|
|
11
|
+
### Global Installation
|
|
12
|
+
|
|
13
|
+
- To install an external plugin globally, run:
|
|
14
|
+
```bash
|
|
15
|
+
yarn add <plugin-module-name>
|
|
16
|
+
```
|
|
17
|
+
- Global plugins are available system‑wide; ensure that your global node_modules directory is in your module resolution path.
|
|
18
|
+
|
|
19
|
+
### Local Installation
|
|
20
|
+
|
|
21
|
+
- To install an external plugin locally in your project, run:
|
|
22
|
+
```bash
|
|
23
|
+
yarn add <plugin-module-name>
|
|
24
|
+
```
|
|
25
|
+
- Local plugins are stored in your project’s `node_modules` directory. x‑fidelity will check local installations first.
|
|
26
|
+
|
|
27
|
+
## Using Plugins with x‑fidelity
|
|
28
|
+
|
|
29
|
+
When running x‑fidelity you can specify one or more plugin names using the `-e` or `--extensions` option:
|
|
30
|
+
```bash
|
|
31
|
+
xfidelity /path/to/project -e xfi-basic-plugin xfi-another-plugin
|
|
32
|
+
```
|
|
33
|
+
Separate multiple plugin module names with spaces.
|
|
34
|
+
|
|
35
|
+
## Creating Custom Plugins
|
|
36
|
+
|
|
37
|
+
To create your own plugin, implement the `XFiPlugin` interface. At a minimum, export an object with the following properties:
|
|
38
|
+
|
|
39
|
+
- **name**: A unique string identifier for your plugin.
|
|
40
|
+
- **version**: The plugin version.
|
|
41
|
+
- **facts**: (optional) An array of fact definitions.
|
|
42
|
+
- **operators**: (optional) An array of operator definitions.
|
|
43
|
+
- **onError**: (optional) A function to handle errors encountered in plugin processing.
|
|
44
|
+
|
|
45
|
+
For example, the new Remote String Validation plugin (`xfiPluginRemoteStringValidator`) implements a fact (`remoteSubstringValidation`) and an operator (`invalidRemoteValidation`). See the sample rule `invalidSystemIdConfigured-iterative-rule.json` for usage details.
|
|
46
|
+
|
|
47
|
+
Example:
|
|
48
|
+
```javascript
|
|
49
|
+
// my-plugin.js
|
|
50
|
+
module.exports = {
|
|
51
|
+
name: 'my-plugin',
|
|
52
|
+
version: '1.0.0',
|
|
53
|
+
facts: [{
|
|
54
|
+
name: 'myCustomFact',
|
|
55
|
+
fn: async () => ({ result: 'custom fact data' })
|
|
56
|
+
}],
|
|
57
|
+
operators: [{
|
|
58
|
+
name: 'myCustomOperator',
|
|
59
|
+
fn: (factValue, expectedValue) => factValue === expectedValue
|
|
60
|
+
}],
|
|
61
|
+
onError: (error) => ({
|
|
62
|
+
message: `Plugin error: ${error.message}`,
|
|
63
|
+
level: 'warning',
|
|
64
|
+
details: error.stack
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
```
|
|
68
|
+
After creating your plugin, install it (locally or globally) and reference it using the `-e` option when running x‑fidelity.
|
|
69
|
+
|
|
70
|
+
## Troubleshooting and Tips
|
|
71
|
+
|
|
72
|
+
- **Environment Variables**: Ensure your Node.js module resolution settings include global modules if using global installations.
|
|
73
|
+
- **Debugging**: Enable verbose logging in x‑fidelity to troubleshoot plugin loading.
|
|
74
|
+
- **Name Conflicts**: If multiple plugins expose facts or operators under the same name, loading order may affect which one is used.
|
|
75
|
+
|
|
76
|
+
For any further questions, consult the x‑fidelity documentation or reach out to the maintainers.
|
|
77
|
+
|
|
78
|
+
## Local Development and Testing
|
|
79
|
+
|
|
80
|
+
### Testing Locally with Yarn Link
|
|
81
|
+
|
|
82
|
+
To test your plugin locally without publishing it to an npm repo, you can use `yarn link`. In your plugin’s development directory, run:
|
|
83
|
+
```bash
|
|
84
|
+
yarn link
|
|
85
|
+
```
|
|
86
|
+
Then, in your x‑fidelity project directory, run:
|
|
87
|
+
```bash
|
|
88
|
+
yarn link <plugin-module-name>
|
|
89
|
+
```
|
|
90
|
+
Replace `<plugin-module-name>` with your plugin's package name. This will create a symlink so that any changes you make to your plugin are immediately available to x‑fidelity.
|
|
91
|
+
|
|
92
|
+
### Important Imports for Plugin Integration
|
|
93
|
+
|
|
94
|
+
For seamless integration with x‑fidelity, ensure your plugin imports the key types and utilities. For example:
|
|
95
|
+
```javascript
|
|
96
|
+
import { XFiPlugin } from 'x-fidelity/types/typeDefs';
|
|
97
|
+
import { logger } from 'x-fidelity/utils/logger';
|
|
98
|
+
import { safeClone, safeStringify } from 'x-fidelity/utils/utils';
|
|
99
|
+
```
|
|
100
|
+
These imports ensure that your plugin can interoperate correctly with x‑fidelity’s API, logging, and utility functions.
|
|
101
|
+
|
|
102
|
+
## Sample Plugin Rules and Unit Tests
|
|
103
|
+
|
|
104
|
+
In addition to creating your plugin, you can create sample rules that exercise your plugin's functionality. These sample rules serve both as documentation and as a basis for unit tests to ensure your plugin operates as expected.
|
|
105
|
+
|
|
106
|
+
### Creating Sample Rules
|
|
107
|
+
|
|
108
|
+
Optionally, include unit tests for your custom facts and operators, as shown in our sample tests.
|
|
109
|
+
|
|
110
|
+
For example, if your plugin defines a fact named `customFact` and an operator named `customOperator`, you can create a sample rule JSON file:
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"name": "custom-plugin-rule",
|
|
114
|
+
"conditions": {
|
|
115
|
+
"all": [
|
|
116
|
+
{
|
|
117
|
+
"fact": "customFact",
|
|
118
|
+
"operator": "customOperator",
|
|
119
|
+
"value": "custom fact data"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"event": {
|
|
124
|
+
"type": "warning",
|
|
125
|
+
"params": {
|
|
126
|
+
"message": "Plugin fact and operator validated successfully"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
Place this sample rule file in your local configuration rules directory (e.g., `rules/`), so that x‑fidelity can pick it up during analysis.
|
|
132
|
+
|
|
133
|
+
### Writing Unit Tests
|
|
134
|
+
|
|
135
|
+
Complement your sample rule with unit tests to validate your plugin behavior. For example, using Jest you might create a test file such as `custom-plugin-rule.test.ts` with the following content:
|
|
136
|
+
```typescript
|
|
137
|
+
import { customFact } from 'xfiPluginSimpleExample/facts/customFact';
|
|
138
|
+
import { customOperator } from 'xfiPluginSimpleExample/operators/customOperator';
|
|
139
|
+
|
|
140
|
+
describe('Custom Plugin Rule', () => {
|
|
141
|
+
it('should trigger when the custom fact produces expected data', async () => {
|
|
142
|
+
const factResult = await customFact.fn();
|
|
143
|
+
expect(factResult).toEqual({ result: 'custom fact data' });
|
|
144
|
+
|
|
145
|
+
const operatorResult = customOperator.fn(factResult.result, 'custom fact data');
|
|
146
|
+
expect(operatorResult).toBe(true);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
Include these tests in your plugin’s test suite and run them via:
|
|
151
|
+
```bash
|
|
152
|
+
yarn test
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Final Notes
|
|
156
|
+
|
|
157
|
+
These sample rules and unit tests not only serve as documentation for plugin usage but also help ensure that any future changes do not break your plugin's functionality.
|
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ x-fidelity is an advanced CLI tool and paired config server designed to perform
|
|
|
42
42
|
- [Defining Archetypes](#defining-archetypes)
|
|
43
43
|
- [Defining rules](#defining-rules)
|
|
44
44
|
- [Included Operators](#included-operators)
|
|
45
|
+
- [External Plugin Extensions](#external-plugin-extensions)
|
|
45
46
|
6. [Installation](#installation)
|
|
46
47
|
7. [Usage](#usage)
|
|
47
48
|
- [Basic Usage](#basic-usage)
|
|
@@ -52,6 +53,7 @@ x-fidelity is an advanced CLI tool and paired config server designed to perform
|
|
|
52
53
|
8. [Hosting Config Servers](#hosting-config-servers)
|
|
53
54
|
- [Docker Example](#docker-example)
|
|
54
55
|
9. [Exemptions](#exemptions)
|
|
56
|
+
10. [GitHub Webhook Endpoints](#github-webhook-endpoints)
|
|
55
57
|
10. [CI Pipeline Integration](#ci-pipeline-integration)
|
|
56
58
|
11. [OpenAI Integration](#openai-integration)
|
|
57
59
|
12. [X-Fi Best Practices](#x-fi-best-practices)
|
|
@@ -82,7 +84,9 @@ The tool is designed to be highly customizable, allowing teams to define their o
|
|
|
82
84
|
- **Content Analysis**: Search for specific patterns or strings within your codebase.
|
|
83
85
|
- **Remote Configuration**: Fetch configurations from a remote server for centralized management.
|
|
84
86
|
- **OpenAI Integration**: Leverage AI for advanced code analysis and suggestions.
|
|
85
|
-
- **Extensible Architecture**: Easily add new operators, facts, and
|
|
87
|
+
- **Extensible Architecture**: Easily add new operators, facts, rules, and external plugin extensions to suit your needs.
|
|
88
|
+
- **Enhanced Remote Validation:** Support for remote string validation via the `invalidRemoteValidation` operator. This operator allows x‑fidelity to send extracted string values to an external API (with interpolated parameters such as "#MATCH#") to validate them. (See the sample rule `invalidSystemIdConfigured-iterative-rule.json` in the demo config.)
|
|
89
|
+
- **GitHub Webhook Integration:** The config server now exposes endpoints (e.g. `/github-config-update` and `/github-pull-request-check`) that let you trigger configuration reloads and validation checks automatically when a GitHub event (push or pull request) occurs.
|
|
86
90
|
|
|
87
91
|
## Components and entity names to understand
|
|
88
92
|
|
|
@@ -90,7 +94,7 @@ The tool is designed to be highly customizable, allowing teams to define their o
|
|
|
90
94
|
|
|
91
95
|
- **Rule**: A set of conditions and corresponding actions that define a specific check or requirement for the codebase. Rules are used to identify warnings or fatal issues in the codebase.
|
|
92
96
|
|
|
93
|
-
- **Exemption**: A time-limited waiver for a given git repo for a given rule until a configured expiry date.
|
|
97
|
+
- **Exemption**: A time-limited waiver for a given git repo for a given rule until a configured expiry date. Exemptions can now be provided either as a single JSON file (e.g. `[archetype]-exemptions.json`) or by placing one or more JSON files in a directory named `[archetype]-exemptions`. Any file in that directory that matches the naming pattern will be merged into the effective exemptions.
|
|
94
98
|
|
|
95
99
|
- **Operator**: A function that performs a specific comparison or check within a rule. Operators are used to evaluate conditions in rules.
|
|
96
100
|
|
|
@@ -160,7 +164,9 @@ This diagram shows the main components of x-fidelity and how they interact:
|
|
|
160
164
|
- **Client Environments**: Where x-fidelity is used (CI systems or local development).
|
|
161
165
|
- **x-fidelity Core**: The main components of the system, including the analysis engine, CLI interface, and configuration manager.
|
|
162
166
|
- **x-fidelity Infrastructure**: Servers for configuration and telemetry.
|
|
163
|
-
- **External Services**: GitHub for repository interaction and optional OpenAI integration.
|
|
167
|
+
- **External Services**: GitHub for repository interaction and optional OpenAI integration. Includes GitHub Webhooks for triggering config refresh.
|
|
168
|
+
- **Remote Validation**: Within the plugins outlined under “Extensions”.
|
|
169
|
+
- **Enhanced Telemetry**: Flows from both client and server to the Telemetry Server.
|
|
164
170
|
- **Data Sources**: The files and dependencies that x-fidelity analyzes.
|
|
165
171
|
|
|
166
172
|
## Configuring and Extending x-fidelity
|
|
@@ -376,6 +382,8 @@ Usage example in a rule:
|
|
|
376
382
|
}
|
|
377
383
|
}
|
|
378
384
|
```
|
|
385
|
+
- **invalidRemoteValidation:** This operator is provided by the xfiPluginRemoteStringValidator plugin. It validates extracted string data by sending a request to a remote endpoint (using customizable HTTP method, headers, and a JSON body where “#MATCH#” is interpolated) and uses a JSONPath check on the response to decide if the value is valid.
|
|
386
|
+
|
|
379
387
|
The 'openaiAnalysisHighSeverity' operator will be discussed in the section on the optional OpenAI integration feature.
|
|
380
388
|
|
|
381
389
|
## Installation
|
|
@@ -401,6 +409,12 @@ xfidelity
|
|
|
401
409
|
|
|
402
410
|
### Advanced Usage
|
|
403
411
|
|
|
412
|
+
### Telemetry & Monitoring
|
|
413
|
+
|
|
414
|
+
- Telemetry data is sent to a configurable endpoint via the `-t`/`--telemetryCollector` option.
|
|
415
|
+
- Analysis start, analysis end (including error events) are issued via telemetry, with optional shared secret headers.
|
|
416
|
+
- The CLI and config server now include built-in logging and telemetry support.
|
|
417
|
+
|
|
404
418
|
Use command-line options for more control:
|
|
405
419
|
|
|
406
420
|
```sh
|
|
@@ -410,17 +424,18 @@ Arguments:
|
|
|
410
424
|
directory code directory to analyze
|
|
411
425
|
|
|
412
426
|
Options:
|
|
413
|
-
-d, --dir
|
|
427
|
+
-d, --dir [directory] code directory to analyze. if an arg was passed to command it
|
|
414
428
|
will be treated as the dir (default: ".")
|
|
415
|
-
-a, --archetype
|
|
416
|
-
-c, --configServer
|
|
429
|
+
-a, --archetype [archetype] The archetype to use for analysis (default: "node-fullstack")
|
|
430
|
+
-c, --configServer [configServer] The config server URL for fetching remote archetype
|
|
417
431
|
configurations and rules
|
|
418
|
-
-o, --openaiEnabled
|
|
419
|
-
-t, --telemetryCollector <telemetryCollector
|
|
420
|
-
-m, --mode
|
|
421
|
-
-p, --port
|
|
422
|
-
-l, --localConfigPath
|
|
423
|
-
-j, --jsonTTL
|
|
432
|
+
-o, --openaiEnabled [boolean] Enable OpenAI analysis (default: false)
|
|
433
|
+
-t, --telemetryCollector [<telemetryCollector] The URL telemetry data will be sent to for usage analysis
|
|
434
|
+
-m, --mode [mode] Run mode: 'client' or 'server' (default: "client")
|
|
435
|
+
-p, --port [port] The port to run the server on (default: "8888")
|
|
436
|
+
-l, --localConfigPath [path] Path to local archetype config and rules
|
|
437
|
+
-j, --jsonTTL [minutes] Set the server JSON cache TTL in minutes (default: "10")
|
|
438
|
+
-e, --extensions <modules...> Space-separated list of npm module names to load as external plugin extensions
|
|
424
439
|
-v, --version Output the version number of xfidelity
|
|
425
440
|
-h, --help Display help for command
|
|
426
441
|
```
|
|
@@ -489,6 +504,13 @@ xfidelity -c https://config-server.example.com
|
|
|
489
504
|
|
|
490
505
|
The remote server is also the xfidelity cli configured in server mode to serve archetype and rule configurations.
|
|
491
506
|
|
|
507
|
+
## GitHub Webhook Endpoints
|
|
508
|
+
|
|
509
|
+
The config server now supports GitHub webhook endpoints for real‑time updates:
|
|
510
|
+
- **`/github-config-update`** – triggered on push events to clear the cache and refresh local configurations.
|
|
511
|
+
- **`/github-pull-request-check`** – reserved for future pull-request–related validations.
|
|
512
|
+
These endpoints require validation via secret headers and are configured via the `GITHUB_WEBHOOK_SECRET` environment variable.
|
|
513
|
+
|
|
492
514
|
## Hosting Config Servers
|
|
493
515
|
|
|
494
516
|
x-fidelity allows for centrally managed, hot-updatable custom rulesets that can be executed within managed CI pipelines and locally, ensuring consistency of applied rules. Here's an overview of the setup required:
|
|
@@ -500,7 +522,7 @@ x-fidelity allows for centrally managed, hot-updatable custom rulesets that can
|
|
|
500
522
|
5. Configure the CLI to:
|
|
501
523
|
- Run on startup in server mode (`--mode server`)
|
|
502
524
|
- Point to your rules directory cloned from GitHub (`--localConfigPath ../rule-repo/config`)
|
|
503
|
-
- Optionally set the port to listen on (`--port
|
|
525
|
+
- Optionally set the port to listen on (`--port [port]`)
|
|
504
526
|
6. Create a simple CI pipeline step 'framework fidelity' after git repo clone to workspace:
|
|
505
527
|
- Install the x-fidelity CLI
|
|
506
528
|
- Run the CLI on the checked-out repo, pointing to the server (`--configServer http://my-server:8888`)
|
|
@@ -509,7 +531,7 @@ x-fidelity allows for centrally managed, hot-updatable custom rulesets that can
|
|
|
509
531
|
|
|
510
532
|
### Docker Example
|
|
511
533
|
|
|
512
|
-
x-fidelity server can run in Docker for easy deployment and configuration. Here is a basic example for local testing. A full repo example is available here:
|
|
534
|
+
x-fidelity server can run in Docker for easy deployment and configuration. Here is a basic example for local testing. A full repo example is available here: todo
|
|
513
535
|
|
|
514
536
|
#### Using Docker Compose
|
|
515
537
|
|
|
@@ -583,7 +605,7 @@ Exemptions in x-fidelity provide a way to temporarily waive specific rules for a
|
|
|
583
605
|
|
|
584
606
|
1. **Definition**: An exemption is defined for a specific rule and repository URL, with an expiration date and a reason.
|
|
585
607
|
|
|
586
|
-
2. **Storage**: Exemptions are stored in JSON files, typically named
|
|
608
|
+
2. **Storage**: Exemptions are stored in JSON files, typically named `[archetype]-exemptions.json` (e.g., `node-fullstack-exemptions.json`). NEW a directory named [archetype]-exemptions can be created in the config dir and each json file matching `*-[archetype]-exemptions.json`will also be included.
|
|
587
609
|
|
|
588
610
|
3. **Structure**: Each exemption is an object with the following properties:
|
|
589
611
|
- `repoUrl`: The URL of the repository where the exemption applies.
|
|
@@ -805,6 +827,78 @@ Example `.xfi-config.json`:
|
|
|
805
827
|
|
|
806
828
|
Remember, while `.xfi-config.json` allows you to adjust x-fidelity's behavior in limited ways, it should be used judiciously to maintain the integrity of your code quality checks.
|
|
807
829
|
|
|
830
|
+
### Using Extensions
|
|
831
|
+
|
|
832
|
+
New extensions are available:
|
|
833
|
+
- *Remote String Validation Plugin:* (module: `xfiPluginRemoteStringValidator`) adds remote validation functionality via the `remoteSubstringValidation` fact and the `invalidRemoteValidation` operator.
|
|
834
|
+
- *Sample Custom Plugin:* (module: `xfiPluginSimpleExample`) shows how to add custom facts and operators.
|
|
835
|
+
|
|
836
|
+
To load these plugins, pass their module names via the `-e` (or `--extensions`) CLI option.
|
|
837
|
+
|
|
838
|
+
x-fidelity supports custom extensions through npm modules. To use extensions:
|
|
839
|
+
|
|
840
|
+
1. Install the extension packages:
|
|
841
|
+
```bash
|
|
842
|
+
npm install xfi-basic-plugin xfi-another-plugin
|
|
843
|
+
```
|
|
844
|
+
|
|
845
|
+
2. Run x-fidelity with the extensions:
|
|
846
|
+
```bash
|
|
847
|
+
xfidelity -e xfi-basic-plugin xfi-another-plugin
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
Multiple extensions can be specified by separating them with spaces.
|
|
851
|
+
|
|
852
|
+
### Creating Extensions
|
|
853
|
+
|
|
854
|
+
You can create custom extensions by implementing the XFiPlugin interface:
|
|
855
|
+
|
|
856
|
+
```typescript
|
|
857
|
+
interface XFiPlugin {
|
|
858
|
+
name: string;
|
|
859
|
+
version: string;
|
|
860
|
+
facts?: {
|
|
861
|
+
name: string;
|
|
862
|
+
fn: Function;
|
|
863
|
+
}[];
|
|
864
|
+
operators?: OperatorDefn[];
|
|
865
|
+
}
|
|
866
|
+
```
|
|
867
|
+
|
|
868
|
+
Example extension:
|
|
869
|
+
```javascript
|
|
870
|
+
module.exports = {
|
|
871
|
+
name: 'my-extension',
|
|
872
|
+
version: '1.0.0',
|
|
873
|
+
facts: [{
|
|
874
|
+
name: 'myCustomFact',
|
|
875
|
+
fn: async () => ({ result: 'custom data' })
|
|
876
|
+
}],
|
|
877
|
+
operators: [{
|
|
878
|
+
name: 'myCustomOperator',
|
|
879
|
+
fn: (factValue, expectedValue) => factValue === expectedValue
|
|
880
|
+
}]
|
|
881
|
+
};
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
### External Plugin Extensions
|
|
885
|
+
|
|
886
|
+
x-fidelity now supports external plugin extensions that allow you to extend its core functionality without modifying the main codebase. These plugins conform to the XFiPlugin interface and can be loaded at runtime.
|
|
887
|
+
|
|
888
|
+
**How to use external plugin extensions:**
|
|
889
|
+
1. Install the extension package(s) via npm. For example, run:
|
|
890
|
+
```bash
|
|
891
|
+
npm install xfi-basic-plugin xfi-another-plugin
|
|
892
|
+
```
|
|
893
|
+
2. Start x-fidelity and pass the extension names using the `-e` or `--extensions` option:
|
|
894
|
+
```bash
|
|
895
|
+
xfidelity /path/to/project -e xfi-basic-plugin xfi-another-plugin
|
|
896
|
+
```
|
|
897
|
+
|
|
898
|
+
You can specify multiple plugins, separated by spaces.
|
|
899
|
+
|
|
900
|
+
For more details on creating your own plugin extensions, please refer to the [PLUGIN_GUIDANCE.md](PLUGIN_GUIDANCE.md) file.
|
|
901
|
+
|
|
808
902
|
## Contributing
|
|
809
903
|
|
|
810
904
|
Contributions to x-fidelity are welcome! Please refer to the `CONTRIBUTING.md` file for guidelines on how to contribute to this project.
|