@lcap/nasl 3.13.1-debug.4 → 3.13.1-debug.6
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.js +6 -48
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/natural/transformTS2UI.d.ts.map +1 -1
- package/out/natural/transformTS2UI.js +53 -35
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transforms/transform2LogicItem.d.ts.map +1 -1
- package/out/natural/transforms/transform2LogicItem.js +1 -3
- package/out/natural/transforms/transform2LogicItem.js.map +1 -1
- package/out/server/naslServer.d.ts +4 -1
- package/out/server/naslServer.d.ts.map +1 -1
- package/out/server/naslServer.js +91 -94
- package/out/server/naslServer.js.map +1 -1
- package/package.json +12 -14
- package/ts-worker/bundle.js +8 -8
- package/ts-worker/src/start.js +100 -40
- package/out/concepts/validator/VusionValidator.d.ts +0 -33
- package/out/concepts/validator/VusionValidator.d.ts.map +0 -1
- package/out/concepts/validator/VusionValidator.js +0 -164
- package/out/concepts/validator/VusionValidator.js.map +0 -1
- package/out/concepts/validator/builtIn/rules.d.ts +0 -5
- package/out/concepts/validator/builtIn/rules.d.ts.map +0 -1
- package/out/concepts/validator/builtIn/rules.js +0 -112
- package/out/concepts/validator/builtIn/rules.js.map +0 -1
- package/out/concepts/validator/builtIn/validators.d.ts +0 -6
- package/out/concepts/validator/builtIn/validators.d.ts.map +0 -1
- package/out/concepts/validator/builtIn/validators.js +0 -146
- package/out/concepts/validator/builtIn/validators.js.map +0 -1
- package/out/concepts/validator/index.d.ts +0 -263
- package/out/concepts/validator/index.d.ts.map +0 -1
- package/out/concepts/validator/index.js +0 -318
- package/out/concepts/validator/index.js.map +0 -1
- package/out/concepts/validator/locales/zh-CN.d.ts +0 -99
- package/out/concepts/validator/locales/zh-CN.d.ts.map +0 -1
- package/out/concepts/validator/locales/zh-CN.js +0 -100
- package/out/concepts/validator/locales/zh-CN.js.map +0 -1
- package/out/concepts/validator/parseRules.d.ts +0 -3
- package/out/concepts/validator/parseRules.d.ts.map +0 -1
- package/out/concepts/validator/parseRules.js +0 -139
- package/out/concepts/validator/parseRules.js.map +0 -1
- package/out/concepts/validator/rules.d.ts +0 -67
- package/out/concepts/validator/rules.d.ts.map +0 -1
- package/out/concepts/validator/rules.js +0 -150
- package/out/concepts/validator/rules.js.map +0 -1
- package/out/concepts/validator/types.d.ts +0 -15
- package/out/concepts/validator/types.d.ts.map +0 -1
- package/out/concepts/validator/types.js +0 -3
- package/out/concepts/validator/types.js.map +0 -1
package/out/server/naslServer.js
CHANGED
|
@@ -45,8 +45,6 @@ const path = __importStar(require("path"));
|
|
|
45
45
|
const worker_threads_1 = require("worker_threads");
|
|
46
46
|
/// #endif
|
|
47
47
|
const concepts_1 = require("../concepts");
|
|
48
|
-
const validator_1 = require("../concepts/validator");
|
|
49
|
-
const utils_1 = require("../utils");
|
|
50
48
|
const asserts_1 = require("@lcap/nasl-concepts/asserts");
|
|
51
49
|
const service_1 = require("@lcap/nasl-concepts/service");
|
|
52
50
|
const Checker = __importStar(require("./checker"));
|
|
@@ -57,7 +55,7 @@ const translator_2 = require("./translator");
|
|
|
57
55
|
const common_1 = require("../common");
|
|
58
56
|
const diagnostic_1 = require("../manager/diagnostic");
|
|
59
57
|
const naslStdlibMap_1 = __importDefault(require("./naslStdlibMap"));
|
|
60
|
-
const
|
|
58
|
+
const utils_1 = require("../utils");
|
|
61
59
|
const decorators_1 = require("../decorators");
|
|
62
60
|
const nasl_concepts_1 = require("@lcap/nasl-concepts");
|
|
63
61
|
const NEED_SYNC_BIND_ATTRIBUTE = [
|
|
@@ -112,41 +110,6 @@ function getBusinessComponentPos(fileNode) {
|
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
}
|
|
115
|
-
/**
|
|
116
|
-
* 属于实体逻辑
|
|
117
|
-
*/
|
|
118
|
-
function belongEntityLogic(node) {
|
|
119
|
-
const logic = (node.getAncestor('Logic') || node);
|
|
120
|
-
return concepts_1.asserts.isLogic(logic) && (0, utils_1.findConceptKeyWordIndexFromNodePath)(logic.nodePath, 'entities') !== -1;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* 属于虚拟入参
|
|
124
|
-
* @param node
|
|
125
|
-
* @returns
|
|
126
|
-
*/
|
|
127
|
-
function belongVirtualParams(node) {
|
|
128
|
-
return (0, utils_1.findConceptKeyWordIndexFromNodePath)(node?.nodePath, 'virtualParams') !== -1;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* 是端事件下的参数
|
|
132
|
-
* @param node
|
|
133
|
-
* @returns
|
|
134
|
-
*/
|
|
135
|
-
function isFrontendEvent(node) {
|
|
136
|
-
let flag = false;
|
|
137
|
-
if (node?.name === 'event') {
|
|
138
|
-
flag = true;
|
|
139
|
-
let target = node;
|
|
140
|
-
const conceptList = ['Param', 'Logic', 'BindEvent', 'Frontend'];
|
|
141
|
-
conceptList.forEach((concept) => {
|
|
142
|
-
if (target?.concept !== concept) {
|
|
143
|
-
flag = false;
|
|
144
|
-
}
|
|
145
|
-
target = target?.parentNode;
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
return flag;
|
|
149
|
-
}
|
|
150
113
|
// 联合类型切割取出类型
|
|
151
114
|
function getDisplayString2Type(displayString) {
|
|
152
115
|
const targetString = displayString.match(/value:\s(\S+)\)/)?.[1];
|
|
@@ -190,6 +153,18 @@ function isFunctionWithFixedTimeZoneParam(calleeName) {
|
|
|
190
153
|
const fns = ['CurrDateTime', 'CurrDate', 'CurrTime', 'FormatDateTime'];
|
|
191
154
|
return fns.includes(calleeName);
|
|
192
155
|
}
|
|
156
|
+
const createWorker = async (link, options) => {
|
|
157
|
+
const blob = await fetch(link).then((res) => res.blob());
|
|
158
|
+
const instance = globalThis.window;
|
|
159
|
+
const electron = instance.electron;
|
|
160
|
+
if (electron?.createWorker) {
|
|
161
|
+
return electron?.createWorker?.(await blob.arrayBuffer(), options);
|
|
162
|
+
}
|
|
163
|
+
const url = URL.createObjectURL(blob);
|
|
164
|
+
const worker = new worker_threads_1.Worker(url, options);
|
|
165
|
+
URL.revokeObjectURL(url);
|
|
166
|
+
return worker;
|
|
167
|
+
};
|
|
193
168
|
const allComponent = {};
|
|
194
169
|
let NaslServer = NaslServer_1 = class NaslServer {
|
|
195
170
|
constructor(opt) {
|
|
@@ -217,6 +192,17 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
217
192
|
this.isFirstScreen = true; // 优化首屏 getAncestor 热点代码
|
|
218
193
|
// 检查共享数据是否有更新
|
|
219
194
|
this._latestVersionsOfSharedApp = [];
|
|
195
|
+
this.promise = this.launch(opt);
|
|
196
|
+
}
|
|
197
|
+
async start() {
|
|
198
|
+
await this.promise;
|
|
199
|
+
return this.messager.requestCommand('start');
|
|
200
|
+
}
|
|
201
|
+
terminate() {
|
|
202
|
+
this.worker.terminate();
|
|
203
|
+
this.worker = null;
|
|
204
|
+
}
|
|
205
|
+
async launch(opt) {
|
|
220
206
|
/// #if process.env.BUILD_TARGET === 'node'
|
|
221
207
|
if (globalThis.process)
|
|
222
208
|
// For TS build
|
|
@@ -226,10 +212,25 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
226
212
|
/// #if process.env.BUILD_TARGET !== 'node'
|
|
227
213
|
if (globalThis.window) {
|
|
228
214
|
// const source = require('!!raw-loader!@lcap/nasl-typescript-worker/dist/index.js').default;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
215
|
+
this.worker = await (async () => {
|
|
216
|
+
if (process.env.NODE_ENV === 'development') {
|
|
217
|
+
const source = require('!!raw-loader!../../ts-worker/bundle.js').default;
|
|
218
|
+
const url = URL.createObjectURL(new Blob([source]));
|
|
219
|
+
const worker = new window.Worker(url);
|
|
220
|
+
URL.revokeObjectURL(url);
|
|
221
|
+
return worker;
|
|
222
|
+
}
|
|
223
|
+
const instance = globalThis.window;
|
|
224
|
+
const baseIdePath = instance?.baseIdePath;
|
|
225
|
+
const hash = process.env.COMMIT_HASH || '';
|
|
226
|
+
const filename = instance?.electron
|
|
227
|
+
? 'tsserver.electron.js'
|
|
228
|
+
: 'tsserver.js';
|
|
229
|
+
// @ts-ignore
|
|
230
|
+
const link = `${baseIdePath}/js/${filename}?${hash}`;
|
|
231
|
+
const options = { name: 'typescript-server' };
|
|
232
|
+
return createWorker(link, options);
|
|
233
|
+
})();
|
|
233
234
|
}
|
|
234
235
|
/// #endif
|
|
235
236
|
this.http = opt.http;
|
|
@@ -329,13 +330,6 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
329
330
|
});
|
|
330
331
|
}
|
|
331
332
|
}
|
|
332
|
-
start() {
|
|
333
|
-
return this.messager.requestCommand('start');
|
|
334
|
-
}
|
|
335
|
-
terminate() {
|
|
336
|
-
this.worker.terminate();
|
|
337
|
-
this.worker = null;
|
|
338
|
-
}
|
|
339
333
|
async createUiTs(components, optinos) {
|
|
340
334
|
const { standardUIComponents, // 标准组件(带有ts类型定义文件的组件)
|
|
341
335
|
} = optinos;
|
|
@@ -1571,7 +1565,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1571
1565
|
// 是否包含组件逻辑
|
|
1572
1566
|
hasComponentLogics(expression) {
|
|
1573
1567
|
let flag = false;
|
|
1574
|
-
(0,
|
|
1568
|
+
(0, utils_1.traverse)((current) => {
|
|
1575
1569
|
const { node } = current || {};
|
|
1576
1570
|
const { concept } = node || {};
|
|
1577
1571
|
if (concept === 'CallLogic') {
|
|
@@ -1687,6 +1681,19 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1687
1681
|
errorFRefNames,
|
|
1688
1682
|
};
|
|
1689
1683
|
}
|
|
1684
|
+
_getDuplicateNames(node, getItems, getName) {
|
|
1685
|
+
const items = getItems(node);
|
|
1686
|
+
const nameSet = new Set();
|
|
1687
|
+
const res = new Set();
|
|
1688
|
+
for (const item of items) {
|
|
1689
|
+
const name = getName(item);
|
|
1690
|
+
if (!nameSet.has(name))
|
|
1691
|
+
nameSet.add(name);
|
|
1692
|
+
else
|
|
1693
|
+
res.add(name);
|
|
1694
|
+
}
|
|
1695
|
+
return Array.from(res);
|
|
1696
|
+
}
|
|
1690
1697
|
/**
|
|
1691
1698
|
* 额外的诊断
|
|
1692
1699
|
* @param fileNode 文件级别的节点
|
|
@@ -1979,6 +1986,21 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1979
1986
|
}
|
|
1980
1987
|
}
|
|
1981
1988
|
else if (node instanceof concepts_1.Logic) {
|
|
1989
|
+
const duplicateVariables = self._getDuplicateNames(node, (logic) => [
|
|
1990
|
+
...logic.variables,
|
|
1991
|
+
...logic.params,
|
|
1992
|
+
...logic.returns,
|
|
1993
|
+
...likeComponent.variables,
|
|
1994
|
+
...likeComponent.params,
|
|
1995
|
+
], (item) => item.name);
|
|
1996
|
+
if (duplicateVariables.length) {
|
|
1997
|
+
const diagnostic = {
|
|
1998
|
+
node,
|
|
1999
|
+
severity: 'error',
|
|
2000
|
+
message: `逻辑${node.name}存在重名变量:${duplicateVariables.join(', ')}`,
|
|
2001
|
+
};
|
|
2002
|
+
diagnostics.push(diagnostic);
|
|
2003
|
+
}
|
|
1982
2004
|
}
|
|
1983
2005
|
else {
|
|
1984
2006
|
self.checkNodeError(node, diagnostics);
|
|
@@ -2052,6 +2074,15 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2052
2074
|
});
|
|
2053
2075
|
}
|
|
2054
2076
|
}
|
|
2077
|
+
// 检查实体重名
|
|
2078
|
+
const duplidateEntities = this._getDuplicateNames(fileNodeRaw, (dataSource) => dataSource.entities, (entity) => entity.name);
|
|
2079
|
+
if (duplidateEntities.length) {
|
|
2080
|
+
diagnostics.push({
|
|
2081
|
+
node: fileNode,
|
|
2082
|
+
severity: 'error',
|
|
2083
|
+
message: `数据源${fileNodeRaw.name}存在重名实体:${duplidateEntities.join(', ')}`,
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2055
2086
|
}
|
|
2056
2087
|
// 加上对实体属性存储类型的校验规则
|
|
2057
2088
|
else if (fileNodeRaw instanceof concepts_1.Entity) {
|
|
@@ -2394,6 +2425,15 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2394
2425
|
}
|
|
2395
2426
|
}
|
|
2396
2427
|
if (fileNodeRaw instanceof concepts_1.Logic && fileNodeRaw.calleewholeKey.startsWith('app.logics')) {
|
|
2428
|
+
const duplicateLogics = this._getDuplicateNames(fileNodeRaw.rootNode, (app) => app.logics, (logic) => logic.name);
|
|
2429
|
+
if (duplicateLogics.includes(fileNodeRaw.name)) {
|
|
2430
|
+
const diagnostic = {
|
|
2431
|
+
node: fileNode,
|
|
2432
|
+
severity: 'error',
|
|
2433
|
+
message: `存在重名服务端逻辑${fileNodeRaw.name}`,
|
|
2434
|
+
};
|
|
2435
|
+
diagnostics.push(diagnostic);
|
|
2436
|
+
}
|
|
2397
2437
|
if (fileNodeRaw.sharedScope?.scope === 'specifiedRange' && !fileNodeRaw.sharedScope?.specifiedRange?.length) {
|
|
2398
2438
|
const diagnostic = {
|
|
2399
2439
|
node: fileNode,
|
|
@@ -2820,49 +2860,6 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2820
2860
|
diagnostics.push(diagnostic);
|
|
2821
2861
|
}
|
|
2822
2862
|
}
|
|
2823
|
-
// 校验节点名
|
|
2824
|
-
function* validateNodeName(node) {
|
|
2825
|
-
// 排除一些不需要校验的情况
|
|
2826
|
-
if (isFrontendEvent(node) || belongEntityLogic(node) || belongVirtualParams(node)) {
|
|
2827
|
-
return;
|
|
2828
|
-
}
|
|
2829
|
-
const { concept } = node || {};
|
|
2830
|
-
const conceptValidator = validator_1.validator[concept];
|
|
2831
|
-
if (conceptValidator) {
|
|
2832
|
-
try {
|
|
2833
|
-
const vusionValidator = new validator_1.VusionValidator({}, {}, conceptValidator.rules(node), null) || {};
|
|
2834
|
-
let toBeVerifiedName = node;
|
|
2835
|
-
const map = {
|
|
2836
|
-
EnumItem: 'value',
|
|
2837
|
-
};
|
|
2838
|
-
const properties = (map[concept] || 'name').split('.');
|
|
2839
|
-
if (properties) {
|
|
2840
|
-
properties.forEach((property) => {
|
|
2841
|
-
toBeVerifiedName = toBeVerifiedName[property];
|
|
2842
|
-
});
|
|
2843
|
-
}
|
|
2844
|
-
const res = yield vusionValidator.validate(toBeVerifiedName, [], {
|
|
2845
|
-
label: (0, concepts_1.getConceptConstructor)(concept).nodeTitle,
|
|
2846
|
-
alwaysResolve: true,
|
|
2847
|
-
});
|
|
2848
|
-
if (res) {
|
|
2849
|
-
const diagnostic = {
|
|
2850
|
-
node,
|
|
2851
|
-
severity: 'error',
|
|
2852
|
-
message: `【${toBeVerifiedName}】命名非法:${res}`,
|
|
2853
|
-
};
|
|
2854
|
-
diagnostics.push(diagnostic);
|
|
2855
|
-
console.log(diagnostic);
|
|
2856
|
-
}
|
|
2857
|
-
}
|
|
2858
|
-
catch (err) {
|
|
2859
|
-
// console.log(err);
|
|
2860
|
-
}
|
|
2861
|
-
}
|
|
2862
|
-
}
|
|
2863
|
-
yield* utils.wrapIteratorToGenerator(fileNodeRaw.sourceMap.entries(), function* ([node]) {
|
|
2864
|
-
yield* validateNodeName(node);
|
|
2865
|
-
});
|
|
2866
2863
|
return diagnostics;
|
|
2867
2864
|
}
|
|
2868
2865
|
timeoutCheck(fileNodeRaw, fileNode, diagnostics) {
|
|
@@ -6345,7 +6342,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
6345
6342
|
this.semData.recoverSlowGetters();
|
|
6346
6343
|
this.semData.clearSemanticData();
|
|
6347
6344
|
this.semData.isFirstScreen = false;
|
|
6348
|
-
const isFrontendLogic = targetNodeRaw.getAncestorRaw('Logic') && (fileNodeRaw.concept === 'View'
|
|
6345
|
+
const isFrontendLogic = targetNodeRaw.getAncestorRaw('Logic') && Boolean(fileNodeRaw.concept === 'View' ?? fileNodeRaw.concept === 'BusinessComponent');
|
|
6349
6346
|
// @ts-ignore
|
|
6350
6347
|
!isFrontendLogic && this.semData.updateDirtyIndRetDeps(fileNodeRaw);
|
|
6351
6348
|
this.logger.timeEnd('TS 文件变更');
|