@lcap/nasl 2.22.1 → 2.22.2-beta.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/breakpoint/generator/AfterStartNode.d.ts +7 -0
- package/out/breakpoint/generator/AfterStartNode.js +27 -0
- package/out/breakpoint/generator/AfterStartNode.js.map +1 -0
- package/out/breakpoint/generator/BeforeEndNode.d.ts +7 -0
- package/out/breakpoint/generator/BeforeEndNode.js +27 -0
- package/out/breakpoint/generator/BeforeEndNode.js.map +1 -0
- package/out/breakpoint/generator/BreakpointNode.d.ts +14 -0
- package/out/breakpoint/generator/BreakpointNode.js +200 -0
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -0
- package/out/breakpoint/generator/index.d.ts +4 -0
- package/out/breakpoint/generator/index.js +98 -0
- package/out/breakpoint/generator/index.js.map +1 -0
- package/out/breakpoint/index.d.ts +3 -0
- package/out/breakpoint/index.js +20 -0
- package/out/breakpoint/index.js.map +1 -0
- package/out/breakpoint/shared/constants.d.ts +31 -0
- package/out/breakpoint/shared/constants.js +91 -0
- package/out/breakpoint/shared/constants.js.map +1 -0
- package/out/breakpoint/shared/index.d.ts +3 -0
- package/out/breakpoint/shared/index.js +33 -0
- package/out/breakpoint/shared/index.js.map +1 -0
- package/out/breakpoint/shared/operations.d.ts +10 -0
- package/out/breakpoint/shared/operations.js +25 -0
- package/out/breakpoint/shared/operations.js.map +1 -0
- package/out/breakpoint/shared/socket.d.ts +47 -0
- package/out/breakpoint/shared/socket.js +210 -0
- package/out/breakpoint/shared/socket.js.map +1 -0
- package/out/breakpoint/shared/utils.d.ts +23 -0
- package/out/breakpoint/shared/utils.js +165 -0
- package/out/breakpoint/shared/utils.js.map +1 -0
- package/out/breakpoint/store/core.d.ts +32 -0
- package/out/breakpoint/store/core.js +388 -0
- package/out/breakpoint/store/core.js.map +1 -0
- package/out/breakpoint/store/dock.d.ts +1 -0
- package/out/breakpoint/store/dock.js +127 -0
- package/out/breakpoint/store/dock.js.map +1 -0
- package/out/breakpoint/store/index.d.ts +2 -0
- package/out/breakpoint/store/index.js +19 -0
- package/out/breakpoint/store/index.js.map +1 -0
- package/out/common/Command.js +1 -1
- package/out/common/Command.js.map +1 -1
- package/out/common/asyncFuncMap.d.ts +2 -0
- package/out/common/asyncFuncMap.js +16 -0
- package/out/common/asyncFuncMap.js.map +1 -0
- package/out/concepts/AnonymousFunction__.js +11 -9
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/AuthInterface__.d.ts +37 -0
- package/out/concepts/AuthInterface__.js +141 -0
- package/out/concepts/AuthInterface__.js.map +1 -0
- package/out/concepts/AuthLogicForCallInterface__.d.ts +138 -0
- package/out/concepts/AuthLogicForCallInterface__.js +493 -0
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -0
- package/out/concepts/AuthLogic__.d.ts +66 -0
- package/out/concepts/AuthLogic__.js +206 -0
- package/out/concepts/AuthLogic__.js.map +1 -0
- package/out/concepts/BackendVariable__.d.ts +137 -0
- package/out/concepts/BackendVariable__.js +422 -0
- package/out/concepts/BackendVariable__.js.map +1 -0
- package/out/concepts/Backend__.d.ts +134 -0
- package/out/concepts/Backend__.js +274 -0
- package/out/concepts/Backend__.js.map +1 -0
- package/out/concepts/CallAuthInterface__.d.ts +126 -0
- package/out/concepts/CallAuthInterface__.js +408 -0
- package/out/concepts/CallAuthInterface__.js.map +1 -0
- package/out/concepts/CallConnector__.d.ts +42 -0
- package/out/concepts/CallConnector__.js +198 -0
- package/out/concepts/CallConnector__.js.map +1 -0
- package/out/concepts/ConnectorTrigger__.d.ts +78 -0
- package/out/concepts/ConnectorTrigger__.js +155 -0
- package/out/concepts/ConnectorTrigger__.js.map +1 -0
- package/out/concepts/Connector__.d.ts +464 -0
- package/out/concepts/Connector__.js +698 -0
- package/out/concepts/Connector__.js.map +1 -0
- package/out/concepts/Destination__.js +6 -4
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/FrontendVariable__.d.ts +21 -0
- package/out/concepts/FrontendVariable__.js +64 -0
- package/out/concepts/FrontendVariable__.js.map +1 -0
- package/out/concepts/Match__.js +25 -6
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MsgTriggerEvent__.d.ts +137 -0
- package/out/concepts/MsgTriggerEvent__.js +228 -0
- package/out/concepts/MsgTriggerEvent__.js.map +1 -0
- package/out/concepts/MsgTriggerLauncher__.d.ts +118 -0
- package/out/concepts/MsgTriggerLauncher__.js +204 -0
- package/out/concepts/MsgTriggerLauncher__.js.map +1 -0
- package/out/concepts/OverriddenLogic__.d.ts +643 -0
- package/out/concepts/OverriddenLogic__.js +1602 -0
- package/out/concepts/OverriddenLogic__.js.map +1 -0
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +5 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/TriggerEvent__.d.ts +120 -0
- package/out/concepts/TriggerEvent__.js +222 -0
- package/out/concepts/TriggerEvent__.js.map +1 -0
- package/out/concepts/TriggerLauncher__.d.ts +88 -0
- package/out/concepts/TriggerLauncher__.js +235 -0
- package/out/concepts/TriggerLauncher__.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.http.d.ts +7 -0
- package/out/concepts/basics/stdlib/nasl.http.js +167 -0
- package/out/concepts/basics/stdlib/nasl.http.js.map +1 -0
- package/out/concepts/types__.d.ts +124 -0
- package/out/concepts/types__.js +3 -0
- package/out/concepts/types__.js.map +1 -0
- package/out/server/getConnector.d.ts +11 -0
- package/out/server/getConnector.js +42 -0
- package/out/server/getConnector.js.map +1 -0
- package/out/server/naslServer.js +55 -0
- package/out/server/naslServer.js.map +1 -1
- package/out/service/creator/errHandles.js +5 -0
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/templator/genCreateBlock.js +2 -1
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +6 -3
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +4 -2
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +2 -1
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -1
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/package.json +2 -2
- package/src/common/Command.ts +1 -1
- package/src/common/dist/Command.js +39 -0
- package/src/concepts/AnonymousFunction__.ts +13 -11
- package/src/concepts/Destination__.ts +7 -5
- package/src/concepts/Match__.ts +24 -6
- package/src/concepts/Param__.ts +1 -1
- package/src/concepts/StringLiteral__.ts +5 -1
- package/src/concepts/dist/App__.js +2204 -0
- package/src/concepts/dist/CallLogic__.js +1149 -0
- package/src/concepts/dist/Destination__.js +756 -0
- package/src/concepts/dist/Entity__.js +729 -0
- package/src/concepts/dist/Logic__.js +1612 -0
- package/src/concepts/dist/Match__.js +768 -0
- package/src/concepts/dist/MsgTriggerEvent__.js +245 -0
- package/src/concepts/dist/OqlQueryComponent__.js +377 -0
- package/src/concepts/dist/Param__.js +1 -1
- package/src/concepts/dist/StringLiteral__.js +158 -0
- package/src/generator/dist/genBundleFiles.js +15 -4
- package/src/generator/dist/genReleaseBody.js +501 -0
- package/src/server/dist/naslServer.js +76 -6
- package/src/server/naslServer.ts +54 -0
- package/src/service/creator/errHandles.js +8 -3
- package/src/service/storage/dist/init.js +34 -32
- package/src/templator/genCreateBlock.ts +2 -1
- package/src/templator/genCurdEditMultipleKeyBlock.ts +6 -3
- package/src/templator/genCurdMultipleKeyBlock.ts +4 -2
- package/src/templator/genEditTableBlock.ts +2 -1
- package/src/templator/genUpdateBlock.ts +2 -1
- package/test/examples/qzbusiness.json +1 -98265
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
50
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
51
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
52
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
53
|
+
r[k] = a[j];
|
|
54
|
+
return r;
|
|
55
|
+
};
|
|
56
|
+
exports.__esModule = true;
|
|
57
|
+
exports.genReleaseBody = void 0;
|
|
58
|
+
var concepts_1 = require("../concepts");
|
|
59
|
+
var genBundleFiles_1 = require("./genBundleFiles");
|
|
60
|
+
var permission_1 = require("./permission");
|
|
61
|
+
var utils = require("../utils");
|
|
62
|
+
function genReleaseBody(app, _a) {
|
|
63
|
+
var env = _a.env, replicas = _a.replicas, realRelease = _a.realRelease, appInfo = _a.appInfo, staticUrl = _a.staticUrl, _b = _a.frontends, frontends = _b === void 0 ? [] : _b, _c = _a.logPublishFunc, logPublishFunc = _c === void 0 ? function () { } : _c;
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var authReport, logicPageResourceDtoList, releaseFrontends, body, NaslAnnotatedJSON, err_1, files, jsonString;
|
|
66
|
+
return __generator(this, function (_d) {
|
|
67
|
+
switch (_d.label) {
|
|
68
|
+
case 0:
|
|
69
|
+
if (!realRelease) return [3 /*break*/, 2];
|
|
70
|
+
authReport = getAuthReport(app, frontends);
|
|
71
|
+
return [4 /*yield*/, permission_1.genPermissionData(app)];
|
|
72
|
+
case 1:
|
|
73
|
+
logicPageResourceDtoList = _d.sent();
|
|
74
|
+
logPublishFunc("[\u6743\u9650] \"[" + app.title + "]\" \u5206\u6790\u6743\u9650\u6570\u636E\u6210\u529F\uFF01");
|
|
75
|
+
_d.label = 2;
|
|
76
|
+
case 2:
|
|
77
|
+
releaseFrontends = app.frontends.map(function (frontend) { return ({
|
|
78
|
+
name: frontend.name,
|
|
79
|
+
type: frontend.type,
|
|
80
|
+
path: frontend.path,
|
|
81
|
+
selected: frontends.includes(frontend),
|
|
82
|
+
title: frontend.title
|
|
83
|
+
}); });
|
|
84
|
+
body = __assign(__assign({}, authReport), { // 如果发布需要上报权限,导出源码不需要
|
|
85
|
+
logicPageResourceDtoList: logicPageResourceDtoList, logicAuthFlag: permission_1.genLogicAuthFlag(app), noAuthApiPathList: getAuthApiPathList(app, frontends), reportIdList: findAllReportIdList(app, frontends), appId: app.id, env: env,
|
|
86
|
+
replicas: replicas, callbackLogicsName: app.getExtensionsCallbackLogics(), frontends: releaseFrontends, files: [] });
|
|
87
|
+
if (logicPageResourceDtoList)
|
|
88
|
+
Object.assign(body, { logicPageResourceDtoList: logicPageResourceDtoList });
|
|
89
|
+
_d.label = 3;
|
|
90
|
+
case 3:
|
|
91
|
+
_d.trys.push([3, 5, , 6]);
|
|
92
|
+
return [4 /*yield*/, app.naslServer.getNaslAnnotatedJSON(app, true)];
|
|
93
|
+
case 4:
|
|
94
|
+
NaslAnnotatedJSON = _d.sent();
|
|
95
|
+
logPublishFunc("[\u8BED\u8A00] \"[" + app.title + "]\" \u83B7\u53D6\u7C7B\u578B\u6807\u6CE8\u6210\u529F\uFF01");
|
|
96
|
+
return [3 /*break*/, 6];
|
|
97
|
+
case 5:
|
|
98
|
+
err_1 = _d.sent();
|
|
99
|
+
console.error(err_1);
|
|
100
|
+
throw new Error('代码标注失败,请稍后重试!或刷新后重试!');
|
|
101
|
+
case 6:
|
|
102
|
+
files = [];
|
|
103
|
+
if (frontends && frontends.length) {
|
|
104
|
+
logPublishFunc("[\u4EE3\u7801] \"[" + app.title + "]\" \u751F\u6210\u9875\u9762\u4EE3\u7801\uFF1A\u5F00\u59CB");
|
|
105
|
+
files = genBundleFiles_1.genFrontendBundleFiles(app, frontends, Object.assign({}, appInfo, {
|
|
106
|
+
env: env,
|
|
107
|
+
appid: app.id,
|
|
108
|
+
devDnsAddr: app.devDnsAddr,
|
|
109
|
+
miniEnable: app.miniEnable
|
|
110
|
+
}));
|
|
111
|
+
if (files && files.length === 0) {
|
|
112
|
+
throw new Error('前端代码生成失败');
|
|
113
|
+
}
|
|
114
|
+
if (staticUrl)
|
|
115
|
+
files = replaceAssetUrl(files, appInfo.USER_STATIC_URL, staticUrl);
|
|
116
|
+
console.log(Date.now());
|
|
117
|
+
console.time('onGetDeploymentStatus');
|
|
118
|
+
logPublishFunc("[\u4EE3\u7801] \"[" + app.title + "]\" \u751F\u6210\u9875\u9762\u4EE3\u7801\uFF1A\u5B8C\u6210\uFF01");
|
|
119
|
+
}
|
|
120
|
+
// 如果是发布,就排除views,导出源码就不排除
|
|
121
|
+
if (realRelease) {
|
|
122
|
+
NaslAnnotatedJSON.frontends.forEach(function (frontend) {
|
|
123
|
+
delete frontend.views;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
jsonString = JSON.stringify(NaslAnnotatedJSON);
|
|
127
|
+
// 打印传给服务端的nasl,为了服务端排查问题方便
|
|
128
|
+
if (globalThis.window) {
|
|
129
|
+
console.info(NaslAnnotatedJSON, '标注后的nasl');
|
|
130
|
+
}
|
|
131
|
+
files.push({ name: 'nasl-annotated.json', content: jsonString });
|
|
132
|
+
body.files = files;
|
|
133
|
+
return [2 /*return*/, body];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
exports.genReleaseBody = genReleaseBody;
|
|
139
|
+
/**
|
|
140
|
+
* 权限上报数据
|
|
141
|
+
*/
|
|
142
|
+
function getAuthReport(app, frontends) {
|
|
143
|
+
var result = {
|
|
144
|
+
roleList: [],
|
|
145
|
+
resourceList: [],
|
|
146
|
+
resourceDataList: [],
|
|
147
|
+
roleResourceMappingList: []
|
|
148
|
+
};
|
|
149
|
+
result.roleList = app.roles;
|
|
150
|
+
var getAuth = function (target) {
|
|
151
|
+
var authDirective = target.bindDirectives.find(function (item) { return item.name === 'auth'; });
|
|
152
|
+
return authDirective === null || authDirective === void 0 ? void 0 : authDirective.value;
|
|
153
|
+
};
|
|
154
|
+
var loopViews = function (view, isMain, frontend) {
|
|
155
|
+
var _a;
|
|
156
|
+
if (view.children) {
|
|
157
|
+
view.children.forEach(function (item) { return loopViews(item, false, frontend); });
|
|
158
|
+
}
|
|
159
|
+
if (view.concept === 'View' && view.elements) {
|
|
160
|
+
view.elements.forEach(function (item) { return loopViews(item, false, frontend); });
|
|
161
|
+
}
|
|
162
|
+
if ((view.concept === 'View' && view.auth)
|
|
163
|
+
|| (view.concept === 'View' && !isMain && view.parentAuth)
|
|
164
|
+
|| (view.concept === 'ViewElement' && getAuth(view))) {
|
|
165
|
+
result.resourceList.push(view.authPath);
|
|
166
|
+
result.resourceDataList.push({
|
|
167
|
+
value: view.authPath,
|
|
168
|
+
description: view.authDescription,
|
|
169
|
+
type: view.concept === 'View' ? 'page' : 'component',
|
|
170
|
+
clientType: frontend.name
|
|
171
|
+
});
|
|
172
|
+
if (view.bindRoles) {
|
|
173
|
+
var _arr = view.bindRoles.map(function (it) { return ({
|
|
174
|
+
roleName: it,
|
|
175
|
+
resourcePath: view.authPath
|
|
176
|
+
}); });
|
|
177
|
+
(_a = result.roleResourceMappingList).push.apply(_a, _arr);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
frontends.forEach(function (frontend) {
|
|
182
|
+
frontend.views.forEach(function (view) { return loopViews(view, true, frontend); });
|
|
183
|
+
});
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
// 以下四个函数 导出源码也有引用 需同步改动
|
|
187
|
+
/**
|
|
188
|
+
* 上报白名单
|
|
189
|
+
*/
|
|
190
|
+
function getAuthApiPathList(app, frontends) {
|
|
191
|
+
var thisDiffLogicList = [];
|
|
192
|
+
/* 转换Path */
|
|
193
|
+
function getPathMethods(logicNameSpace) {
|
|
194
|
+
var logic = app.findNodeByCompleteName(logicNameSpace);
|
|
195
|
+
if (!logic) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
var logicName = logic === null || logic === void 0 ? void 0 : logic.name;
|
|
199
|
+
var _pathArr = logicNameSpace.split('.');
|
|
200
|
+
var isProcess = _pathArr[1] === 'processes';
|
|
201
|
+
var moduleNode = logic.getAncestor('Module');
|
|
202
|
+
var isEntity = false;
|
|
203
|
+
var namespaceLinkedNode = null;
|
|
204
|
+
var namespaceNode = logic.getAncestor('Namespace');
|
|
205
|
+
if (namespaceNode) {
|
|
206
|
+
namespaceLinkedNode = app.findNodeByCompleteName([namespaceNode.getNamespace(), namespaceNode.name].join('.'));
|
|
207
|
+
isEntity = namespaceNode && (namespaceLinkedNode === null || namespaceLinkedNode === void 0 ? void 0 : namespaceLinkedNode.concept) === 'Entity';
|
|
208
|
+
}
|
|
209
|
+
// 实体
|
|
210
|
+
if (isEntity) {
|
|
211
|
+
var dataSource = namespaceLinkedNode.parentNode;
|
|
212
|
+
if (dataSource.name !== 'defaultDS') {
|
|
213
|
+
return "/api/" + dataSource.name + "/" + getName(namespaceLinkedNode.name) + getEntityMethods(logic.name);
|
|
214
|
+
}
|
|
215
|
+
return "/api/" + getName(namespaceLinkedNode.name) + getEntityMethods(logic.name);
|
|
216
|
+
}
|
|
217
|
+
else if (moduleNode) {
|
|
218
|
+
// 外部模块引入的逻辑
|
|
219
|
+
return "/api/" + getModuleName(moduleNode.name) + "/" + logicName + ":POST";
|
|
220
|
+
}
|
|
221
|
+
else if (isProcess) {
|
|
222
|
+
if (_pathArr.length === 7) {
|
|
223
|
+
var _name = _pathArr[2];
|
|
224
|
+
var _path = _pathArr[4];
|
|
225
|
+
var _logic = _pathArr[6];
|
|
226
|
+
return "/api/" + _name + "/" + _path + "/" + _logic + ":POST";
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
var _name = _pathArr[2];
|
|
230
|
+
var _path = _pathArr[4];
|
|
231
|
+
return "/api/" + _name + "/" + _path + ":POST";
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
return "/api/lcplogics/" + logicName + ":POST";
|
|
236
|
+
}
|
|
237
|
+
function getName(name) {
|
|
238
|
+
var _name = name.replace(/[A-Z]/g, function (item) { return '-' + item.toLowerCase(); });
|
|
239
|
+
return _name[0] === '-' ? _name.slice(1) : _name;
|
|
240
|
+
}
|
|
241
|
+
function getModuleName(name) {
|
|
242
|
+
return name.replace(/-/g, '_');
|
|
243
|
+
}
|
|
244
|
+
function getEntityMethods(path) {
|
|
245
|
+
var name = '';
|
|
246
|
+
switch (path) {
|
|
247
|
+
case 'get':
|
|
248
|
+
name = ":GET";
|
|
249
|
+
break;
|
|
250
|
+
case 'import':
|
|
251
|
+
name = '/import:POST';
|
|
252
|
+
break;
|
|
253
|
+
case 'create':
|
|
254
|
+
name = ':POST';
|
|
255
|
+
break;
|
|
256
|
+
case 'update':
|
|
257
|
+
name = ':PUT';
|
|
258
|
+
break;
|
|
259
|
+
case 'delete':
|
|
260
|
+
name = ":DELETE";
|
|
261
|
+
break;
|
|
262
|
+
case 'createOrUpdate':
|
|
263
|
+
name = '/createOrUpdate:POST';
|
|
264
|
+
break;
|
|
265
|
+
case 'updateBy':
|
|
266
|
+
name = '/by:PUT';
|
|
267
|
+
break;
|
|
268
|
+
case 'deleteBy':
|
|
269
|
+
name = '/by:DELETE';
|
|
270
|
+
break;
|
|
271
|
+
case 'batchUpdate':
|
|
272
|
+
name = "/batch:PUT";
|
|
273
|
+
break;
|
|
274
|
+
case 'batchDelete':
|
|
275
|
+
name = "/batch:DELETE";
|
|
276
|
+
break;
|
|
277
|
+
case 'batchCreate':
|
|
278
|
+
name = "/batch:POST";
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
return name;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/* 获取LogicITEM */
|
|
285
|
+
function getStatement(state, frontend) {
|
|
286
|
+
var _a, _b, _c, _d, _e;
|
|
287
|
+
var logicItems = [];
|
|
288
|
+
if (state instanceof concepts_1.Assignment) {
|
|
289
|
+
logicItems = [state.left, state.right];
|
|
290
|
+
}
|
|
291
|
+
else if (state instanceof concepts_1.BatchAssignment) {
|
|
292
|
+
logicItems = __spreadArrays([(_a = state.left) === null || _a === void 0 ? void 0 : _a.expression], (_b = state.left) === null || _b === void 0 ? void 0 : _b.members, state.rights.map(function (item) { return __spreadArrays([item === null || item === void 0 ? void 0 : item.expression], item === null || item === void 0 ? void 0 : item.members); }).flat(1));
|
|
293
|
+
}
|
|
294
|
+
else if (state instanceof concepts_1.IfStatement) {
|
|
295
|
+
logicItems = __spreadArrays(state.consequent, state.alternate);
|
|
296
|
+
}
|
|
297
|
+
else if (state instanceof concepts_1.ForEachStatement) {
|
|
298
|
+
logicItems = __spreadArrays(state.body, [state.each, state.start, state.end]);
|
|
299
|
+
}
|
|
300
|
+
else if (state instanceof concepts_1.Match) {
|
|
301
|
+
logicItems = __spreadArrays([state.expression], state.cases.map(function (case1) { return getStatement(case1, frontend); }).flat(1));
|
|
302
|
+
}
|
|
303
|
+
else if (state instanceof concepts_1.MatchCase) {
|
|
304
|
+
logicItems = __spreadArrays(state.patterns, state.body);
|
|
305
|
+
}
|
|
306
|
+
else if (state instanceof concepts_1.SwitchStatement) {
|
|
307
|
+
logicItems = state.cases.map(function (case1) { return getStatement(case1, frontend); }).flat(1);
|
|
308
|
+
}
|
|
309
|
+
else if (state instanceof concepts_1.SwitchCase) {
|
|
310
|
+
logicItems = __spreadArrays([state.test], state.consequent);
|
|
311
|
+
}
|
|
312
|
+
else if (state instanceof concepts_1.WhileStatement) {
|
|
313
|
+
logicItems = __spreadArrays([state.test], state.body);
|
|
314
|
+
}
|
|
315
|
+
else if (state instanceof concepts_1.CallLogic) {
|
|
316
|
+
logicItems = (_c = state.arguments) === null || _c === void 0 ? void 0 : _c.map(function (item) { return item.expression; });
|
|
317
|
+
getLogic(state.calleewholeKey, frontend);
|
|
318
|
+
}
|
|
319
|
+
else if (state instanceof concepts_1.CallFunction) {
|
|
320
|
+
logicItems = (_d = state.arguments) === null || _d === void 0 ? void 0 : _d.map(function (item) { return item.expression; });
|
|
321
|
+
}
|
|
322
|
+
else if (state instanceof concepts_1.CallInterface) {
|
|
323
|
+
logicItems = (_e = state.arguments) === null || _e === void 0 ? void 0 : _e.map(function (item) { return item.expression; });
|
|
324
|
+
}
|
|
325
|
+
else if (state instanceof concepts_1.MemberExpression) {
|
|
326
|
+
logicItems = [state.object, state.property];
|
|
327
|
+
}
|
|
328
|
+
else if (state instanceof concepts_1.StringInterpolation) {
|
|
329
|
+
logicItems = __spreadArrays(state.expressions);
|
|
330
|
+
}
|
|
331
|
+
else if (state instanceof concepts_1.ExternalDestination) {
|
|
332
|
+
logicItems = [state.anchor, state.link];
|
|
333
|
+
}
|
|
334
|
+
else if (state instanceof concepts_1.NewComposite) {
|
|
335
|
+
logicItems = __spreadArrays((state.rights || []).map(function (item) { return item.expression; }));
|
|
336
|
+
}
|
|
337
|
+
else if (state instanceof concepts_1.NewList) {
|
|
338
|
+
logicItems = __spreadArrays(state.items);
|
|
339
|
+
}
|
|
340
|
+
return logicItems.filter(function (item) { return !!item; });
|
|
341
|
+
}
|
|
342
|
+
/* 获取非鉴权全局逻辑 */
|
|
343
|
+
function getLogic(key, frontend) {
|
|
344
|
+
if (!thisDiffLogicList.find(function (diffLogic) { return diffLogic.logicName === key && diffLogic.frontendName === frontend.name; })) {
|
|
345
|
+
thisDiffLogicList.push({ logicName: key, frontendName: frontend.name });
|
|
346
|
+
var logic = app.findNodeByCompleteName(key);
|
|
347
|
+
if (logic && logic.body && logic.body.length > 2) {
|
|
348
|
+
logic.body.map(function (item) { return getStatement(item, frontend); });
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
var importList = [];
|
|
353
|
+
var itemloop = function (state, view, frontend) {
|
|
354
|
+
var logicItems = getStatement(state, frontend);
|
|
355
|
+
if (logicItems.length) {
|
|
356
|
+
logicItems.map(function (item) { return itemloop(item, view, frontend); });
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
var loopEle = function (view, frontend) {
|
|
360
|
+
var _a, _b;
|
|
361
|
+
(_a = view === null || view === void 0 ? void 0 : view.children) === null || _a === void 0 ? void 0 : _a.forEach(function (vitem) { return loopEle(vitem, frontend); });
|
|
362
|
+
view.concept === 'View' && ((_b = view === null || view === void 0 ? void 0 : view.elements) === null || _b === void 0 ? void 0 : _b.forEach(function (ele) { return loopEle(ele, frontend); }));
|
|
363
|
+
if (!view.parentAuth) {
|
|
364
|
+
if (view.bindEvents) {
|
|
365
|
+
view.bindEvents.forEach(function (item) {
|
|
366
|
+
if (item.logics) {
|
|
367
|
+
item.logics.forEach(function (logic) {
|
|
368
|
+
if (logic.body.length > 2) {
|
|
369
|
+
logic.body.forEach(function (it) {
|
|
370
|
+
itemloop(it, view, frontend);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
var bindExpressions = [];
|
|
378
|
+
var bindAttrs = view.bindAttrs || [];
|
|
379
|
+
var bindDirectives = view.bindDirectives || [];
|
|
380
|
+
var bindStyles = view.bindStyles || [];
|
|
381
|
+
bindExpressions.push.apply(bindExpressions, __spreadArrays(bindAttrs, bindDirectives, bindStyles));
|
|
382
|
+
if (Array.isArray(bindExpressions) && bindExpressions.length) {
|
|
383
|
+
bindExpressions.forEach(function (bindExpression) { return utils.traverse(function (current) {
|
|
384
|
+
if (current.node instanceof concepts_1.CallLogic) {
|
|
385
|
+
getLogic(current.node.calleewholeKey, frontend);
|
|
386
|
+
}
|
|
387
|
+
}, { node: bindExpression }, {
|
|
388
|
+
mode: 'anyObject',
|
|
389
|
+
excludedKeySet: new Set([
|
|
390
|
+
// 排除playground里的表达式
|
|
391
|
+
'playground',
|
|
392
|
+
'parentNode',
|
|
393
|
+
'sourceMap',
|
|
394
|
+
'storageJSON',
|
|
395
|
+
'tsErrorDetail',
|
|
396
|
+
'NaslAnnotatedJSON',
|
|
397
|
+
'calledFrom',
|
|
398
|
+
'_events',
|
|
399
|
+
'_collectingList',
|
|
400
|
+
'_historyList',
|
|
401
|
+
])
|
|
402
|
+
}); });
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (view.concept === 'ViewElement' && (view.tag === 'u-uploader' || view.tag === 'van-uploader')) {
|
|
406
|
+
var attr = view === null || view === void 0 ? void 0 : view.bindAttrs.find(function (item) { return item.name === 'url'; });
|
|
407
|
+
if ((attr === null || attr === void 0 ? void 0 : attr.value.endsWith('/import')) && !view.parentAuth) {
|
|
408
|
+
importList.push({ path: attr === null || attr === void 0 ? void 0 : attr.value, frontendName: frontend.name });
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
var loopViews = function (view, isChild, frontend) {
|
|
413
|
+
// 有权限的页面下的逻辑都不需要上报白名单
|
|
414
|
+
if (!view.auth) {
|
|
415
|
+
if (view.logics) {
|
|
416
|
+
view.logics.forEach(function (logic) {
|
|
417
|
+
if (logic.body.length > 2) {
|
|
418
|
+
logic.body.forEach(function (it) {
|
|
419
|
+
itemloop(it, view, frontend);
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
if (view.bindEvents) {
|
|
425
|
+
view.bindEvents.forEach(function (item) {
|
|
426
|
+
if (item.logics) {
|
|
427
|
+
item.logics.forEach(function (logic) {
|
|
428
|
+
if (logic.body.length > 2) {
|
|
429
|
+
logic.body.forEach(function (it) {
|
|
430
|
+
itemloop(it, view, frontend);
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
view.children.forEach(function (item) { return loopViews(item, true, frontend); });
|
|
438
|
+
}
|
|
439
|
+
if (!isChild) {
|
|
440
|
+
view.children.forEach(function (vitem) { return loopEle(vitem, frontend); });
|
|
441
|
+
view.elements.forEach(function (vele) { return loopEle(vele, frontend); });
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
frontends.forEach(function (frontend) {
|
|
445
|
+
frontend.views.forEach(function (view) { return loopViews(view, false, frontend); });
|
|
446
|
+
});
|
|
447
|
+
var diffLogicList = thisDiffLogicList.filter(function (item) { return item.logicName.startsWith('app') || item.logicName.startsWith('extensions'); });
|
|
448
|
+
var authApiList = __spreadArrays(diffLogicList.map(function (diffLogic) {
|
|
449
|
+
var path = getPathMethods(diffLogic.logicName);
|
|
450
|
+
if (path)
|
|
451
|
+
return path + ":" + diffLogic.frontendName;
|
|
452
|
+
return '';
|
|
453
|
+
}).filter(function (path) { return !!path; }), Array.from(new Set(importList.map(function (item) { return item.path + ":POST:" + item.frontendName; })))).filter(function (item) { return !!item; });
|
|
454
|
+
return authApiList;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* 获取页面中所有 分析报告组件 的reportId
|
|
458
|
+
*/
|
|
459
|
+
function findAllReportIdList(app, frontends) {
|
|
460
|
+
var reportIds = [];
|
|
461
|
+
frontends.forEach(function (frontend) {
|
|
462
|
+
frontend.views.forEach(function (view) { return loop(view); });
|
|
463
|
+
});
|
|
464
|
+
function loop(root) {
|
|
465
|
+
if (root.concept === 'ViewElement') {
|
|
466
|
+
root.bindAttrs.forEach(function (attr) {
|
|
467
|
+
if (attr.name === 'reportId') {
|
|
468
|
+
reportIds.push(JSON.parse(attr.value || '{}').id);
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
if (root.children && root.children.length) {
|
|
473
|
+
root.children.forEach(function (item) { return loop(item); });
|
|
474
|
+
}
|
|
475
|
+
if (root.concept === 'View' && root.elements && root.elements.length) {
|
|
476
|
+
root.elements.forEach(function (item) { return loop(item); });
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return __spreadArrays(new Set(reportIds)).filter(Boolean);
|
|
480
|
+
}
|
|
481
|
+
function replaceAssetUrl(files, oldUrlWithoutProtocol, newUrlWithProtocol) {
|
|
482
|
+
var newUrlWithoutProtocol = newUrlWithProtocol.replace(/^https?:/, '');
|
|
483
|
+
if (newUrlWithoutProtocol === oldUrlWithoutProtocol)
|
|
484
|
+
return files;
|
|
485
|
+
var reg = new RegExp(oldUrlWithoutProtocol + "[^?'\"\\s]*\\?[^?'\"\\s]*(?=(\"|'))", 'g');
|
|
486
|
+
var reg2 = new RegExp("(https?:)?" + oldUrlWithoutProtocol, 'g');
|
|
487
|
+
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
488
|
+
var file = files_1[_i];
|
|
489
|
+
// 清除 query 参数
|
|
490
|
+
file.content = file.content.replace(reg, function () {
|
|
491
|
+
var args = [];
|
|
492
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
493
|
+
args[_i] = arguments[_i];
|
|
494
|
+
}
|
|
495
|
+
return args[0].split('?')[0];
|
|
496
|
+
});
|
|
497
|
+
file.content = file.content.replace(reg2, function (whole, protocol) { return (protocol ? newUrlWithProtocol : newUrlWithoutProtocol); });
|
|
498
|
+
file.name = file.name.replace(reg2, function (whole, protocol) { return (protocol ? newUrlWithProtocol : newUrlWithoutProtocol); });
|
|
499
|
+
}
|
|
500
|
+
return files;
|
|
501
|
+
}
|
|
@@ -180,6 +180,8 @@ var NaslServer = /** @class */ (function () {
|
|
|
180
180
|
records = _b.sent();
|
|
181
181
|
this.diagnosticManager.pushAll(records);
|
|
182
182
|
try {
|
|
183
|
+
// 结束诊断和标注
|
|
184
|
+
common_1.invokeCommand('naslServer:endWork');
|
|
183
185
|
common_1.invokeCommand('naslServer:nodeChange');
|
|
184
186
|
}
|
|
185
187
|
catch (e) {
|
|
@@ -981,7 +983,13 @@ var NaslServer = /** @class */ (function () {
|
|
|
981
983
|
var records;
|
|
982
984
|
return __generator(this, function (_a) {
|
|
983
985
|
switch (_a.label) {
|
|
984
|
-
case 0:
|
|
986
|
+
case 0:
|
|
987
|
+
// 开始诊断和标注
|
|
988
|
+
try {
|
|
989
|
+
common_1.invokeCommand('naslServer:startWork');
|
|
990
|
+
}
|
|
991
|
+
catch (err) { }
|
|
992
|
+
return [4 /*yield*/, this.getDiagnosticRecords(fileNames)];
|
|
985
993
|
case 1:
|
|
986
994
|
records = _a.sent();
|
|
987
995
|
return [2 /*return*/];
|
|
@@ -2556,6 +2564,52 @@ var NaslServer = /** @class */ (function () {
|
|
|
2556
2564
|
if (node instanceof concepts_1.Entity) {
|
|
2557
2565
|
// 过滤一把不需要改的信息
|
|
2558
2566
|
refsList = refsList.filter(function (item) { return fileNode.getEmbeddedFilePath() !== item.file || item.isDefinition === true; });
|
|
2567
|
+
// 防止死循环
|
|
2568
|
+
// const forRefsList = [...refsList];
|
|
2569
|
+
// for (let i = 0; i < forRefsList.length; i++) {
|
|
2570
|
+
// const refItem = forRefsList[i];
|
|
2571
|
+
// if (refItem.lineText?.includes('new nasl.langUtil.Collection')) {
|
|
2572
|
+
// try {
|
|
2573
|
+
// const fileNode = this.file2NodeMap.get(refItem.file);
|
|
2574
|
+
// if (!fileNode)
|
|
2575
|
+
// return;
|
|
2576
|
+
// const minRange = this._findMinRange(refItem, fileNode as FileNode);
|
|
2577
|
+
// if (minRange.node && (minRange.node instanceof QueryFromExpression || minRange.node instanceof QueryJoinExpression)) {
|
|
2578
|
+
// const callQueryComponent = minRange.node.getAncestor('CallQueryComponent') as CallQueryComponent;
|
|
2579
|
+
// const callQueryComponentTypeAnnotation = callQueryComponent.typeAnnotation;
|
|
2580
|
+
// const { currentSource: qcTypeAnnotationCurrentSource, fileNode } = callQueryComponentTypeAnnotation.getCurrentSource();
|
|
2581
|
+
// const { currentSource: logicCurrentSource } = fileNode.getCurrentSource();
|
|
2582
|
+
// const aggregateLength = callQueryComponent.select.selectAggregateElements.filter((item: any) => item.aggregateName && item.asName).length;
|
|
2583
|
+
// const groupByLength = callQueryComponent.groupBy.filter((item) => (item.groupElement as QueryFieldExpression)?.propertyName && (item.groupElement as QueryFieldExpression).asName).length;
|
|
2584
|
+
// if (!groupByLength && !aggregateLength && callQueryComponentTypeAnnotation.typeKind === 'anonymousStructure') {
|
|
2585
|
+
// // 拿到 List 的泛型(匿名数据结构)的所有属性
|
|
2586
|
+
// const properties = callQueryComponentTypeAnnotation.properties[0].typeAnnotation.typeArguments[0].properties;
|
|
2587
|
+
// const targetProperty = properties.find((p) => p.name === utils.firstLowerCase(node.name));
|
|
2588
|
+
// if (!targetProperty) {
|
|
2589
|
+
// continue;
|
|
2590
|
+
// }
|
|
2591
|
+
// const { currentSource: propertyTypeCurrentSource } = targetProperty.typeAnnotation.getCurrentSource();
|
|
2592
|
+
// // 减去 ": " 2个字符、减去属性名长度
|
|
2593
|
+
// const propertyCharacter = propertyTypeCurrentSource.range.start.character - 2 - targetProperty.name.length;
|
|
2594
|
+
// const propertyOffset = propertyCharacter - qcTypeAnnotationCurrentSource.range.start.character;
|
|
2595
|
+
// const qcTypeAnnotationOffset = logicCurrentSource.code.indexOf(qcTypeAnnotationCurrentSource.code);
|
|
2596
|
+
// const declarationCodeArr = logicCurrentSource.code.slice(0, qcTypeAnnotationOffset).split('\n');
|
|
2597
|
+
// const line = declarationCodeArr.length - 1;
|
|
2598
|
+
// const character = declarationCodeArr[declarationCodeArr.length - 1].length;
|
|
2599
|
+
// // eslint-disable-next-line no-await-in-loop
|
|
2600
|
+
// const newRefs = await this.references({
|
|
2601
|
+
// file: (fileNode as any).getEmbeddedFilePath(),
|
|
2602
|
+
// line: line + 2,
|
|
2603
|
+
// offset: character + 1 + propertyOffset,
|
|
2604
|
+
// });
|
|
2605
|
+
// refsList.push(...newRefs.refs);
|
|
2606
|
+
// }
|
|
2607
|
+
// }
|
|
2608
|
+
// } catch (e) {
|
|
2609
|
+
// console.error('naslServer实体引用', e);
|
|
2610
|
+
// }
|
|
2611
|
+
// }
|
|
2612
|
+
// }
|
|
2559
2613
|
// 不再当前文件里
|
|
2560
2614
|
// 或者在当前列表但是位置小于entity的结束位置
|
|
2561
2615
|
}
|
|
@@ -2899,7 +2953,10 @@ var NaslServer = /** @class */ (function () {
|
|
|
2899
2953
|
if (minRange.node instanceof concepts_1.EntityProperty) {
|
|
2900
2954
|
minRange.setTypeMethods = 'setRelationEntity';
|
|
2901
2955
|
}
|
|
2902
|
-
else if (minRange.node instanceof concepts_1.QueryFieldExpression
|
|
2956
|
+
else if (minRange.node instanceof concepts_1.QueryFieldExpression) {
|
|
2957
|
+
minRange.setTypeMethods = 'setEntityAsNameAndEffect';
|
|
2958
|
+
}
|
|
2959
|
+
else if (minRange.node instanceof concepts_1.QueryGroupByExpression) {
|
|
2903
2960
|
minRange.setTypeMethods = 'setEntityAsName';
|
|
2904
2961
|
}
|
|
2905
2962
|
else if (minRange.node instanceof concepts_1.QueryFromExpression || minRange.node instanceof concepts_1.QueryJoinExpression) {
|
|
@@ -2912,6 +2969,8 @@ var NaslServer = /** @class */ (function () {
|
|
|
2912
2969
|
var newTextValue = node.parentNode.name === 'defaultDS' ? "/api/" + newName + "/import" : "/api/" + node.parentNode.name + "/" + newName + "/import";
|
|
2913
2970
|
minRange.setTypeMethods = 'setUrlValue';
|
|
2914
2971
|
minRange.newValue = newTextValue;
|
|
2972
|
+
// } else if (minRange.node instanceof Identifier) {
|
|
2973
|
+
// minRange.newValue = utils.firstLowerCase(newValue);
|
|
2915
2974
|
}
|
|
2916
2975
|
}
|
|
2917
2976
|
// 如果是修改实体属性,要同步实体属性
|
|
@@ -3182,7 +3241,18 @@ var NaslServer = /** @class */ (function () {
|
|
|
3182
3241
|
return minRange;
|
|
3183
3242
|
})
|
|
3184
3243
|
// 过滤掉不需要操作的
|
|
3185
|
-
.filter(function (item) { return !!item; })
|
|
3244
|
+
.filter(function (item) { return !!item; })
|
|
3245
|
+
// 排序:
|
|
3246
|
+
// QueryFieldExpression依赖Entity,把Entity放在QueryFieldExpression前,
|
|
3247
|
+
.sort(function (a, b) {
|
|
3248
|
+
if (a.node.concept === 'QueryFieldExpression') {
|
|
3249
|
+
return 1;
|
|
3250
|
+
}
|
|
3251
|
+
else if (b.node.concept === 'QueryFieldExpression') {
|
|
3252
|
+
return -1;
|
|
3253
|
+
}
|
|
3254
|
+
return 0;
|
|
3255
|
+
});
|
|
3186
3256
|
return result;
|
|
3187
3257
|
};
|
|
3188
3258
|
// 增加参数的副作用,用于更新logic和view
|
|
@@ -3972,7 +4042,7 @@ var NaslServer = /** @class */ (function () {
|
|
|
3972
4042
|
};
|
|
3973
4043
|
NaslServer.prototype.annotationToJson = function (typesMap, json) {
|
|
3974
4044
|
typesMap.forEach(function (value, node) {
|
|
3975
|
-
var _a, _b, _c, _d, _e;
|
|
4045
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3976
4046
|
// 如果节点本身有类型就不去在塞一遍了
|
|
3977
4047
|
// 有值而且没有类型再去设置
|
|
3978
4048
|
// 但是Identifier 和 MemberExpression 都用标注出来的因为本身是变量,有类型也需要覆盖一下
|
|
@@ -4043,7 +4113,7 @@ var NaslServer = /** @class */ (function () {
|
|
|
4043
4113
|
if (node instanceof concepts_1.Match) {
|
|
4044
4114
|
var matchExpression_1 = node.expression;
|
|
4045
4115
|
if (((_d = matchExpression_1 === null || matchExpression_1 === void 0 ? void 0 : matchExpression_1.__TypeAnnotation) === null || _d === void 0 ? void 0 : _d.typeKind) === 'union' && (matchExpression_1 instanceof concepts_1.Identifier || matchExpression_1 instanceof concepts_1.MemberExpression)) {
|
|
4046
|
-
var
|
|
4116
|
+
var _g = matchExpression_1 === null || matchExpression_1 === void 0 ? void 0 : matchExpression_1.getCurrentSource(), currentSource_6 = _g.currentSource, fileNode = _g.fileNode;
|
|
4047
4117
|
fileNode.sourceMap.forEach(function (item, itemNode) {
|
|
4048
4118
|
if (itemNode.concept === matchExpression_1.concept && item.code === currentSource_6.code) {
|
|
4049
4119
|
var jsonNode = jsoner.queryNodeByPath(json, itemNode.getNodePath(false));
|
|
@@ -4060,7 +4130,7 @@ var NaslServer = /** @class */ (function () {
|
|
|
4060
4130
|
jsonNode.typeAnnotation = value.toJSON();
|
|
4061
4131
|
}
|
|
4062
4132
|
}
|
|
4063
|
-
if (node instanceof concepts_1.NewComposite && ((_e = node.typeAnnotation) === null || _e === void 0 ? void 0 : _e.typeKind) === 'anonymousStructure') {
|
|
4133
|
+
if (node instanceof concepts_1.NewComposite && (((_e = node.typeAnnotation) === null || _e === void 0 ? void 0 : _e.typeKind) === 'anonymousStructure' || ((_f = node.typeAnnotation) === null || _f === void 0 ? void 0 : _f.typeKind) === 'generic')) {
|
|
4064
4134
|
var jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
|
|
4065
4135
|
jsonNode.typeAnnotation = value.toJSON();
|
|
4066
4136
|
}
|