@lcap/nasl 4.1.0-beta.9 → 4.1.0-creator.1
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/generator/genBundleFiles.d.ts +1 -0
- package/out/generator/genBundleFiles.d.ts.map +1 -1
- package/out/generator/genBundleFiles.js +21 -96
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genSimpleBundleFile.d.ts +19 -0
- package/out/generator/genSimpleBundleFile.d.ts.map +1 -0
- package/out/generator/genSimpleBundleFile.js +114 -0
- package/out/generator/genSimpleBundleFile.js.map +1 -0
- package/out/generator/index.d.ts +1 -0
- package/out/generator/index.d.ts.map +1 -1
- package/out/generator/index.js +1 -0
- package/out/generator/index.js.map +1 -1
- package/out/generator/permission.d.ts.map +1 -1
- package/out/generator/permission.js +70 -34
- package/out/generator/permission.js.map +1 -1
- package/out/generator/release-body/body.d.ts.map +1 -1
- package/out/generator/release-body/body.js +3 -4
- package/out/generator/release-body/body.js.map +1 -1
- package/out/generator/release-body/utils.d.ts +7 -3
- package/out/generator/release-body/utils.d.ts.map +1 -1
- package/out/generator/release-body/utils.js +7 -5
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/natural/index.d.ts +1 -0
- package/out/natural/index.d.ts.map +1 -1
- package/out/natural/index.js +1 -0
- package/out/natural/index.js.map +1 -1
- package/out/natural/parseNaturalTS.d.ts +1 -1
- package/out/natural/parseNaturalTS.d.ts.map +1 -1
- package/out/natural/parseNaturalTS.js +150 -4
- package/out/natural/parseNaturalTS.js.map +1 -1
- package/out/natural/parseNaturalTSXView.d.ts +6 -0
- package/out/natural/parseNaturalTSXView.d.ts.map +1 -0
- package/out/natural/parseNaturalTSXView.js +536 -0
- package/out/natural/parseNaturalTSXView.js.map +1 -0
- package/out/natural/transformTS2UI.d.ts.map +1 -1
- package/out/natural/transformTS2UI.js +6 -9
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.d.ts.map +1 -1
- package/out/natural/transformTSCode.js +1 -1
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/natural/transforms/transform2Entity.d.ts.map +1 -1
- package/out/natural/transforms/transform2Entity.js +3 -1
- package/out/natural/transforms/transform2Entity.js.map +1 -1
- package/out/natural/transforms/transform2Enum.js +1 -1
- package/out/natural/transforms/transform2Enum.js.map +1 -1
- package/out/natural/transforms/transform2Logic.d.ts +3 -1
- package/out/natural/transforms/transform2Logic.d.ts.map +1 -1
- package/out/natural/transforms/transform2Logic.js +37 -6
- package/out/natural/transforms/transform2Logic.js.map +1 -1
- package/out/natural/transforms/transform2LogicItem.d.ts +34 -6
- package/out/natural/transforms/transform2LogicItem.d.ts.map +1 -1
- package/out/natural/transforms/transform2LogicItem.js +312 -140
- package/out/natural/transforms/transform2LogicItem.js.map +1 -1
- package/out/natural/transforms/transform2MetadataType.d.ts +3 -0
- package/out/natural/transforms/transform2MetadataType.d.ts.map +1 -0
- package/out/natural/transforms/transform2MetadataType.js +14 -0
- package/out/natural/transforms/transform2MetadataType.js.map +1 -0
- package/out/natural/transforms/transform2ValidationRule.d.ts +3 -0
- package/out/natural/transforms/transform2ValidationRule.d.ts.map +1 -0
- package/out/natural/transforms/transform2ValidationRule.js +19 -0
- package/out/natural/transforms/transform2ValidationRule.js.map +1 -0
- package/out/natural/transforms/transform2Variable.d.ts +1 -0
- package/out/natural/transforms/transform2Variable.d.ts.map +1 -1
- package/out/natural/transforms/transform2Variable.js +25 -1
- package/out/natural/transforms/transform2Variable.js.map +1 -1
- package/out/natural/transforms/transformThemeAndStyle.d.ts +24 -0
- package/out/natural/transforms/transformThemeAndStyle.d.ts.map +1 -0
- package/out/natural/transforms/transformThemeAndStyle.js +269 -0
- package/out/natural/transforms/transformThemeAndStyle.js.map +1 -0
- package/out/natural/transforms/utils.d.ts +16 -2
- package/out/natural/transforms/utils.d.ts.map +1 -1
- package/out/natural/transforms/utils.js +67 -11
- package/out/natural/transforms/utils.js.map +1 -1
- package/out/server/OQL/sqlCategory.json +410 -0
- package/out/server/OQL/sqlFunctions.json +695 -7
- package/out/server/client/nasl-server-client.d.ts +7 -0
- package/out/server/client/nasl-server-client.d.ts.map +1 -0
- package/out/server/client/nasl-server-client.js +9 -0
- package/out/server/client/nasl-server-client.js.map +1 -0
- package/out/server/extendBaseNode.d.ts.map +1 -1
- package/out/server/extendBaseNode.js +18 -9
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/index.d.ts +1 -0
- package/out/server/index.d.ts.map +1 -1
- package/out/server/index.js +1 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +10 -1
- package/out/server/naslServer.d.ts.map +1 -1
- package/out/server/naslServer.js +119 -62
- package/out/server/naslServer.js.map +1 -1
- package/out/service/initial/form-designer.d.ts +1 -1
- package/out/service/initial/form-designer.d.ts.map +1 -1
- package/out/service/initial/form-designer.js +4 -1
- package/out/service/initial/form-designer.js.map +1 -1
- package/out/service/initial/processV2.d.ts +1 -1
- package/out/service/initial/processV2.d.ts.map +1 -1
- package/out/service/initial/processV2.js +4 -1
- package/out/service/initial/processV2.js.map +1 -1
- package/out/service/initial/types.d.ts +1 -0
- package/out/service/initial/types.d.ts.map +1 -1
- package/out/service/storage/api.d.ts +16 -7
- package/out/service/storage/api.js +6 -0
- package/out/service/storage/api.js.map +1 -1
- package/out/service/storage/cache/index.d.ts +3 -15
- package/out/service/storage/cache/index.d.ts.map +1 -1
- package/out/service/storage/cache/index.js +14 -299
- package/out/service/storage/cache/index.js.map +1 -1
- package/out/service/storage/cache/split.d.ts +0 -21
- package/out/service/storage/cache/split.d.ts.map +1 -1
- package/out/service/storage/cache/split.js +24 -33
- package/out/service/storage/cache/split.js.map +1 -1
- package/out/service/storage/init.d.ts +9 -0
- package/out/service/storage/init.d.ts.map +1 -1
- package/out/service/storage/init.js +61 -90
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/service.js +1 -1
- package/out/service/storage/service.js.map +1 -1
- package/package.json +15 -13
package/out/server/naslServer.js
CHANGED
|
@@ -40,12 +40,15 @@ const Messager_1 = __importDefault(require("../common/Messager"));
|
|
|
40
40
|
const oql_cache_1 = require("./OQL/oql-cache");
|
|
41
41
|
const initial_1 = require("../service/initial");
|
|
42
42
|
const set_1 = require("mnemonist/set");
|
|
43
|
+
const sqlFunctions_json_1 = __importDefault(require("./OQL/sqlFunctions.json"));
|
|
44
|
+
const sqlCategory_json_1 = __importDefault(require("./OQL/sqlCategory.json"));
|
|
43
45
|
/// #if process.env.BUILD_TARGET === 'node'
|
|
44
46
|
const fs = __importStar(require("fs-extra"));
|
|
45
47
|
const path = __importStar(require("path"));
|
|
46
48
|
const worker_threads_1 = require("worker_threads");
|
|
47
49
|
/// #endif
|
|
48
50
|
const concepts_1 = require("../concepts");
|
|
51
|
+
// import { validator, VusionValidator } from '@lcap/nasl-concepts';
|
|
49
52
|
const asserts_1 = require("@lcap/nasl-concepts/asserts");
|
|
50
53
|
const service_1 = require("@lcap/nasl-concepts/service");
|
|
51
54
|
const utils = __importStar(require("../utils"));
|
|
@@ -60,25 +63,7 @@ const decorators_1 = require("../decorators");
|
|
|
60
63
|
const nasl_concepts_1 = require("@lcap/nasl-concepts");
|
|
61
64
|
const nasl_language_server_core_1 = require("@lcap/nasl-language-server-core");
|
|
62
65
|
const findReference_1 = require("./findReference");
|
|
63
|
-
const
|
|
64
|
-
'textField',
|
|
65
|
-
'valueField',
|
|
66
|
-
'iconField',
|
|
67
|
-
'toField',
|
|
68
|
-
'parentField',
|
|
69
|
-
'childrenField',
|
|
70
|
-
'hasChildrenField',
|
|
71
|
-
'field',
|
|
72
|
-
'idField',
|
|
73
|
-
'titleField',
|
|
74
|
-
'closableField',
|
|
75
|
-
'descriptionField',
|
|
76
|
-
'expandedField',
|
|
77
|
-
'disabledField',
|
|
78
|
-
'nameField',
|
|
79
|
-
'labelField',
|
|
80
|
-
'sortField'
|
|
81
|
-
];
|
|
66
|
+
const nasl_server_client_1 = require("./client/nasl-server-client");
|
|
82
67
|
const SentryMessager = (0, nasl_sentry_1.sentryMonitorTSWorkerMessager)(Messager_1.default);
|
|
83
68
|
// naslStdlib文件缓存;作为全局变量给多实例用复用
|
|
84
69
|
const __naslStdlibFileCacheMap = new Map();
|
|
@@ -184,6 +169,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
184
169
|
// 当前重命名模式:rename-only: 只重命名,update: 更新引用
|
|
185
170
|
this.currentRenameMode = null;
|
|
186
171
|
this.oqlDisaster = false;
|
|
172
|
+
this.useCache = false; // 是否使用本地缓存文件,目前用于AI沙箱无法调用接口的环境
|
|
187
173
|
this.isFirstScreen = true; // 优化首屏 getAncestor 热点代码
|
|
188
174
|
/**
|
|
189
175
|
* 语言服务运行完毕
|
|
@@ -327,6 +313,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
327
313
|
this.http = opt.http;
|
|
328
314
|
this.isAnnotationMode = opt?.isAnnotationMode ?? false;
|
|
329
315
|
this.logger = opt.logger ?? utils.internalLogger;
|
|
316
|
+
this.useCache = opt.useCache ?? false;
|
|
330
317
|
this.diagnosticManager = new diagnostic_1.DiagnosticManager();
|
|
331
318
|
this.messager = new SentryMessager({
|
|
332
319
|
protocol: 'ts-worker',
|
|
@@ -388,13 +375,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
388
375
|
const diagAppStartTime = performance.now();
|
|
389
376
|
await utils.runGeneratorAsync(this.semEnv.errorDiagnoser.diagnosticApp());
|
|
390
377
|
const diagAppEndTime = performance.now();
|
|
391
|
-
console.
|
|
378
|
+
console.info(`\x1b[44m\x1b[97m Diagnostic App \x1b[0m: ${((diagAppEndTime - diagAppStartTime) / 1000).toFixed(3)}s`);
|
|
392
379
|
const diagnosticMap = this.semEnv.errorDiagnoser.getAllDiagnostics();
|
|
393
380
|
const transformStartTime = performance.now();
|
|
394
381
|
const records = transformDiagnosticMapToRecords(diagnosticMap);
|
|
395
382
|
await this.diagnosticManager.setInitialDiagData(records);
|
|
396
383
|
const transformEndTime = performance.now();
|
|
397
|
-
console.
|
|
384
|
+
console.info(`\x1b[44m\x1b[97m Transform Diagnostic Map To Records \x1b[0m: ${((transformEndTime - transformStartTime) / 1000).toFixed(3)}s`);
|
|
398
385
|
// 首屏和增量通路不同,首屏时需要手动调用lsRunEndSwitch;增量时则在增量代码中调用
|
|
399
386
|
this._lsRunEndSwitch();
|
|
400
387
|
this.isFirstScreen = false;
|
|
@@ -406,7 +393,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
406
393
|
rawApp.emit('collect:end');
|
|
407
394
|
this.semData.isFirstScreen = false;
|
|
408
395
|
this.semEnv.allocatedVEQNames.forEach(n => {
|
|
409
|
-
this.semEnv.refMgr.
|
|
396
|
+
this.semEnv.refMgr.gQNameDefs.delete(n);
|
|
410
397
|
});
|
|
411
398
|
this.semEnv.allocatedVEQNames.length = 0;
|
|
412
399
|
for (const value of this.cachedEventPayloadValues) {
|
|
@@ -704,8 +691,14 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
704
691
|
return results;
|
|
705
692
|
}
|
|
706
693
|
async requestDatabaseConfigs(http, app) {
|
|
707
|
-
|
|
708
|
-
|
|
694
|
+
let data = [];
|
|
695
|
+
if (this.useCache) {
|
|
696
|
+
data = JSON.parse(JSON.stringify(sqlCategory_json_1.default));
|
|
697
|
+
}
|
|
698
|
+
else {
|
|
699
|
+
const res = await http.get('/api/v1/app/config/list?category=sql');
|
|
700
|
+
data = res.data?.result || [];
|
|
701
|
+
}
|
|
709
702
|
const map = data.filter((item) => item.category === 'sql' && item.available)
|
|
710
703
|
?.reduce((acc, item) => ({
|
|
711
704
|
...acc,
|
|
@@ -714,8 +707,14 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
714
707
|
app.saveDatabaseConfigIdToTypeMap(map);
|
|
715
708
|
}
|
|
716
709
|
async requestSqlFunctions(http, appName) {
|
|
717
|
-
|
|
718
|
-
|
|
710
|
+
let data = [];
|
|
711
|
+
if (this.useCache) {
|
|
712
|
+
data = JSON.parse(JSON.stringify(sqlFunctions_json_1.default));
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
const res = await http.get('/api/v1/app/config/database/functions');
|
|
716
|
+
data = res.data?.result?.result || [];
|
|
717
|
+
}
|
|
719
718
|
const files = data
|
|
720
719
|
.filter((item) => !!item.signature)
|
|
721
720
|
.map((item) => {
|
|
@@ -761,9 +760,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
761
760
|
provider: item.provider,
|
|
762
761
|
version: item.version,
|
|
763
762
|
}));
|
|
764
|
-
const res = await this.http.post('/api/v1/share/center/imported/changed/list', params);
|
|
765
|
-
this._latestVersionsOfSharedApp = res.data;
|
|
766
|
-
this.semEnv?.errorDiagnoser?.setLatestVersionsOfSharedApp(res.data);
|
|
763
|
+
// const res = await this.http.post('/api/v1/share/center/imported/changed/list', params);
|
|
764
|
+
// this._latestVersionsOfSharedApp = res.data;
|
|
765
|
+
// this.semEnv?.errorDiagnoser?.setLatestVersionsOfSharedApp(res.data);
|
|
767
766
|
}
|
|
768
767
|
getStatusOfSharedApp(sharedApp) {
|
|
769
768
|
const version = this._latestVersionsOfSharedApp.find((item) => item.name === sharedApp.name && item.provider === sharedApp.provider);
|
|
@@ -825,7 +824,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
825
824
|
this.logger.info('运行在自动化测试模式下...');
|
|
826
825
|
}
|
|
827
826
|
// 初始化 App 配置
|
|
828
|
-
await (0, initial_1.initialize)({ app, axios: this.http });
|
|
827
|
+
await (0, initial_1.initialize)({ app, axios: this.http, useCache: this.useCache });
|
|
829
828
|
this.logger.time('全量生成并写入 TS 文件——总计');
|
|
830
829
|
const toEmbeddedTSStartTime = new Date().getTime();
|
|
831
830
|
this.logger.time('全量生成 TS——翻译');
|
|
@@ -849,6 +848,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
849
848
|
catch (err) {
|
|
850
849
|
this.logger.error('请求数据库配置列表失败', err);
|
|
851
850
|
}
|
|
851
|
+
let sqlSignatureFiles = [];
|
|
852
852
|
try {
|
|
853
853
|
this.sqlSignatureFiles = await this.requestSqlFunctions(this.http, app.name);
|
|
854
854
|
}
|
|
@@ -1326,13 +1326,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1326
1326
|
nodeType = '连接';
|
|
1327
1327
|
}
|
|
1328
1328
|
timeoutConfig.values.forEach((value) => {
|
|
1329
|
-
const
|
|
1329
|
+
const env = value.env;
|
|
1330
1330
|
const timeout = Number(value.value);
|
|
1331
1331
|
if (timeout * 1000 < retryInterval * retryTimes) {
|
|
1332
1332
|
const diagnostic = {
|
|
1333
1333
|
node: fileNode,
|
|
1334
1334
|
severity: 'warning',
|
|
1335
|
-
message: `${nodeType}"${fileNodeRaw.title ?? fileNodeRaw.name}"配置的重试间隔时间乘以重试次数大于${
|
|
1335
|
+
message: `${nodeType}"${fileNodeRaw.title ?? fileNodeRaw.name}"配置的重试间隔时间乘以重试次数大于${env === 'dev' ? '开发环境' : '生产环境'}接口超时时间,可能导致重试失败`,
|
|
1336
1336
|
text: config_1.HTTP_TIMEOUT_ORIGIN_MESSAGE,
|
|
1337
1337
|
};
|
|
1338
1338
|
diagnostics.push(diagnostic);
|
|
@@ -1645,17 +1645,10 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1645
1645
|
return result;
|
|
1646
1646
|
};
|
|
1647
1647
|
const nd = NaslServer_1.toRaw(__node);
|
|
1648
|
-
if (concepts_1.asserts.isDirectory(__node)) {
|
|
1649
|
-
return [];
|
|
1650
|
-
}
|
|
1651
1648
|
const { parentNode } = nd;
|
|
1652
1649
|
const semEnv = NaslServer_1.toRaw(this.semEnv);
|
|
1653
1650
|
let result = wrapRefs(semEnv.refMgr.getReferences(semEnv, nd));
|
|
1654
|
-
if (nd.concept === '
|
|
1655
|
-
const refMemAddrs = semEnv.refMgr.getViewElementRefs(semEnv, nd);
|
|
1656
|
-
result.push(...wrapRefs(refMemAddrs));
|
|
1657
|
-
}
|
|
1658
|
-
else if (nd.concept === 'ProcessElementV2') {
|
|
1651
|
+
if (nd.concept === 'ProcessElementV2') {
|
|
1659
1652
|
const refMemAddrs = semEnv.refMgr.getProcessElementRefs(semEnv, nd);
|
|
1660
1653
|
result.push(...wrapRefs(refMemAddrs));
|
|
1661
1654
|
}
|
|
@@ -1668,10 +1661,18 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1668
1661
|
}
|
|
1669
1662
|
}
|
|
1670
1663
|
}
|
|
1671
|
-
else if (
|
|
1664
|
+
else if (nd.concept === 'BindEvent') {
|
|
1665
|
+
// v4.1 新增 绑定事件 改类型,需要把 事件逻辑的引用,全部迁移过去
|
|
1666
|
+
// v4.1 修改:logics 其实只能有一个
|
|
1667
|
+
if (nd.logics[0].concept === 'Logic') {
|
|
1668
|
+
const eventLogicRefs = semEnv.refMgr.getReferences(semEnv, nd.logics[0]);
|
|
1669
|
+
result.push(...wrapRefs(eventLogicRefs));
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
else if (nd.concept === 'Param' || nd.concept === 'ParamWithGroup') {
|
|
1672
1673
|
// 调用处的 keyword = XXX 等也要修改,所以查 Logic、View 等的引用
|
|
1673
1674
|
const pNode = NaslServer_1.toRaw(parentNode);
|
|
1674
|
-
if ((0,
|
|
1675
|
+
if ((0, service_1.isCallableNaslLogic)(pNode) || concepts_1.asserts.isStrictView(pNode)) {
|
|
1675
1676
|
const refs = semEnv.refMgr.getReferences(semEnv, pNode);
|
|
1676
1677
|
result.push(...wrapRefs(refs));
|
|
1677
1678
|
}
|
|
@@ -1715,6 +1716,22 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1715
1716
|
const minRange = {
|
|
1716
1717
|
...record,
|
|
1717
1718
|
};
|
|
1719
|
+
// 搞事情:v4.1 新增 绑定事件 改类型,需要把 事件逻辑的引用,全部迁移过去
|
|
1720
|
+
if (nd.concept === 'BindEvent') {
|
|
1721
|
+
if (minRange.node.concept === 'Identifier') {
|
|
1722
|
+
/**
|
|
1723
|
+
* 使用正则替换倒数第二个点和倒数第一个点之间的内容
|
|
1724
|
+
* 例如 elements.button_1.bindEvents.XXX.logics -> elements.button_1.bindEvents.YYY.logics
|
|
1725
|
+
*/
|
|
1726
|
+
minRange.newValue = minRange.node.namespace.replace(/(\.bindEvents\.)([^.]+)(\.logics)$/, `$1${newValue}$3`);
|
|
1727
|
+
minRange.setTypeMethods = 'setNamespace';
|
|
1728
|
+
}
|
|
1729
|
+
else if (minRange.node === nd) {
|
|
1730
|
+
// 自己
|
|
1731
|
+
minRange.newValue = newValue;
|
|
1732
|
+
minRange.setTypeMethods = 'setName';
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1718
1735
|
// 节点上ts临时变量标识,如果有这个就不rename
|
|
1719
1736
|
if (minRange.node?.noTsReName) {
|
|
1720
1737
|
return null;
|
|
@@ -1748,6 +1765,22 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1748
1765
|
}
|
|
1749
1766
|
// 如果匹配到的节点是Identifier表达式
|
|
1750
1767
|
if (minRange.node instanceof concepts_1.Identifier) {
|
|
1768
|
+
/**
|
|
1769
|
+
* v4.1 新增 Identifier 可能是 页面元素 的事件逻辑 Logic 的引用 或 逻辑的引用
|
|
1770
|
+
* 页面元素 改名后,这个 Identifier 的 namespace 中间的元素名需要修改
|
|
1771
|
+
*/
|
|
1772
|
+
if (nd.concept === 'ViewElement') {
|
|
1773
|
+
minRange.setTypeMethods = 'setNamespace';
|
|
1774
|
+
/**
|
|
1775
|
+
* 使用正则替换第二个点和第三个点之间的内容
|
|
1776
|
+
* 例如 elements.XXX.bindEvents.click.logics -> elements.YYY.bindEvents.click.logics
|
|
1777
|
+
*/
|
|
1778
|
+
const parts = minRange.node.namespace.split('.');
|
|
1779
|
+
if (parts.length >= 1) {
|
|
1780
|
+
parts[1] = newValue;
|
|
1781
|
+
minRange.newValue = parts.join('.');
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1751
1784
|
// 如果参数修改影响了Identifier, 就说明是上一级逻辑的引用,所以就直接过滤掉就好了
|
|
1752
1785
|
if (nd instanceof concepts_1.Param && minRange.node?.namespace?.endsWith('logics')) {
|
|
1753
1786
|
return null;
|
|
@@ -1826,7 +1859,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1826
1859
|
minRange.setTypeMethods = 'setUrlValue';
|
|
1827
1860
|
minRange.newValue = newTextValue;
|
|
1828
1861
|
}
|
|
1829
|
-
else if (minRange.node instanceof concepts_1.BindAttribute &&
|
|
1862
|
+
else if (minRange.node instanceof concepts_1.BindAttribute && nasl_language_server_core_1.specialStringRefs.includes(minRange.node.name)) {
|
|
1830
1863
|
// eslint-disable-next-line no-confusing-arrow
|
|
1831
1864
|
minRange.newValue = (minRange.node.value ?? '').split('.').map((v, i) => i ? v : newValue.charAt(0).toLowerCase() + newValue.slice(1)).join('.');
|
|
1832
1865
|
minRange.setTypeMethods = 'setValue';
|
|
@@ -1865,7 +1898,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1865
1898
|
// 如果要修改实体属性
|
|
1866
1899
|
if (nd instanceof concepts_1.EntityProperty) {
|
|
1867
1900
|
// 如果是修改实体属性,要同步绑定属性(属性名为 valueField / textField)
|
|
1868
|
-
if (minRange.node instanceof concepts_1.BindAttribute &&
|
|
1901
|
+
if (minRange.node instanceof concepts_1.BindAttribute && nasl_language_server_core_1.specialStringRefs.includes(minRange.node.name)) {
|
|
1869
1902
|
// eslint-disable-next-line no-confusing-arrow
|
|
1870
1903
|
minRange.newValue = (minRange.node.value ?? '').split('.').slice(0, -1).concat(newValue).join('.');
|
|
1871
1904
|
minRange.setTypeMethods = 'setValue';
|
|
@@ -2130,7 +2163,16 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2130
2163
|
// 增加参数的副作用,用于更新logic和view
|
|
2131
2164
|
_addParamsEffect(refsList, nd) {
|
|
2132
2165
|
const parentNode = nd?.parentNode;
|
|
2133
|
-
|
|
2166
|
+
// 按 node.nodePath 降序排列,保证父级或更深层的引用先处理
|
|
2167
|
+
const sortedRefs = (refsList || []).slice().sort((a, b) => {
|
|
2168
|
+
const pa = a?.node?.nodePath ?? '';
|
|
2169
|
+
const pb = b?.node?.nodePath ?? '';
|
|
2170
|
+
return pb.localeCompare(pa);
|
|
2171
|
+
});
|
|
2172
|
+
// 考虑 CallA(CallA(null))
|
|
2173
|
+
// 如果 不按 nodePath 降序排列,那么更新了第一个 CallA 后,第二个的 CallA 的 nodePath 中会有 -1
|
|
2174
|
+
// 推测可能是 CallA 变成了新节点,所以存的 node 变了
|
|
2175
|
+
sortedRefs.forEach(({ node: minRangeNode }) => {
|
|
2134
2176
|
// 如果找到节点是callLogic就去更新
|
|
2135
2177
|
if (nd instanceof concepts_1.Param) {
|
|
2136
2178
|
if (minRangeNode instanceof concepts_1.CallLogic || minRangeNode instanceof concepts_1.CallAuthInterface) {
|
|
@@ -2309,13 +2351,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2309
2351
|
}
|
|
2310
2352
|
// Convert和new都是自身携带类型的,就不进行修改
|
|
2311
2353
|
if (node instanceof concepts_1.CallFunction && node.calleeNamespace === 'nasl.util' && ['Convert', 'New', 'FromString'].includes(node.calleeName)) {
|
|
2312
|
-
if (node.typeArguments
|
|
2354
|
+
if (node.typeArguments?.length) {
|
|
2313
2355
|
return node.typeArguments[0];
|
|
2314
2356
|
}
|
|
2315
2357
|
}
|
|
2316
2358
|
// Convert和new都是自身携带类型的,就不进行修改
|
|
2317
2359
|
if (node instanceof concepts_1.CallLogic && node.calleeNamespace === 'nasl.util' && node.calleeName === 'jsonDeserialize') {
|
|
2318
|
-
if (node.typeArguments
|
|
2360
|
+
if (node.typeArguments?.length) {
|
|
2319
2361
|
return node.typeArguments[0];
|
|
2320
2362
|
}
|
|
2321
2363
|
}
|
|
@@ -2358,6 +2400,8 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2358
2400
|
utils.delay(55);
|
|
2359
2401
|
}
|
|
2360
2402
|
const { node, filePath, item } = itemDetail;
|
|
2403
|
+
if (!item)
|
|
2404
|
+
return;
|
|
2361
2405
|
// 先按照顺序占位
|
|
2362
2406
|
types.set(node, null);
|
|
2363
2407
|
// 获取已知节点类型的类型
|
|
@@ -2388,6 +2432,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2388
2432
|
'CallFunction',
|
|
2389
2433
|
'CallInterface',
|
|
2390
2434
|
'CallMicroserviceInterface',
|
|
2435
|
+
'CallGatewayInterface',
|
|
2391
2436
|
'MemberExpression',
|
|
2392
2437
|
'Return',
|
|
2393
2438
|
'Variable',
|
|
@@ -2680,14 +2725,16 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2680
2725
|
// 集成内存优化:在标注过程中直接优化JSON,减少内存使用和处理时间
|
|
2681
2726
|
(0, memory_optimization_1.optimizeJsonDuringAnnotation)(newJson);
|
|
2682
2727
|
let tyAnn = tyAnnToJSON(this.semEnv.getType(oldNd));
|
|
2683
|
-
if ((oldNd.concept === 'Variable' || oldNd.concept === 'Return' || oldNd.concept === 'Param')
|
|
2728
|
+
if ((oldNd.concept === 'Variable' || oldNd.concept === 'Return' || oldNd.concept === 'Param' || oldNd.concept === 'ParamWithGroup')
|
|
2684
2729
|
&& !oldNd.typeAnnotation
|
|
2685
2730
|
&& tyAnn?.typeKind !== 'typeParam') {
|
|
2686
2731
|
newJson.typeAnnotation = tyAnn;
|
|
2687
2732
|
}
|
|
2688
2733
|
// 原来的标注环节复制粘贴过来改写的,调整了顺序
|
|
2689
2734
|
// jsonSerializer 是 CallLogic,其余是 CallFunction。CallLogic 有好几个子类。
|
|
2690
|
-
|
|
2735
|
+
const isCallType1 = oldNd.concept === 'CallLogic' || oldNd.concept === 'CallConnector';
|
|
2736
|
+
const isCallFn = oldNd.concept === 'CallFunction';
|
|
2737
|
+
if (isCallType1 || isCallFn) {
|
|
2691
2738
|
const tzArgIdx = timeZoneArgumentIndexMap.get(oldNd.calleeName);
|
|
2692
2739
|
const args = oldNd.arguments;
|
|
2693
2740
|
const tzArg = args ? args[tzArgIdx] : undefined;
|
|
@@ -2700,9 +2747,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2700
2747
|
/**
|
|
2701
2748
|
* 特殊处理,不想去查两次类型, 因为是从函数签名上拿类型,所以直接合并在一起,先这样
|
|
2702
2749
|
* 应该主要是 Java 扩展库逻辑调用
|
|
2703
|
-
*/
|
|
2704
|
-
if (oldNd
|
|
2705
|
-
newJson.typeArguments = oldNd.__TypeArguments.map(tyAnnToJSON);
|
|
2750
|
+
*/ // @ts-ignore
|
|
2751
|
+
if (oldNd.__TypeArguments?.length && isCallType1) { // @ts-ignore
|
|
2752
|
+
newJson.typeArguments = oldNd.__TypeArguments.map(tyAnnToJSON);
|
|
2706
2753
|
newJson.typeAnnotation = tyAnn;
|
|
2707
2754
|
}
|
|
2708
2755
|
// 根据 https://projectmanage.netease-official.lcap.163yun.com/dashboard/FeatureDetail?id=2737356895760128&id1=null&iterationId=null&versionid=null&tab=info
|
|
@@ -2710,7 +2757,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2710
2757
|
// - 对argument.expression.typeAnnotation 无需做修改,保持为其实际类型
|
|
2711
2758
|
// - 对argument.typeAnnotation,为根据对应Collection的泛型参数的类型填写其类型
|
|
2712
2759
|
// 先不动这里,有空再调整
|
|
2713
|
-
if (
|
|
2760
|
+
if (isCallFn) {
|
|
2714
2761
|
if (oldNd.calleeNamespace === 'nasl.util') {
|
|
2715
2762
|
const calleeName = oldNd.calleeName;
|
|
2716
2763
|
const listFunctionParamIndexMaps = new Map(Object.entries({
|
|
@@ -2766,34 +2813,41 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2766
2813
|
}
|
|
2767
2814
|
}
|
|
2768
2815
|
if (!tyAnn) {
|
|
2816
|
+
const isCallItfc = oldNd.concept === 'CallInterface' ||
|
|
2817
|
+
oldNd.concept === 'CallAuthInterface' ||
|
|
2818
|
+
oldNd.concept === 'CallMicroserviceInterface' ||
|
|
2819
|
+
oldNd.concept === 'CallGatewayInterface';
|
|
2820
|
+
if (isCallType1 || isCallFn || isCallItfc) {
|
|
2821
|
+
newJson.typeAnnotation = nasl_language_server_core_1.naslVoidTy.toJSON();
|
|
2822
|
+
}
|
|
2769
2823
|
return newJson;
|
|
2770
2824
|
}
|
|
2771
|
-
if (oldNd.concept === 'CallQueryComponent' /* && !oldNd.isAutoInfer() 直接覆盖得了,老版的 typeAnnotation 问题有点多 */) {
|
|
2825
|
+
if (oldNd.concept === 'CallQueryComponent' /* && !oldNd.isAutoInfer() 直接覆盖得了,老版的 typeAnnotation 问题有点多 */) {
|
|
2772
2826
|
newJson.typeAnnotation = tyAnn;
|
|
2773
2827
|
// 新类型标注标的是对的,所以不再需要原来的改法(即,把 T 变为 { list:T, total: Long }
|
|
2774
2828
|
}
|
|
2775
2829
|
// 如果节点本身有类型就不去在塞一遍了
|
|
2776
2830
|
// 有值而且没有类型再去设置
|
|
2777
2831
|
// 但是Identifier 和 MemberExpression 都用标注出来的因为本身是变量,有类型也需要覆盖一下
|
|
2778
|
-
else if (tyAnn && (oldNd.concept === 'Argument') && oldNd.getAncestor('Connector')?.concept === 'Connector') {
|
|
2832
|
+
else if (tyAnn && (oldNd.concept === 'Argument') && oldNd.getAncestor('Connector')?.concept === 'Connector') {
|
|
2779
2833
|
newJson.typeAnnotation = tyAnn;
|
|
2780
2834
|
}
|
|
2781
2835
|
else if (oldNd.concept === 'Identifier' || oldNd.concept === 'MemberExpression') {
|
|
2782
2836
|
// @ts-ignore 处理 Match,还是需要,因为后端翻译比较特殊
|
|
2783
|
-
const iName = getNameOfIdAndMemExpr(newJson);
|
|
2837
|
+
const iName = getNameOfIdAndMemExpr(newJson);
|
|
2784
2838
|
newJson.typeAnnotation = matchExprTyAnnMap.has(iName) ? matchExprTyAnnMap.get(iName) : tyAnn;
|
|
2785
2839
|
}
|
|
2786
2840
|
else if ((oldNd.concept === 'NewComposite') &&
|
|
2787
|
-
(oldNd.typeAnnotation?.typeKind === 'anonymousStructure' || oldNd.typeAnnotation?.typeKind === 'generic')) {
|
|
2841
|
+
(oldNd.typeAnnotation?.typeKind === 'anonymousStructure' || oldNd.typeAnnotation?.typeKind === 'generic')) {
|
|
2788
2842
|
newJson.typeAnnotation = tyAnn;
|
|
2789
2843
|
}
|
|
2790
2844
|
// 服务端需要默认值节点有类型来判断父节点是否是日期类型
|
|
2791
2845
|
else if (newJson.concept === 'DefaultValue') {
|
|
2792
|
-
//
|
|
2846
|
+
// v3.14.x 先改成这样,应该直接拿就行
|
|
2793
2847
|
newJson.typeAnnotation = tyAnn;
|
|
2794
2848
|
}
|
|
2795
2849
|
// 定义上不挂类型
|
|
2796
|
-
else if ((!oldNd.typeAnnotation) && !nasl_language_server_core_1.ReferenceManager.defConcept.includes(oldNd.concept)) {
|
|
2850
|
+
else if ((!oldNd.typeAnnotation) && !nasl_language_server_core_1.ReferenceManager.defConcept.includes(oldNd.concept)) {
|
|
2797
2851
|
newJson.typeAnnotation = tyAnn;
|
|
2798
2852
|
}
|
|
2799
2853
|
return newJson;
|
|
@@ -3258,7 +3312,6 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3258
3312
|
this.logger.timeEnd('语言服务变更');
|
|
3259
3313
|
}
|
|
3260
3314
|
catch (e) {
|
|
3261
|
-
console.log('error', e);
|
|
3262
3315
|
console.error('error', e);
|
|
3263
3316
|
this.logger.info('no "naslServer:nodeChange" event received');
|
|
3264
3317
|
}
|
|
@@ -3313,7 +3366,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3313
3366
|
this.typerErrRecords.length = 0;
|
|
3314
3367
|
this.oqlRemoveNodesTsPath.clear();
|
|
3315
3368
|
this.semEnv.allocatedVEQNames.forEach(n => {
|
|
3316
|
-
this.semEnv.refMgr.
|
|
3369
|
+
this.semEnv.refMgr.gQNameDefs.delete(n);
|
|
3317
3370
|
});
|
|
3318
3371
|
this.semEnv.allocatedVEQNames.length = 0;
|
|
3319
3372
|
this.originProxyTargetNodes.clear();
|
|
@@ -3553,7 +3606,8 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3553
3606
|
};
|
|
3554
3607
|
proxyApp.frontendTypes.forEach((fet) => {
|
|
3555
3608
|
fet.frontends.forEach((fe) => {
|
|
3556
|
-
|
|
3609
|
+
// 兼容 null 是为了看从服务端发布 json 恢复出来的内容,基本前端都是 null 而不是标准的空数组 []
|
|
3610
|
+
fe.views?.forEach((view) => {
|
|
3557
3611
|
traverseChildrenGetElementLogicRoot(view);
|
|
3558
3612
|
});
|
|
3559
3613
|
});
|
|
@@ -3600,6 +3654,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3600
3654
|
ctxProcessV2?.getSubLogics();
|
|
3601
3655
|
});
|
|
3602
3656
|
}
|
|
3657
|
+
async getClient() {
|
|
3658
|
+
return (0, nasl_server_client_1.getNaslServerClient)(this);
|
|
3659
|
+
}
|
|
3603
3660
|
};
|
|
3604
3661
|
exports.NaslServer = NaslServer;
|
|
3605
3662
|
__decorate([
|