@lcap/nasl 3.13.1-debug.6 → 3.13.1-rc.2

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.
Files changed (49) hide show
  1. package/out/concepts/validator/VusionValidator.d.ts +33 -0
  2. package/out/concepts/validator/VusionValidator.d.ts.map +1 -0
  3. package/out/concepts/validator/VusionValidator.js +164 -0
  4. package/out/concepts/validator/VusionValidator.js.map +1 -0
  5. package/out/concepts/validator/builtIn/rules.d.ts +5 -0
  6. package/out/concepts/validator/builtIn/rules.d.ts.map +1 -0
  7. package/out/concepts/validator/builtIn/rules.js +112 -0
  8. package/out/concepts/validator/builtIn/rules.js.map +1 -0
  9. package/out/concepts/validator/builtIn/validators.d.ts +6 -0
  10. package/out/concepts/validator/builtIn/validators.d.ts.map +1 -0
  11. package/out/concepts/validator/builtIn/validators.js +146 -0
  12. package/out/concepts/validator/builtIn/validators.js.map +1 -0
  13. package/out/concepts/validator/index.d.ts +263 -0
  14. package/out/concepts/validator/index.d.ts.map +1 -0
  15. package/out/concepts/validator/index.js +318 -0
  16. package/out/concepts/validator/index.js.map +1 -0
  17. package/out/concepts/validator/locales/zh-CN.d.ts +99 -0
  18. package/out/concepts/validator/locales/zh-CN.d.ts.map +1 -0
  19. package/out/concepts/validator/locales/zh-CN.js +100 -0
  20. package/out/concepts/validator/locales/zh-CN.js.map +1 -0
  21. package/out/concepts/validator/parseRules.d.ts +3 -0
  22. package/out/concepts/validator/parseRules.d.ts.map +1 -0
  23. package/out/concepts/validator/parseRules.js +139 -0
  24. package/out/concepts/validator/parseRules.js.map +1 -0
  25. package/out/concepts/validator/rules.d.ts +67 -0
  26. package/out/concepts/validator/rules.d.ts.map +1 -0
  27. package/out/concepts/validator/rules.js +150 -0
  28. package/out/concepts/validator/rules.js.map +1 -0
  29. package/out/concepts/validator/types.d.ts +15 -0
  30. package/out/concepts/validator/types.d.ts.map +1 -0
  31. package/out/concepts/validator/types.js +3 -0
  32. package/out/concepts/validator/types.js.map +1 -0
  33. package/out/generator/genBundleFiles.js +49 -7
  34. package/out/generator/genBundleFiles.js.map +1 -1
  35. package/out/generator/ui-library-declaration/types.d.ts +1 -1
  36. package/out/generator/ui-library-declaration/types.d.ts.map +1 -1
  37. package/out/natural/transformTS2UI.d.ts.map +1 -1
  38. package/out/natural/transformTS2UI.js +35 -53
  39. package/out/natural/transformTS2UI.js.map +1 -1
  40. package/out/natural/transforms/transform2LogicItem.d.ts.map +1 -1
  41. package/out/natural/transforms/transform2LogicItem.js +7 -4
  42. package/out/natural/transforms/transform2LogicItem.js.map +1 -1
  43. package/out/server/extendBaseNode.js +1 -1
  44. package/out/server/extendBaseNode.js.map +1 -1
  45. package/out/server/naslServer.d.ts.map +1 -1
  46. package/out/server/naslServer.js +102 -3
  47. package/out/server/naslServer.js.map +1 -1
  48. package/out/service/autofix/rules/rule-convert-incompatible-assignment-to-union.js.map +1 -1
  49. package/package.json +12 -10
@@ -45,6 +45,8 @@ const path = __importStar(require("path"));
45
45
  const worker_threads_1 = require("worker_threads");
46
46
  /// #endif
47
47
  const concepts_1 = require("../concepts");
48
+ const validator_1 = require("../concepts/validator");
49
+ const utils_1 = require("../utils");
48
50
  const asserts_1 = require("@lcap/nasl-concepts/asserts");
49
51
  const service_1 = require("@lcap/nasl-concepts/service");
50
52
  const Checker = __importStar(require("./checker"));
@@ -55,7 +57,7 @@ const translator_2 = require("./translator");
55
57
  const common_1 = require("../common");
56
58
  const diagnostic_1 = require("../manager/diagnostic");
57
59
  const naslStdlibMap_1 = __importDefault(require("./naslStdlibMap"));
58
- const utils_1 = require("../utils");
60
+ const utils_2 = require("../utils");
59
61
  const decorators_1 = require("../decorators");
60
62
  const nasl_concepts_1 = require("@lcap/nasl-concepts");
61
63
  const NEED_SYNC_BIND_ATTRIBUTE = [
@@ -110,6 +112,51 @@ function getBusinessComponentPos(fileNode) {
110
112
  }
111
113
  }
112
114
  }
