@lcap/nasl-language-server-core 4.3.0-beta.9 → 4.3.0-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.
- package/out/checker.d.ts.map +1 -1
- package/out/checker.js +79 -29
- package/out/checker.js.map +1 -1
- package/out/reference-manager/reference-manager.d.ts.map +1 -1
- package/out/reference-manager/reference-manager.js +6 -2
- package/out/reference-manager/reference-manager.js.map +1 -1
- package/out/reference-manager/update-nasl-fragment.d.ts.map +1 -1
- package/out/reference-manager/update-nasl-fragment.js +2 -1
- package/out/reference-manager/update-nasl-fragment.js.map +1 -1
- package/out/semantic-rules/index.d.ts +5 -0
- package/out/semantic-rules/index.d.ts.map +1 -0
- package/out/semantic-rules/index.js +8 -0
- package/out/semantic-rules/index.js.map +1 -0
- package/out/semantic-rules/reject-file-types.d.ts +7 -0
- package/out/semantic-rules/reject-file-types.d.ts.map +1 -0
- package/out/semantic-rules/reject-file-types.js +228 -0
- package/out/semantic-rules/reject-file-types.js.map +1 -0
- package/out/typer/dispatch-all.d.ts.map +1 -1
- package/out/typer/dispatch-all.js.map +1 -1
- package/out/typer/dispatch-call.d.ts.map +1 -1
- package/out/typer/dispatch-call.js +0 -6
- package/out/typer/dispatch-call.js.map +1 -1
- package/out/typer/dispatch-expr.d.ts.map +1 -1
- package/out/typer/dispatch-expr.js +37 -19
- package/out/typer/dispatch-expr.js.map +1 -1
- package/out/typer/incremental-update.js +1 -1
- package/out/typer/incremental-update.js.map +1 -1
- package/out/typer/oql-checker/chain-call-transformer.d.ts +2 -0
- package/out/typer/oql-checker/chain-call-transformer.d.ts.map +1 -1
- package/out/typer/oql-checker/chain-call-transformer.js +157 -13
- package/out/typer/oql-checker/chain-call-transformer.js.map +1 -1
- package/out/typer/oql-checker/ts-parser.d.ts.map +1 -1
- package/out/typer/oql-checker/ts-parser.js +60 -40
- package/out/typer/oql-checker/ts-parser.js.map +1 -1
- package/out/typer/subster.d.ts.map +1 -1
- package/out/typer/subster.js +6 -4
- package/out/typer/subster.js.map +1 -1
- package/out/typer/type-predicate.d.ts.map +1 -1
- package/out/typer/type-predicate.js +41 -10
- package/out/typer/type-predicate.js.map +1 -1
- package/out/utils/parseTsClassType.d.ts.map +1 -1
- package/out/utils/parseTsClassType.js +19 -0
- package/out/utils/parseTsClassType.js.map +1 -1
- package/out/utils/type-operator.d.ts.map +1 -1
- package/out/utils/type-operator.js +11 -21
- package/out/utils/type-operator.js.map +1 -1
- package/package.json +5 -5
package/out/checker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAU2G,GAAG,EAMxH,QAAQ,
|
|
1
|
+
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAU2G,GAAG,EAMxH,QAAQ,EAET,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACgE,cAAc,EAGpF,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAK5C,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAMpE,oBAAY,QAAQ;IAClB,IAAI,YAAY;IAChB,KAAK,UAAU;CAChB;AAED,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAEnE,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAMF,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAEpE,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,UAAU,EAAE,k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|
|
|
12
12
|
const service_2 = require("@lcap/nasl-concepts/service");
|
|
13
13
|
const lodash_1 = require("lodash");
|
|
14
14
|
const helper_1 = require("./typer/helper");
|
|
15
|
+
const semantic_rules_1 = require("./semantic-rules");
|
|
15
16
|
var Severity;
|
|
16
17
|
(function (Severity) {
|
|
17
18
|
Severity["WARN"] = "warning";
|
|
@@ -261,13 +262,14 @@ function createErrorDiagnoser(context) {
|
|
|
261
262
|
const nodeNameCache = new Map();
|
|
262
263
|
const nodeNameGetterMap = {
|
|
263
264
|
View: 'getViewExistingNames',
|
|
265
|
+
BusinessComponent: 'getBusinessComponentExistingNames',
|
|
264
266
|
Logic: 'getLogicExistingNames',
|
|
265
267
|
AuthLogic: 'getAuthLogicExistingNames',
|
|
266
268
|
AuthLogicForCallInterface: 'getAuthLogicForCallInterfaceExistingNames',
|
|
267
269
|
Param: 'getVarExistingNames',
|
|
268
270
|
Return: 'getVarExistingNames',
|
|
269
271
|
Variable: 'getVarExistingNames',
|
|
270
|
-
Enum: '
|
|
272
|
+
Enum: 'getEnumExistingNames',
|
|
271
273
|
EnumItem: 'getEnumItemExistingNames',
|
|
272
274
|
EnumItemInteger: 'getEnumItemExistingNames',
|
|
273
275
|
DataSource: 'getDataSourceExistingNames',
|
|
@@ -2500,6 +2502,7 @@ function createErrorDiagnoser(context) {
|
|
|
2500
2502
|
function* checkLogic(node) {
|
|
2501
2503
|
env.enterScope(node);
|
|
2502
2504
|
checkVariableAndReturnTypeAnnotations(node.variables ?? [], node.returns ?? []);
|
|
2505
|
+
yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
|
|
2503
2506
|
const module = node.getAncestor('Module');
|
|
2504
2507
|
if (!(module?.parentKey === 'dependencies')) {
|
|
2505
2508
|
if (node.params?.length) {
|
|
@@ -2703,36 +2706,59 @@ function createErrorDiagnoser(context) {
|
|
|
2703
2706
|
const ancestorSubLogic = node.getAncestor('SubLogic');
|
|
2704
2707
|
const shouldReportAsyncAsError = !(ancestorSubLogic && ancestorSubLogic !== node) && (0, type_predicate_1.isSyncFuncTy)(ty);
|
|
2705
2708
|
const subLogicNode = node;
|
|
2709
|
+
function isAsyncNode(node) {
|
|
2710
|
+
switch (node.concept) {
|
|
2711
|
+
case 'CallLogic': {
|
|
2712
|
+
if (!node.calleeName) {
|
|
2713
|
+
return false;
|
|
2714
|
+
}
|
|
2715
|
+
else {
|
|
2716
|
+
const syncMap = {
|
|
2717
|
+
jsonSerialize: 'nasl.util',
|
|
2718
|
+
jsonDeserialize: 'nasl.util',
|
|
2719
|
+
INFO: 'nasl.logging',
|
|
2720
|
+
WARN: 'nasl.logging',
|
|
2721
|
+
ERROR: 'nasl.logging',
|
|
2722
|
+
DEBUG: 'nasl.logging',
|
|
2723
|
+
showMessage: 'nasl.ui',
|
|
2724
|
+
};
|
|
2725
|
+
if (syncMap[node.calleeName] === node.calleeNamespace) {
|
|
2726
|
+
return false;
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
const callee = context.env.resolveRef(node);
|
|
2730
|
+
if (callee) {
|
|
2731
|
+
const funTy = context.env.getType(callee);
|
|
2732
|
+
if (funTy) {
|
|
2733
|
+
return (0, type_predicate_1.isAsyncFuncTy)(funTy);
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
return false;
|
|
2737
|
+
}
|
|
2738
|
+
case 'CallFunction': {
|
|
2739
|
+
if (!node.calleeName) {
|
|
2740
|
+
return false;
|
|
2741
|
+
}
|
|
2742
|
+
// fallthrough
|
|
2743
|
+
}
|
|
2744
|
+
case 'Unparsed':
|
|
2745
|
+
case 'CallConnector':
|
|
2746
|
+
case 'JSBlock':
|
|
2747
|
+
case 'CallInterface': {
|
|
2748
|
+
return true;
|
|
2749
|
+
}
|
|
2750
|
+
default: {
|
|
2751
|
+
return false;
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2706
2755
|
function checkAsync(current, subLogicNode) {
|
|
2707
2756
|
if (shouldReportAsyncAsError) {
|
|
2708
2757
|
current.traverseStrictChildren((n) => {
|
|
2709
2758
|
if (!n)
|
|
2710
2759
|
return;
|
|
2711
2760
|
if (isAsyncNode(n)) {
|
|
2712
|
-
error(n, `同步执行的子逻辑 ${subLogicNode.name}
|
|
2713
|
-
}
|
|
2714
|
-
function isAsyncNode(node) {
|
|
2715
|
-
switch (node.concept) {
|
|
2716
|
-
case 'CallLogic': {
|
|
2717
|
-
const callee = context.env.resolveRef(node);
|
|
2718
|
-
if (callee) {
|
|
2719
|
-
const funTy = context.env.getType(callee);
|
|
2720
|
-
if (funTy) {
|
|
2721
|
-
return (0, type_predicate_1.isAsyncFuncTy)(funTy);
|
|
2722
|
-
}
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
case 'Unparsed':
|
|
2726
|
-
case 'CallConnector':
|
|
2727
|
-
case 'CallFunction':
|
|
2728
|
-
case 'JSBlock':
|
|
2729
|
-
case 'CallInterface': {
|
|
2730
|
-
return true;
|
|
2731
|
-
}
|
|
2732
|
-
default: {
|
|
2733
|
-
return false;
|
|
2734
|
-
}
|
|
2735
|
-
}
|
|
2761
|
+
error(n, `同步执行的子逻辑 ${subLogicNode.name} 中不支持使用该${formatNodeConcept(n)}`);
|
|
2736
2762
|
}
|
|
2737
2763
|
});
|
|
2738
2764
|
}
|
|
@@ -2858,6 +2884,7 @@ function createErrorDiagnoser(context) {
|
|
|
2858
2884
|
if (node.calleeName === 'ListSort' || node.calleeName === 'ListSortAsync') {
|
|
2859
2885
|
checkListSort(node);
|
|
2860
2886
|
}
|
|
2887
|
+
yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
|
|
2861
2888
|
if (node.typeArguments?.length) {
|
|
2862
2889
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.typeArguments, function* (node) {
|
|
2863
2890
|
yield* checkNode(node);
|
|
@@ -2927,13 +2954,13 @@ function createErrorDiagnoser(context) {
|
|
|
2927
2954
|
// HACK 取这个字段会修复 arguments 中 keyword 为空的问题
|
|
2928
2955
|
// 参考:流程回退接口报错500 http://projectmanage.netease-official.lcap.163yun.com/dashboard/BugDetail?id=3127862102823424
|
|
2929
2956
|
node.completeArguments;
|
|
2957
|
+
yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
|
|
2930
2958
|
if (inAuthLogic && node.calleeNamespace?.startsWith?.('app.logics')) {
|
|
2931
2959
|
const authLogic = node.getAncestor('AuthLogic');
|
|
2932
2960
|
error(authLogic, `鉴权逻辑 ${authLogic.name} 不允许调用 服务端逻辑`);
|
|
2933
2961
|
}
|
|
2934
2962
|
const viewElement = node.getAncestor('ViewElement');
|
|
2935
2963
|
if (viewElement && viewElement.tag === 'u-download' && node.parentNode.name === 'dataSource') {
|
|
2936
|
-
// node.Pa
|
|
2937
2964
|
const args = ['page', 'size'];
|
|
2938
2965
|
const values = [];
|
|
2939
2966
|
node.arguments && node.arguments.forEach((arg) => {
|
|
@@ -3408,9 +3435,16 @@ function createErrorDiagnoser(context) {
|
|
|
3408
3435
|
if (node.typeAnnotation?.typeKind === 'primitive' && node.typeAnnotation?.typeName === 'Long') {
|
|
3409
3436
|
const MIN_LONG = -9223372036854775808n;
|
|
3410
3437
|
const MAX_LONG = 9223372036854775807n;
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3438
|
+
try {
|
|
3439
|
+
// AI完全可以构造出node.value="2.2"而ty显式指定为Long的东西,让BigInt报错。
|
|
3440
|
+
// 因此需要try catch
|
|
3441
|
+
const value = BigInt(node.value);
|
|
3442
|
+
if (value < MIN_LONG || value > MAX_LONG) {
|
|
3443
|
+
error(node, `整数数值超出合法范围,最小值:${MIN_LONG},最大值:${MAX_LONG}。`);
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
catch (error) {
|
|
3447
|
+
console.error(error);
|
|
3414
3448
|
}
|
|
3415
3449
|
}
|
|
3416
3450
|
return env.getType(node);
|
|
@@ -3430,6 +3464,7 @@ function createErrorDiagnoser(context) {
|
|
|
3430
3464
|
* @param node
|
|
3431
3465
|
*/
|
|
3432
3466
|
function* checkStringInterpolation(node) {
|
|
3467
|
+
yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
|
|
3433
3468
|
if (node.expressions?.length) {
|
|
3434
3469
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.expressions, function* (node) {
|
|
3435
3470
|
yield* checkNode(node);
|
|
@@ -3463,6 +3498,7 @@ function createErrorDiagnoser(context) {
|
|
|
3463
3498
|
* @param node
|
|
3464
3499
|
*/
|
|
3465
3500
|
function* checkNewList(node) {
|
|
3501
|
+
yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
|
|
3466
3502
|
// 匿名函数返回值有可能是newList,需要过滤。代码来源:AnonymousFunction.__ts
|
|
3467
3503
|
const grandParent = node.parentNode?.parentNode?.parentNode;
|
|
3468
3504
|
if (isEntityUpdate(grandParent)) {
|
|
@@ -3489,6 +3525,7 @@ function createErrorDiagnoser(context) {
|
|
|
3489
3525
|
* @param node
|
|
3490
3526
|
*/
|
|
3491
3527
|
function* checkNewMap(node) {
|
|
3528
|
+
yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
|
|
3492
3529
|
if (node.keys?.length) {
|
|
3493
3530
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.keys, function* (node) {
|
|
3494
3531
|
yield* checkNode(node);
|
|
@@ -3520,6 +3557,7 @@ function createErrorDiagnoser(context) {
|
|
|
3520
3557
|
* @param node
|
|
3521
3558
|
*/
|
|
3522
3559
|
function* checkNewComposite(node) {
|
|
3560
|
+
yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
|
|
3523
3561
|
const type = env.getType(node);
|
|
3524
3562
|
if (node.properties?.length) {
|
|
3525
3563
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.properties, function* (property, index) {
|
|
@@ -3555,6 +3593,9 @@ function createErrorDiagnoser(context) {
|
|
|
3555
3593
|
}
|
|
3556
3594
|
return type;
|
|
3557
3595
|
}
|
|
3596
|
+
function checkNewRegex(node) {
|
|
3597
|
+
return env.getType(node);
|
|
3598
|
+
}
|
|
3558
3599
|
/**
|
|
3559
3600
|
* 检查 赋值语句
|
|
3560
3601
|
* @param node
|
|
@@ -3856,6 +3897,12 @@ function createErrorDiagnoser(context) {
|
|
|
3856
3897
|
env.addDiagnosticsFor(e.message, node);
|
|
3857
3898
|
});
|
|
3858
3899
|
}
|
|
3900
|
+
else {
|
|
3901
|
+
// 无错误时,需要手动根据 codeSourceMap oqlSyntaxError 报错
|
|
3902
|
+
if (node.codeSourceMap?.oqlSyntaxError) {
|
|
3903
|
+
error(node, `SQL查询:语句可能有异常。`);
|
|
3904
|
+
}
|
|
3905
|
+
}
|
|
3859
3906
|
return env.getType(node);
|
|
3860
3907
|
}
|
|
3861
3908
|
/**
|
|
@@ -3884,6 +3931,7 @@ function createErrorDiagnoser(context) {
|
|
|
3884
3931
|
* @param node
|
|
3885
3932
|
*/
|
|
3886
3933
|
function* checkBinaryExpression(node) {
|
|
3934
|
+
yield* semantic_rules_1.ExtraSemanticRules.rejectFileTypes(node, env, error);
|
|
3887
3935
|
if (ensureNodeKeyExists(node, 'left')) {
|
|
3888
3936
|
yield* checkNode(node.left);
|
|
3889
3937
|
}
|
|
@@ -4267,6 +4315,8 @@ function createErrorDiagnoser(context) {
|
|
|
4267
4315
|
return yield* checkNewMap(node);
|
|
4268
4316
|
case 'NewComposite':
|
|
4269
4317
|
return yield* checkNewComposite(node);
|
|
4318
|
+
case 'NewRegex':
|
|
4319
|
+
return checkNewRegex(node);
|
|
4270
4320
|
case 'Assignment':
|
|
4271
4321
|
return yield* checkAssignment(node);
|
|
4272
4322
|
case 'BatchAssignment':
|