@lcap/nasl 3.3.2-beta.1 → 3.3.2-beta.3
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/.nyc_output/{ce2372a3-88ed-485c-a936-9b880eb0f082.json → d58d92d8-c0d6-479b-9f82-1f4da8e73ff3.json} +1 -1
- package/.nyc_output/processinfo/{ce2372a3-88ed-485c-a936-9b880eb0f082.json → d58d92d8-c0d6-479b-9f82-1f4da8e73ff3.json} +1 -1
- package/.nyc_output/processinfo/index.json +1 -1
- package/coverage/index.html +73 -73
- package/coverage/src/automate/engine/index.html +1 -1
- package/coverage/src/automate/engine/utils.js.html +11 -11
- package/coverage/src/bak/index.html +1 -1
- package/coverage/src/bak/translator.js.html +1 -1
- package/coverage/src/breakpoint/generator/AfterStartNode.ts.html +1 -1
- package/coverage/src/breakpoint/generator/BeforeEndNode.ts.html +1 -1
- package/coverage/src/breakpoint/generator/BreakpointNode.ts.html +181 -181
- package/coverage/src/breakpoint/generator/CallbackNode.ts.html +1 -1
- package/coverage/src/breakpoint/generator/index.html +1 -1
- package/coverage/src/breakpoint/generator/index.ts.html +1 -1
- package/coverage/src/breakpoint/index.html +1 -1
- package/coverage/src/breakpoint/index.ts.html +1 -1
- package/coverage/src/breakpoint/shared/constants.ts.html +5 -5
- package/coverage/src/breakpoint/shared/index.html +26 -26
- package/coverage/src/breakpoint/shared/index.ts.html +1 -1
- package/coverage/src/breakpoint/shared/operations.ts.html +2 -2
- package/coverage/src/breakpoint/shared/socket.ts.html +278 -278
- package/coverage/src/breakpoint/shared/utils.ts.html +200 -200
- package/coverage/src/breakpoint/store/core.ts.html +7 -7
- package/coverage/src/breakpoint/store/dock.ts.html +147 -147
- package/coverage/src/breakpoint/store/index.html +21 -21
- package/coverage/src/breakpoint/store/index.ts.html +1 -1
- package/coverage/src/common/BaseNode.ts.html +83 -83
- package/coverage/src/common/Command.ts.html +1 -1
- package/coverage/src/common/EventEmitter.ts.html +6 -6
- package/coverage/src/common/Messager.ts.html +1 -1
- package/coverage/src/common/asyncFuncMap.ts.html +1 -1
- package/coverage/src/common/index.html +1 -1
- package/coverage/src/common/index.ts.html +1 -1
- package/coverage/src/concepts/Abort__.ts.html +1 -1
- package/coverage/src/concepts/Anchor__.ts.html +1 -1
- package/coverage/src/concepts/AnonymousFunction__.ts.html +1 -1
- package/coverage/src/concepts/App__.ts.html +1 -1
- package/coverage/src/concepts/Argument__.ts.html +5 -5
- package/coverage/src/concepts/Assignee__.ts.html +1 -1
- package/coverage/src/concepts/AssignmentLine__.ts.html +1 -1
- package/coverage/src/concepts/Assignment__.ts.html +1 -1
- package/coverage/src/concepts/Attribute__.ts.html +1 -1
- package/coverage/src/concepts/AuthInterface__.ts.html +1 -1
- package/coverage/src/concepts/AuthLogicForCallInterface__.ts.html +27 -27
- package/coverage/src/concepts/AuthLogic__.ts.html +1 -1
- package/coverage/src/concepts/BackendVariable__.ts.html +1 -1
- package/coverage/src/concepts/Backend__.ts.html +1 -1
- package/coverage/src/concepts/BatchAssignment__.ts.html +1 -1
- package/coverage/src/concepts/BinaryExpression__.ts.html +7 -7
- package/coverage/src/concepts/BindAttribute__.ts.html +1 -1
- package/coverage/src/concepts/BindDirective__.ts.html +1 -1
- package/coverage/src/concepts/BindEvent__.ts.html +1 -1
- package/coverage/src/concepts/BindStyle__.ts.html +1 -1
- package/coverage/src/concepts/BooleanLiteral__.ts.html +1 -1
- package/coverage/src/concepts/CallAuthInterface__.ts.html +1 -1
- package/coverage/src/concepts/CallConnector__.ts.html +147 -147
- package/coverage/src/concepts/CallFunction__.ts.html +355 -355
- package/coverage/src/concepts/CallInterface__.ts.html +1 -1
- package/coverage/src/concepts/CallLogic__.ts.html +135 -111
- package/coverage/src/concepts/CallQueryComponent__.ts.html +1 -1
- package/coverage/src/concepts/Comment__.ts.html +1 -1
- package/coverage/src/concepts/CompletionProperty__.ts.html +1 -1
- package/coverage/src/concepts/ConfigGroup__.ts.html +1 -1
- package/coverage/src/concepts/ConfigPropertyValue__.ts.html +1 -1
- package/coverage/src/concepts/ConfigProperty__.ts.html +1 -1
- package/coverage/src/concepts/Configuration__.ts.html +1 -1
- package/coverage/src/concepts/Connection__.ts.html +2 -2
- package/coverage/src/concepts/ConnectorTrigger__.ts.html +1 -1
- package/coverage/src/concepts/Connector__.ts.html +1 -1
- package/coverage/src/concepts/Constant__.ts.html +1 -1
- package/coverage/src/concepts/DataSource__.ts.html +1 -1
- package/coverage/src/concepts/DatabaseTypeAnnotation__.ts.html +1 -1
- package/coverage/src/concepts/Destination__.ts.html +1 -1
- package/coverage/src/concepts/End__.ts.html +1 -1
- package/coverage/src/concepts/EntityIndex__.ts.html +1 -1
- package/coverage/src/concepts/EntityProperty__.ts.html +1 -1
- package/coverage/src/concepts/Entity__.ts.html +1 -1
- package/coverage/src/concepts/EnumItem__.ts.html +1 -1
- package/coverage/src/concepts/Enum__.ts.html +1 -1
- package/coverage/src/concepts/Event__.ts.html +1 -1
- package/coverage/src/concepts/ExternalDestination__.ts.html +1 -1
- package/coverage/src/concepts/ForEachStatement__.ts.html +21 -21
- package/coverage/src/concepts/FrontendLibrary__.ts.html +1 -1
- package/coverage/src/concepts/FrontendVariable__.ts.html +1 -1
- package/coverage/src/concepts/Frontend__.ts.html +1 -1
- package/coverage/src/concepts/Function__.ts.html +1 -1
- package/coverage/src/concepts/Identifier__.ts.html +21 -21
- package/coverage/src/concepts/IfStatement__.ts.html +47 -47
- package/coverage/src/concepts/Integration__.ts.html +1 -1
- package/coverage/src/concepts/InterfaceParam__.ts.html +1 -1
- package/coverage/src/concepts/Interface__.ts.html +1 -1
- package/coverage/src/concepts/JSBlock__.ts.html +1 -1
- package/coverage/src/concepts/JavaLogic__.ts.html +1 -1
- package/coverage/src/concepts/LogicItem__.ts.html +6 -6
- package/coverage/src/concepts/Logic__.ts.html +359 -359
- package/coverage/src/concepts/MatchCase__.ts.html +402 -402
- package/coverage/src/concepts/Match__.ts.html +4 -4
- package/coverage/src/concepts/MemberExpression__.ts.html +1 -1
- package/coverage/src/concepts/MicroApp__.ts.html +1 -1
- package/coverage/src/concepts/Module__.ts.html +1 -1
- package/coverage/src/concepts/MsgTriggerEvent__.ts.html +1 -1
- package/coverage/src/concepts/MsgTriggerLauncher__.ts.html +1 -1
- package/coverage/src/concepts/Namespace__.ts.html +1 -1
- package/coverage/src/concepts/NewComposite__.ts.html +388 -388
- package/coverage/src/concepts/NewList__.ts.html +54 -54
- package/coverage/src/concepts/NewMap__.ts.html +61 -61
- package/coverage/src/concepts/New__.ts.html +21 -21
- package/coverage/src/concepts/NullLiteral__.ts.html +1 -1
- package/coverage/src/concepts/NumericLiteral__.ts.html +1 -1
- package/coverage/src/concepts/OqlQueryComponent__.ts.html +1 -1
- package/coverage/src/concepts/OverriddenLogic__.ts.html +1 -1
- package/coverage/src/concepts/Param__.ts.html +1 -1
- package/coverage/src/concepts/Point__.ts.html +1 -1
- package/coverage/src/concepts/ProcessComponent__.ts.html +1 -1
- package/coverage/src/concepts/ProcessElement__.ts.html +1 -1
- package/coverage/src/concepts/ProcessOutcome__.ts.html +1 -1
- package/coverage/src/concepts/ProcessOutcomes__.ts.html +1 -1
- package/coverage/src/concepts/Process__.ts.html +1 -1
- package/coverage/src/concepts/QueryAggregateExpression__.ts.html +1 -1
- package/coverage/src/concepts/QueryFieldExpression__.ts.html +1 -1
- package/coverage/src/concepts/QueryFromExpression__.ts.html +1 -1
- package/coverage/src/concepts/QueryGroupByExpression__.ts.html +1 -1
- package/coverage/src/concepts/QueryJoinExpression__.ts.html +1 -1
- package/coverage/src/concepts/QueryLimitExpression__.ts.html +1 -1
- package/coverage/src/concepts/QueryOrderByExpression__.ts.html +1 -1
- package/coverage/src/concepts/QuerySelectExpression__.ts.html +1 -1
- package/coverage/src/concepts/Rect__.ts.html +1 -1
- package/coverage/src/concepts/Return__.ts.html +7 -7
- package/coverage/src/concepts/Role__.ts.html +1 -1
- package/coverage/src/concepts/SelectMembers__.ts.html +1 -1
- package/coverage/src/concepts/Slot__.ts.html +1 -1
- package/coverage/src/concepts/SqlQueryComponent__.ts.html +1 -1
- package/coverage/src/concepts/Start__.ts.html +1 -1
- package/coverage/src/concepts/StringInterpolation__.ts.html +5 -5
- package/coverage/src/concepts/StringLiteral__.ts.html +1 -1
- package/coverage/src/concepts/StructureProperty__.ts.html +1 -1
- package/coverage/src/concepts/Structure__.ts.html +1 -1
- package/coverage/src/concepts/SwitchCase__.ts.html +31 -31
- package/coverage/src/concepts/SwitchStatement__.ts.html +1 -1
- package/coverage/src/concepts/Theme__.ts.html +1 -1
- package/coverage/src/concepts/Transactional__.ts.html +1 -1
- package/coverage/src/concepts/TriggerEvent__.ts.html +1 -1
- package/coverage/src/concepts/TriggerLauncher__.ts.html +1 -1
- package/coverage/src/concepts/TypeAnnotation__.ts.html +23 -23
- package/coverage/src/concepts/TypeParam__.ts.html +1 -1
- package/coverage/src/concepts/UnaryExpression__.ts.html +1 -1
- package/coverage/src/concepts/Unparsed__.ts.html +1 -1
- package/coverage/src/concepts/UseComponent__.ts.html +1 -1
- package/coverage/src/concepts/ValidationRule__.ts.html +1 -1
- package/coverage/src/concepts/Variable__.ts.html +1 -1
- package/coverage/src/concepts/ViewBlock__.ts.html +1 -1
- package/coverage/src/concepts/ViewComponent__.ts.html +1 -1
- package/coverage/src/concepts/ViewElement__.ts.html +1 -1
- package/coverage/src/concepts/View__.ts.html +1 -1
- package/coverage/src/concepts/WhileStatement__.ts.html +40 -40
- package/coverage/src/concepts/basics/stdlib/index.html +28 -13
- package/coverage/src/concepts/basics/stdlib/index.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.auth.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.browser.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.collection.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.configuration.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.core.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.event.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.http.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.interface.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.io.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.logging.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.process.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.ui.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/nasl.util.ts.html +10 -10
- package/coverage/src/concepts/basics/stdlib/nasl.validation.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts.html +1 -1
- package/coverage/src/concepts/basics/stdlib/timeZone.ts.html +664 -0
- package/coverage/src/concepts/basics/types/coreTypeList.ts.html +1 -1
- package/coverage/src/concepts/basics/types/index.html +1 -1
- package/coverage/src/concepts/basics/types/index.ts.html +1 -1
- package/coverage/src/concepts/index.html +118 -118
- package/coverage/src/concepts/index.ts.html +1 -1
- package/coverage/src/concepts/index__.ts.html +1 -1
- package/coverage/src/config.ts.html +1 -1
- package/coverage/src/decorators/index.html +1 -1
- package/coverage/src/decorators/index.ts.html +17 -17
- package/coverage/src/decorators/promise.ts.html +1 -1
- package/coverage/src/eventBus.ts.html +1 -1
- package/coverage/src/generator/compileComponent.ts.html +1 -1
- package/coverage/src/generator/genBundleFiles.ts.html +207 -207
- package/coverage/src/generator/genHash.ts.html +1 -1
- package/coverage/src/generator/genMetaData.ts.html +1 -1
- package/coverage/src/generator/genReleaseBody.ts.html +1 -1
- package/coverage/src/generator/icestark.ts.html +1 -1
- package/coverage/src/generator/index.html +11 -11
- package/coverage/src/generator/index.ts.html +1 -1
- package/coverage/src/generator/microApp.ts.html +1 -1
- package/coverage/src/generator/permission.ts.html +1 -1
- package/coverage/src/generator/qiankun.ts.html +1 -1
- package/coverage/src/generator/styleReplacer.ts.html +1 -1
- package/coverage/src/index.html +1 -1
- package/coverage/src/index.ts.html +1 -1
- package/coverage/src/manager/diagnostic.ts.html +1 -1
- package/coverage/src/manager/index.html +1 -1
- package/coverage/src/manager/stepRecorder.ts.html +1 -1
- package/coverage/src/natural/genNaturalTS.ts.html +4 -4
- package/coverage/src/natural/index.html +15 -15
- package/coverage/src/natural/index.ts.html +1 -1
- package/coverage/src/natural/naslStdlibMap.ts.html +1 -1
- package/coverage/src/natural/transformTSCode.ts.html +351 -351
- package/coverage/src/sentry/index.html +1 -1
- package/coverage/src/sentry/index.ts.html +14 -14
- package/coverage/src/server/createUiTs.ts.html +1 -1
- package/coverage/src/server/entity2LogicNamespace.ts.html +1 -1
- package/coverage/src/server/event.js.html +1 -1
- package/coverage/src/server/extendBaseNode.ts.html +1 -1
- package/coverage/src/server/formatTsUtils.ts.html +1 -1
- package/coverage/src/server/getConnector.ts.html +1 -1
- package/coverage/src/server/getExtensionModules.ts.html +1 -1
- package/coverage/src/server/getFunctions.ts.html +1 -1
- package/coverage/src/server/getInterfaces.ts.html +1 -1
- package/coverage/src/server/getLogging.ts.html +1 -1
- package/coverage/src/server/getLogics.ts.html +70 -70
- package/coverage/src/server/getMemberIdentifier.ts.html +1 -1
- package/coverage/src/server/getProcessComponents.ts.html +1 -1
- package/coverage/src/server/getProcesses.ts.html +1 -1
- package/coverage/src/server/getValidates.ts.html +1 -1
- package/coverage/src/server/index.html +15 -15
- package/coverage/src/server/index.ts.html +1 -1
- package/coverage/src/server/naslServer.ts.html +1481 -1481
- package/coverage/src/server/naslStdlibMap.ts.html +1 -1
- package/coverage/src/server/process2LogicNamespace.ts.html +1 -1
- package/coverage/src/server/translator.ts.html +1 -1
- package/coverage/src/service/creator/add.configs.js.html +1 -1
- package/coverage/src/service/creator/errHandles.js.html +1 -1
- package/coverage/src/service/creator/index.html +1 -1
- package/coverage/src/service/creator/index.js.html +1 -1
- package/coverage/src/service/datasource/api.js.html +1 -1
- package/coverage/src/service/datasource/index.html +1 -1
- package/coverage/src/service/datasource/index.js.html +1 -1
- package/coverage/src/service/logic/api.js.html +1 -1
- package/coverage/src/service/logic/index.html +1 -1
- package/coverage/src/service/logic/index.js.html +1 -1
- package/coverage/src/service/storage/api.js.html +1 -1
- package/coverage/src/service/storage/index.html +1 -1
- package/coverage/src/service/storage/index.ts.html +1 -1
- package/coverage/src/service/storage/init.ts.html +1 -1
- package/coverage/src/service/storage/jsoner.ts.html +1 -1
- package/coverage/src/service/storage/map.ts.html +3 -3
- package/coverage/src/service/storage/service.ts.html +1 -1
- package/coverage/src/service/storage/storagePoint.ts.html +1 -1
- package/coverage/src/templator/genCallComponentLogic.ts.html +1 -1
- package/coverage/src/templator/genCreateBlock.ts.html +1 -1
- package/coverage/src/templator/genCurdEditMultipleKeyBlock.ts.html +1 -1
- package/coverage/src/templator/genCurdMultipleKeyBlock.ts.html +1 -1
- package/coverage/src/templator/genEditTableBlock.ts.html +1 -1
- package/coverage/src/templator/genEnumSelectBlock.ts.html +1 -1
- package/coverage/src/templator/genGetBlock.ts.html +1 -1
- package/coverage/src/templator/genGridViewBlock.ts.html +1 -1
- package/coverage/src/templator/genListViewBlock.ts.html +1 -1
- package/coverage/src/templator/genQueryComponent.ts.html +1 -1
- package/coverage/src/templator/genSelectBlock.ts.html +1 -1
- package/coverage/src/templator/genTableBlock.ts.html +1 -1
- package/coverage/src/templator/genUpdateBlock.ts.html +1 -1
- package/coverage/src/templator/index.html +1 -1
- package/coverage/src/templator/index.ts.html +1 -1
- package/coverage/src/templator/utils.ts.html +1 -1
- package/coverage/src/translator/constant.ts.html +1 -1
- package/coverage/src/translator/index.html +15 -15
- package/coverage/src/translator/index.ts.html +1 -1
- package/coverage/src/translator/utils.ts.html +36 -36
- package/coverage/src/utils/cookie.ts.html +1 -1
- package/coverage/src/utils/env.ts.html +1 -1
- package/coverage/src/utils/index.html +1 -1
- package/coverage/src/utils/index.ts.html +13 -13
- package/coverage/src/utils/logger.ts.html +1 -1
- package/coverage/src/utils/sortTsString.ts.html +1 -1
- package/coverage/src/utils/string.ts.html +1 -1
- package/coverage/src/utils/time-slicing.ts.html +1 -1
- package/coverage/src/utils/traverse.ts.html +1 -1
- package/coverage/src/utils/window.ts.html +1 -1
- package/out/bak/translator.js +16 -18
- package/out/bak/translator.js.map +1 -1
- package/out/concepts/BindAttribute__.js +2 -2
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/CallFunction__.js +4 -1
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/IfStatement__.js +14 -14
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +11 -14
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +14 -14
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +4 -2
- package/out/concepts/ViewElement__.js +7 -21
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/natural/transformTSCode.js +5 -3
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/createUiTs.js +3 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/getMemberIdentifier.js +15 -0
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.js +21 -41
- package/out/server/naslServer.js.map +1 -1
- package/out/service/creator/errHandles.js +10 -19
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/service/storage/init.js +7 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/jsoner.js +1 -3
- package/out/service/storage/jsoner.js.map +1 -1
- package/out/templator/genEditTableBlock.js +24 -2
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +22 -1
- package/out/templator/genTableBlock.js.map +1 -1
- package/package.json +1 -1
- package/sandbox/stdlib/nasl.ui.definition.ts +2220 -2218
- package/sandbox-natural/stdlib/nasl.core.ts +0 -2
- package/sandbox-natural/stdlib/nasl.util.ts +1 -0
- package/src/bak/translator.js +16 -17
- package/src/concepts/BindAttribute__.ts +3 -3
- package/src/concepts/CallFunction__.ts +4 -1
- package/src/concepts/CallLogic__.ts +0 -1
- package/src/concepts/IfStatement__.ts +14 -14
- package/src/concepts/MemberExpression__.ts +11 -14
- package/src/concepts/TypeAnnotation__.ts +14 -14
- package/src/concepts/ViewElement__.ts +8 -22
- package/src/natural/transformTSCode.ts +5 -4
- package/src/server/createUiTs.ts +3 -0
- package/src/server/getMemberIdentifier.ts +15 -0
- package/src/server/naslServer.ts +26 -25
- package/src/service/creator/errHandles.js +10 -16
- package/src/service/storage/init.ts +8 -3
- package/src/service/storage/jsoner.ts +2 -2
- package/src/templator/genEditTableBlock.ts +24 -2
- package/src/templator/genTableBlock.ts +22 -1
- package/test/concepts/member-expression/__snapshots__/toEmbeddedTS.spec.ts.snap +1 -1
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +4 -4
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">2.
|
|
26
|
+
<span class="strong">2.27% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>9/
|
|
28
|
+
<span class='fraction'>9/396</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
33
|
<span class="strong">0% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>0/
|
|
35
|
+
<span class='fraction'>0/311</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
40
|
<span class="strong">0% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>0/
|
|
42
|
+
<span class='fraction'>0/81</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">2.
|
|
47
|
+
<span class="strong">2.41% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>9/
|
|
49
|
+
<span class='fraction'>9/373</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -1264,7 +1264,6 @@
|
|
|
1264
1264
|
<span class="cline-any cline-no"> </span>
|
|
1265
1265
|
<span class="cline-any cline-neutral"> </span>
|
|
1266
1266
|
<span class="cline-any cline-neutral"> </span>
|
|
1267
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1268
1267
|
<span class="cline-any cline-no"> </span>
|
|
1269
1268
|
<span class="cline-any cline-neutral"> </span>
|
|
1270
1269
|
<span class="cline-any cline-no"> </span>
|
|
@@ -1297,6 +1296,17 @@
|
|
|
1297
1296
|
<span class="cline-any cline-neutral"> </span>
|
|
1298
1297
|
<span class="cline-any cline-no"> </span>
|
|
1299
1298
|
<span class="cline-any cline-no"> </span>
|
|
1299
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1300
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1301
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1302
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1303
|
+
<span class="cline-any cline-no"> </span>
|
|
1304
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1305
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1306
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1307
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1308
|
+
<span class="cline-any cline-no"> </span>
|
|
1309
|
+
<span class="cline-any cline-no"> </span>
|
|
1300
1310
|
<span class="cline-any cline-no"> </span>
|
|
1301
1311
|
<span class="cline-any cline-no"> </span>
|
|
1302
1312
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -1304,6 +1314,8 @@
|
|
|
1304
1314
|
<span class="cline-any cline-neutral"> </span>
|
|
1305
1315
|
<span class="cline-any cline-neutral"> </span>
|
|
1306
1316
|
<span class="cline-any cline-neutral"> </span>
|
|
1317
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1318
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1307
1319
|
<span class="cline-any cline-no"> </span>
|
|
1308
1320
|
<span class="cline-any cline-neutral"> </span>
|
|
1309
1321
|
<span class="cline-any cline-no"> </span>
|
|
@@ -1319,6 +1331,8 @@
|
|
|
1319
1331
|
<span class="cline-any cline-neutral"> </span>
|
|
1320
1332
|
<span class="cline-any cline-neutral"> </span>
|
|
1321
1333
|
<span class="cline-any cline-neutral"> </span>
|
|
1334
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1335
|
+
<span class="cline-any cline-neutral"> </span>
|
|
1322
1336
|
<span class="cline-any cline-no"> </span>
|
|
1323
1337
|
<span class="cline-any cline-neutral"> </span>
|
|
1324
1338
|
<span class="cline-any cline-no"> </span>
|
|
@@ -1757,20 +1771,6 @@
|
|
|
1757
1771
|
<span class="cline-any cline-no"> </span>
|
|
1758
1772
|
<span class="cline-any cline-no"> </span>
|
|
1759
1773
|
<span class="cline-any cline-neutral"> </span>
|
|
1760
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1761
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1762
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1763
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1764
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1765
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1766
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1767
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1768
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1769
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1770
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1771
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1772
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1773
|
-
<span class="cline-any cline-neutral"> </span>
|
|
1774
1774
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* eslint-disable global-require */
|
|
1775
1775
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
1776
1776
|
import * as babel from '@babel/core';
|
|
@@ -2118,24 +2118,24 @@ export function <span class="fstat-no" title="function not covered" >transformTS
|
|
|
2118
2118
|
typeArguments: node?.typeParameters?.params.map(<span class="fstat-no" title="function not covered" >(c</span>urType: any) => <span class="cstat-no" title="statement not covered" >transformTypeAnnotation({ ...curType, typeNamespace }))</span>,
|
|
2119
2119
|
});
|
|
2120
2120
|
// console.log('lemon ~ callFunction ~ 3:', nodeElement);
|
|
2121
|
-
return nodeElement
|
|
2122
|
-
}
|
|
2123
|
-
if (callee.length === 3 && calleeName.startsWith('nasl.ui.')) {
|
|
2121
|
+
<span class="cstat-no" title="statement not covered" > return nodeElement;</span>
|
|
2122
|
+
}
|
|
2123
|
+
<span class="cstat-no" title="statement not covered" > if (callee.length === 3 && calleeName.startsWith('nasl.ui.')) {</span>
|
|
2124
2124
|
<span class="cstat-no" title="statement not covered" > if ((callee[2] as babelTypes.Identifier).name === 'destination') {</span>
|
|
2125
|
-
<span class="cstat-no" title="statement not covered" >
|
|
2126
|
-
const nsArr =
|
|
2127
|
-
const viewName<span class="cstat-no" title="statement not covered" >
|
|
2128
|
-
|
|
2129
|
-
return new naslTypes.Destination({
|
|
2130
|
-
<span class="
|
|
2131
|
-
viewName, // viewName
|
|
2132
|
-
arguments: node.arguments.slice(1).map((
|
|
2133
|
-
expression: transformLogicNode(arg)
|
|
2125
|
+
const namespace = (<span class="cstat-no" title="statement not covered" >node.arguments[0] as babelTypes.StringLiteral).value;</span>
|
|
2126
|
+
const nsArr = <span class="cstat-no" title="statement not covered" >namespace.split('.').map(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >item.replace(/_view$/, ''))</span>;</span>
|
|
2127
|
+
const viewName = <span class="cstat-no" title="statement not covered" >nsArr.pop();</span>
|
|
2128
|
+
|
|
2129
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.Destination({</span>
|
|
2130
|
+
viewNamespace: `app.frontends.pc.views${nsArr.map(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >`.${item}.views`)</span>.join('')}`, // viewNamespace
|
|
2131
|
+
viewName, // viewName
|
|
2132
|
+
arguments: node.arguments.slice(1).map(<span class="fstat-no" title="function not covered" >(a</span>rg) => <span class="cstat-no" title="statement not covered" >new naslTypes.Argument({</span>
|
|
2133
|
+
expression: transformLogicNode(arg),
|
|
2134
2134
|
})) as naslTypes.Argument[],
|
|
2135
2135
|
});
|
|
2136
2136
|
}
|
|
2137
|
-
return new naslTypes.CallLogic({
|
|
2138
|
-
|
|
2137
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.CallLogic({</span>
|
|
2138
|
+
calleeNamespace: 'nasl.ui',
|
|
2139
2139
|
calleeName: (callee[2] as babelTypes.Identifier).name,
|
|
2140
2140
|
shortcut: true,
|
|
2141
2141
|
/**
|
|
@@ -2143,411 +2143,411 @@ export function <span class="fstat-no" title="function not covered" >transformTS
|
|
|
2143
2143
|
* @param node
|
|
2144
2144
|
* @returns
|
|
2145
2145
|
*/
|
|
2146
|
-
arguments: node.arguments.map((
|
|
2147
|
-
expression:
|
|
2146
|
+
arguments: node.arguments.map(<span class="fstat-no" title="function not covered" >(a</span>rg) => <span class="cstat-no" title="statement not covered" >new naslTypes.Argument({</span>
|
|
2147
|
+
expression: transformLogicNode(arg),
|
|
2148
2148
|
})) as naslTypes.Argument[],
|
|
2149
2149
|
});
|
|
2150
2150
|
}
|
|
2151
|
-
if (calleeName.endsWith('.map')) {
|
|
2151
|
+
<span class="cstat-no" title="statement not covered" > if (calleeName.endsWith('.map')) {</span>
|
|
2152
2152
|
<span class="cstat-no" title="statement not covered" > return new naslTypes.CallFunction({</span>
|
|
2153
|
-
calleeNamespace
|
|
2154
|
-
calleeName: '
|
|
2155
|
-
arguments: [new
|
|
2153
|
+
calleeNamespace: 'nasl.util',
|
|
2154
|
+
calleeName: 'ListTransform',
|
|
2155
|
+
arguments: [new naslTypes.Argument({
|
|
2156
2156
|
expression: transformLogicNode((node.callee as babelTypes.MemberExpression).object),
|
|
2157
|
-
}), ...node.arguments.map((
|
|
2157
|
+
}), ...node.arguments.map(<span class="fstat-no" title="function not covered" >(a</span>rg: any) => <span class="cstat-no" title="statement not covered" >new naslTypes.Argument({</span>
|
|
2158
2158
|
expression: transformLogicNode(arg),
|
|
2159
2159
|
}))],
|
|
2160
2160
|
});
|
|
2161
|
-
}
|
|
2162
|
-
if (calleeName === 'ForEach') {
|
|
2163
|
-
<span class="cstat-no" title="statement not covered" >
|
|
2164
|
-
const arrowFunction = node.arguments[3] as babelTypes.ArrowFunctionExpression
|
|
2165
|
-
<span class="cstat-no" title="statement not covered" >
|
|
2166
|
-
each:
|
|
2167
|
-
|
|
2168
|
-
end:
|
|
2169
|
-
item: transformParam(
|
|
2170
|
-
index: arrowFunction
|
|
2161
|
+
}
|
|
2162
|
+
<span class="cstat-no" title="statement not covered" > if (calleeName === 'ForEach') {</span>
|
|
2163
|
+
const newCallee = <span class="cstat-no" title="statement not covered" >node.arguments;</span>
|
|
2164
|
+
const arrowFunction = <span class="cstat-no" title="statement not covered" >node.arguments[3] as babelTypes.ArrowFunctionExpression;</span>
|
|
2165
|
+
const nodeElement = <span class="cstat-no" title="statement not covered" >new naslTypes.ForEachStatement({</span>
|
|
2166
|
+
each: transformLogicNode(newCallee[0]),
|
|
2167
|
+
start: transformLogicNode(newCallee[1]),
|
|
2168
|
+
end: transformLogicNode(newCallee[2]),
|
|
2169
|
+
item: transformParam(arrowFunction.params[0] as babelTypes.Identifier),
|
|
2170
|
+
index: arrowFunction.params[1] ? transformParam(arrowFunction.params[1] as babelTypes.Identifier) : new naslTypes.Param({
|
|
2171
2171
|
name: 'index', typeAnnotation: naslTypes.TypeAnnotation.createPrimitive('Long'),
|
|
2172
2172
|
}),
|
|
2173
|
-
body: (arrowFunction.body as babelTypes.BlockStatement).body.map((
|
|
2173
|
+
body: (arrowFunction.body as babelTypes.BlockStatement).body.map(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >transformLogicNode(item))</span>.filter(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >!!item)</span>,
|
|
2174
2174
|
});
|
|
2175
|
-
return nodeElement
|
|
2176
|
-
}
|
|
2177
|
-
if (callee.length === 2) {
|
|
2178
|
-
|
|
2179
|
-
if (curCalleeName === 'forEach') {
|
|
2180
|
-
|
|
2181
|
-
<span class="cstat-no" title="statement not covered" >
|
|
2182
|
-
|
|
2183
|
-
|
|
2175
|
+
<span class="cstat-no" title="statement not covered" > return nodeElement;</span>
|
|
2176
|
+
}
|
|
2177
|
+
<span class="cstat-no" title="statement not covered" > if (callee.length === 2) {</span>
|
|
2178
|
+
const curCalleeName = (<span class="cstat-no" title="statement not covered" >node.callee as any).property.name;</span>
|
|
2179
|
+
<span class="cstat-no" title="statement not covered" > if (curCalleeName === 'forEach') {</span>
|
|
2180
|
+
const newCallee = (<span class="cstat-no" title="statement not covered" >node.callee as any).object;</span>
|
|
2181
|
+
const arrowFunction = <span class="cstat-no" title="statement not covered" >node.arguments[0] as babelTypes.ArrowFunctionExpression;</span>
|
|
2182
|
+
const nodeElement = <span class="cstat-no" title="statement not covered" >new naslTypes.ForEachStatement({</span>
|
|
2183
|
+
each: transformLogicNode(newCallee.callee.object),
|
|
2184
2184
|
start: transformLogicNode(newCallee?.arguments?.[0]),
|
|
2185
2185
|
end: transformLogicNode(newCallee?.arguments?.[1]),
|
|
2186
2186
|
item: transformParam(arrowFunction.params[0] as babelTypes.Identifier),
|
|
2187
|
-
index: arrowFunction.params[
|
|
2187
|
+
index: arrowFunction.params[1] ? transformParam(arrowFunction.params[1] as babelTypes.Identifier) : new naslTypes.Param({
|
|
2188
2188
|
name: 'index', typeAnnotation: naslTypes.TypeAnnotation.createPrimitive('Long'),
|
|
2189
2189
|
}),
|
|
2190
|
-
body: (arrowFunction.body as babelTypes.BlockStatement).body.map((
|
|
2191
|
-
})
|
|
2190
|
+
body: (arrowFunction.body as babelTypes.BlockStatement).body.map(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >transformLogicNode(item))</span>.filter(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >!!item)</span>,
|
|
2191
|
+
});
|
|
2192
2192
|
<span class="cstat-no" title="statement not covered" > return nodeElement;</span>
|
|
2193
2193
|
}
|
|
2194
|
-
} else if (['plus', 'minus', 'multiply', 'divide', 'remainder'].includes(calleeName)) {
|
|
2195
|
-
|
|
2196
|
-
} else if (calleeName === 'alert') {
|
|
2197
|
-
return new naslTypes.CallLogic({
|
|
2194
|
+
} else <span class="cstat-no" title="statement not covered" >if (['plus', 'minus', 'multiply', 'divide', 'remainder'].includes(calleeName)) {</span>
|
|
2195
|
+
<span class="cstat-no" title="statement not covered" > return handleBinaryExpression(calleeName, node?.arguments);</span>
|
|
2196
|
+
} else <span class="cstat-no" title="statement not covered" >if (calleeName === 'alert') {</span>
|
|
2197
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.CallLogic({</span>
|
|
2198
2198
|
calleeNamespace: 'nasl.ui',
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
<span class="
|
|
2199
|
+
calleeName: 'showMessage',
|
|
2200
|
+
shortcut: true,
|
|
2201
|
+
arguments: node.arguments.map(<span class="fstat-no" title="function not covered" >(a</span>rg) => <span class="cstat-no" title="statement not covered" >new naslTypes.Argument({</span>
|
|
2202
2202
|
expression: transformLogicNode(arg),
|
|
2203
2203
|
})) as naslTypes.Argument[],
|
|
2204
|
-
})
|
|
2205
|
-
} else if (/^app.dataSources|app.logics|load/.test(calleeName)) {
|
|
2206
|
-
return new naslTypes.CallLogic({
|
|
2204
|
+
});
|
|
2205
|
+
} else <span class="cstat-no" title="statement not covered" >if (/^app.dataSources|app.logics|load/.test(calleeName)) {</span>
|
|
2206
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.CallLogic({</span>
|
|
2207
2207
|
calleeNamespace: generate((node.callee as any).object).code,
|
|
2208
2208
|
calleeName: (callee[callee.length - 1] as babelTypes.Identifier).name,
|
|
2209
|
-
<span class="
|
|
2209
|
+
arguments: node.arguments.map(<span class="fstat-no" title="function not covered" >(a</span>rg) => <span class="cstat-no" title="statement not covered" >new naslTypes.Argument({</span>
|
|
2210
2210
|
expression: transformLogicNode(arg),
|
|
2211
2211
|
})) as naslTypes.Argument[],
|
|
2212
|
-
})
|
|
2213
|
-
} else if (callee.length === 1) {
|
|
2214
|
-
if (calleeName.startsWith('viewLogic_')) {
|
|
2215
|
-
return new naslTypes.CallLogic({
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
arguments: node.arguments.map((
|
|
2212
|
+
});
|
|
2213
|
+
} else <span class="cstat-no" title="statement not covered" >if (callee.length === 1) {</span>
|
|
2214
|
+
<span class="cstat-no" title="statement not covered" > if (calleeName.startsWith('viewLogic_')) {</span>
|
|
2215
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.CallLogic({</span>
|
|
2216
|
+
calleeNamespace: '',
|
|
2217
|
+
calleeName: calleeName.slice('viewLogic_'.length),
|
|
2218
|
+
arguments: node.arguments.map(<span class="fstat-no" title="function not covered" >(a</span>rg) => <span class="cstat-no" title="statement not covered" >new naslTypes.Argument({</span>
|
|
2219
2219
|
expression: transformLogicNode(arg),
|
|
2220
|
-
})) as naslTypes.Argument[]
|
|
2220
|
+
})) as naslTypes.Argument[],
|
|
2221
2221
|
});
|
|
2222
2222
|
}
|
|
2223
|
-
return new naslTypes.CallLogic({
|
|
2223
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.CallLogic({</span>
|
|
2224
2224
|
calleeNamespace: `app.logics`,
|
|
2225
2225
|
calleeName,
|
|
2226
|
-
arguments: node.arguments.map((
|
|
2226
|
+
arguments: node.arguments.map(<span class="fstat-no" title="function not covered" >(a</span>rg) => <span class="cstat-no" title="statement not covered" >new naslTypes.Argument({</span>
|
|
2227
2227
|
expression: transformLogicNode(arg),
|
|
2228
2228
|
})) as naslTypes.Argument[],
|
|
2229
2229
|
});
|
|
2230
|
-
} else if (/interfaces/.test(calleeName)) {
|
|
2231
|
-
return new naslTypes.CallInterface({
|
|
2230
|
+
} else <span class="cstat-no" title="statement not covered" >if (/interfaces/.test(calleeName)) {</span>
|
|
2231
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.CallInterface({</span>
|
|
2232
2232
|
calleeNamespace: generate((node.callee as any).object).code,
|
|
2233
2233
|
calleeName: (callee[callee.length - 1] as babelTypes.Identifier).name,
|
|
2234
|
-
arguments: node.arguments.map((
|
|
2234
|
+
arguments: node.arguments.map(<span class="fstat-no" title="function not covered" >(a</span>rg: any) => <span class="cstat-no" title="statement not covered" >new naslTypes.Argument({</span>
|
|
2235
2235
|
keyword: arg.properties[0].key.name,
|
|
2236
2236
|
expression: transformLogicNode(arg.properties[0].value),
|
|
2237
|
-
}
|
|
2237
|
+
})) as naslTypes.Argument[],
|
|
2238
2238
|
});
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
// const
|
|
2239
|
+
}
|
|
2240
|
+
// else if (/destination/.test(calleeName)) {
|
|
2241
|
+
// const newCallee = flatMemberExpression((node.callee as any).object);
|
|
2242
2242
|
// return new naslTypes.Destination({
|
|
2243
2243
|
// viewNamespace: generate((node.callee as any).object.object).code,
|
|
2244
|
-
// viewName: (newCallee[newCallee.length - 1] as
|
|
2244
|
+
// viewName: (newCallee[newCallee.length - 1] as babelTypes.Identifier).name,
|
|
2245
2245
|
// target: (node.arguments[0] as any).properties[1].value.value,
|
|
2246
|
-
// anchor: new naslTypes.Anchor({
|
|
2246
|
+
// anchor: new naslTypes.Anchor({
|
|
2247
2247
|
// expression: transformLogicNode((node.arguments[0] as any).properties[0].value),
|
|
2248
2248
|
// }),
|
|
2249
|
-
//
|
|
2250
|
-
// }
|
|
2251
|
-
else if (node.callee.type === 'ArrowFunctionExpression') {
|
|
2249
|
+
// });
|
|
2250
|
+
// }
|
|
2251
|
+
else <span class="cstat-no" title="statement not covered" >if (node.callee.type === 'ArrowFunctionExpression') {</span>
|
|
2252
2252
|
// NOTE: 适用于 if else
|
|
2253
|
-
const newCallee = (node.callee.body as any).body
|
|
2254
|
-
if (newCallee[newCallee.length - 1].argument?.callee?.name === '__MatchExpressionFuntion') {
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
cases: flatIfStatement(newCallee[1].body.body[0]).map((
|
|
2259
|
-
|
|
2260
|
-
<span class="
|
|
2261
|
-
})
|
|
2253
|
+
const newCallee = (<span class="cstat-no" title="statement not covered" >node.callee.body as any).body;</span>
|
|
2254
|
+
<span class="cstat-no" title="statement not covered" > if (newCallee[newCallee.length - 1].argument?.callee?.name === '__MatchExpressionFuntion') {</span>
|
|
2255
|
+
const match = <span class="cstat-no" title="statement not covered" >new naslTypes.Match({</span>
|
|
2256
|
+
expression: transformLogicNode(newCallee[0]),
|
|
2257
|
+
isExpression: type === 'expression',
|
|
2258
|
+
cases: flatIfStatement(newCallee[1].body.body[0]).map(<span class="fstat-no" title="function not covered" >(_</span>case: any) => <span class="cstat-no" title="statement not covered" >new naslTypes.MatchCase({</span>
|
|
2259
|
+
patterns: !_case.test ? [] : flatMatchPatternsExpression(transformLogicNode(_case.test)) as any,
|
|
2260
|
+
body: _case.consequent.body.filter(<span class="fstat-no" title="function not covered" >(i</span>tem: any) => <span class="cstat-no" title="statement not covered" >item.type !== 'BreakStatement')</span>.map(<span class="fstat-no" title="function not covered" >(i</span>tem: any) => <span class="cstat-no" title="statement not covered" >transformLogicNode(item))</span>.filter(<span class="fstat-no" title="function not covered" >(i</span>tem: any) => <span class="cstat-no" title="statement not covered" >!!item)</span>,
|
|
2261
|
+
})),
|
|
2262
2262
|
});
|
|
2263
|
-
if (!match.cases.length || match.cases[match.cases.length - 1].patterns.length) {
|
|
2264
|
-
match.cases.push(new naslTypes.MatchCase({
|
|
2263
|
+
<span class="cstat-no" title="statement not covered" > if (!match.cases.length || match.cases[match.cases.length - 1].patterns.length) {</span>
|
|
2264
|
+
<span class="cstat-no" title="statement not covered" > match.cases.push(new naslTypes.MatchCase({</span>
|
|
2265
2265
|
patterns: [],
|
|
2266
2266
|
body: [],
|
|
2267
2267
|
}));
|
|
2268
2268
|
}
|
|
2269
|
-
match.cases.forEach((
|
|
2270
|
-
if (case_.body.length && (case_.body[0].concept === 'BooleanLiteral' || case_.body[0].concept === 'StringLiteral')) {
|
|
2271
|
-
case_.isMatchedTypeEnumable = true
|
|
2269
|
+
<span class="cstat-no" title="statement not covered" > match.cases.forEach(<span class="fstat-no" title="function not covered" >(c</span>ase_: any) => {</span>
|
|
2270
|
+
<span class="cstat-no" title="statement not covered" > if (case_.body.length && (case_.body[0].concept === 'BooleanLiteral' || case_.body[0].concept === 'StringLiteral')) {</span>
|
|
2271
|
+
<span class="cstat-no" title="statement not covered" > case_.isMatchedTypeEnumable = true;</span>
|
|
2272
2272
|
}
|
|
2273
|
-
if (case_.patterns.length && case_.patterns[0].concept === 'MemberExpression') {
|
|
2274
|
-
case_.isMatchedTypeEnumable = true
|
|
2275
|
-
case_.patterns[0] = new naslTypes.MemberExpression({
|
|
2276
|
-
|
|
2273
|
+
<span class="cstat-no" title="statement not covered" > if (case_.patterns.length && case_.patterns[0].concept === 'MemberExpression') {</span>
|
|
2274
|
+
<span class="cstat-no" title="statement not covered" > case_.isMatchedTypeEnumable = true;</span>
|
|
2275
|
+
<span class="cstat-no" title="statement not covered" > case_.patterns[0] = new naslTypes.MemberExpression({</span>
|
|
2276
|
+
object: {
|
|
2277
2277
|
concept: 'Identifier',
|
|
2278
|
-
|
|
2279
|
-
folded: false
|
|
2280
|
-
|
|
2278
|
+
name: case_.patterns[0].object.property.name,
|
|
2279
|
+
folded: false,
|
|
2280
|
+
namespace: 'app.enums'
|
|
2281
2281
|
} as any,
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2282
|
+
property: {
|
|
2283
|
+
concept: 'Identifier',
|
|
2284
|
+
name: case_.patterns[0].property.value,
|
|
2285
2285
|
folded: false,
|
|
2286
2286
|
} as any,
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
return match
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
});
|
|
2290
|
+
<span class="cstat-no" title="statement not covered" > return match;</span>
|
|
2291
2291
|
}
|
|
2292
|
-
|
|
2293
|
-
<span class="cstat-no" title="statement not covered" >
|
|
2294
|
-
|
|
2292
|
+
<span class="cstat-no" title="statement not covered" > if (newCallee[newCallee.length - 1].argument?.callee?.name === '__SwitchExpressionFuntion') {</span>
|
|
2293
|
+
const switchStatement = <span class="cstat-no" title="statement not covered" >transformLogicNode(newCallee[0].body.body[0]);</span>
|
|
2294
|
+
<span class="cstat-no" title="statement not covered" > return switchStatement;</span>
|
|
2295
2295
|
}
|
|
2296
|
-
console.error(node)
|
|
2296
|
+
<span class="cstat-no" title="statement not covered" > console.error(node);</span>
|
|
2297
2297
|
<span class="cstat-no" title="statement not covered" > if (debug) {</span>
|
|
2298
|
-
<span class="cstat-no" title="statement not covered" > throw new Error(`
|
|
2298
|
+
<span class="cstat-no" title="statement not covered" > throw new Error(`Unhandled ArrowFunctionExpression node ${node.type}`);</span>
|
|
2299
2299
|
}
|
|
2300
|
-
|
|
2301
|
-
console.error(node)
|
|
2302
|
-
|
|
2303
|
-
throw new Error(`Unhandled node ${callee.map(
|
|
2300
|
+
} else {
|
|
2301
|
+
<span class="cstat-no" title="statement not covered" > console.error(node);</span>
|
|
2302
|
+
<span class="cstat-no" title="statement not covered" > if (debug) {</span>
|
|
2303
|
+
<span class="cstat-no" title="statement not covered" > throw new Error(`Unhandled node ${callee.map(<span class="fstat-no" title="function not covered" >(i</span>tem: babelTypes.Identifier) => <span class="cstat-no" title="statement not covered" >item.name)</span>.join('.')} ${node.type}`);</span>
|
|
2304
2304
|
}
|
|
2305
|
-
}
|
|
2306
|
-
} <span class="cstat-no" title="statement not covered" >
|
|
2307
|
-
if (node.alternate && node.alternate.type === 'IfStatement') {
|
|
2308
|
-
const switchStatement =
|
|
2305
|
+
}
|
|
2306
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'IfStatement') {</span>
|
|
2307
|
+
<span class="cstat-no" title="statement not covered" > if (node.alternate && node.alternate.type === 'IfStatement') {</span>
|
|
2308
|
+
const switchStatement = <span class="cstat-no" title="statement not covered" >new naslTypes.SwitchStatement({</span>
|
|
2309
2309
|
cases: [],
|
|
2310
|
-
})
|
|
2311
|
-
|
|
2312
|
-
return switchStatement
|
|
2310
|
+
});
|
|
2311
|
+
<span class="cstat-no" title="statement not covered" > pushElseIf(node, switchStatement);</span>
|
|
2312
|
+
<span class="cstat-no" title="statement not covered" > return switchStatement;</span>
|
|
2313
2313
|
}
|
|
2314
|
-
|
|
2314
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.IfStatement({</span>
|
|
2315
2315
|
test: transformLogicNode(node.test),
|
|
2316
|
-
consequent: !node.consequent ? [
|
|
2317
|
-
alternate: !node.alternate ? [] : (node.alternate as babelTypes.BlockStatement).body.map((
|
|
2316
|
+
consequent: !node.consequent ? [] : (node.consequent as babelTypes.BlockStatement).body.map(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >transformLogicNode(item))</span>.filter(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >!!item)</span>,
|
|
2317
|
+
alternate: !node.alternate ? [] : (node.alternate as babelTypes.BlockStatement).body.map(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >transformLogicNode(item))</span>.filter(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >!!item)</span>,
|
|
2318
2318
|
});
|
|
2319
|
-
} <span class="cstat-no" title="statement not covered" >
|
|
2320
|
-
|
|
2319
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'WhileStatement') {</span>
|
|
2320
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.WhileStatement({</span>
|
|
2321
2321
|
test: transformLogicNode(node.test),
|
|
2322
|
-
body: (node.body as babelTypes.BlockStatement).body.map((
|
|
2322
|
+
body: (node.body as babelTypes.BlockStatement).body.map(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >transformLogicNode(item))</span>.filter(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >!!item)</span>,
|
|
2323
2323
|
});
|
|
2324
|
-
} else if (node.type === 'SwitchStatement') {
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
cases: node.cases.map((
|
|
2329
|
-
|
|
2330
|
-
<span class="
|
|
2331
|
-
})
|
|
2324
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'SwitchStatement') {</span>
|
|
2325
|
+
const match = <span class="cstat-no" title="statement not covered" >new naslTypes.Match({</span>
|
|
2326
|
+
expression: transformLogicNode(node.discriminant),
|
|
2327
|
+
isExpression: type === 'expression',
|
|
2328
|
+
cases: node.cases.map(<span class="fstat-no" title="function not covered" >(_</span>case) => <span class="cstat-no" title="statement not covered" >new naslTypes.MatchCase({</span>
|
|
2329
|
+
patterns: !_case.test ? [] : [transformLogicNode(_case.test)],
|
|
2330
|
+
body: _case.consequent.filter(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >item.type !== 'BreakStatement')</span>.map(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >transformLogicNode(item))</span>.filter(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >!!item)</span>,
|
|
2331
|
+
})),
|
|
2332
2332
|
});
|
|
2333
|
-
if (!match.cases.length || match.cases[match.cases.length - 1].patterns.length) {
|
|
2334
|
-
<span class="cstat-no" title="statement not covered" > match.cases
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2333
|
+
<span class="cstat-no" title="statement not covered" > if (!match.cases.length || match.cases[match.cases.length - 1].patterns.length) {</span>
|
|
2334
|
+
<span class="cstat-no" title="statement not covered" > match.cases.push(new naslTypes.MatchCase({</span>
|
|
2335
|
+
patterns: [],
|
|
2336
|
+
body: [],
|
|
2337
|
+
}));
|
|
2338
2338
|
}
|
|
2339
|
-
match.cases.forEach((
|
|
2340
|
-
if (case_.body.length && (case_.body[0].concept === 'BooleanLiteral' || case_.body[0].concept === 'StringLiteral')) {
|
|
2341
|
-
case_.isMatchedTypeEnumable = true
|
|
2339
|
+
<span class="cstat-no" title="statement not covered" > match.cases.forEach(<span class="fstat-no" title="function not covered" >(c</span>ase_: any) => {</span>
|
|
2340
|
+
<span class="cstat-no" title="statement not covered" > if (case_.body.length && (case_.body[0].concept === 'BooleanLiteral' || case_.body[0].concept === 'StringLiteral')) {</span>
|
|
2341
|
+
<span class="cstat-no" title="statement not covered" > case_.isMatchedTypeEnumable = true;</span>
|
|
2342
2342
|
}
|
|
2343
|
-
if (case_.patterns.length && case_.patterns[0].concept === 'MemberExpression') {
|
|
2344
|
-
case_.isMatchedTypeEnumable = true
|
|
2345
|
-
case_.patterns[0].object.namespace = 'app.enums'
|
|
2343
|
+
<span class="cstat-no" title="statement not covered" > if (case_.patterns.length && case_.patterns[0].concept === 'MemberExpression') {</span>
|
|
2344
|
+
<span class="cstat-no" title="statement not covered" > case_.isMatchedTypeEnumable = true;</span>
|
|
2345
|
+
<span class="cstat-no" title="statement not covered" > case_.patterns[0].object.namespace = 'app.enums';</span>
|
|
2346
2346
|
}
|
|
2347
2347
|
});
|
|
2348
|
-
return match
|
|
2349
|
-
} else if (node.type === 'MemberExpression') {
|
|
2348
|
+
<span class="cstat-no" title="statement not covered" > return match;</span>
|
|
2349
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'MemberExpression') {</span>
|
|
2350
2350
|
<span class="cstat-no" title="statement not covered" > if (node.property.type === 'NumericLiteral') {</span>
|
|
2351
|
-
return new naslTypes.CallFunction({
|
|
2351
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.CallFunction({</span>
|
|
2352
2352
|
calleeNamespace: 'nasl.util',
|
|
2353
2353
|
calleeName: 'Get',
|
|
2354
|
-
|
|
2355
|
-
|
|
2354
|
+
arguments: [
|
|
2355
|
+
new naslTypes.Argument({
|
|
2356
2356
|
expression: transformLogicNode(node.object),
|
|
2357
2357
|
}),
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
}
|
|
2364
|
-
return new naslTypes.MemberExpression({
|
|
2358
|
+
new naslTypes.Argument({
|
|
2359
|
+
expression: transformLogicNode(node.property),
|
|
2360
|
+
}),
|
|
2361
|
+
],
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.MemberExpression({</span>
|
|
2365
2365
|
object: transformLogicNode(node.object),
|
|
2366
2366
|
property: transformLogicNode(node.property),
|
|
2367
2367
|
});
|
|
2368
|
-
} else if (node.type === 'Identifier') {
|
|
2369
|
-
|
|
2368
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'Identifier') {</span>
|
|
2369
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.Identifier({</span>
|
|
2370
2370
|
name: node.name,
|
|
2371
2371
|
});
|
|
2372
|
-
} else if (node.type === 'ExpressionStatement') {
|
|
2373
|
-
return transformLogicNode(node.expression)
|
|
2374
|
-
} else if (node.type === 'AssignmentExpression') {
|
|
2375
|
-
if (node.operator === '+=' || node.operator === '-=') {
|
|
2376
|
-
if (type === 'expression') {
|
|
2377
|
-
return new naslTypes.BinaryExpression({
|
|
2378
|
-
|
|
2379
|
-
|
|
2372
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'ExpressionStatement') {</span>
|
|
2373
|
+
<span class="cstat-no" title="statement not covered" > return transformLogicNode(node.expression);</span>
|
|
2374
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'AssignmentExpression') {</span>
|
|
2375
|
+
<span class="cstat-no" title="statement not covered" > if (node.operator === '+=' || node.operator === '-=') {</span>
|
|
2376
|
+
<span class="cstat-no" title="statement not covered" > if (type === 'expression') {</span>
|
|
2377
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.BinaryExpression({</span>
|
|
2378
|
+
operator: node.operator[0] as '+' | '-',
|
|
2379
|
+
left: transformLogicNode(node.left),
|
|
2380
2380
|
right: transformLogicNode(node.right),
|
|
2381
|
-
|
|
2381
|
+
});
|
|
2382
2382
|
}
|
|
2383
|
-
return new naslTypes.Assignment({
|
|
2383
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.Assignment({</span>
|
|
2384
2384
|
left: transformLogicNode(node.left),
|
|
2385
|
-
|
|
2386
|
-
operator:
|
|
2387
|
-
|
|
2388
|
-
|
|
2385
|
+
right: new naslTypes.BinaryExpression({
|
|
2386
|
+
operator: node.operator[0] as '+' | '-',
|
|
2387
|
+
left: transformLogicNode(node.left),
|
|
2388
|
+
right: transformLogicNode(node.right),
|
|
2389
2389
|
}),
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
return transformLogicNode(node.right)
|
|
2394
|
-
}
|
|
2390
|
+
});
|
|
2391
|
+
}
|
|
2392
|
+
<span class="cstat-no" title="statement not covered" > if (type === 'expression') {</span>
|
|
2393
|
+
<span class="cstat-no" title="statement not covered" > return transformLogicNode(node.right);</span>
|
|
2394
|
+
}
|
|
2395
2395
|
<span class="cstat-no" title="statement not covered" > return new naslTypes.Assignment({</span>
|
|
2396
|
-
left: transformLogicNode
|
|
2396
|
+
left: transformLogicNode(node.left),
|
|
2397
2397
|
right: transformLogicNode(node.right),
|
|
2398
2398
|
});
|
|
2399
2399
|
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'NewExpression') {</span>
|
|
2400
|
-
<span class="cstat-no" title="statement not covered" >
|
|
2401
|
-
if (['Boolean', 'Integer', 'Double', 'Decimal', 'Long'].includes(calleeName)) {
|
|
2402
|
-
return transformLogicNode(node.arguments[0], naslTypes.TypeAnnotation.createPrimitive(calleeName))
|
|
2403
|
-
}
|
|
2400
|
+
const calleeName = <span class="cstat-no" title="statement not covered" >generate(node.callee as any).code;</span>
|
|
2401
|
+
<span class="cstat-no" title="statement not covered" > if (['Boolean', 'Integer', 'Double', 'Decimal', 'Long'].includes(calleeName)) {</span>
|
|
2402
|
+
<span class="cstat-no" title="statement not covered" > return transformLogicNode(node.arguments[0], naslTypes.TypeAnnotation.createPrimitive(calleeName));</span>
|
|
2403
|
+
}
|
|
2404
2404
|
<span class="cstat-no" title="statement not covered" > console.error(node);</span>
|
|
2405
|
-
if (debug) {
|
|
2406
|
-
throw new Error(`Unhandled node ${node.type}`)
|
|
2407
|
-
}
|
|
2408
|
-
} else
|
|
2409
|
-
return new naslTypes.AnonymousFunction({
|
|
2410
|
-
params: node.params.map((
|
|
2405
|
+
<span class="cstat-no" title="statement not covered" > if (debug) {</span>
|
|
2406
|
+
<span class="cstat-no" title="statement not covered" > throw new Error(`Unhandled node ${node.type}`);</span>
|
|
2407
|
+
}
|
|
2408
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'ArrowFunctionExpression') {</span>
|
|
2409
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.AnonymousFunction({</span>
|
|
2410
|
+
params: node.params.map(<span class="fstat-no" title="function not covered" >(p</span>aram: babelTypes.Identifier) => <span class="cstat-no" title="statement not covered" >transformParam(param))</span>,
|
|
2411
2411
|
body: transformLogicNode(node.body),
|
|
2412
|
-
|
|
2413
|
-
} <span class="cstat-no" title="statement not covered" >
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
})
|
|
2417
|
-
} else
|
|
2418
|
-
return new naslTypes.StringLiteral({
|
|
2412
|
+
}) as any as naslTypes.LogicItem;
|
|
2413
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'BooleanLiteral') {</span>
|
|
2414
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.BooleanLiteral({</span>
|
|
2415
|
+
value: String(node.value),
|
|
2416
|
+
});
|
|
2417
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'StringLiteral') {</span>
|
|
2418
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.StringLiteral({</span>
|
|
2419
2419
|
value: node.value,
|
|
2420
2420
|
});
|
|
2421
|
-
} else if (node.type === 'NumericLiteral') {
|
|
2422
|
-
const literal = new naslTypes.NumericLiteral({
|
|
2423
|
-
|
|
2421
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'NumericLiteral') {</span>
|
|
2422
|
+
const literal = <span class="cstat-no" title="statement not covered" >new naslTypes.NumericLiteral({</span>
|
|
2423
|
+
value: String(node.value),
|
|
2424
2424
|
typeAnnotation: typeAnnotation || naslTypes.TypeAnnotation.createPrimitive('Integer'),
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
return literal
|
|
2425
|
+
});
|
|
2426
|
+
<span class="cstat-no" title="statement not covered" > literal.typeAnnotation.typeName = literal.changeType(String(node.value));</span>
|
|
2427
|
+
<span class="cstat-no" title="statement not covered" > return literal;</span>
|
|
2428
2428
|
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'NullLiteral') {</span>
|
|
2429
2429
|
<span class="cstat-no" title="statement not covered" > return new naslTypes.NullLiteral();</span>
|
|
2430
|
-
}
|
|
2431
|
-
<span class="cstat-no" title="statement not covered" >
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2430
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'TemplateLiteral') {</span>
|
|
2431
|
+
const expressions = <span class="cstat-no" title="statement not covered" >[...node.expressions as babelTypes.Expression[], ...node.quasis.map(<span class="fstat-no" title="function not covered" >(e</span>lement) => (<span class="cstat-no" title="statement not covered" >{</span></span>
|
|
2432
|
+
type: 'StringLiteral',
|
|
2433
|
+
value: element.value.raw,
|
|
2434
|
+
start: element.start,
|
|
2435
2435
|
end: element.end,
|
|
2436
2436
|
})) as babelTypes.StringLiteral[]];
|
|
2437
|
-
expressions.sort((a
|
|
2437
|
+
<span class="cstat-no" title="statement not covered" > expressions.sort(<span class="fstat-no" title="function not covered" >(a</span>, b) => <span class="cstat-no" title="statement not covered" >a.start - b.start)</span>;</span>
|
|
2438
2438
|
|
|
2439
|
-
return new naslTypes.StringInterpolation({
|
|
2440
|
-
<span class="
|
|
2441
|
-
|
|
2442
|
-
}
|
|
2443
|
-
if (node.operator === '===')
|
|
2444
|
-
|
|
2439
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.StringInterpolation({</span>
|
|
2440
|
+
expressions: expressions.map(<span class="fstat-no" title="function not covered" >(i</span>tem) => <span class="cstat-no" title="statement not covered" >transformLogicNode(item))</span>,
|
|
2441
|
+
});
|
|
2442
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'BinaryExpression' || node.type === 'LogicalExpression') {</span>
|
|
2443
|
+
<span class="cstat-no" title="statement not covered" > if (node.operator === '===')</span>
|
|
2444
|
+
<span class="cstat-no" title="statement not covered" > node.operator = '==';</span>
|
|
2445
2445
|
<span class="cstat-no" title="statement not covered" > if (node.operator === '!==')</span>
|
|
2446
2446
|
<span class="cstat-no" title="statement not covered" > node.operator = '!=';</span>
|
|
2447
|
-
if (['+', '-', '*', '/', '%', '==', '!=', '>', '<', '>=', '<=', '&&', '||', 'startwith', 'endwith', 'like', 'in'].includes(node.operator)) {
|
|
2448
|
-
return new naslTypes.BinaryExpression({
|
|
2447
|
+
<span class="cstat-no" title="statement not covered" > if (['+', '-', '*', '/', '%', '==', '!=', '>', '<', '>=', '<=', '&&', '||', 'startwith', 'endwith', 'like', 'in'].includes(node.operator)) {</span>
|
|
2448
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.BinaryExpression({</span>
|
|
2449
2449
|
operator: node.operator as any,
|
|
2450
2450
|
left: transformLogicNode(node.left),
|
|
2451
|
-
|
|
2452
|
-
|
|
2451
|
+
right: transformLogicNode(node.right),
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2454
|
+
<span class="cstat-no" title="statement not covered" > console.error(node);</span>
|
|
2455
|
+
<span class="cstat-no" title="statement not covered" > if (debug) {</span>
|
|
2456
|
+
<span class="cstat-no" title="statement not covered" > throw new Error(`Unhandled node ${node.type}`);</span>
|
|
2453
2457
|
}
|
|
2454
|
-
|
|
2455
|
-
if (
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
return new naslTypes.UnaryExpression({
|
|
2461
|
-
o<span class="cstat-no" title="statement not covered" >perator: node.operator as any,</span>
|
|
2462
|
-
<span class="cstat-no" title="statement not covered" > argument: transformLogicNode(node.argument),</span>
|
|
2463
|
-
<span class="cstat-no" title="statement not covered" > });</span>
|
|
2458
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'UnaryExpression') {</span>
|
|
2459
|
+
<span class="cstat-no" title="statement not covered" > if (['!'].includes(node.operator)) {</span>
|
|
2460
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.UnaryExpression({</span>
|
|
2461
|
+
operator: node.operator as any,
|
|
2462
|
+
argument: transformLogicNode(node.argument),
|
|
2463
|
+
});
|
|
2464
2464
|
}
|
|
2465
|
-
if (['-'].includes(node.operator) && node.argument.type === 'NumericLiteral') {
|
|
2466
|
-
return transformLogicNode({
|
|
2465
|
+
<span class="cstat-no" title="statement not covered" > if (['-'].includes(node.operator) && node.argument.type === 'NumericLiteral') {</span>
|
|
2466
|
+
<span class="cstat-no" title="statement not covered" > return transformLogicNode({</span>
|
|
2467
2467
|
type: 'NumericLiteral',
|
|
2468
2468
|
value: -node.argument.value,
|
|
2469
2469
|
} as babelTypes.NumericLiteral);
|
|
2470
2470
|
}
|
|
2471
|
-
console.error(node)
|
|
2472
|
-
if (debug) {
|
|
2473
|
-
throw new Error(`Unhandled node ${node.type}`)
|
|
2471
|
+
<span class="cstat-no" title="statement not covered" > console.error(node);</span>
|
|
2472
|
+
<span class="cstat-no" title="statement not covered" > if (debug) {</span>
|
|
2473
|
+
<span class="cstat-no" title="statement not covered" > throw new Error(`Unhandled node ${node.type}`);</span>
|
|
2474
2474
|
}
|
|
2475
2475
|
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'UpdateExpression') {</span>
|
|
2476
2476
|
<span class="cstat-no" title="statement not covered" > if (node.operator === '++' || node.operator === '--') {</span>
|
|
2477
2477
|
<span class="cstat-no" title="statement not covered" > return new naslTypes.Assignment({</span>
|
|
2478
|
-
|
|
2478
|
+
left: transformLogicNode(node.argument),
|
|
2479
2479
|
right: new naslTypes.BinaryExpression({
|
|
2480
|
-
|
|
2481
|
-
|
|
2480
|
+
operator: node.operator[0] as '+' | '-',
|
|
2481
|
+
left: transformLogicNode(node.argument),
|
|
2482
2482
|
right: new naslTypes.NumericLiteral({
|
|
2483
2483
|
value: '1',
|
|
2484
2484
|
typeAnnotation: naslTypes.TypeAnnotation.createPrimitive('Integer'),
|
|
2485
|
-
|
|
2485
|
+
}),
|
|
2486
2486
|
}),
|
|
2487
2487
|
});
|
|
2488
2488
|
}
|
|
2489
|
-
} else if (node.type === 'ReturnStatement') {
|
|
2490
|
-
if (node.argument) {
|
|
2491
|
-
if (type === 'expression') {
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
if (!logic.returns.length) {
|
|
2495
|
-
logic.returns.push(new naslTypes.Return({
|
|
2496
|
-
|
|
2497
|
-
|
|
2489
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'ReturnStatement') {</span>
|
|
2490
|
+
<span class="cstat-no" title="statement not covered" > if (node.argument) {</span>
|
|
2491
|
+
<span class="cstat-no" title="statement not covered" > if (type === 'expression') {</span>
|
|
2492
|
+
<span class="cstat-no" title="statement not covered" > return transformLogicNode(node.argument);</span>
|
|
2493
|
+
}
|
|
2494
|
+
<span class="cstat-no" title="statement not covered" > if (!logic.returns.length) {</span>
|
|
2495
|
+
<span class="cstat-no" title="statement not covered" > logic.returns.push(new naslTypes.Return({</span>
|
|
2496
|
+
name: 'result',
|
|
2497
|
+
}));
|
|
2498
2498
|
}
|
|
2499
|
-
<span class="cstat-no" title="statement not covered" > return new
|
|
2500
|
-
|
|
2501
|
-
|
|
2499
|
+
<span class="cstat-no" title="statement not covered" > return new naslTypes.Assignment({</span>
|
|
2500
|
+
left: new naslTypes.Identifier({
|
|
2501
|
+
name: logic.returns[0].name,
|
|
2502
2502
|
}),
|
|
2503
2503
|
right: transformLogicNode(node.argument),
|
|
2504
2504
|
});
|
|
2505
2505
|
}
|
|
2506
|
-
} else
|
|
2507
|
-
return node.leadingComments && new naslTypes.Comment({
|
|
2506
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'EmptyStatement') {</span>
|
|
2507
|
+
<span class="cstat-no" title="statement not covered" > return node.leadingComments && new naslTypes.Comment({</span>
|
|
2508
2508
|
value: String(node.leadingComments[0].value),
|
|
2509
2509
|
});
|
|
2510
|
-
} else if (node.type === 'BlockStatement') {
|
|
2511
|
-
|
|
2512
|
-
} else {
|
|
2513
|
-
console.error(node)
|
|
2514
|
-
if (debug) {
|
|
2510
|
+
} else <span class="cstat-no" title="statement not covered" >if (node.type === 'BlockStatement') {</span>
|
|
2511
|
+
<span class="cstat-no" title="statement not covered" > return transformLogicNode(node?.body?.[0]);</span>
|
|
2512
|
+
} else {
|
|
2513
|
+
<span class="cstat-no" title="statement not covered" > console.error(node);</span>
|
|
2514
|
+
<span class="cstat-no" title="statement not covered" > if (debug) {</span>
|
|
2515
2515
|
<span class="cstat-no" title="statement not covered" > throw new Error(`Unhandled node ${node.type}`);</span>
|
|
2516
|
-
|
|
2516
|
+
}
|
|
2517
2517
|
}
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
const root = babel.parseSync(tsCode, {
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
const root = <span class="cstat-no" title="statement not covered" >babel.parseSync(tsCode, {</span>
|
|
2521
2521
|
filename: 'result.ts',
|
|
2522
2522
|
presets: [require('@babel/preset-typescript')],
|
|
2523
2523
|
}) as babelTypes.File;
|
|
2524
2524
|
|
|
2525
|
-
let parameters: babelTypes.Identifier[] = []
|
|
2526
|
-
let statements: babelTypes.
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
if (root.program.body[0].type === 'ExportNamedDeclaration') {
|
|
2530
|
-
func = root.program.body[0].declaration as babelTypes.FunctionDeclaration
|
|
2525
|
+
let parameters: babelTypes.Identifier[] = <span class="cstat-no" title="statement not covered" >[];</span>
|
|
2526
|
+
let statements: babelTypes.Statement[] = <span class="cstat-no" title="statement not covered" >[];</span>
|
|
2527
|
+
|
|
2528
|
+
let func: babelTypes.FunctionDeclaration;
|
|
2529
|
+
<span class="cstat-no" title="statement not covered" > if (root.program.body[0].type === 'ExportNamedDeclaration') {</span>
|
|
2530
|
+
<span class="cstat-no" title="statement not covered" > func = root.program.body[0].declaration as babelTypes.FunctionDeclaration;</span>
|
|
2531
2531
|
}
|
|
2532
|
-
parameters = func.params as babelTypes.Identifier[]
|
|
2533
|
-
statements = func.body.body
|
|
2532
|
+
<span class="cstat-no" title="statement not covered" > parameters = func.params as babelTypes.Identifier[];</span>
|
|
2533
|
+
<span class="cstat-no" title="statement not covered" > statements = func.body.body;</span>
|
|
2534
2534
|
// traverse<babelTypes.Node>((current) => {
|
|
2535
2535
|
// if (current.node.type === 'FunctionDeclaration' && (current.node.id.name === contextLogicName || type === 'expression')) {
|
|
2536
2536
|
// return true;
|
|
2537
2537
|
// }
|
|
2538
2538
|
// }, { node: root.program }, { mode: 'anyObject' });
|
|
2539
2539
|
|
|
2540
|
-
const currentPositionComment = root.comments.find((
|
|
2541
|
-
if (currentPositionComment) {
|
|
2542
|
-
statements = statements.filter((
|
|
2540
|
+
const currentPositionComment = <span class="cstat-no" title="statement not covered" >root.comments.find(<span class="fstat-no" title="function not covered" >(c</span>omment) => <span class="cstat-no" title="statement not covered" >comment.type === 'CommentLine' && comment.value === ' 当前位置')</span>;</span>
|
|
2541
|
+
<span class="cstat-no" title="statement not covered" > if (currentPositionComment) {</span>
|
|
2542
|
+
<span class="cstat-no" title="statement not covered" > statements = statements.filter(<span class="fstat-no" title="function not covered" >(s</span>tat) => <span class="cstat-no" title="statement not covered" >stat.start > currentPositionComment.start)</span>;</span>
|
|
2543
2543
|
}
|
|
2544
|
-
|
|
2545
|
-
// traverse<
|
|
2546
|
-
|
|
2544
|
+
|
|
2545
|
+
// traverse<babelTypes.Node>((current) => {
|
|
2546
|
+
// if (!current.node.type)
|
|
2547
2547
|
// console.log(current.key, current.node);
|
|
2548
|
-
|
|
2549
|
-
// }, { node: {
|
|
2550
|
-
|
|
2548
|
+
// // console.log(current.node.type);
|
|
2549
|
+
// }, { node: {
|
|
2550
|
+
// type: 'BlockStatement',
|
|
2551
2551
|
// body: statements,
|
|
2552
2552
|
// } as babelTypes.BlockStatement }, {
|
|
2553
2553
|
// mode: 'anyObject',
|
|
@@ -2555,75 +2555,75 @@ export function <span class="fstat-no" title="function not covered" >transformTS
|
|
|
2555
2555
|
// excludedKeySet: new Set(['loc']),
|
|
2556
2556
|
// });
|
|
2557
2557
|
|
|
2558
|
-
parameters.forEach((
|
|
2559
|
-
const param = transformParam(node)
|
|
2560
|
-
<span class="cstat-no" title="statement not covered" > param &&
|
|
2558
|
+
<span class="cstat-no" title="statement not covered" > parameters.forEach(<span class="fstat-no" title="function not covered" >(n</span>ode) => {</span>
|
|
2559
|
+
const param = <span class="cstat-no" title="statement not covered" >transformParam(node);</span>
|
|
2560
|
+
<span class="cstat-no" title="statement not covered" > param && logic.params.push(param);</span>
|
|
2561
2561
|
});
|
|
2562
|
-
statements.forEach((
|
|
2563
|
-
const item
|
|
2562
|
+
<span class="cstat-no" title="statement not covered" > statements.forEach(<span class="fstat-no" title="function not covered" >(n</span>ode) => {</span>
|
|
2563
|
+
const item = <span class="cstat-no" title="statement not covered" >transformLogicNode(node);</span>
|
|
2564
2564
|
<span class="cstat-no" title="statement not covered" > item && logic.body.push(item);</span>
|
|
2565
|
-
})
|
|
2566
|
-
|
|
2567
|
-
//
|
|
2565
|
+
});
|
|
2566
|
+
|
|
2567
|
+
// console.log(JSON.stringify(logic));
|
|
2568
2568
|
// try {
|
|
2569
2569
|
// console.log(logic.toNaturalTS());
|
|
2570
|
-
|
|
2570
|
+
// } catch (e) {
|
|
2571
2571
|
// console.error(e);
|
|
2572
2572
|
// }
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
}
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
<span class="cstat-no" title="statement not covered" >
|
|
2580
|
-
if (cap)
|
|
2573
|
+
|
|
2574
|
+
<span class="cstat-no" title="statement not covered" > return logic;</span>
|
|
2575
|
+
}
|
|
2576
|
+
|
|
2577
|
+
export function <span class="fstat-no" title="function not covered" >tryTransformTSCode(</span>tsCode: string, contextLogicName: string, type?: string): naslTypes.Logic {
|
|
2578
|
+
<span class="cstat-no" title="statement not covered" > if (tsCode.includes('```')) {</span>
|
|
2579
|
+
const cap = <span class="cstat-no" title="statement not covered" >tsCode.match(/```.*\n([\s\S]+?)```/);</span>
|
|
2580
|
+
<span class="cstat-no" title="statement not covered" > if (cap)</span>
|
|
2581
2581
|
<span class="cstat-no" title="statement not covered" > tsCode = cap[1].trim();</span>
|
|
2582
2582
|
}
|
|
2583
2583
|
|
|
2584
|
-
|
|
2585
|
-
}
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
let <span class="cstat-no" title="statement not covered" >
|
|
2589
|
-
const { app, nasl } = context
|
|
2590
|
-
<span class="cstat-no" title="statement not covered" > if (activeLogic.
|
|
2591
|
-
<span class="cstat-no" title="statement not covered" > logicName = `viewLogic_${
|
|
2592
|
-
}
|
|
2593
|
-
logicName = `on_${(activeLogic.parentNode).element.name}_${activeLogic.name}
|
|
2594
|
-
|
|
2584
|
+
<span class="cstat-no" title="statement not covered" > return transformTSCode(tsCode, contextLogicName, type);</span>
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
export function <span class="fstat-no" title="function not covered" >transformTSCodeEx(</span>answer: any, activeLogic: any, context: any) {
|
|
2588
|
+
let logicName = <span class="cstat-no" title="statement not covered" >activeLogic.name;</span>
|
|
2589
|
+
const { app, nasl } = <span class="cstat-no" title="statement not covered" >context;</span>
|
|
2590
|
+
<span class="cstat-no" title="statement not covered" > if (activeLogic.parentNode instanceof nasl.BindEvent && activeLogic.parentNode.parentNode instanceof nasl.View) {</span>
|
|
2591
|
+
<span class="cstat-no" title="statement not covered" > logicName = `viewLogic_${activeLogic.name}`;</span>
|
|
2592
|
+
} else <span class="cstat-no" title="statement not covered" >if (activeLogic.parentNode instanceof nasl.BindEvent && activeLogic.parentNode.parentNode instanceof nasl.ViewElement) {</span>
|
|
2593
|
+
<span class="cstat-no" title="statement not covered" > logicName = `on_${(activeLogic.parentNode).element.name}_${activeLogic.name}`;</span>
|
|
2594
|
+
} else {
|
|
2595
2595
|
<span class="cstat-no" title="statement not covered" > logicName = activeLogic.name;</span>
|
|
2596
2596
|
}
|
|
2597
|
-
|
|
2598
|
-
<span class="cstat-no" title="statement not covered" >
|
|
2599
|
-
app.emit('collect:start', { actionMsg: '自然语言生成代码' })
|
|
2600
|
-
logic.params.forEach((
|
|
2601
|
-
if (!
|
|
2602
|
-
activeLogic.addParam(param.toJSON())
|
|
2603
|
-
<span class="cstat-no" title="statement not covered" > });</span>
|
|
2604
|
-
lo<span class="cstat-no" title="statement not covered" >gic.variables.forEach((variable: any) => {</span>
|
|
2605
|
-
if (!activeLogic.variables.find((_: any) => _.name === variable.name))
|
|
2606
|
-
<span class="cstat-no" title="statement not covered" > activeLogic.addVariabl</span>e(variable.toJSON());
|
|
2597
|
+
|
|
2598
|
+
const logic = <span class="cstat-no" title="statement not covered" >tryTransformTSCode(answer, logicName);</span>
|
|
2599
|
+
<span class="cstat-no" title="statement not covered" > app.emit('collect:start', { actionMsg: '自然语言生成代码' });</span>
|
|
2600
|
+
<span class="cstat-no" title="statement not covered" > logic.params.forEach(<span class="fstat-no" title="function not covered" >(p</span>aram: any) => {</span>
|
|
2601
|
+
<span class="cstat-no" title="statement not covered" > if (!activeLogic.params.find(<span class="fstat-no" title="function not covered" >(_</span>: any) => <span class="cstat-no" title="statement not covered" >_.name === param.name)</span>)</span>
|
|
2602
|
+
<span class="cstat-no" title="statement not covered" > activeLogic.addParam(param.toJSON());</span>
|
|
2607
2603
|
});
|
|
2608
|
-
|
|
2604
|
+
<span class="cstat-no" title="statement not covered" > logic.variables.forEach(<span class="fstat-no" title="function not covered" >(v</span>ariable: any) => {</span>
|
|
2605
|
+
<span class="cstat-no" title="statement not covered" > if (!activeLogic.variables.find(<span class="fstat-no" title="function not covered" >(_</span>: any) => <span class="cstat-no" title="statement not covered" >_.name === variable.name)</span>)</span>
|
|
2606
|
+
<span class="cstat-no" title="statement not covered" > activeLogic.addVariable(variable.toJSON());</span>
|
|
2607
|
+
});
|
|
2608
|
+
<span class="cstat-no" title="statement not covered" > if (logic.returns.length && !activeLogic.returns.length) {</span>
|
|
2609
2609
|
<span class="cstat-no" title="statement not covered" > activeLogic.addReturn(logic.returns[0].toJSON());</span>
|
|
2610
|
-
}
|
|
2611
|
-
<span class="cstat-no" title="statement not covered" > logic.body.forEach((
|
|
2612
|
-
<span class="cstat-no" title="statement not covered" > app.emit('
|
|
2610
|
+
}
|
|
2611
|
+
<span class="cstat-no" title="statement not covered" > logic.body.forEach(<span class="fstat-no" title="function not covered" >(i</span>tem: any) => <span class="cstat-no" title="statement not covered" >activeLogic.insertItemInBodyAt(item.toJSON(), activeLogic.body.length - 1))</span>;</span>
|
|
2612
|
+
<span class="cstat-no" title="statement not covered" > app.emit('collect:end');</span>
|
|
2613
2613
|
}
|
|
2614
2614
|
|
|
2615
|
-
export function transformTSCodeToExpression(answer: any, context: any) {
|
|
2615
|
+
export function <span class="fstat-no" title="function not covered" >transformTSCodeToExpression(</span>answer: any, context: any) {
|
|
2616
2616
|
let logic;
|
|
2617
|
-
try {
|
|
2618
|
-
logic = tryTransformTSCode(answer, '', 'expression')
|
|
2617
|
+
<span class="cstat-no" title="statement not covered" > try {</span>
|
|
2618
|
+
<span class="cstat-no" title="statement not covered" > logic = tryTransformTSCode(answer, '', 'expression');</span>
|
|
2619
2619
|
} catch (error) {
|
|
2620
|
-
throw new Error(error)
|
|
2620
|
+
<span class="cstat-no" title="statement not covered" > throw new Error(error);</span>
|
|
2621
2621
|
}
|
|
2622
|
-
const { app } = context
|
|
2623
|
-
app.emit('collect:start', { actionMsg: '自然语言生成代码' })
|
|
2624
|
-
const { body } = logic
|
|
2625
|
-
app.emit('collect:end')
|
|
2626
|
-
return body
|
|
2622
|
+
const { app } = <span class="cstat-no" title="statement not covered" >context;</span>
|
|
2623
|
+
<span class="cstat-no" title="statement not covered" > app.emit('collect:start', { actionMsg: '自然语言生成代码' });</span>
|
|
2624
|
+
const { body } = <span class="cstat-no" title="statement not covered" >logic;</span>
|
|
2625
|
+
<span class="cstat-no" title="statement not covered" > app.emit('collect:end');</span>
|
|
2626
|
+
<span class="cstat-no" title="statement not covered" > return body;</span>
|
|
2627
2627
|
}
|
|
2628
2628
|
</pre></td></tr></table></pre>
|
|
2629
2629
|
|
|
@@ -2632,7 +2632,7 @@ export function transformTSCodeToExpression(answer: any, context: any) {
|
|
|
2632
2632
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
2633
2633
|
Code coverage generated by
|
|
2634
2634
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
2635
|
-
at 2023-10-18T11:
|
|
2635
|
+
at 2023-10-18T11:36:07.885Z
|
|
2636
2636
|
</div>
|
|
2637
2637
|
<script src="../../prettify.js"></script>
|
|
2638
2638
|
<script>
|