@lcap/nasl 1.0.2 → 2.12.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.
Files changed (299) hide show
  1. package/out/automate/engine/index.d.ts +1 -0
  2. package/out/automate/engine/index.js +34 -12
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/operators.d.ts +10 -2
  5. package/out/automate/engine/operators.js +105 -7
  6. package/out/automate/engine/operators.js.map +1 -1
  7. package/out/automate/engine/uniqueName.d.ts +8 -2
  8. package/out/automate/engine/uniqueName.js +72 -4
  9. package/out/automate/engine/uniqueName.js.map +1 -1
  10. package/out/automate/engine/utils.d.ts +1 -0
  11. package/out/automate/engine/utils.js +92 -67
  12. package/out/automate/engine/utils.js.map +1 -1
  13. package/out/automate/template/process.d.ts +9 -0
  14. package/out/automate/template/process.js +10976 -0
  15. package/out/automate/template/process.js.map +1 -0
  16. package/out/bak/translator.js +1 -0
  17. package/out/bak/translator.js.map +1 -1
  18. package/out/common/BaseNode.d.ts +5 -0
  19. package/out/common/BaseNode.js +24 -3
  20. package/out/common/BaseNode.js.map +1 -1
  21. package/out/concepts/App__.d.ts +51 -49
  22. package/out/concepts/App__.js +86 -53
  23. package/out/concepts/App__.js.map +1 -1
  24. package/out/concepts/BindAttribute__.js +2 -2
  25. package/out/concepts/BindAttribute__.js.map +1 -1
  26. package/out/concepts/BindDirective__.js +10 -3
  27. package/out/concepts/BindDirective__.js.map +1 -1
  28. package/out/concepts/BindEvent__.js +15 -6
  29. package/out/concepts/BindEvent__.js.map +1 -1
  30. package/out/concepts/BooleanLiteral__.d.ts +4 -0
  31. package/out/concepts/BooleanLiteral__.js +11 -0
  32. package/out/concepts/BooleanLiteral__.js.map +1 -1
  33. package/out/concepts/CallFunction__.js +8 -2
  34. package/out/concepts/CallFunction__.js.map +1 -1
  35. package/out/concepts/CallLogic__.js +48 -30
  36. package/out/concepts/CallLogic__.js.map +1 -1
  37. package/out/concepts/CallQueryComponent__.d.ts +8 -7
  38. package/out/concepts/CallQueryComponent__.js +86 -76
  39. package/out/concepts/CallQueryComponent__.js.map +1 -1
  40. package/out/concepts/Comment__.js +1 -1
  41. package/out/concepts/Comment__.js.map +1 -1
  42. package/out/concepts/ConfigGroup__.d.ts +1 -0
  43. package/out/concepts/ConfigGroup__.js +7 -0
  44. package/out/concepts/ConfigGroup__.js.map +1 -1
  45. package/out/concepts/ConfigProperty__.d.ts +1 -0
  46. package/out/concepts/ConfigProperty__.js +3 -0
  47. package/out/concepts/ConfigProperty__.js.map +1 -1
  48. package/out/concepts/Configuration__.d.ts +1 -0
  49. package/out/concepts/Configuration__.js +3 -0
  50. package/out/concepts/Configuration__.js.map +1 -1
  51. package/out/concepts/DataSource__.d.ts +143 -0
  52. package/out/concepts/DataSource__.js +318 -0
  53. package/out/concepts/DataSource__.js.map +1 -0
  54. package/out/concepts/Destination__.js +8 -8
  55. package/out/concepts/Destination__.js.map +1 -1
  56. package/out/concepts/End__.js +2 -2
  57. package/out/concepts/End__.js.map +1 -1
  58. package/out/concepts/EntityIndex__.d.ts +5 -0
  59. package/out/concepts/EntityIndex__.js +6 -0
  60. package/out/concepts/EntityIndex__.js.map +1 -1
  61. package/out/concepts/EntityProperty__.d.ts +9 -0
  62. package/out/concepts/EntityProperty__.js +19 -2
  63. package/out/concepts/EntityProperty__.js.map +1 -1
  64. package/out/concepts/Entity__.d.ts +5 -0
  65. package/out/concepts/Entity__.js +20 -10
  66. package/out/concepts/Entity__.js.map +1 -1
  67. package/out/concepts/Enum__.js +12 -6
  68. package/out/concepts/Enum__.js.map +1 -1
  69. package/out/concepts/ForEachStatement__.js +2 -2
  70. package/out/concepts/ForEachStatement__.js.map +1 -1
  71. package/out/concepts/Function__.d.ts +18 -0
  72. package/out/concepts/Function__.js +96 -1
  73. package/out/concepts/Function__.js.map +1 -1
  74. package/out/concepts/Identifier__.js +6 -15
  75. package/out/concepts/Identifier__.js.map +1 -1
  76. package/out/concepts/IfStatement__.js +8 -8
  77. package/out/concepts/IfStatement__.js.map +1 -1
  78. package/out/concepts/Interface__.js +19 -12
  79. package/out/concepts/Interface__.js.map +1 -1
  80. package/out/concepts/JSBlock__.js +3 -5
  81. package/out/concepts/JSBlock__.js.map +1 -1
  82. package/out/concepts/Logic__.js +44 -44
  83. package/out/concepts/Logic__.js.map +1 -1
  84. package/out/concepts/Module__.d.ts +116 -194
  85. package/out/concepts/Module__.js +31 -114
  86. package/out/concepts/Module__.js.map +1 -1
  87. package/out/concepts/Namespace__.d.ts +0 -86
  88. package/out/concepts/Namespace__.js +1 -108
  89. package/out/concepts/Namespace__.js.map +1 -1
  90. package/out/concepts/Param__.d.ts +2 -1
  91. package/out/concepts/Param__.js +1 -1
  92. package/out/concepts/Param__.js.map +1 -1
  93. package/out/concepts/ProcessElement__.js +30 -10
  94. package/out/concepts/ProcessElement__.js.map +1 -1
  95. package/out/concepts/Process__.d.ts +1 -1
  96. package/out/concepts/Process__.js +17 -10
  97. package/out/concepts/Process__.js.map +1 -1
  98. package/out/concepts/QueryFieldExpression__.js +8 -1
  99. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  100. package/out/concepts/QueryFromExpression__.d.ts +4 -0
  101. package/out/concepts/QueryFromExpression__.js +13 -2
  102. package/out/concepts/QueryFromExpression__.js.map +1 -1
  103. package/out/concepts/QueryJoinExpression__.d.ts +4 -0
  104. package/out/concepts/QueryJoinExpression__.js +14 -3
  105. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  106. package/out/concepts/Return__.js +1 -1
  107. package/out/concepts/Return__.js.map +1 -1
  108. package/out/concepts/Role__.js +10 -3
  109. package/out/concepts/Role__.js.map +1 -1
  110. package/out/concepts/SqlQueryComponent__.d.ts +14 -0
  111. package/out/concepts/SqlQueryComponent__.js +48 -5
  112. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  113. package/out/concepts/StringLiteral__.d.ts +1 -1
  114. package/out/concepts/StringLiteral__.js +1 -1
  115. package/out/concepts/StructureProperty__.js +6 -5
  116. package/out/concepts/StructureProperty__.js.map +1 -1
  117. package/out/concepts/Structure__.js +19 -12
  118. package/out/concepts/Structure__.js.map +1 -1
  119. package/out/concepts/SwitchCase__.d.ts +1 -1
  120. package/out/concepts/SwitchCase__.js +23 -25
  121. package/out/concepts/SwitchCase__.js.map +1 -1
  122. package/out/concepts/SwitchStatement__.js +1 -6
  123. package/out/concepts/SwitchStatement__.js.map +1 -1
  124. package/out/concepts/TypeAnnotation__.d.ts +8 -0
  125. package/out/concepts/TypeAnnotation__.js +44 -2
  126. package/out/concepts/TypeAnnotation__.js.map +1 -1
  127. package/out/concepts/Variable__.js +1 -1
  128. package/out/concepts/Variable__.js.map +1 -1
  129. package/out/concepts/ViewElement__.js +25 -20
  130. package/out/concepts/ViewElement__.js.map +1 -1
  131. package/out/concepts/View__.d.ts +0 -2
  132. package/out/concepts/View__.js +27 -32
  133. package/out/concepts/View__.js.map +1 -1
  134. package/out/concepts/WhileStatement__.js +4 -4
  135. package/out/concepts/WhileStatement__.js.map +1 -1
  136. package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
  137. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  138. package/out/concepts/basics/stdlib/nasl.process.d.ts +4 -0
  139. package/out/concepts/basics/stdlib/nasl.process.js +410 -0
  140. package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
  141. package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
  142. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  143. package/out/concepts/basics/stdlib/nasl.util.js +280 -2
  144. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  145. package/out/concepts/basics/types/index.d.ts +1 -0
  146. package/out/concepts/basics/types/index.js +4 -1
  147. package/out/concepts/basics/types/index.js.map +1 -1
  148. package/out/concepts/index__.d.ts +1 -0
  149. package/out/concepts/index__.js +1 -0
  150. package/out/concepts/index__.js.map +1 -1
  151. package/out/generator/genBundleFiles.d.ts +3 -1
  152. package/out/generator/genBundleFiles.js +23 -5
  153. package/out/generator/genBundleFiles.js.map +1 -1
  154. package/out/generator/genMetaData.d.ts +1 -0
  155. package/out/generator/genMetaData.js +20 -12
  156. package/out/generator/genMetaData.js.map +1 -1
  157. package/out/index.d.ts +1 -1
  158. package/out/index.js +2 -1
  159. package/out/index.js.map +1 -1
  160. package/out/server/createUiTs.js +1 -0
  161. package/out/server/createUiTs.js.map +1 -1
  162. package/out/server/getLogics.js +27 -1
  163. package/out/server/getLogics.js.map +1 -1
  164. package/out/server/getMemberIdentifier.js +5 -0
  165. package/out/server/getMemberIdentifier.js.map +1 -1
  166. package/out/server/getProcesses.d.ts +4 -0
  167. package/out/server/getProcesses.js +69 -1
  168. package/out/server/getProcesses.js.map +1 -1
  169. package/out/server/naslServer.d.ts +1 -0
  170. package/out/server/naslServer.js +223 -26
  171. package/out/server/naslServer.js.map +1 -1
  172. package/out/server/process2LogicNamespace.js +10 -1
  173. package/out/server/process2LogicNamespace.js.map +1 -1
  174. package/out/server/translator.js +37 -1
  175. package/out/server/translator.js.map +1 -1
  176. package/out/service/creator/errHandles.js +5 -0
  177. package/out/service/creator/errHandles.js.map +1 -1
  178. package/out/service/storage/init.d.ts +1 -0
  179. package/out/service/storage/init.js +95 -84
  180. package/out/service/storage/init.js.map +1 -1
  181. package/out/templator/genCreateBlock.js +34 -24
  182. package/out/templator/genCreateBlock.js.map +1 -1
  183. package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
  184. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  185. package/out/templator/genCurdMultipleKeyBlock.js +45 -29
  186. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  187. package/out/templator/genEditTableBlock.js +15 -13
  188. package/out/templator/genEditTableBlock.js.map +1 -1
  189. package/out/templator/genEnumSelectBlock.js +1 -1
  190. package/out/templator/genEnumSelectBlock.js.map +1 -1
  191. package/out/templator/genGridViewBlock.js +29 -24
  192. package/out/templator/genGridViewBlock.js.map +1 -1
  193. package/out/templator/genListViewBlock.js +7 -5
  194. package/out/templator/genListViewBlock.js.map +1 -1
  195. package/out/templator/genQueryComponent.js +25 -26
  196. package/out/templator/genQueryComponent.js.map +1 -1
  197. package/out/templator/genSelectBlock.js +8 -7
  198. package/out/templator/genSelectBlock.js.map +1 -1
  199. package/out/templator/genTableBlock.js +31 -21
  200. package/out/templator/genTableBlock.js.map +1 -1
  201. package/out/templator/genUpdateBlock.js +34 -24
  202. package/out/templator/genUpdateBlock.js.map +1 -1
  203. package/out/templator/utils.d.ts +2 -2
  204. package/out/templator/utils.js.map +1 -1
  205. package/out/test/integration/connect-file.js +6 -6
  206. package/out/test/integration/connect-file.js.map +1 -1
  207. package/out/translator/index.js +1 -1
  208. package/out/translator/index.js.map +1 -1
  209. package/out/utils/index.d.ts +5 -0
  210. package/out/utils/index.js +50 -1
  211. package/out/utils/index.js.map +1 -1
  212. package/package.json +1 -1
  213. package/src/automate/engine/index.js +33 -8
  214. package/src/automate/engine/operators.js +114 -17
  215. package/src/automate/engine/uniqueName.js +77 -9
  216. package/src/automate/engine/utils.js +95 -68
  217. package/src/automate/template/process.js +10999 -0
  218. package/src/bak/translator.js +1 -0
  219. package/src/common/BaseNode.ts +21 -4
  220. package/src/concepts/App__.ts +128 -94
  221. package/src/concepts/BindAttribute__.ts +2 -2
  222. package/src/concepts/BindDirective__.ts +9 -7
  223. package/src/concepts/BindEvent__.ts +14 -6
  224. package/src/concepts/BooleanLiteral__.ts +12 -0
  225. package/src/concepts/CallFunction__.ts +6 -2
  226. package/src/concepts/CallLogic__.ts +47 -32
  227. package/src/concepts/CallQueryComponent__.ts +92 -81
  228. package/src/concepts/Comment__.ts +1 -1
  229. package/src/concepts/ConfigGroup__.ts +3 -1
  230. package/src/concepts/ConfigProperty__.ts +4 -0
  231. package/src/concepts/Configuration__.ts +3 -0
  232. package/src/concepts/DataSource__.ts +391 -0
  233. package/src/concepts/Destination__.ts +24 -8
  234. package/src/concepts/End__.ts +2 -2
  235. package/src/concepts/EntityIndex__.ts +7 -0
  236. package/src/concepts/EntityProperty__.ts +20 -2
  237. package/src/concepts/Entity__.ts +23 -11
  238. package/src/concepts/Enum__.ts +25 -6
  239. package/src/concepts/ForEachStatement__.ts +2 -2
  240. package/src/concepts/Function__.ts +95 -1
  241. package/src/concepts/Identifier__.ts +15 -15
  242. package/src/concepts/IfStatement__.ts +9 -9
  243. package/src/concepts/Interface__.ts +20 -12
  244. package/src/concepts/JSBlock__.ts +3 -12
  245. package/src/concepts/Logic__.ts +45 -79
  246. package/src/concepts/Module__.ts +141 -342
  247. package/src/concepts/Namespace__.ts +1 -204
  248. package/src/concepts/Param__.ts +3 -2
  249. package/src/concepts/ProcessElement__.ts +33 -12
  250. package/src/concepts/Process__.ts +18 -12
  251. package/src/concepts/QueryFieldExpression__.ts +9 -1
  252. package/src/concepts/QueryFromExpression__.ts +13 -2
  253. package/src/concepts/QueryJoinExpression__.ts +14 -3
  254. package/src/concepts/Return__.ts +1 -1
  255. package/src/concepts/Role__.ts +10 -4
  256. package/src/concepts/SqlQueryComponent__.ts +47 -11
  257. package/src/concepts/StringLiteral__.ts +1 -1
  258. package/src/concepts/StructureProperty__.ts +6 -9
  259. package/src/concepts/Structure__.ts +19 -11
  260. package/src/concepts/SwitchCase__.ts +23 -27
  261. package/src/concepts/SwitchStatement__.ts +1 -5
  262. package/src/concepts/TypeAnnotation__.ts +43 -2
  263. package/src/concepts/Variable__.ts +1 -1
  264. package/src/concepts/ViewElement__.ts +26 -39
  265. package/src/concepts/View__.ts +29 -34
  266. package/src/concepts/WhileStatement__.ts +4 -4
  267. package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
  268. package/src/concepts/basics/stdlib/nasl.process.ts +406 -0
  269. package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
  270. package/src/concepts/basics/stdlib/nasl.util.ts +281 -2
  271. package/src/concepts/basics/types/index.ts +1 -0
  272. package/src/concepts/index__.ts +1 -0
  273. package/src/generator/genBundleFiles.ts +28 -7
  274. package/src/generator/genMetaData.ts +22 -13
  275. package/src/index.ts +1 -1
  276. package/src/server/createUiTs.ts +1 -0
  277. package/src/server/getLogics.ts +29 -4
  278. package/src/server/getMemberIdentifier.ts +4 -0
  279. package/src/server/getProcesses.ts +68 -0
  280. package/src/server/naslServer.ts +227 -30
  281. package/src/server/process2LogicNamespace.ts +29 -19
  282. package/src/server/translator.ts +39 -1
  283. package/src/service/creator/errHandles.js +6 -0
  284. package/src/service/storage/init.ts +97 -86
  285. package/src/templator/genCreateBlock.ts +35 -26
  286. package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
  287. package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
  288. package/src/templator/genEditTableBlock.ts +17 -14
  289. package/src/templator/genEnumSelectBlock.ts +1 -1
  290. package/src/templator/genGridViewBlock.ts +30 -25
  291. package/src/templator/genListViewBlock.ts +10 -7
  292. package/src/templator/genQueryComponent.ts +28 -27
  293. package/src/templator/genSelectBlock.ts +9 -8
  294. package/src/templator/genTableBlock.ts +32 -23
  295. package/src/templator/genUpdateBlock.ts +35 -25
  296. package/src/templator/utils.ts +2 -2
  297. package/src/test/integration/connect-file.ts +6 -6
  298. package/src/translator/index.ts +1 -1
  299. package/src/utils/index.ts +51 -0
