@lcap/nasl 2.18.0-beta.3 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/bak/translator.js +1 -1
- package/out/bak/translator.js.map +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +4 -4
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchExpression__.d.ts +97 -0
- package/out/concepts/MatchExpression__.js +281 -0
- package/out/concepts/MatchExpression__.js.map +1 -0
- package/out/concepts/Match__.js +1 -1
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.js +2 -2
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Return__.js +1 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/StringInterpolation__.d.ts +16 -16
- package/out/concepts/StringInterpolation__.js +12 -12
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +1 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/View__.js +2 -2
- package/out/concepts/View__.js.map +1 -1
- package/out/server/naslServer.d.ts +2 -1
- package/out/server/naslServer.js +84 -38
- package/out/server/naslServer.js.map +1 -1
- package/out/templator/genQueryComponent.d.ts +2 -2
- package/out/templator/genQueryComponent.js +4 -1
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/sql-parser/index.d.ts +1 -0
- package/out/templator/sql-parser/index.js +228 -0
- package/out/templator/sql-parser/index.js.map +1 -0
- package/out/templator/sql-parser/parser.js +26664 -0
- package/out/templator/sql-parser/parser.js.map +1 -0
- package/package.json +3 -4
- package/src/automate/engine/dist/index.dev.js +517 -0
- package/src/bak/translator.js +1 -1
- package/src/common/dist/BaseNode.js +1101 -0
- package/src/concepts/CallInterface__.ts +9 -9
- package/src/concepts/Destination__.ts +9 -9
- package/src/concepts/ExternalDestination__.ts +5 -5
- package/src/concepts/LogicItem__.ts +4 -0
- package/src/concepts/Logic__.ts +42 -5
- package/src/concepts/Match__.ts +21 -1
- package/src/concepts/MemberExpression__.ts +11 -0
- package/src/concepts/OqlQueryComponent__.ts +7 -0
- package/src/concepts/Param__.ts +3 -2
- package/src/concepts/Return__.ts +5 -1
- package/src/concepts/StringInterpolation__.ts +26 -26
- package/src/concepts/UnaryExpression__.ts +4 -4
- package/src/concepts/ValidationRule__.ts +1 -1
- package/src/concepts/Variable__.ts +1 -1
- package/src/concepts/ViewElement__.ts +1 -1
- package/src/concepts/View__.ts +2 -2
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
- package/src/concepts/dist/Anchor__.js +179 -0
- package/src/concepts/dist/Assignment__.js +301 -0
- package/src/concepts/dist/CallFunction__.js +473 -0
- package/src/concepts/dist/CallInterface__.js +533 -0
- package/src/concepts/dist/CallLogic__.js +864 -0
- package/src/concepts/dist/ForEachStatement__.js +426 -0
- package/src/concepts/dist/MatchCase__.js +587 -0
- package/src/concepts/dist/MemberExpression__.js +348 -0
- package/src/concepts/dist/Param__.js +537 -0
- package/src/concepts/dist/Return__.js +493 -0
- package/src/generator/dist/genBundleFiles.js +414 -0
- package/src/server/dist/formatTsUtils.js +683 -0
- package/src/server/dist/naslServer.js +3396 -0
- package/src/server/naslServer.ts +84 -39
- package/src/service/storage/dist/init.js +541 -0
- package/src/templator/genQueryComponent.ts +8 -3
- package/ts-worker/dist/webpack.config.dev.js +104 -0
- package/ts-worker/lib/cancellationToken.js +67 -0
- package/ts-worker/lib/dist/tsserver.dev.js +22953 -0
- package/ts-worker/lib/harness.js +1 -1
- package/ts-worker/sources/lib/dist/tsserver.dev.js +22912 -0
- package/ts-worker/src/start.js +1 -1
- package/ts-worker/webpack.config.js +3 -1
- package/dist/bundle.js +0 -3962
- package/dist/bundle.js.LICENSE.txt +0 -16
- package/out/generator/release.d.ts +0 -1
- package/out/generator/release.js +0 -51
- package/out/generator/release.js.map +0 -1
package/out/server/naslServer.js
CHANGED
|
@@ -538,6 +538,49 @@ class NaslServer {
|
|
|
538
538
|
}
|
|
539
539
|
return '';
|
|
540
540
|
}
|
|
541
|
+
async getDataSchemaStructureOrTypeAnnotation(node) {
|
|
542
|
+
if (!(node instanceof concepts_1.ViewElement))
|
|
543
|
+
return;
|
|
544
|
+
const { currentSource, fileNode } = this.getCurrentSource(node);
|
|
545
|
+
const quickInfo = await this._getTypeQuickinfo({
|
|
546
|
+
file: fileNode.getEmbeddedFilePath(),
|
|
547
|
+
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
548
|
+
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character) + `new nasl.ui.`.length,
|
|
549
|
+
});
|
|
550
|
+
if (quickInfo.responseRequired) {
|
|
551
|
+
const displayString = quickInfo?.response?.displayString || '';
|
|
552
|
+
const flag = displayString.includes('<') && displayString.includes('>');
|
|
553
|
+
if (!flag)
|
|
554
|
+
return;
|
|
555
|
+
const types = /\<([^()]+)\>/g.exec(displayString);
|
|
556
|
+
let typeStr = types && types[1];
|
|
557
|
+
const app = node.app;
|
|
558
|
+
if (typeStr.includes('__name: "AStructure_')) {
|
|
559
|
+
const properties = [];
|
|
560
|
+
typeStr
|
|
561
|
+
.replace(/([^:\s]+):\s+([^;]+);/g, ($1, name, typeKey) => {
|
|
562
|
+
if (name === '__name')
|
|
563
|
+
return;
|
|
564
|
+
typeKey = `app.${typeKey}`;
|
|
565
|
+
const keys = typeKey.split('.');
|
|
566
|
+
const typeName = keys.pop();
|
|
567
|
+
const typeNamespace = keys.join('.');
|
|
568
|
+
properties.push(concepts_1.StructureProperty.from({
|
|
569
|
+
name,
|
|
570
|
+
typeAnnotation: concepts_1.TypeAnnotation.from({
|
|
571
|
+
typeKind: 'reference',
|
|
572
|
+
typeName,
|
|
573
|
+
typeNamespace,
|
|
574
|
+
})
|
|
575
|
+
}));
|
|
576
|
+
return '';
|
|
577
|
+
});
|
|
578
|
+
return concepts_1.TypeAnnotation.createTypeAnonymousStructure(properties);
|
|
579
|
+
}
|
|
580
|
+
else if (typeStr.startsWith('structures'))
|
|
581
|
+
return app.findNodeByCompleteName(`app.${typeStr}`);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
541
584
|
/**
|
|
542
585
|
* ts的 quickInfo方法,查询指定位置的详情
|
|
543
586
|
* @param args 文件信息数组
|
|
@@ -904,41 +947,37 @@ class NaslServer {
|
|
|
904
947
|
const jsCode = nodeIn.toJS();
|
|
905
948
|
if (!jsCode.includes(`${node.name} = `))
|
|
906
949
|
return;
|
|
907
|
-
//
|
|
908
|
-
if (
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
return;
|
|
913
|
-
if (node instanceof concepts_1.Variable
|
|
914
|
-
&& node.parentNode instanceof concepts_1.View
|
|
915
|
-
&& (nodeIn.logic?.params.find((param) => jsCode.includes(param.name))
|
|
916
|
-
|| nodeIn.logic?.virtualParams.find((vParam) => jsCode.includes(vParam.name))
|
|
917
|
-
|| nodeIn.logic?.variables.find((variable) => jsCode.includes(variable.name)))) {
|
|
950
|
+
// 页面局部变量
|
|
951
|
+
if (node instanceof concepts_1.Variable && node.parentNode instanceof concepts_1.View) {
|
|
952
|
+
// 跟页面局部变量无关的赋值过滤
|
|
953
|
+
if (!jsCode.includes(`this.${node.name} = `))
|
|
954
|
+
return;
|
|
918
955
|
// 直接赋值 logic 内局部变量、输入参数直接提示系统无法推断类型
|
|
919
|
-
if (
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
956
|
+
if (nodeIn.logic?.params.find((param) => jsCode.includes(param.name))
|
|
957
|
+
|| nodeIn.logic?.virtualParams.find((vParam) => jsCode.includes(vParam.name))
|
|
958
|
+
|| nodeIn.logic?.variables.find((variable) => jsCode.includes(variable.name))) {
|
|
959
|
+
if (!nodeIn.tsErrorDetail) {
|
|
960
|
+
const diagnostic = {
|
|
961
|
+
node: nodeIn,
|
|
962
|
+
severity: 'error',
|
|
963
|
+
message: `页面${nodeTypeName} ${node.name} 赋值页面逻辑内局部变量或输入参数时,系统无法推导类型。`,
|
|
964
|
+
};
|
|
965
|
+
nodeIn.tsErrorDetail = diagnostic;
|
|
966
|
+
diagnostics.push(diagnostic);
|
|
967
|
+
}
|
|
968
|
+
msg = '系统无法推断类型。';
|
|
927
969
|
}
|
|
928
|
-
msg = '系统无法推断类型。';
|
|
929
970
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
diagnostics.push(diagnostic);
|
|
939
|
-
}
|
|
940
|
-
msg = '必须赋值有返回值的内容。';
|
|
971
|
+
if (!nodeIn.tsErrorDetail) {
|
|
972
|
+
const diagnostic = {
|
|
973
|
+
node: nodeIn,
|
|
974
|
+
severity: 'error',
|
|
975
|
+
message: `${nodeIn.label}左边 ${node.name} 未设置类型,右边必须为有返回值的内容。`,
|
|
976
|
+
};
|
|
977
|
+
nodeIn.tsErrorDetail = diagnostic;
|
|
978
|
+
diagnostics.push(diagnostic);
|
|
941
979
|
}
|
|
980
|
+
msg = '必须赋值有返回值的内容。';
|
|
942
981
|
}
|
|
943
982
|
});
|
|
944
983
|
if (!msg)
|
|
@@ -2218,7 +2257,6 @@ class NaslServer {
|
|
|
2218
2257
|
const nodeTypeAnnotation = this.getCurrentNodeKnownTypeAnnotation(node);
|
|
2219
2258
|
if (nodeTypeAnnotation) {
|
|
2220
2259
|
types.set(node, nodeTypeAnnotation);
|
|
2221
|
-
node.__TypeAnnotation = nodeTypeAnnotation;
|
|
2222
2260
|
return;
|
|
2223
2261
|
}
|
|
2224
2262
|
// 要通过自己或者依赖关系拿的,二次遍历
|
|
@@ -2233,7 +2271,7 @@ class NaslServer {
|
|
|
2233
2271
|
'Return',
|
|
2234
2272
|
'Variable',
|
|
2235
2273
|
].includes(node.concept) && node.typeAnnotation) {
|
|
2236
|
-
node
|
|
2274
|
+
types.set(node, node.typeAnnotation);
|
|
2237
2275
|
return;
|
|
2238
2276
|
}
|
|
2239
2277
|
if (![
|
|
@@ -2300,7 +2338,9 @@ class NaslServer {
|
|
|
2300
2338
|
}
|
|
2301
2339
|
args.push(fileDetail);
|
|
2302
2340
|
});
|
|
2341
|
+
console.time('请求');
|
|
2303
2342
|
const resultMap = (await this.getNaslNodeTypeFull(args)).response;
|
|
2343
|
+
console.timeEnd('请求');
|
|
2304
2344
|
// console.log(resultMap);
|
|
2305
2345
|
// const result = (await this.getNaslNodeQuickInfoFull(args)).response;
|
|
2306
2346
|
// console.log(result);
|
|
@@ -2314,22 +2354,19 @@ class NaslServer {
|
|
|
2314
2354
|
const nodeTypeAnnotation = (0, formatTsUtils_1.type2TypeAnnotation)(item?.[0]?.nodeType);
|
|
2315
2355
|
// console.log(newQuickInfoNodes[index].node, nodeTypeAnnotation, nodeTypeAnnotation?.typeKey);
|
|
2316
2356
|
types.set(newQuickInfoNodes[index].node, nodeTypeAnnotation);
|
|
2317
|
-
newQuickInfoNodes[index].node.
|
|
2318
|
-
newQuickInfoNodes[index].node.__nodeType = item?.[0]?.nodeType;
|
|
2357
|
+
newQuickInfoNodes[index].node.__nodeType = Object.freeze(item?.[0]?.nodeType);
|
|
2319
2358
|
// console.log('方案1:', displayString1);
|
|
2320
2359
|
});
|
|
2321
2360
|
getFromOthers.forEach((type, node) => {
|
|
2322
2361
|
if (node instanceof concepts_1.Assignment) {
|
|
2323
2362
|
if (!types.get(node.left)) {
|
|
2324
2363
|
types.set(node.left, types.get(node.right));
|
|
2325
|
-
node.left.__TypeAnnotation = types.get(node.right);
|
|
2326
2364
|
}
|
|
2327
2365
|
}
|
|
2328
2366
|
else if (node instanceof concepts_1.Argument) {
|
|
2329
2367
|
// 如果Argument,但是没可以用的类型,就用原来logic的参数类型
|
|
2330
2368
|
const argType = this.getArgumentTypeAnnotation(node, newQuickInfoNodes, types);
|
|
2331
2369
|
types.set(node, argType);
|
|
2332
|
-
node.__TypeAnnotation = argType.typeAnnotation;
|
|
2333
2370
|
}
|
|
2334
2371
|
else if (node instanceof concepts_1.MatchCase) {
|
|
2335
2372
|
// matchCase的类型
|
|
@@ -2338,7 +2375,6 @@ class NaslServer {
|
|
|
2338
2375
|
const last = node.body[node.body.length - 1];
|
|
2339
2376
|
if (last.__TypeAnnotation) {
|
|
2340
2377
|
types.set(node, last.__TypeAnnotation);
|
|
2341
|
-
node.__TypeAnnotation = last.__TypeAnnotation;
|
|
2342
2378
|
}
|
|
2343
2379
|
}
|
|
2344
2380
|
}
|
|
@@ -2346,6 +2382,14 @@ class NaslServer {
|
|
|
2346
2382
|
// 重置类型状态
|
|
2347
2383
|
types.forEach((value, node) => {
|
|
2348
2384
|
node.__isCorrectTypeAnnotation = true;
|
|
2385
|
+
if (value) {
|
|
2386
|
+
if (value instanceof concepts_1.TypeAnnotation) {
|
|
2387
|
+
node.__TypeAnnotation = Object.freeze(value);
|
|
2388
|
+
}
|
|
2389
|
+
else if (value.typeAnnotation) {
|
|
2390
|
+
node.__TypeAnnotation = Object.freeze(value.typeAnnotation);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2349
2393
|
});
|
|
2350
2394
|
// newQuickInfoNodes.forEach((itemDetail, index) => {
|
|
2351
2395
|
// const { node, filePath } = itemDetail;
|
|
@@ -2443,6 +2487,7 @@ class NaslServer {
|
|
|
2443
2487
|
}
|
|
2444
2488
|
// 增量标注
|
|
2445
2489
|
async IncrementalAnnotationJSON(records) {
|
|
2490
|
+
console.time('增量标注');
|
|
2446
2491
|
const nodes = [];
|
|
2447
2492
|
records.forEach((record) => {
|
|
2448
2493
|
const fileNode = this.file2NodeMap.get(record.filePath);
|
|
@@ -2461,6 +2506,7 @@ class NaslServer {
|
|
|
2461
2506
|
}
|
|
2462
2507
|
});
|
|
2463
2508
|
await this.getQuickInfoNodesTypeMap(nodes);
|
|
2509
|
+
console.timeEnd('增量标注');
|
|
2464
2510
|
}
|
|
2465
2511
|
annotationToJson(typesMap, json) {
|
|
2466
2512
|
typesMap.forEach((value, node) => {
|