115
+ /**
116
+ * 属于实体逻辑
117
+ */
118
+ function belongEntityLogic(node) {
119
+ const logic = (node.getAncestor('Logic') || node);
120
+ return concepts_1.asserts.isLogic(logic) && (0, utils_1.findConceptKeyWordIndexFromNodePath)(logic.nodePath, 'entities') !== -1;
121
+ }
122
+ /**
123
+ * 属于虚拟入参
124
+ * @param node
125
+ * @returns
126
+ */
127
+ function belongVirtualParams(node) {
128
+ return (0, utils_1.findConceptKeyWordIndexFromNodePath)(node?.nodePath, 'virtualParams') !== -1;
129
+ }
130
+ /**
131
+ * 包含特定的关键字
132
+ * @param node
133
+ * @param keywords
134
+ * @returns
135
+ */
136
+ function containsSpecificKeywords(node, keywords) {
137
+ return keywords.filter((keyword) => {
138
+ return (0, utils_1.findConceptKeyWordIndexFromNodePath)(node?.nodePath, keyword) !== -1;
139
+ })?.length;
140
+ }
141
+ /**
142
+ * 方法下入参'_'
143
+ * @param node
144
+ * @returns
145
+ */
146
+ function isFunctionUnderlineParam(node) {
147
+ return node?.name === '_' && node?.concept === 'Param' && node?.parentNode?.concept === 'Function';
148
+ }
149
+ /**
150
+ * 是端类型下的参数
151
+ * @param node
152
+ * @returns
153
+ */
154
+ function isFrontendTypeEvent(node) {
155
+ if (node?.name === 'event') {
156
+ return node.getAncestor('FrontendType');
157
+ }
158
+ return false;
159
+ }
113
160
  // 联合类型切割取出类型
114
161
  function getDisplayString2Type(displayString) {
115
162
  const targetString = displayString.match(/value:\s(\S+)\)/)?.[1];
@@ -1565,7 +1612,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
1565
1612
  // 是否包含组件逻辑
1566
1613
  hasComponentLogics(expression) {
1567
1614
  let flag = false;
1568
- (0, utils_1.traverse)((current) => {
1615
+ (0, utils_2.traverse)((current) => {
1569
1616
  const { node } = current || {};
1570
1617
  const { concept } = node || {};
1571
1618
  if (concept === 'CallLogic') {
@@ -2860,6 +2907,58 @@ let NaslServer = NaslServer_1 = class NaslServer {
2860
2907
  diagnostics.push(diagnostic);
2861
2908
  }
2862
2909
  }
2910
+ // 校验节点名
2911
+ function* validateNodeName(node) {
2912
+ // 排除一些不需要校验的情况
2913
+ if (isFrontendTypeEvent(node) || belongEntityLogic(node) || belongVirtualParams(node)
2914
+ || containsSpecificKeywords(node, ['dependencies', 'interfaceDependencies'])
2915
+ || isFunctionUnderlineParam(node)) {
2916
+ return;
2917
+ }
2918
+ const { concept } = node || {};
2919
+ let conceptValidator = validator_1.validator[concept];
2920
+ if (concept === 'EnumItem' && node?.parentNode?.valueType?.typeName === 'Long') {
2921
+ conceptValidator = validator_1.validator['EnumItemInteger'];
2922
+ }
2923
+ if (conceptValidator) {
2924
+ try {
2925
+ const vusionValidator = new validator_1.VusionValidator({}, {}, conceptValidator.rules(node), null) || {};
2926
+ let toBeVerifiedName = node;
2927
+ const map = {
2928
+ EnumItem: 'value',
2929
+ };
2930
+ const properties = (map[concept] || 'name').split('.');
2931
+ if (properties) {
2932
+ properties.forEach((property) => {
2933
+ toBeVerifiedName = toBeVerifiedName[property];
2934
+ });
2935
+ }
2936
+ const res = yield vusionValidator.validate(toBeVerifiedName, [], {
2937
+ label: (0, concepts_1.getConceptConstructor)(concept).nodeTitle,
2938
+ alwaysResolve: true,
2939
+ });
2940
+ if (res) {
2941
+ const diagnostic = {
2942
+ node,
2943
+ severity: 'error',
2944
+ message: `【${toBeVerifiedName}】命名非法:${res}`,
2945
+ };
2946
+ diagnostics.push(diagnostic);
2947
+ }
2948
+ }
2949
+ catch (err) {
2950
+ if (utils.isDebugMode) {
2951
+ self.logger.info(err);
2952
+ }
2953
+ }
2954
+ }
2955
+ }
2956
+ /**
2957
+ * 问题没有收敛,先注释
2958
+ */
2959
+ // yield* utils.wrapIteratorToGenerator(fileNodeRaw.sourceMap.entries(), function* ([node]: any) {
2960
+ // yield* validateNodeName(node);
2961
+ // });
2863
2962
  return diagnostics;
2864
2963
  }
2865
2964
  timeoutCheck(fileNodeRaw, fileNode, diagnostics) {
@@ -6342,7 +6441,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
6342
6441
  this.semData.recoverSlowGetters();
6343
6442
  this.semData.clearSemanticData();
6344
6443
  this.semData.isFirstScreen = false;
6345
- const isFrontendLogic = targetNodeRaw.getAncestorRaw('Logic') && Boolean(fileNodeRaw.concept === 'View' ?? fileNodeRaw.concept === 'BusinessComponent');
6444
+ const isFrontendLogic = targetNodeRaw.getAncestorRaw('Logic') && (fileNodeRaw.concept === 'View' || fileNodeRaw.concept === 'BusinessComponent');
6346
6445
  // @ts-ignore
6347
6446
  !isFrontendLogic && this.semData.updateDirtyIndRetDeps(fileNodeRaw);
6348
6447
  this.logger.timeEnd('TS 文件变更');