@@ -1,8 +1,10 @@
1
1
  import { TranslatorState, shiftState, withSourceMap } from '../translator';
2
2
  import Logic from './Logic__';
3
3
  import Param from './Param__';
4
+ import View from './View__';
4
5
  import { ElementToVueOptions } from './ViewElement__';
5
6
  import { getNodeByNodeCallee } from '../automate/engine/utils';
7
+ import { findConceptKeyWordIndexFromNamespace } from '../utils';
6
8
 
7
9
  //================================================================================
8
10
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -387,6 +389,10 @@ export class CallLogic extends LogicItem {
387
389
 
388
390
  // 用于logic回填
389
391
  get calleewholeKey(): string {
392
+ if (!this.calleeNamespace && this.calleeName && this.view) {
393
+ // 页面逻辑单独处理
394
+ return `${this.view.getNamespace()}.${this.view.name}.logics.${this.calleeName}`;
395
+ }
390
396
  return this.calleeNamespace + '.' + this.calleeName;
391
397
  }
392
398
  get calleeKey(): string {
@@ -437,6 +443,9 @@ export class CallLogic extends LogicItem {
437
443
 
438
444
  _setCallee(logic: Logic) {
439
445
  this.calleeNamespace = logic.getNamespace();
446
+ if (logic.parentNode instanceof View) {
447
+ this.calleeNamespace = '';
448
+ }
440
449
  this.calleeName = logic.name;
441
450
  this.arguments = [];
442
451
  logic.params.forEach((param) => {
@@ -453,7 +462,10 @@ export class CallLogic extends LogicItem {
453
462
  }
454
463
 
455
464
  setCallee(logic: Logic) {
456
- const calleeNamespace = logic.getNamespace();
465
+ let calleeNamespace = logic.getNamespace();
466
+ if (logic.parentNode instanceof View) {
467
+ calleeNamespace = '';
468
+ }
457
469
  const calleeName = logic.name;
458
470
  const params = logic.params.map((param) => {
459
471
  const relationOptions = { parentNode: this, parentKey: 'arguments' };
@@ -482,7 +494,10 @@ export class CallLogic extends LogicItem {
482
494
  }
483
495
 
484
496
  setCalleeArgName(logic: Logic) {
485
- const calleeNamespace = logic.getNamespace();
497
+ let calleeNamespace = logic.getNamespace();
498
+ if (logic.parentNode instanceof View) {
499
+ calleeNamespace = '';
500
+ }
486
501
  const calleeName = logic.name;
487
502
  /**
488
503
  * a: logic.params b: this.arguments
@@ -528,7 +543,7 @@ export class CallLogic extends LogicItem {
528
543
 
529
544
  toVue(options?: ElementToVueOptions): string {
530
545
  let code = '';
531
- if (this.calleeNamespace === 'nasl.browser' || this.calleeNamespace === 'nasl.auth' || this.calleeNamespace === 'nasl.configuration') {
546
+ if (this.calleeNamespace === 'nasl.browser' || this.calleeNamespace === 'nasl.auth' || this.calleeNamespace === 'nasl.configuration' || this.calleeNamespace === 'nasl.process') {
532
547
  code += '$global.';
533
548
  }
534
549
  code += this.calleeName;
@@ -563,21 +578,20 @@ export class CallLogic extends LogicItem {
563
578
  let isComponentLogic = false;
564
579
  let componentName = '';
565
580
  const calleeNamespace = this.calleeNamespace;
566
- const isProcessLogic = this.calleeNamespace?.startsWith('app.processes');
567
-
581
+ const keywordProcessIndex = findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'processes');
582
+ const isProcessLogic = keywordProcessIndex !== -1;
568
583
  // calleeNamespace不存在,一定是页面逻辑
569
584
  if (calleeNamespace) {
570
585
  const namespaceArr = calleeNamespace.split('.');
571
- const start = namespaceArr.shift();
586
+ const start = namespaceArr[0];
572
587
  if (start === 'app' || start === 'extensions') {
573
- const mod = start === 'app' ? 0 : 1;
574
- const keywordViews = namespaceArr.filter((namespaceItem, index) => index % 2 === mod).find((namespaceItem) => namespaceItem === 'views');
575
- if (!keywordViews) {
588
+ const keywordViewsIndex = findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'views');
589
+ if (keywordViewsIndex === -1) {
576
590
  isViewLogic = false;
577
591
  }
578
- } else if (start === 'elements' && namespaceArr.length === 2 && namespaceArr[1] === 'logics') {
592
+ } else if (start === 'elements' && namespaceArr.length === 3 && namespaceArr[2] === 'logics') {
579
593
  isComponentLogic = true;
580
- componentName = namespaceArr[0];
594
+ componentName = namespaceArr[1];
581
595
  }
582
596
  }
583
597
  // 全局逻辑
@@ -598,17 +612,7 @@ export class CallLogic extends LogicItem {
598
612
  };
599
613
  });
600
614
  const args = logic?.params || [];
601
-
602
- // 去掉app
603
- namespaceArr.shift();
604
- const keywordEntities = namespaceArr
605
- .map((namespaceItem, index) => ({
606
- key: namespaceItem,
607
- index,
608
- }))
609
- .filter((namespaceItem, index) => index % 2 === 0)
610
- .find((namespaceItem) => namespaceItem.key === 'entities');
611
- const entityName = namespaceArr[keywordEntities?.index + 1];
615
+ const keywordEntitiesIndex = findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'entities');
612
616
  code += `this.$logics['${this.calleeNamespace ? `${this.calleeNamespace}.${this.calleeName}` : this.calleeName}']`;
613
617
  code += `({
614
618
  config: {
@@ -629,7 +633,7 @@ export class CallLogic extends LogicItem {
629
633
  headers: {},
630
634
  `;
631
635
 
632
- if (entityName) {
636
+ if (keywordEntitiesIndex !== -1) {
633
637
  let logicArgs = this.arguments;
634
638
  switch (this.calleeName) {
635
639
  case 'get':
@@ -688,19 +692,30 @@ export class CallLogic extends LogicItem {
688
692
  code += `JSON.parse`;
689
693
  break;
690
694
  }
691
- } else if (calleeNamespace === 'nasl.browser' || calleeNamespace === 'nasl.auth' || calleeNamespace === 'nasl.configuration') {
695
+ } else if (calleeNamespace === 'nasl.browser' || calleeNamespace === 'nasl.auth' || calleeNamespace === 'nasl.configuration' || calleeNamespace === 'nasl.process') {
692
696
  code += `this.$global.${this.calleeName}`;
693
697
  } else {
694
698
  code += `this.${this.calleeName}`;
695
699
  }
696
- code += '(';
697
- this.arguments?.filter((arg) => arg?.expression)
698
- .forEach((arg, index) => {
699
- code += arg?.toJS(shiftState(state, code));
700
- if (index !== this.arguments?.length - 1)
701
- code += ', ';
702
- });
703
- code += ')';
700
+ if (calleeNamespace === 'nasl.process') {
701
+ code += '({';
702
+ this.arguments?.filter((arg) => arg?.expression)
703
+ .forEach((arg, index) => {
704
+ code += `${arg.keyword}: ${arg?.toJS(shiftState(state, code))}`;
705
+ if (index !== this.arguments?.length - 1)
706
+ code += ', ';
707
+ });
708
+ code += '})';
709
+ } else {
710
+ code += '(';
711
+ this.arguments?.filter((arg) => arg?.expression)
712
+ .forEach((arg, index) => {
713
+ code += arg?.toJS(shiftState(state, code));
714
+ if (index !== this.arguments?.length - 1)
715
+ code += ', ';
716
+ });
717
+ code += ')';
718
+ }
704
719
  }
705
720
  return code;
706
721
  }
@@ -751,16 +751,16 @@ export class CallQueryComponent extends LogicItem {
751
751
  if (list.length === 0)
752
752
  return code;
753
753
 
754
- code += indent(state.tabSize + 1) + `.${key}(() => `;
754
+ code += indent((state?.tabSize || 0) + 1) + `.${key}(() => `;
755
755
  list.forEach((item, index) => {
756
756
  if (index > 0)
757
- code += `,\n${indent(state.tabSize + 2)}() => `;
757
+ code += `,\n${indent((state?.tabSize || 0) + 2)}() => `;
758
758
  code += item?.toEmbeddedTS?.(shiftState(state, code, { tabSize: 0 }));
759
759
  });
760
760
  if (list.length > 1) {
761
761
  if (multipleErrorType)
762
- code += `,\n${indent(state.tabSize + 2)}() => ${multipleErrorType}`;
763
- code += `\n${indent(state.tabSize + 1)}`;
762
+ code += `,\n${indent((state?.tabSize || 0) + 2)}() => ${multipleErrorType}`;
763
+ code += `\n${indent((state?.tabSize || 0) + 1)}`;
764
764
  }
765
765
  code += ')\n';
766
766
 
@@ -819,7 +819,7 @@ export class CallQueryComponent extends LogicItem {
819
819
  }
820
820
  // 聚合属性别名
821
821
  this.select.selectElements.forEach((item, index, array) => {
822
- code += indent(state.tabSize + 1);
822
+ code += indent((state?.tabSize || 0) + 1);
823
823
  const { asName, aggregateName, aggregateParam } = item;
824
824
  if (asName)
825
825
  code += `const __${asName} = `;
@@ -835,9 +835,9 @@ export class CallQueryComponent extends LogicItem {
835
835
  });
836
836
 
837
837
  if (this.from)
838
- code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: state.tabSize + 1 }));
838
+ code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
839
839
  else
840
- code += `${indent(state.tabSize + 1)}nasl.langUtil.FROM()\n`;
840
+ code += `${indent((state?.tabSize || 0) + 1)}nasl.langUtil.FROM()\n`;
841
841
 
842
842
  // where 子句
843
843
  code = this.toEmbeddedTSOfSubPart('WHERE', this.where ? [this.where] : [], {
@@ -878,8 +878,8 @@ export class CallQueryComponent extends LogicItem {
878
878
  });
879
879
 
880
880
  code += '\n';
881
- code += indent(state.tabSize + 1) + 'return;\n';
882
- code += indent(state.tabSize) + '})();\n';
881
+ code += indent((state?.tabSize || 0) + 1) + 'return;\n';
882
+ code += indent((state?.tabSize || 0)) + '})();\n';
883
883
  return code;
884
884
  }
885
885
 
@@ -888,6 +888,7 @@ export class CallQueryComponent extends LogicItem {
888
888
  return [];
889
889
 
890
890
  const entityName = node.entityName;
891
+ const entityNamespace = node.entityNamespace;
891
892
  entities.push({
892
893
  concept: 'StructureProperty',
893
894
  name: utils.firstLowerCase(entityName),
@@ -895,7 +896,7 @@ export class CallQueryComponent extends LogicItem {
895
896
  concept: 'TypeAnnotation',
896
897
  typeKind: 'reference',
897
898
  typeName: entityName,
898
- typeNamespace: `${this.app.getNamespace()}.entities`,
899
+ typeNamespace: entityNamespace,
899
900
  },
900
901
  });
901
902
 
@@ -906,7 +907,7 @@ export class CallQueryComponent extends LogicItem {
906
907
  return entities;
907
908
  }
908
909
 
909
- genPropertyListOfAggregate(node: CallQueryComponent) {
910
+ genPropertyListOfAggregate(node: CallQueryComponent, entities: Entity[]) {
910
911
  return node.select.selectElements
911
912
  .filter((item) => item.aggregateName && item.asName)
912
913
  .map((item) => {
@@ -917,9 +918,9 @@ export class CallQueryComponent extends LogicItem {
917
918
  typeName = 'Double';
918
919
  } else {
919
920
  const { entityAsName, propertyName } = item.aggregateParam;
920
- const entity = this.app.entities.find((item: Entity) => item.name === entityAsName);
921
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
921
922
  const property = entity?.properties.find((item) => item.name === propertyName);
922
- typeName = property?.typeAnnotation.typeName;
923
+ typeName = property?.typeAnnotation?.typeName;
923
924
  }
924
925
  return {
925
926
  concept: 'StructureProperty',
@@ -934,22 +935,23 @@ export class CallQueryComponent extends LogicItem {
934
935
  });
935
936
  }
936
937
 
937
- genPropertyListOfGroupBy(node: CallQueryComponent) {
938
+ genPropertyListOfGroupBy(node: CallQueryComponent, entities: Entity[]) {
938
939
  return node.groupBy
939
940
  .filter((item) => item.groupElement && (item.groupElement as QueryFieldExpression).propertyName && (item.groupElement as QueryFieldExpression).asName)
940
941
  .map((item) => {
941
942
  const { entityAsName, propertyName, asName } = item.groupElement as QueryFieldExpression;
942
- const entity = this.app.entities.find((item: Entity) => item.name === entityAsName);
943
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
943
944
  const property = entity?.properties.find((item) => item.name === propertyName);
944
- const typeName = property?.typeAnnotation.typeName;
945
+ const propertyTypeAnnotation = property.typeAnnotation;
946
+
945
947
  return {
946
948
  concept: 'StructureProperty',
947
949
  name: asName,
948
950
  typeAnnotation: {
949
- concept: 'TypeAnnotation',
950
- typeKind: 'primitive',
951
- typeName,
952
- typeNamespace: 'nasl.core',
951
+ concept: propertyTypeAnnotation.concept,
952
+ typeKind: propertyTypeAnnotation.typeKind,
953
+ typeName: propertyTypeAnnotation.typeName,
954
+ typeNamespace: propertyTypeAnnotation.typeNamespace,
953
955
  },
954
956
  };
955
957
  });
@@ -966,13 +968,14 @@ export class CallQueryComponent extends LogicItem {
966
968
 
967
969
  saveStructure() {
968
970
  // 没有数据源时不初始化数据结构
969
- if (!this.entityNames.length) {
971
+ if (!this.entityInfos.length) {
970
972
  return;
971
973
  }
972
-
974
+ const entityNamespace = this.from?.entityNamespace;
975
+ const entities = this.app.findNodeByCompleteName(entityNamespace);
973
976
  if (!this.isAutoInfer()) {
974
977
  // 存量应用走之前的逻辑
975
- return this.saveStructureNoInfer();
978
+ return this.saveStructureNoInfer(entities);
976
979
  }
977
980
 
978
981
  const groupBy = this.groupBy;
@@ -999,35 +1002,35 @@ export class CallQueryComponent extends LogicItem {
999
1002
  const groupByLength = groupBy.filter((item) => (item.groupElement as QueryFieldExpression)?.propertyName && (item.groupElement as QueryFieldExpression).asName).length;
1000
1003
  const aggregateLength = selectElements.filter((item) => item.aggregateName && item.asName).length;
1001
1004
 
1005
+
1006
+
1002
1007
  // 1. 有分组
1003
1008
  if (groupByLength) {
1004
1009
  if (!aggregateLength && groupByLength === 1) {
1005
1010
  // 1.1 单分组无聚合:`PageOf<列的类型>`
1006
- const { entityAsName, propertyName } = groupBy[0].groupElement as any;
1007
- const entity = this.app.entities.find((item: Entity) => item.name === entityAsName);
1008
- const property = entity?.properties.find((item) => item.name === propertyName);
1009
- const typeName = property?.typeAnnotation.typeName;
1011
+ const { entityAsName, propertyName } = groupBy[0].groupElement as QueryFieldExpression;
1012
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
1013
+ const property = entity?.properties.find((item: any) => item.name === propertyName);
1014
+ const propertyTypeAnnotation = property.typeAnnotation;
1010
1015
 
1011
1016
  typeAnnotation = TypeAnnotation.from({
1012
- text: `PageOf<${typeName}>`,
1017
+ text: `PageOf<${propertyTypeAnnotation.typeName}>`,
1013
1018
  concept: 'TypeAnnotation',
1014
1019
  typeKind: 'generic',
1015
1020
  typeName: 'PageOf',
1016
1021
  typeNamespace: `nasl.collection`,
1017
- typeArguments: [
1018
- TypeAnnotation.from({
1019
- concept: 'TypeAnnotation',
1020
- typeKind: 'primitive',
1021
- typeName,
1022
- typeNamespace: 'nasl.core',
1023
- }, this.typeAnnotation, 'typeAnnotation'),
1024
- ],
1022
+ typeArguments: [TypeAnnotation.from({
1023
+ concept: propertyTypeAnnotation.concept,
1024
+ typeKind: propertyTypeAnnotation.typeKind,
1025
+ typeName: propertyTypeAnnotation.typeName,
1026
+ typeNamespace: propertyTypeAnnotation.typeNamespace,
1027
+ }, this.typeAnnotation, 'typeAnnotation')],
1025
1028
  }, this, 'typeAnnotation');
1026
1029
  } else {
1027
1030
  // 1.2 多分组:`PageOf<Structure>`
1028
1031
  const structure = this.genStructure(structureName, [
1029
- ...this.genPropertyListOfGroupBy(this),
1030
- ...this.genPropertyListOfAggregate(this),
1032
+ ...this.genPropertyListOfGroupBy(this, entities),
1033
+ ...this.genPropertyListOfAggregate(this, entities),
1031
1034
  ]);
1032
1035
  this.app.addStructure(structure);
1033
1036
 
@@ -1061,9 +1064,9 @@ export class CallQueryComponent extends LogicItem {
1061
1064
  } else {
1062
1065
  // 2.1.3. 其他返回列类型,包含:`Integer`、`Long`、`Double`
1063
1066
  const { entityAsName, propertyName } = selectElements[0].aggregateParam;
1064
- const entity = this.app.entities.find((item: Entity) => item.name === entityAsName);
1065
- const property = entity?.properties.find((item) => item.name === propertyName);
1066
- typeName = property?.typeAnnotation.typeName;
1067
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
1068
+ const property = entity?.properties.find((item: any) => item.name === propertyName);
1069
+ typeName = property?.typeAnnotation?.typeName;
1067
1070
  }
1068
1071
  typeAnnotation = TypeAnnotation.from({
1069
1072
  concept: 'TypeAnnotation',
@@ -1074,7 +1077,7 @@ export class CallQueryComponent extends LogicItem {
1074
1077
  } else {
1075
1078
  // 2.2. 多聚合:`Structure`(自动创建 `Structure`)
1076
1079
  const structure = this.genStructure(structureName, [
1077
- ...this.genPropertyListOfAggregate(this),
1080
+ ...this.genPropertyListOfAggregate(this, entities),
1078
1081
  ]);
1079
1082
  this.app.addStructure(structure);
1080
1083
 
@@ -1089,7 +1092,7 @@ export class CallQueryComponent extends LogicItem {
1089
1092
  // 2.3. 无聚合(默认情况):`PageOf<Structure>`(自动创建 `Structure`)
1090
1093
  const structure = this.genStructure(structureName, [
1091
1094
  ...this.genPropertyListOfFrom(this.from),
1092
- ...this.genPropertyListOfAggregate(this),
1095
+ ...this.genPropertyListOfAggregate(this, entities),
1093
1096
  ]);
1094
1097
  this.app.addStructure(structure);
1095
1098
 
@@ -1114,10 +1117,10 @@ export class CallQueryComponent extends LogicItem {
1114
1117
  this.update({ typeAnnotation });
1115
1118
  }
1116
1119
 
1117
- saveStructureNoInfer() {
1120
+ saveStructureNoInfer(entities: any[] = []) {
1118
1121
  const source = this.genStructure(null, [
1119
1122
  ...this.genPropertyListOfFrom(this.from),
1120
- ...this.genPropertyListOfAggregate(this),
1123
+ ...this.genPropertyListOfAggregate(this, entities),
1121
1124
  ]);
1122
1125
  if (this.typeAnnotation) {
1123
1126
  const structure = this.app.structures.find((item) => item.name === this.typeAnnotation.typeName);
@@ -1162,53 +1165,61 @@ export class CallQueryComponent extends LogicItem {
1162
1165
  } catch {}
1163
1166
  }
1164
1167
 
1165
- getEntityNames(node: QueryFromExpression | QueryJoinExpression, set = new Set()) {
1168
+ getEntityInfos(node: QueryFromExpression | QueryJoinExpression, set = new Set()) {
1166
1169
  if (node?.entityName)
1167
- set.add(node.entityName);
1170
+ set.add({
1171
+ namespace: node.entityNamespace,
1172
+ name: node.entityName,
1173
+ });
1168
1174
 
1169
1175
  node?.joinParts?.forEach((child) => {
1170
- this.getEntityNames(child, set);
1176
+ this.getEntityInfos(child, set);
1171
1177
  });
1172
1178
  return Array.from(set);
1173
1179
  }
1174
1180
 
1175
- get entityNames() {
1176
- return this.getEntityNames(this.from);
1181
+ get entityInfos() {
1182
+ return this.getEntityInfos(this.from);
1177
1183
  }
1178
1184
 
1179
1185
  getCompletionPropertyOfEntities() {
1180
- const entities = this.app.entities;
1181
- const children = this.entityNames
1182
- .map((name) => entities.find((item) => item.name === name))
1183
- .filter((item) => item)
1184
- .map((entity) => ({
1185
- concept: 'Entity',
1186
- name: entity.name,
1187
- children: entity.properties.map((property) => {
1188
- const completionProperty = new CompletionProperty({
1189
- concept: 'CompletionProperty',
1190
- name: property.name,
1191
- value: `${entity.name}.${property.name}`,
1192
- expression: LogicItem.from({
1193
- concept: 'QueryFieldExpression',
1194
- name: property.name,
1195
- value: `${entity.name}.${property.name}`,
1196
- entityAsName: entity.name,
1197
- propertyName: property.name,
1186
+ const firstEntityInfo: any = this.entityInfos[0];
1187
+ if (firstEntityInfo) {
1188
+ const namespace = firstEntityInfo.namespace;
1189
+ const entities: Entity[] = this.app.findNodeByCompleteName(namespace);
1190
+ if (Array.isArray(entities)) {
1191
+ const children = this.entityInfos
1192
+ .map(({ name }) => entities.find((item) => item.name === name))
1193
+ .filter((item) => item)
1194
+ .map((entity) => ({
1195
+ concept: 'Entity',
1196
+ name: entity.name,
1197
+ children: entity.properties.map((property) => {
1198
+ const completionProperty = new CompletionProperty({
1199
+ concept: 'CompletionProperty',
1200
+ name: property.name,
1201
+ value: `${entity.name}.${property.name}`,
1202
+ expression: LogicItem.from({
1203
+ concept: 'QueryFieldExpression',
1204
+ name: property.name,
1205
+ value: `${entity.name}.${property.name}`,
1206
+ entityAsName: entity.name,
1207
+ propertyName: property.name,
1208
+ }),
1209
+ });
1210
+ completionProperty.icon = 'property';
1211
+ return completionProperty;
1198
1212
  }),
1199
- });
1200
- completionProperty.icon = 'property';
1201
- return completionProperty;
1202
- }),
1203
- }));
1204
- if (children.length === 0)
1205
- return;
1206
-
1207
- return {
1208
- name: '实体',
1209
- icon: 'category',
1210
- children,
1211
- };
1213
+ }));
1214
+ if (children.length) {
1215
+ return {
1216
+ name: '实体',
1217
+ icon: 'category',
1218
+ children,
1219
+ };
1220
+ }
1221
+ }
1222
+ }
1212
1223
  }
1213
1224
 
1214
1225
  getCompletionPropertyOfAggregateAsNames() {
@@ -79,7 +79,7 @@ export class Comment extends LogicItem {
79
79
  @withSourceMap()
80
80
  toEmbeddedTS(state?: TranslatorState): string {
81
81
  let code = '';
82
- code += `\n${indent(state.tabSize)}
82
+ code += `\n${indent((state?.tabSize || 0))}
83
83
  /**
84
84
  * 注释不用翻译
85
85
  */
@@ -275,7 +275,9 @@ export class ConfigGroup extends BaseNode {
275
275
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
276
276
  // 自动生成的代码已结束。下面可以手动编写。
277
277
  //================================================================================
278
-
278
+ getProperty(name = '') {
279
+ return this.properties.find((item) => item.name === name);
280
+ }
279
281
  //================================================================================
280
282
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
281
283
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -292,6 +292,10 @@ export class ConfigProperty extends BaseNode {
292
292
  ...object,
293
293
  });
294
294
  }
295
+
296
+ getPropertyEnv(env = '') {
297
+ return this.values.find((item) => item.env === env);
298
+ }
295
299
  //================================================================================
296
300
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
297
301
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -271,6 +271,9 @@ export class Configuration extends BaseNode {
271
271
  ],
272
272
  };
273
273
  }
274
+ getGroup(name = '') {
275
+ return this.groups.find((item) => item.name === name);
276
+ }
274
277
 
275
278
  //================================================================================
276
279
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!