@lcap/nasl 2.18.0-beta.6 → 2.18.0-beta.7

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 (81) hide show
  1. package/out/common/BaseNode.js +1 -0
  2. package/out/common/BaseNode.js.map +1 -1
  3. package/out/concepts/BatchAssignment__.js +63 -46
  4. package/out/concepts/BatchAssignment__.js.map +1 -1
  5. package/out/concepts/CallLogic__.d.ts +2 -1
  6. package/out/concepts/CallLogic__.js +26 -11
  7. package/out/concepts/CallLogic__.js.map +1 -1
  8. package/out/concepts/Destination__.d.ts +2 -1
  9. package/out/concepts/Destination__.js +90 -22
  10. package/out/concepts/Destination__.js.map +1 -1
  11. package/out/concepts/Logic__.js +6 -7
  12. package/out/concepts/Logic__.js.map +1 -1
  13. package/out/concepts/MatchExpression__.d.ts +97 -0
  14. package/out/concepts/MatchExpression__.js +281 -0
  15. package/out/concepts/MatchExpression__.js.map +1 -0
  16. package/out/concepts/ViewElement__.js +1 -1
  17. package/out/concepts/ViewElement__.js.map +1 -1
  18. package/out/concepts/View__.js +4 -0
  19. package/out/concepts/View__.js.map +1 -1
  20. package/out/generator/genBundleFiles.js +27 -181
  21. package/out/generator/genBundleFiles.js.map +1 -1
  22. package/out/generator/genMetaData.d.ts +1 -10
  23. package/out/generator/genMetaData.js +189 -50
  24. package/out/generator/genMetaData.js.map +1 -1
  25. package/out/server/extendBaseNode.js +4 -18
  26. package/out/server/extendBaseNode.js.map +1 -1
  27. package/out/server/formatTsUtils.js +2 -1
  28. package/out/server/formatTsUtils.js.map +1 -1
  29. package/out/server/naslServer.js +5 -6
  30. package/out/server/naslServer.js.map +1 -1
  31. package/out/server/translator.js +19 -4
  32. package/out/server/translator.js.map +1 -1
  33. package/out/templator/sql-parser/index.d.ts +1 -0
  34. package/out/templator/sql-parser/index.js +228 -0
  35. package/out/templator/sql-parser/index.js.map +1 -0
  36. package/out/templator/sql-parser/parser.js +26664 -0
  37. package/out/templator/sql-parser/parser.js.map +1 -0
  38. package/package.json +2 -2
  39. package/sandbox/stdlib/dist/nasl.logging.js +0 -0
  40. package/sandbox/stdlib/nasl.util.ts +1 -1
  41. package/src/automate/engine/dist/index.dev.js +517 -0
  42. package/src/common/BaseNode.ts +1 -0
  43. package/src/common/dist/BaseNode.js +1101 -0
  44. package/src/concepts/BatchAssignment__.ts +66 -50
  45. package/src/concepts/CallLogic__.ts +26 -11
  46. package/src/concepts/Destination__.ts +92 -22
  47. package/src/concepts/Logic__.ts +6 -7
  48. package/src/concepts/ViewElement__.ts +8 -29
  49. package/src/concepts/View__.ts +4 -0
  50. package/src/concepts/basics/stdlib/dist/nasl.util.js +1503 -0
  51. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
  52. package/src/concepts/dist/Anchor__.js +179 -0
  53. package/src/concepts/dist/Assignment__.js +301 -0
  54. package/src/concepts/dist/CallFunction__.js +513 -0
  55. package/src/concepts/dist/CallInterface__.js +533 -0
  56. package/src/concepts/dist/CallLogic__.js +892 -0
  57. package/src/concepts/dist/ForEachStatement__.js +426 -0
  58. package/src/concepts/dist/MatchCase__.js +587 -0
  59. package/src/concepts/dist/Match__.js +631 -0
  60. package/src/concepts/dist/MemberExpression__.js +348 -0
  61. package/src/concepts/dist/Param__.js +538 -0
  62. package/src/concepts/dist/Return__.js +494 -0
  63. package/src/concepts/dist/Variable__.js +537 -0
  64. package/src/concepts/dist/ViewElement__.js +1680 -0
  65. package/src/generator/dist/genBundleFiles.js +261 -0
  66. package/src/generator/dist/genMetaData.js +249 -0
  67. package/src/generator/genBundleFiles.ts +29 -218
  68. package/src/generator/genMetaData.ts +182 -77
  69. package/src/server/dist/formatTsUtils.js +683 -0
  70. package/src/server/dist/naslServer.js +3474 -0
  71. package/src/server/extendBaseNode.ts +4 -19
  72. package/src/server/formatTsUtils.ts +2 -1
  73. package/src/server/naslServer.ts +5 -6
  74. package/src/server/translator.ts +18 -4
  75. package/src/service/storage/dist/init.js +572 -0
  76. package/ts-worker/dist/webpack.config.dev.js +108 -0
  77. package/dist/bundle.js +0 -3962
  78. package/dist/bundle.js.LICENSE.txt +0 -16
  79. package/out/generator/release.d.ts +0 -1
  80. package/out/generator/release.js +0 -51
  81. package/out/generator/release.js.map +0 -1
