@lcap/nasl-language-server-core 4.4.0-beta.23 → 4.4.0-beta.27
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 +68 -4
- package/out/checker.js.map +1 -1
- package/out/typer/dispatch-expr.js +1 -1
- package/out/typer/dispatch-expr.js.map +1 -1
- package/out/typer/incremental-update.d.ts.map +1 -1
- package/out/typer/incremental-update.js +4 -3
- package/out/typer/incremental-update.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,EAC4C,QAAQ,EAC5B,IAAI,EAQ+E,GAAG,EAMxH,QAAQ,EAGT,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;AAYpE,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;AAOF,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAEpE,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;AAMrE,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MA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CAyCxB,CAAC;AAMF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/out/checker.js
CHANGED
|
@@ -74,6 +74,7 @@ function getExpressionNodeName(concept) {
|
|
|
74
74
|
CallMicroserviceInterface: '微服务接口',
|
|
75
75
|
CallGatewayInterface: '网关接口',
|
|
76
76
|
CallEvent: '事件',
|
|
77
|
+
Destination: '页面',
|
|
77
78
|
};
|
|
78
79
|
return expressionNodeName[concept];
|
|
79
80
|
}
|
|
@@ -269,6 +270,8 @@ function createErrorDiagnoser(context) {
|
|
|
269
270
|
let inModule = false;
|
|
270
271
|
let inPlayground = 0;
|
|
271
272
|
let inAuthLogic = false;
|
|
273
|
+
let inFrontendType = false;
|
|
274
|
+
let currentFrontendKind = '';
|
|
272
275
|
let dbType = '';
|
|
273
276
|
let curVarCounter = 0;
|
|
274
277
|
const listComponentStack = [];
|
|
@@ -895,7 +898,8 @@ function createErrorDiagnoser(context) {
|
|
|
895
898
|
if (param?.spread) {
|
|
896
899
|
continue;
|
|
897
900
|
}
|
|
898
|
-
|
|
901
|
+
// 严格模式非必填也需要有Argument占位
|
|
902
|
+
if (isStrictMode || !isNonRequiredParam(param)) {
|
|
899
903
|
minArgsCount++; // 如果参数有默认值,则跳过
|
|
900
904
|
}
|
|
901
905
|
}
|
|
@@ -1013,7 +1017,11 @@ function createErrorDiagnoser(context) {
|
|
|
1013
1017
|
error(node, `预期 ${paramsLen} 个参数,但传入了 ${argsLen} 个。`);
|
|
1014
1018
|
}
|
|
1015
1019
|
else if (argsLen < minArgsCount) {
|
|
1016
|
-
|
|
1020
|
+
let msg = `传入参数的个数 ${argsLen} 与 ${getExpressionNodeName(node.concept)} 定义的参数个数 ${paramsLen} 不符。`;
|
|
1021
|
+
if (isStrictMode) {
|
|
1022
|
+
msg += `可选参数和默认值参数必须用 undefined 占位`;
|
|
1023
|
+
}
|
|
1024
|
+
error(node, msg);
|
|
1017
1025
|
}
|
|
1018
1026
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(args, function* (arg, index) {
|
|
1019
1027
|
const param = params?.[index];
|
|
@@ -3353,7 +3361,7 @@ function createErrorDiagnoser(context) {
|
|
|
3353
3361
|
return;
|
|
3354
3362
|
}
|
|
3355
3363
|
yield* checkVoidCallUsedAsStatement(node);
|
|
3356
|
-
const ref = env.resolveRef(node); // 前端
|
|
3364
|
+
const ref = env.resolveRef(node) ?? env.quickGetLibDef(node, node.calleeName, undefined); // 前端
|
|
3357
3365
|
// TODO: sql 函数的 namespace 带有数据库名 nasl.sqlFunction.mysql nasl.sqlFunction.oracle ...
|
|
3358
3366
|
// 暂时不在 gQNameDefs 里,用 isBuiltInCall 简单判断了
|
|
3359
3367
|
if (!ref && !isBuiltInCall(node)) {
|
|
@@ -3514,6 +3522,29 @@ function createErrorDiagnoser(context) {
|
|
|
3514
3522
|
error(node, '下载组件必须为page和size指定入参,且不能重复');
|
|
3515
3523
|
}
|
|
3516
3524
|
}
|
|
3525
|
+
const map = {
|
|
3526
|
+
frontend: {
|
|
3527
|
+
scope: '前端',
|
|
3528
|
+
forbiddenScope: '服务端',
|
|
3529
|
+
forbiddenCalleeNamesMap: {
|
|
3530
|
+
'nasl.auth': ['getCurrentUser', 'generateUserId', 'validatePassword', 'encryptPassword'],
|
|
3531
|
+
},
|
|
3532
|
+
},
|
|
3533
|
+
backend: {
|
|
3534
|
+
scope: '服务端',
|
|
3535
|
+
forbiddenScope: '前端',
|
|
3536
|
+
forbiddenCalleeNamespaces: ['nasl.browser', 'nasl.io'],
|
|
3537
|
+
forbiddenCalleeNamesMap: {
|
|
3538
|
+
'nasl.auth': ['decryptByAES', 'encryptByAES', 'logout', 'hasAuth'],
|
|
3539
|
+
'nasl.configuration': ['getCurrentIp', 'getUserLanguage', 'getI18nList', 'setI18nLocale'],
|
|
3540
|
+
},
|
|
3541
|
+
},
|
|
3542
|
+
};
|
|
3543
|
+
const config = inFrontendType ? map.frontend : map.backend;
|
|
3544
|
+
const { scope, forbiddenScope, forbiddenCalleeNamespaces, forbiddenCalleeNamesMap } = config;
|
|
3545
|
+
if (forbiddenCalleeNamespaces?.includes(node.calleeNamespace) || forbiddenCalleeNamesMap?.[node.calleeNamespace]?.includes(node.calleeName)) {
|
|
3546
|
+
error(node, `不能在${scope}作用域下使用${forbiddenScope}系统逻辑`);
|
|
3547
|
+
}
|
|
3517
3548
|
return env.getType(node);
|
|
3518
3549
|
}
|
|
3519
3550
|
/**
|
|
@@ -3973,6 +4004,36 @@ function createErrorDiagnoser(context) {
|
|
|
3973
4004
|
scopedError(node, `${node.toNaturalTS()} 枚举类不能直接使用,请取它的枚举项`);
|
|
3974
4005
|
return errorType;
|
|
3975
4006
|
}
|
|
4007
|
+
const map = {
|
|
4008
|
+
frontend: {
|
|
4009
|
+
scope: '前端',
|
|
4010
|
+
forbiddenScope: '服务端',
|
|
4011
|
+
prefix: 'app.frontendTypes',
|
|
4012
|
+
forbiddenPrefix: 'app.backend',
|
|
4013
|
+
},
|
|
4014
|
+
backend: {
|
|
4015
|
+
scope: '服务端',
|
|
4016
|
+
forbiddenScope: '前端',
|
|
4017
|
+
prefix: 'app.backend',
|
|
4018
|
+
forbiddenPrefix: 'app.frontendTypes',
|
|
4019
|
+
forbiddenCalleeNamesMap: {
|
|
4020
|
+
'nasl.auth': ['userInfo']
|
|
4021
|
+
}
|
|
4022
|
+
},
|
|
4023
|
+
};
|
|
4024
|
+
const config = inFrontendType ? map.frontend : map.backend;
|
|
4025
|
+
const { scope, forbiddenScope, prefix, forbiddenPrefix, forbiddenCalleeNamesMap } = config;
|
|
4026
|
+
// 互斥的端类型 (pc <-> h5)
|
|
4027
|
+
const forbiddenKind = currentFrontendKind === 'pc' ? 'h5' : 'pc';
|
|
4028
|
+
if (node.namespace?.startsWith(forbiddenPrefix)) {
|
|
4029
|
+
error(node, `不能在${scope}作用域下使用${forbiddenScope}全局变量`);
|
|
4030
|
+
}
|
|
4031
|
+
else if (inFrontendType && node.namespace?.startsWith(`${prefix}.${forbiddenKind}`)) {
|
|
4032
|
+
error(node, `不能在${currentFrontendKind}作用域下使用${forbiddenKind}作用域下的前端变量`);
|
|
4033
|
+
}
|
|
4034
|
+
if (forbiddenCalleeNamesMap?.[node.namespace]?.includes(node.name)) {
|
|
4035
|
+
error(node, '不能在服务端作用域下使用前端公共变量');
|
|
4036
|
+
}
|
|
3976
4037
|
// 检查使用范围
|
|
3977
4038
|
yield* checkScopeOfUse(node, ref);
|
|
3978
4039
|
return env.getType(node);
|
|
@@ -5267,6 +5328,9 @@ function createErrorDiagnoser(context) {
|
|
|
5267
5328
|
inModule = !!node.getAncestor?.('Module');
|
|
5268
5329
|
inPlayground = 0;
|
|
5269
5330
|
inAuthLogic = false;
|
|
5331
|
+
const frontendType = node.getAncestor?.('FrontendType');
|
|
5332
|
+
inFrontendType = !!frontendType;
|
|
5333
|
+
currentFrontendKind = frontendType?.kind || '';
|
|
5270
5334
|
fileNodes.push(node);
|
|
5271
5335
|
let diagnostics = diagnosticMap.get(node);
|
|
5272
5336
|
if (!diagnostics) {
|
|
@@ -5590,7 +5654,7 @@ exports.transformDiagnosticsToRecords = transformDiagnosticsToRecords;
|
|
|
5590
5654
|
// @ts-expect-error
|
|
5591
5655
|
const toRaw = (nd) => nd.__v_raw ?? nd;
|
|
5592
5656
|
// 是否来自系统内置
|
|
5593
|
-
const isBuiltInCall = (nd) => !!nd.calleeNamespace?.startsWith('nasl.');
|
|
5657
|
+
const isBuiltInCall = (nd) => !!nd.calleeNamespace?.startsWith('nasl.') && !['nasl.auth'].includes(nd.calleeNamespace);
|
|
5594
5658
|
// 获取依赖库名
|
|
5595
5659
|
const getExtensionLibName = (nd) => nd.calleeNamespace?.startsWith('extensions.') ? nd.calleeNamespace.split('.')[1] : undefined;
|
|
5596
5660
|
//# sourceMappingURL=checker.js.map
|