@lcap/nasl-language-server-core 4.4.0-beta.26 → 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 +60 -2
- 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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AMD,eAAO,MAAM,6BAA6B,aAC9B,UAAU,+DAGnB,MAAM,gBAAgB,CAyCxB,CAAC;AAMF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/out/checker.js
CHANGED
|
@@ -270,6 +270,8 @@ function createErrorDiagnoser(context) {
|
|
|
270
270
|
let inModule = false;
|
|
271
271
|
let inPlayground = 0;
|
|
272
272
|
let inAuthLogic = false;
|
|
273
|
+
let inFrontendType = false;
|
|
274
|
+
let currentFrontendKind = '';
|
|
273
275
|
let dbType = '';
|
|
274
276
|
let curVarCounter = 0;
|
|
275
277
|
const listComponentStack = [];
|
|
@@ -3359,7 +3361,7 @@ function createErrorDiagnoser(context) {
|
|
|
3359
3361
|
return;
|
|
3360
3362
|
}
|
|
3361
3363
|
yield* checkVoidCallUsedAsStatement(node);
|
|
3362
|
-
const ref = env.resolveRef(node); // 前端
|
|
3364
|
+
const ref = env.resolveRef(node) ?? env.quickGetLibDef(node, node.calleeName, undefined); // 前端
|
|
3363
3365
|
// TODO: sql 函数的 namespace 带有数据库名 nasl.sqlFunction.mysql nasl.sqlFunction.oracle ...
|
|
3364
3366
|
// 暂时不在 gQNameDefs 里,用 isBuiltInCall 简单判断了
|
|
3365
3367
|
if (!ref && !isBuiltInCall(node)) {
|
|
@@ -3520,6 +3522,29 @@ function createErrorDiagnoser(context) {
|
|
|
3520
3522
|
error(node, '下载组件必须为page和size指定入参,且不能重复');
|
|
3521
3523
|
}
|
|
3522
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
|
+
}
|
|
3523
3548
|
return env.getType(node);
|
|
3524
3549
|
}
|
|
3525
3550
|
/**
|
|
@@ -3979,6 +4004,36 @@ function createErrorDiagnoser(context) {
|
|
|
3979
4004
|
scopedError(node, `${node.toNaturalTS()} 枚举类不能直接使用,请取它的枚举项`);
|
|
3980
4005
|
return errorType;
|
|
3981
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
|
+
}
|
|
3982
4037
|
// 检查使用范围
|
|
3983
4038
|
yield* checkScopeOfUse(node, ref);
|
|
3984
4039
|
return env.getType(node);
|
|
@@ -5273,6 +5328,9 @@ function createErrorDiagnoser(context) {
|
|
|
5273
5328
|
inModule = !!node.getAncestor?.('Module');
|
|
5274
5329
|
inPlayground = 0;
|
|
5275
5330
|
inAuthLogic = false;
|
|
5331
|
+
const frontendType = node.getAncestor?.('FrontendType');
|
|
5332
|
+
inFrontendType = !!frontendType;
|
|
5333
|
+
currentFrontendKind = frontendType?.kind || '';
|
|
5276
5334
|
fileNodes.push(node);
|
|
5277
5335
|
let diagnostics = diagnosticMap.get(node);
|
|
5278
5336
|
if (!diagnostics) {
|
|
@@ -5596,7 +5654,7 @@ exports.transformDiagnosticsToRecords = transformDiagnosticsToRecords;
|
|
|
5596
5654
|
// @ts-expect-error
|
|
5597
5655
|
const toRaw = (nd) => nd.__v_raw ?? nd;
|
|
5598
5656
|
// 是否来自系统内置
|
|
5599
|
-
const isBuiltInCall = (nd) => !!nd.calleeNamespace?.startsWith('nasl.');
|
|
5657
|
+
const isBuiltInCall = (nd) => !!nd.calleeNamespace?.startsWith('nasl.') && !['nasl.auth'].includes(nd.calleeNamespace);
|
|
5600
5658
|
// 获取依赖库名
|
|
5601
5659
|
const getExtensionLibName = (nd) => nd.calleeNamespace?.startsWith('extensions.') ? nd.calleeNamespace.split('.')[1] : undefined;
|
|
5602
5660
|
//# sourceMappingURL=checker.js.map
|