@@ -161,19 +161,6 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
161
161
  refsList = refsList.filter((item) =>
162
162
  // 因为ui组件本身会多渲染一次,就先过滤一个
163
163
  !(item.lineText.includes(': nasl.ui.')));
164
- // 删除参数单独处理
165
- if (node instanceof Param) {
166
- const methodRefs: tsProtocol.ReferencesResponseItem[] = [];
167
- refsList.forEach((item) => {
168
- // 入参查找引用,查到logic 和自己,内容完全一样,就保留一个
169
- const find = methodRefs.find((findItem) => item.lineText === findItem.lineText);
170
- if (!find) {
171
- methodRefs.push(item);
172
- }
173
- });
174
- refsList = methodRefs;
175
- }
176
-
177
164
  // delete的弹框展示
178
165
  const confirmParms = {
179
166
  actionType: 'delete',
@@ -182,7 +169,7 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
182
169
  icon: 'warning',
183
170
  };
184
171
  let callback = null;
185
- if (refsList.length <= 1) {
172
+ if (refsList.length <= 1 || (node instanceof Param && node.parentNode instanceof Logic && refsList.length <= 2)) {
186
173
  // 页面组件直接删除然后return
187
174
  if (node instanceof ViewElement) {
188
175
  this.delete();
@@ -235,6 +222,7 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
235
222
  App.emit('collect:start', {
236
223
  actionMsg: '删除参数',
237
224
  });
225
+ const Index = node.getIndexOfParent();
238
226
  this.delete();
239
227
  refsList.forEach((record) => {
240
228
  const fileNode = naslServer.file2NodeMap.get(record.file);
@@ -242,11 +230,8 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
242
230
  return null;
243
231
  const minRange: MinRange = naslServer._findMinRange(record, fileNode as FileNode);
244
232
  if (minRange) {
245
- if (minRange.node instanceof CallLogic) {
246
- minRange.node.setCalleeArgName(parentNode as Logic);
247
- }
248
- if (minRange.node instanceof Destination) {
249
- minRange.node.setViewArgument(parentNode as View);
233
+ if (minRange.node instanceof CallLogic || minRange.node instanceof Destination) {
234
+ minRange.node.deleteCalleeArg(Index);
250
235
  }
251
236
  }
252
237
  });
@@ -505,8 +505,9 @@ export function formatVariableData(data: unknown | variableItem[], node: BaseNod
505
505
  item.typeKey = typeKey;
506
506
  } else {
507
507
  item.value = `${parent.value}.${item.name}`;
508
+ const object: any = BaseNode.from(parent.expression.toJSON());
508
509
  const memberExpression = new MemberExpression({
509
- object: parent.expression,
510
+ object,
510
511
  property: new Identifier({ name: item.name }),
511
512
  });
512
513
  item.expression = memberExpression;
@@ -1035,6 +1035,9 @@ export class NaslServer {
1035
1035
  // 子页面内部逻辑过滤
1036
1036
  if (nodeIn.view !== fileNode)
1037
1037
  return;
1038
+ // 当局部变量、输出参数属于页面内逻辑时,需过滤同页面下不同逻辑下的同名变量
1039
+ if (node.logic && node.logic !== nodeIn.logic)
1040
+ return;
1038
1041
  // 跟变量无关的赋值过滤
1039
1042
  const jsCode = nodeIn.toJS();
1040
1043
  if (!jsCode.includes(`${node.name} = `))
@@ -1983,12 +1986,8 @@ export class NaslServer {
1983
1986
  const minRange: MinRange = this._findMinRange(record, fileNode as FileNode);
1984
1987
  if (minRange) {
1985
1988
  // 如果找到节点是callLogic就去更新
1986
- if (minRange.node instanceof CallLogic && node instanceof Param) {
1987
- minRange.node.setCalleeArgName(parantNode as Logic);
1988
- }
1989
- // 如果节点参数增加页面也要更新
1990
- if (minRange.node instanceof Destination && node instanceof Param) {
1991
- minRange.node.setViewArgument(parantNode as View);
1989
+ if ((minRange.node instanceof CallLogic || minRange.node instanceof Destination) && node instanceof Param) {
1990
+ minRange.node.addCalleeArg(parantNode as any);
1992
1991
  }
1993
1992
  }
1994
1993
  });
@@ -86,6 +86,8 @@ function transformType(tsType: string): string {
86
86
  return '无返回值';
87
87
  else if (tsType === '__elements')
88
88
  return '页面元素';
89
+ else if (tsType === '__unknown__')
90
+ return '无效';
89
91
  else if (tsType === 'extensions')
90
92
  return '拓展模块';
91
93
  else if (tsType === 'Promise<void>')
@@ -173,8 +175,13 @@ const TS_RULES: Array<{
173
175
  }> = [
174
176
  {
175
177
  re: /Object literal may only specify known properties, and '(.+?)' does not exist in type/,
176
- result: '当前参数$1,不可用',
177
- transforms: [outOriginalvalue],
178
+ result: '当前参数$1,不可用。',
179
+ transforms: [transformType],
180
+ },
181
+ {
182
+ re: /Object literal may only specify known properties, but '(.+?)' does not exist in type/,
183
+ result: '当前参数$1,不可用。',
184
+ transforms: [transformType],
178
185
  },
179
186
  {
180
187
  re: /Argument of type '(.+?)' is not assignable to parameter of type '(.+?)'/,
@@ -494,8 +501,15 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
494
501
  }
495
502
  // 赋值左右侧类型不一致, 把文字换一下
496
503
  if (/Argument of type '(.+?)' is not assignable to parameter of type '(.+?)'/.exec(text) && node.parentNode instanceof Assignment) {
497
- // node = node.getAncestor('CallLogic');
498
- tsErrorDetail.message = tsErrorDetail.message.replace('参数类型不一致!传入类型:', '赋值:类型不一致!右边类型:').replace('接收类型:', '左边类型:');
504
+ // OQL 的返回类型报错需要转换翻译,其内部 SQL 语句的参数类型报错不转换翻译
505
+ if (node instanceof OqlQueryComponent) {
506
+ if ((node.getCurrentSource().currentSource.range.start.line + 1) === tsErrorDetail.originalDiagnostic.start.line) {
507
+ tsErrorDetail.message = tsErrorDetail.message.replace('参数类型不一致!传入类型:', '赋值:类型不一致!右边类型:').replace('接收类型:', '左边类型:');
508
+ }
509
+ } else {
510
+ // node = node.getAncestor('CallLogic');
511
+ tsErrorDetail.message = tsErrorDetail.message.replace('参数类型不一致!传入类型:', '赋值:类型不一致!右边类型:').replace('接收类型:', '左边类型:');
512
+ }
499
513
  }
500
514
  if (node instanceof Argument || node instanceof Anchor) {
501
515
  // if (/Type '(.+?)' is not assignable to type '(.+?)'./.exec(text)) {