arkanalyzer 1.0.42 → 1.0.44

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.
Files changed (78) hide show
  1. package/lib/Scene.d.ts +1 -2
  2. package/lib/Scene.d.ts.map +1 -1
  3. package/lib/Scene.js +59 -47
  4. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts +11 -5
  5. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts.map +1 -1
  6. package/lib/callgraph/pointerAnalysis/PTAUtils.js +42 -24
  7. package/lib/callgraph/pointerAnalysis/Pag.d.ts +6 -11
  8. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  9. package/lib/callgraph/pointerAnalysis/Pag.js +26 -23
  10. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +11 -63
  11. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
  12. package/lib/callgraph/pointerAnalysis/PagBuilder.js +62 -495
  13. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
  14. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +4 -2
  15. package/lib/callgraph/pointerAnalysis/plugins/ContainerPlugin.d.ts +24 -0
  16. package/lib/callgraph/pointerAnalysis/plugins/ContainerPlugin.d.ts.map +1 -0
  17. package/lib/callgraph/pointerAnalysis/plugins/ContainerPlugin.js +167 -0
  18. package/lib/callgraph/pointerAnalysis/plugins/FunctionPlugin.d.ts +26 -0
  19. package/lib/callgraph/pointerAnalysis/plugins/FunctionPlugin.d.ts.map +1 -0
  20. package/lib/callgraph/pointerAnalysis/plugins/FunctionPlugin.js +151 -0
  21. package/lib/callgraph/pointerAnalysis/plugins/IPagPlugin.d.ts +15 -0
  22. package/lib/callgraph/pointerAnalysis/plugins/IPagPlugin.d.ts.map +1 -0
  23. package/lib/callgraph/pointerAnalysis/plugins/IPagPlugin.js +16 -0
  24. package/lib/callgraph/pointerAnalysis/plugins/PluginManager.d.ts +25 -0
  25. package/lib/callgraph/pointerAnalysis/plugins/PluginManager.d.ts.map +1 -0
  26. package/lib/callgraph/pointerAnalysis/plugins/PluginManager.js +66 -0
  27. package/lib/callgraph/pointerAnalysis/plugins/SdkPlugin.d.ts +37 -0
  28. package/lib/callgraph/pointerAnalysis/plugins/SdkPlugin.d.ts.map +1 -0
  29. package/lib/callgraph/pointerAnalysis/plugins/SdkPlugin.js +160 -0
  30. package/lib/callgraph/pointerAnalysis/plugins/StoragePlugin.d.ts +68 -0
  31. package/lib/callgraph/pointerAnalysis/plugins/StoragePlugin.d.ts.map +1 -0
  32. package/lib/callgraph/pointerAnalysis/plugins/StoragePlugin.js +288 -0
  33. package/lib/core/common/DummyMainCreater.js +1 -1
  34. package/lib/core/common/IRInference.d.ts.map +1 -1
  35. package/lib/core/common/IRInference.js +4 -0
  36. package/lib/core/common/SdkUtils.d.ts +1 -1
  37. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  38. package/lib/core/common/SdkUtils.js +18 -18
  39. package/lib/core/common/TypeInference.d.ts.map +1 -1
  40. package/lib/core/common/TypeInference.js +11 -2
  41. package/lib/core/graph/builder/CfgBuilder.js +1 -1
  42. package/lib/core/graph/builder/ConditionBuilder.js +1 -1
  43. package/lib/core/model/ArkClass.d.ts.map +1 -1
  44. package/lib/core/model/ArkClass.js +2 -1
  45. package/lib/core/model/builder/ArkMethodBuilder.d.ts +1 -0
  46. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  47. package/lib/core/model/builder/ArkMethodBuilder.js +40 -5
  48. package/lib/core/model/builder/BodyBuilder.js +1 -1
  49. package/lib/pass/Dispatcher.d.ts +2 -2
  50. package/lib/pass/Dispatcher.d.ts.map +1 -1
  51. package/lib/pass/Pass.d.ts +3 -3
  52. package/lib/pass/Pass.d.ts.map +1 -1
  53. package/lib/pass/ScenePassMgr.d.ts +4 -4
  54. package/lib/pass/ScenePassMgr.d.ts.map +1 -1
  55. package/lib/pass/validators/Exprs.d.ts +9 -0
  56. package/lib/pass/validators/Exprs.d.ts.map +1 -0
  57. package/lib/pass/validators/Exprs.js +40 -0
  58. package/lib/pass/validators/Models.d.ts +14 -0
  59. package/lib/pass/validators/Models.d.ts.map +1 -0
  60. package/lib/pass/validators/Models.js +42 -0
  61. package/lib/pass/validators/SceneValidator.d.ts +19 -0
  62. package/lib/pass/validators/SceneValidator.d.ts.map +1 -0
  63. package/lib/pass/validators/SceneValidator.js +77 -0
  64. package/lib/pass/validators/Stmts.d.ts +7 -0
  65. package/lib/pass/validators/Stmts.d.ts.map +1 -0
  66. package/lib/pass/validators/Stmts.js +36 -0
  67. package/lib/pass/{SceneValidator.d.ts → validators/Validator.d.ts} +100 -108
  68. package/lib/pass/validators/Validator.d.ts.map +1 -0
  69. package/lib/pass/{SceneValidator.js → validators/Validator.js} +147 -143
  70. package/lib/pass/validators/Values.d.ts +7 -0
  71. package/lib/pass/validators/Values.d.ts.map +1 -0
  72. package/lib/pass/validators/Values.js +34 -0
  73. package/lib/save/source/SourceStmt.js +1 -1
  74. package/lib/save/source/SourceTransformer.d.ts.map +1 -1
  75. package/lib/save/source/SourceTransformer.js +16 -1
  76. package/lib/utils/FileUtils.js +1 -1
  77. package/package.json +2 -2
  78. package/lib/pass/SceneValidator.d.ts.map +0 -1
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.SdkPlugin = void 0;
18
+ const Expr_1 = require("../../../core/base/Expr");
19
+ const Local_1 = require("../../../core/base/Local");
20
+ const Stmt_1 = require("../../../core/base/Stmt");
21
+ const Type_1 = require("../../../core/base/Type");
22
+ const Pag_1 = require("../Pag");
23
+ const PTAUtils_1 = require("../PTAUtils");
24
+ /**
25
+ * SdkPlugin processes OpenHarmony and built-in SDK APIs.
26
+ * creates fake PAG nodes for SDK method return values and parameters.
27
+ */
28
+ class SdkPlugin {
29
+ constructor(pag, pagBuilder, cg) {
30
+ this.pag = pag;
31
+ this.pagBuilder = pagBuilder;
32
+ this.cg = cg;
33
+ this.sdkMethodReturnValueMap = new Map();
34
+ this.methodParamValueMap = new Map();
35
+ this.fakeSdkMethodParamDeclaringStmt = new Stmt_1.ArkAssignStmt(new Local_1.Local(''), new Local_1.Local(''));
36
+ }
37
+ getName() {
38
+ return 'SdkPlugin';
39
+ }
40
+ canHandle(cs, cgNode) {
41
+ let methodType = (0, PTAUtils_1.getBuiltInApiType)(cgNode.getMethod());
42
+ return cgNode.isSdkMethod() && (methodType === PTAUtils_1.BuiltApiType.NotBuiltIn);
43
+ }
44
+ processCallSite(cs, cid, basePTNode) {
45
+ let srcNodes = [];
46
+ this.addSDKMethodPagCallEdge(cs, cid, 0, srcNodes);
47
+ return srcNodes;
48
+ }
49
+ addSDKMethodPagCallEdge(cs, callerCid, calleeCid, srcNodes) {
50
+ let calleeFuncID = cs.getCalleeFuncID();
51
+ let calleeNode = this.cg.getNode(calleeFuncID);
52
+ let calleeMethod = this.cg.getArkMethodByFuncID(calleeFuncID);
53
+ if (!calleeMethod) {
54
+ return;
55
+ }
56
+ if (!this.methodParamValueMap.has(calleeNode.getID())) {
57
+ this.buildSDKFuncPag(calleeNode.getID(), calleeMethod);
58
+ }
59
+ this.addSDKMethodReturnPagEdge(cs, callerCid, calleeCid, calleeMethod, srcNodes);
60
+ this.addSDKMethodParamPagEdge(cs, callerCid, calleeCid, calleeNode.getID(), srcNodes);
61
+ return;
62
+ }
63
+ /**
64
+ * will not create real funcPag, only create param values
65
+ */
66
+ buildSDKFuncPag(funcID, sdkMethod) {
67
+ let paramArr = this.createDummyParamValue(sdkMethod);
68
+ this.methodParamValueMap.set(funcID, paramArr);
69
+ }
70
+ createDummyParamValue(sdkMethod) {
71
+ let args = sdkMethod.getParameters();
72
+ let paramArr = [];
73
+ if (!args) {
74
+ return paramArr;
75
+ }
76
+ // Local
77
+ args.forEach((arg) => {
78
+ let argInstance = new Local_1.Local(arg.getName(), arg.getType());
79
+ argInstance.setDeclaringStmt(this.fakeSdkMethodParamDeclaringStmt);
80
+ paramArr.push(argInstance);
81
+ });
82
+ return paramArr;
83
+ }
84
+ addSDKMethodReturnPagEdge(cs, callerCid, calleeCid, calleeMethod, srcNodes) {
85
+ let returnType = calleeMethod.getReturnType();
86
+ if (!(returnType instanceof Type_1.ClassType) || !(cs.callStmt instanceof Stmt_1.ArkAssignStmt)) {
87
+ return;
88
+ }
89
+ // check fake heap object exists or not
90
+ let cidMap = this.sdkMethodReturnValueMap.get(calleeMethod);
91
+ if (!cidMap) {
92
+ cidMap = new Map();
93
+ }
94
+ let newExpr = cidMap.get(calleeCid);
95
+ if (!newExpr) {
96
+ if (returnType instanceof Type_1.ClassType) {
97
+ newExpr = new Expr_1.ArkNewExpr(returnType);
98
+ }
99
+ }
100
+ cidMap.set(calleeCid, newExpr);
101
+ this.sdkMethodReturnValueMap.set(calleeMethod, cidMap);
102
+ let srcPagNode = this.pagBuilder.getOrNewPagNode(calleeCid, newExpr);
103
+ let dstPagNode = this.pagBuilder.getOrNewPagNode(callerCid, cs.callStmt.getLeftOp(), cs.callStmt);
104
+ this.pag.addPagEdge(srcPagNode, dstPagNode, Pag_1.PagEdgeKind.Address, cs.callStmt);
105
+ srcNodes.push(srcPagNode.getID());
106
+ return;
107
+ }
108
+ /**
109
+ * process the anonymous method param, create a new CallSite for it and invoke it.
110
+ */
111
+ addSDKMethodParamPagEdge(cs, callerCid, calleeCid, funcID, srcNodes) {
112
+ var _a, _b;
113
+ let argNum = (_a = cs.args) === null || _a === void 0 ? void 0 : _a.length;
114
+ if (!argNum) {
115
+ return;
116
+ }
117
+ // add args to parameters edges
118
+ for (let i = 0; i < argNum; i++) {
119
+ let arg = (_b = cs.args) === null || _b === void 0 ? void 0 : _b[i];
120
+ let paramValue;
121
+ if (arg instanceof Local_1.Local && arg.getType() instanceof Type_1.FunctionType) {
122
+ paramValue = this.methodParamValueMap.get(funcID)[i];
123
+ }
124
+ else {
125
+ continue;
126
+ }
127
+ if (!(arg && paramValue)) {
128
+ continue;
129
+ }
130
+ // Get or create new PAG node for argument and parameter
131
+ let srcPagNode = this.pagBuilder.getOrNewPagNode(callerCid, arg, cs.callStmt);
132
+ let dstPagNode = this.pagBuilder.getOrNewPagNode(calleeCid, paramValue, cs.callStmt);
133
+ if (dstPagNode instanceof Pag_1.PagLocalNode) {
134
+ // set the fake param Value in PagLocalNode
135
+ /**
136
+ * TODO: !!!
137
+ * some API param is in the form of anonymous method:
138
+ * component/common.d.ts
139
+ * declare function animateTo(value: AnimateParam, event: () => void): void;
140
+ *
141
+ * this param fake Value will create PagFuncNode rather than PagLocalNode
142
+ * when this API is called, the anonymous method pointer will not be able to pass into the fake Value PagNode
143
+ */
144
+ dstPagNode.setSdkParam();
145
+ let sdkParamInvokeStmt = new Stmt_1.ArkInvokeStmt(new Expr_1.ArkPtrInvokeExpr(arg.getType().getMethodSignature(), paramValue, []));
146
+ // create new DynCallSite
147
+ let sdkParamCallSite = this.cg.getCallSiteManager().newDynCallSite(sdkParamInvokeStmt, undefined, undefined, funcID);
148
+ dstPagNode.addRelatedDynCallSite(sdkParamCallSite);
149
+ }
150
+ this.pag.addPagEdge(srcPagNode, dstPagNode, Pag_1.PagEdgeKind.Copy, cs.callStmt);
151
+ srcNodes.push(srcPagNode.getID());
152
+ }
153
+ return;
154
+ }
155
+ getParamValues(method) {
156
+ const funcID = this.cg.getCallGraphNodeByMethod(method.getSignature()).getID();
157
+ return this.methodParamValueMap.get(funcID);
158
+ }
159
+ }
160
+ exports.SdkPlugin = SdkPlugin;
@@ -0,0 +1,68 @@
1
+ import { Stmt } from '../../../core/base/Stmt';
2
+ import { Value } from '../../../core/base/Value';
3
+ import { NodeID } from '../../../core/graph/GraphTraits';
4
+ import { CallGraph, CallGraphNode } from '../../model/CallGraph';
5
+ import { ICallSite } from '../../model/CallSite';
6
+ import { ContextID } from '../context/Context';
7
+ import { Pag, PagNode } from '../Pag';
8
+ import { PagBuilder } from '../PagBuilder';
9
+ import { IPagPlugin } from './IPagPlugin';
10
+ export declare enum StorageType {
11
+ APP_STORAGE = 0,
12
+ LOCAL_STORAGE = 1,
13
+ SUBSCRIBED_ABSTRACT_PROPERTY = 2,
14
+ Undefined = 3
15
+ }
16
+ export declare enum StorageLinkEdgeType {
17
+ Property2Local = 0,
18
+ Local2Property = 1,
19
+ TwoWay = 2
20
+ }
21
+ /**
22
+ * StoragePlugin processes AppStorage, LocalStorage, and SubscribedAbstractProperty APIs.
23
+ */
24
+ export declare class StoragePlugin implements IPagPlugin {
25
+ pag: Pag;
26
+ pagBuilder: PagBuilder;
27
+ cg: CallGraph;
28
+ private storagePropertyMap;
29
+ constructor(pag: Pag, pagBuilder: PagBuilder, cg: CallGraph);
30
+ getName(): string;
31
+ canHandle(cs: ICallSite, cgNode: CallGraphNode): boolean;
32
+ processCallSite(cs: ICallSite, cid: ContextID, emptyNode: NodeID): NodeID[];
33
+ /**
34
+ * get storageType enum with method's Declaring ClassName
35
+ *
36
+ * @param storageName ClassName that method belongs to, currently support AppStorage and SubscribedAbstractProperty
37
+ * SubscribedAbstractProperty: in following listing, `link1` is infered as ClassType `SubscribedAbstractProperty`,
38
+ * it needs to get PAG node to check the StorageType
39
+ * let link1: SubscribedAbstractProperty<A> = AppStorage.link('PropA');
40
+ * link1.set(a);
41
+ * @param cs: for search PAG node in SubscribedAbstractProperty
42
+ * @param cid: for search PAG node in SubscribedAbstractProperty
43
+ * @returns StorageType enum
44
+ */
45
+ private getStorageType;
46
+ private processStorageAPI;
47
+ private processStorageSetOrCreate;
48
+ /**
49
+ * search the storage map to get propertyNode with given storage and propertyFieldName
50
+ * @param storage storage type: AppStorage, LocalStorage etc.
51
+ * @param propertyName string property key
52
+ * @returns propertyNode: PagLocalNode
53
+ */
54
+ getOrNewPropertyNode(storage: StorageType, propertyName: string): PagNode;
55
+ /**
56
+ * add PagEdge
57
+ * @param edgeKind: edge kind differs from API
58
+ * @param propertyNode: PAG node created by protpertyName
59
+ * @param obj: heapObj stored with Storage API
60
+ */
61
+ addPropertyLinkEdge(propertyNode: PagNode, storageObj: Value, cid: ContextID, stmt: Stmt, edgeKind: number, srcNodes: NodeID[]): void;
62
+ private processStorageLink;
63
+ private processStorageProp;
64
+ private processStorageSet;
65
+ private processStorageGet;
66
+ private getPropertyName;
67
+ }
68
+ //# sourceMappingURL=StoragePlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StoragePlugin.d.ts","sourceRoot":"","sources":["../../../../src/callgraph/pointerAnalysis/plugins/StoragePlugin.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,IAAI,EAAiB,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAA6B,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,oBAAY,WAAW;IACnB,WAAW,IAAA;IACX,aAAa,IAAA;IACb,4BAA4B,IAAA;IAC5B,SAAS,IAAA;CACZ;AAED,oBAAY,mBAAmB;IAC3B,cAAc,IAAA;IACd,cAAc,IAAA;IACd,MAAM,IAAA;CACT;AAED;;GAEG;AACH,qBAAa,aAAc,YAAW,UAAU;IAC5C,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,UAAU,CAAC;IACvB,EAAE,EAAE,SAAS,CAAC;IACd,OAAO,CAAC,kBAAkB,CAAmD;gBAEjE,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS;IAU3D,OAAO,IAAI,MAAM;IAIjB,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO;IAKxD,eAAe,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAc3E;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,yBAAyB;IAoBjC;;;;;OAKG;IACI,oBAAoB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO;IAsBhF;;;;;OAKG;IACI,mBAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;IAuB5I,OAAO,CAAC,kBAAkB;IAyB1B,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,eAAe;CAY1B"}
@@ -0,0 +1,288 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.StoragePlugin = exports.StorageLinkEdgeType = exports.StorageType = void 0;
18
+ const Constant_1 = require("../../../core/base/Constant");
19
+ const Expr_1 = require("../../../core/base/Expr");
20
+ const Local_1 = require("../../../core/base/Local");
21
+ const Stmt_1 = require("../../../core/base/Stmt");
22
+ const Type_1 = require("../../../core/base/Type");
23
+ const Pag_1 = require("../Pag");
24
+ var StorageType;
25
+ (function (StorageType) {
26
+ StorageType[StorageType["APP_STORAGE"] = 0] = "APP_STORAGE";
27
+ StorageType[StorageType["LOCAL_STORAGE"] = 1] = "LOCAL_STORAGE";
28
+ StorageType[StorageType["SUBSCRIBED_ABSTRACT_PROPERTY"] = 2] = "SUBSCRIBED_ABSTRACT_PROPERTY";
29
+ StorageType[StorageType["Undefined"] = 3] = "Undefined";
30
+ })(StorageType = exports.StorageType || (exports.StorageType = {}));
31
+ ;
32
+ var StorageLinkEdgeType;
33
+ (function (StorageLinkEdgeType) {
34
+ StorageLinkEdgeType[StorageLinkEdgeType["Property2Local"] = 0] = "Property2Local";
35
+ StorageLinkEdgeType[StorageLinkEdgeType["Local2Property"] = 1] = "Local2Property";
36
+ StorageLinkEdgeType[StorageLinkEdgeType["TwoWay"] = 2] = "TwoWay";
37
+ })(StorageLinkEdgeType = exports.StorageLinkEdgeType || (exports.StorageLinkEdgeType = {}));
38
+ ;
39
+ /**
40
+ * StoragePlugin processes AppStorage, LocalStorage, and SubscribedAbstractProperty APIs.
41
+ */
42
+ class StoragePlugin {
43
+ constructor(pag, pagBuilder, cg) {
44
+ this.storagePropertyMap = new Map();
45
+ this.pag = pag;
46
+ this.pagBuilder = pagBuilder;
47
+ this.cg = cg;
48
+ // Initialize storagePropertyMap for each StorageType
49
+ this.storagePropertyMap.set(StorageType.APP_STORAGE, new Map());
50
+ this.storagePropertyMap.set(StorageType.LOCAL_STORAGE, new Map());
51
+ }
52
+ getName() {
53
+ return 'StoragePlugin';
54
+ }
55
+ canHandle(cs, cgNode) {
56
+ const storageName = cgNode.getMethod().getDeclaringClassSignature().getClassName();
57
+ return this.getStorageType(storageName) !== StorageType.Undefined;
58
+ }
59
+ processCallSite(cs, cid, emptyNode) {
60
+ let calleeFuncID = cs.getCalleeFuncID();
61
+ if (!calleeFuncID) {
62
+ return [];
63
+ }
64
+ const cgNode = this.cg.getNode(calleeFuncID);
65
+ const storageName = cgNode.getMethod().getDeclaringClassSignature().getClassName();
66
+ const storageType = this.getStorageType(storageName);
67
+ const calleeName = cgNode.getMethod().getMethodSubSignature().getMethodName();
68
+ return this.processStorageAPI(cs, cid, storageType, calleeName, this.pagBuilder);
69
+ }
70
+ /**
71
+ * get storageType enum with method's Declaring ClassName
72
+ *
73
+ * @param storageName ClassName that method belongs to, currently support AppStorage and SubscribedAbstractProperty
74
+ * SubscribedAbstractProperty: in following listing, `link1` is infered as ClassType `SubscribedAbstractProperty`,
75
+ * it needs to get PAG node to check the StorageType
76
+ * let link1: SubscribedAbstractProperty<A> = AppStorage.link('PropA');
77
+ * link1.set(a);
78
+ * @param cs: for search PAG node in SubscribedAbstractProperty
79
+ * @param cid: for search PAG node in SubscribedAbstractProperty
80
+ * @returns StorageType enum
81
+ */
82
+ getStorageType(storageName) {
83
+ switch (storageName) {
84
+ case 'AppStorage':
85
+ return StorageType.APP_STORAGE;
86
+ case 'SubscribedAbstractProperty':
87
+ return StorageType.SUBSCRIBED_ABSTRACT_PROPERTY;
88
+ case 'LocalStorage':
89
+ return StorageType.LOCAL_STORAGE;
90
+ default:
91
+ return StorageType.Undefined;
92
+ }
93
+ }
94
+ processStorageAPI(cs, cid, storageType, calleeName, pagBuilder) {
95
+ let srcNodes = [];
96
+ switch (calleeName) {
97
+ case 'setOrCreate':
98
+ this.processStorageSetOrCreate(cs, cid, storageType, srcNodes);
99
+ break;
100
+ case 'link':
101
+ this.processStorageLink(cs, cid, storageType, srcNodes);
102
+ break;
103
+ case 'prop':
104
+ this.processStorageProp(cs, cid, storageType, srcNodes);
105
+ break;
106
+ case 'set':
107
+ this.processStorageSet(cs, cid, storageType, srcNodes);
108
+ break;
109
+ case 'get':
110
+ this.processStorageGet(cs, cid, storageType, srcNodes);
111
+ break;
112
+ default:
113
+ break;
114
+ }
115
+ ;
116
+ return srcNodes;
117
+ }
118
+ processStorageSetOrCreate(cs, cid, storageType, srcNodes) {
119
+ let propertyStr = this.getPropertyName(cs.args[0]);
120
+ if (!propertyStr) {
121
+ return;
122
+ }
123
+ let propertyName = propertyStr;
124
+ let propertyNode = this.getOrNewPropertyNode(StorageType.APP_STORAGE, propertyName);
125
+ if (storageType === StorageType.APP_STORAGE) {
126
+ let storageObj = cs.args[1];
127
+ this.addPropertyLinkEdge(propertyNode, storageObj, cid, cs.callStmt, StorageLinkEdgeType.Local2Property, srcNodes);
128
+ }
129
+ else if (storageType === StorageType.LOCAL_STORAGE) {
130
+ // TODO: WIP
131
+ }
132
+ return;
133
+ }
134
+ /**
135
+ * search the storage map to get propertyNode with given storage and propertyFieldName
136
+ * @param storage storage type: AppStorage, LocalStorage etc.
137
+ * @param propertyName string property key
138
+ * @returns propertyNode: PagLocalNode
139
+ */
140
+ getOrNewPropertyNode(storage, propertyName) {
141
+ let storageMap = this.storagePropertyMap.get(storage);
142
+ let propertyLocal = storageMap.get(propertyName);
143
+ if (!propertyLocal) {
144
+ switch (storage) {
145
+ case StorageType.APP_STORAGE:
146
+ propertyLocal = new Local_1.Local('AppStorage.' + propertyName);
147
+ break;
148
+ case StorageType.LOCAL_STORAGE:
149
+ propertyLocal = new Local_1.Local('LocalStorage.' + propertyName);
150
+ break;
151
+ default:
152
+ propertyLocal = new Local_1.Local(propertyName);
153
+ }
154
+ ;
155
+ storageMap.set(propertyName, propertyLocal);
156
+ }
157
+ return this.pag.getOrNewNode(-1, propertyLocal);
158
+ }
159
+ /**
160
+ * add PagEdge
161
+ * @param edgeKind: edge kind differs from API
162
+ * @param propertyNode: PAG node created by protpertyName
163
+ * @param obj: heapObj stored with Storage API
164
+ */
165
+ addPropertyLinkEdge(propertyNode, storageObj, cid, stmt, edgeKind, srcNodes) {
166
+ if (!(storageObj.getType() instanceof Type_1.ClassType)) {
167
+ return;
168
+ }
169
+ let objNode = this.pag.getOrNewNode(cid, storageObj);
170
+ if (edgeKind === StorageLinkEdgeType.Property2Local) {
171
+ // propertyNode --> objNode
172
+ this.pag.addPagEdge(propertyNode, objNode, Pag_1.PagEdgeKind.Copy, stmt);
173
+ srcNodes.push(propertyNode.getID());
174
+ }
175
+ else if (edgeKind === StorageLinkEdgeType.Local2Property) {
176
+ // propertyNode <-- objNode
177
+ this.pag.addPagEdge(objNode, propertyNode, Pag_1.PagEdgeKind.Copy, stmt);
178
+ srcNodes.push(objNode.getID());
179
+ }
180
+ else if (edgeKind === StorageLinkEdgeType.TwoWay) {
181
+ // propertyNode <-> objNode
182
+ this.pag.addPagEdge(propertyNode, objNode, Pag_1.PagEdgeKind.Copy, stmt);
183
+ this.pag.addPagEdge(objNode, propertyNode, Pag_1.PagEdgeKind.Copy, stmt);
184
+ srcNodes.push(propertyNode.getID(), objNode.getID());
185
+ }
186
+ return;
187
+ }
188
+ processStorageLink(cs, cid, storageType, srcNodes) {
189
+ let propertyStr = this.getPropertyName(cs.args[0]);
190
+ if (!propertyStr) {
191
+ return;
192
+ }
193
+ let propertyName = propertyStr;
194
+ let propertyNode = this.getOrNewPropertyNode(StorageType.APP_STORAGE, propertyName);
195
+ let leftOp = cs.callStmt.getLeftOp();
196
+ let linkedOpNode = this.pag.getOrNewNode(cid, leftOp);
197
+ if (storageType === StorageType.APP_STORAGE) {
198
+ if (linkedOpNode instanceof Pag_1.PagLocalNode) {
199
+ linkedOpNode.setStorageLink(StorageType.APP_STORAGE, propertyName);
200
+ }
201
+ this.pag.addPagEdge(propertyNode, linkedOpNode, Pag_1.PagEdgeKind.Copy);
202
+ this.pag.addPagEdge(linkedOpNode, propertyNode, Pag_1.PagEdgeKind.Copy);
203
+ srcNodes.push(propertyNode.getID(), linkedOpNode.getID());
204
+ }
205
+ else if (storageType === StorageType.LOCAL_STORAGE) {
206
+ // TODO: WIP
207
+ }
208
+ return;
209
+ }
210
+ processStorageProp(cs, cid, storageType, srcNodes) {
211
+ let propertyStr = this.getPropertyName(cs.args[0]);
212
+ if (!propertyStr) {
213
+ return;
214
+ }
215
+ let propertyName = propertyStr;
216
+ let propertyNode = this.getOrNewPropertyNode(StorageType.APP_STORAGE, propertyName);
217
+ let leftOp = cs.callStmt.getLeftOp();
218
+ let propedOpNode = this.pag.getOrNewNode(cid, leftOp);
219
+ if (storageType === StorageType.APP_STORAGE) {
220
+ if (propedOpNode instanceof Pag_1.PagLocalNode) {
221
+ propedOpNode.setStorageLink(StorageType.APP_STORAGE, propertyName);
222
+ }
223
+ this.pag.addPagEdge(propertyNode, propedOpNode, Pag_1.PagEdgeKind.Copy);
224
+ srcNodes.push(propertyNode.getID());
225
+ }
226
+ else if (storageType === StorageType.LOCAL_STORAGE) {
227
+ // TODO: WIP
228
+ }
229
+ return;
230
+ }
231
+ processStorageSet(cs, cid, storageType, srcNodes) {
232
+ let ivkExpr = cs.callStmt.getInvokeExpr();
233
+ if (ivkExpr instanceof Expr_1.ArkInstanceInvokeExpr) {
234
+ let base = ivkExpr.getBase();
235
+ let baseNode = this.pag.getOrNewNode(cid, base);
236
+ if (baseNode.isStorageLinked()) {
237
+ let argsNode = this.pag.getOrNewNode(cid, cs.args[0]);
238
+ this.pag.addPagEdge(argsNode, baseNode, Pag_1.PagEdgeKind.Copy);
239
+ srcNodes.push(argsNode.getID());
240
+ return;
241
+ }
242
+ }
243
+ else if (ivkExpr instanceof Expr_1.ArkStaticInvokeExpr) {
244
+ // TODO: process AppStorage.set()
245
+ }
246
+ return;
247
+ }
248
+ processStorageGet(cs, cid, storageType, srcNodes) {
249
+ if (!(cs.callStmt instanceof Stmt_1.ArkAssignStmt)) {
250
+ return;
251
+ }
252
+ let leftOp = cs.callStmt.getLeftOp();
253
+ let leftOpNode = this.pag.getOrNewNode(cid, leftOp);
254
+ let ivkExpr = cs.callStmt.getInvokeExpr();
255
+ let propertyName;
256
+ if (ivkExpr instanceof Expr_1.ArkStaticInvokeExpr) {
257
+ let propertyStr = this.getPropertyName(cs.args[0]);
258
+ if (propertyStr) {
259
+ propertyName = propertyStr;
260
+ }
261
+ let propertyNode = this.getOrNewPropertyNode(storageType, propertyName);
262
+ if (!propertyNode) {
263
+ return;
264
+ }
265
+ this.pag.addPagEdge(propertyNode, leftOpNode, Pag_1.PagEdgeKind.Copy, cs.callStmt);
266
+ srcNodes.push(propertyNode.getID());
267
+ }
268
+ else if (ivkExpr instanceof Expr_1.ArkInstanceInvokeExpr) {
269
+ let baseNode = this.pag.getOrNewNode(cid, ivkExpr.getBase());
270
+ this.pag.addPagEdge(baseNode, leftOpNode, Pag_1.PagEdgeKind.Copy, cs.callStmt);
271
+ srcNodes.push(baseNode.getID());
272
+ }
273
+ return;
274
+ }
275
+ getPropertyName(value) {
276
+ if (value instanceof Local_1.Local) {
277
+ let type = value.getType();
278
+ if (type instanceof Type_1.StringType) {
279
+ return type.getName();
280
+ }
281
+ }
282
+ else if (value instanceof Constant_1.Constant) {
283
+ return value.getValue();
284
+ }
285
+ return undefined;
286
+ }
287
+ }
288
+ exports.StoragePlugin = StoragePlugin;
@@ -228,7 +228,7 @@ class DummyMainCreater {
228
228
  const whileStmt = new Stmt_1.ArkIfStmt(conditionTrue);
229
229
  firstBlock.addStmt(countAssignStmt);
230
230
  dummyCfg.addBlock(firstBlock);
231
- dummyCfg.setStartingStmt(firstBlock.getStmts()[0]);
231
+ dummyCfg.setStartingStmt(firstBlock.getHead());
232
232
  const whileBlock = new BasicBlock_1.BasicBlock();
233
233
  whileBlock.addStmt(whileStmt);
234
234
  dummyCfg.addBlock(whileBlock);
@@ -1 +1 @@
1
- {"version":3,"file":"IRInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/IRInference.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAKH,SAAS,EAKT,IAAI,EAKP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EAErB,mBAAmB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,OAAO,EAGH,cAAc,EAEd,eAAe,EAElB,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAEH,WAAW,EAEX,mBAAmB,EACnB,eAAe,EAElB,MAAM,aAAa,CAAC;AAYrB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKlF,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAqB/B,OAAO,CAAC,MAAM,CAAC,gBAAgB;WAMjB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;WAyB9B,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,EAAE,SAAS,EAAE,SAAS,GAAG,kBAAkB;IAyCxG,OAAO,CAAC,MAAM,CAAC,iCAAiC;WAwClC,uBAAuB,CAAC,IAAI,EAAE,qBAAqB,EAAE,SAAS,EAAE,SAAS,GAAG,kBAAkB;IA6B5G;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;WAkBlB,aAAa,CAAC,GAAG,EAAE,mBAAmB,EAAE,SAAS,EAAE,SAAS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WAiChB,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,YAAY;WAiC3E,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;WA2CnE,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;WAcnE,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,GAAG,WAAW;CAsB3F"}
@@ -198,6 +198,10 @@ class IRInference {
198
198
  this.inferBase(expr, arkMethod);
199
199
  const baseType = TypeInference_1.TypeInference.replaceAliasType(expr.getBase().getType());
200
200
  let methodName = expr.getMethodSignature().getMethodSubSignature().getMethodName();
201
+ if (methodName === TSConst_1.CONSTRUCTOR_NAME &&
202
+ expr.getMethodSignature().getDeclaringClassSignature().getDeclaringFileSignature().getFileName() !== Const_1.UNKNOWN_FILE_NAME) {
203
+ return expr;
204
+ }
201
205
  if (methodName.startsWith(Const_1.NAME_PREFIX)) {
202
206
  const declaringStmt = (_b = (_a = arkMethod.getBody()) === null || _a === void 0 ? void 0 : _a.getLocals().get(methodName)) === null || _b === void 0 ? void 0 : _b.getDeclaringStmt();
203
207
  if (declaringStmt instanceof Stmt_1.ArkAssignStmt && declaringStmt.getRightOp() instanceof Ref_1.ArkInstanceFieldRef) {
@@ -9,8 +9,8 @@ export declare class SdkUtils {
9
9
  private static sdkImportMap;
10
10
  static BUILT_IN_NAME: string;
11
11
  private static BUILT_IN_PATH;
12
- static BUILT_IN_SDK: Sdk;
13
12
  static setEsVersion(buildProfile: any): void;
13
+ static getBuiltInSdk(): Sdk;
14
14
  static fetchBuiltInFiles(builtInPath: string): string[];
15
15
  private static dfsFiles;
16
16
  static dispose(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"SdkUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/SdkUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAA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qBrE,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;WAWtE,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,QAAQ,GAAE,OAAe,GAAG,IAAI;WAY3F,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;IAgBrF,OAAO,CAAC,MAAM,CAAC,SAAS;IAiBxB,OAAO,CAAC,MAAM,CAAC,eAAe;IA0B9B,OAAO,CAAC,MAAM,CAAC,WAAW;WAkBZ,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;CAUxF"}
@@ -63,21 +63,26 @@ class SdkUtils {
63
63
  this.esVersion = version;
64
64
  }
65
65
  }
66
+ static getBuiltInSdk() {
67
+ let builtInPath;
68
+ try {
69
+ // If arkanalyzer is used as dependency by other project, the base directory should be the module path.
70
+ const moduleRoot = path_1.default.dirname(path_1.default.dirname(require.resolve('arkanalyzer')));
71
+ builtInPath = path_1.default.join(moduleRoot, this.BUILT_IN_PATH);
72
+ logger.debug(`arkanalyzer is used as dependency, so using builtin sdk file in ${builtInPath}.`);
73
+ }
74
+ catch (_a) {
75
+ builtInPath = path_1.default.resolve(this.BUILT_IN_PATH);
76
+ logger.debug(`use builtin sdk file in ${builtInPath}.`);
77
+ }
78
+ return {
79
+ moduleName: '',
80
+ name: this.BUILT_IN_NAME,
81
+ path: builtInPath
82
+ };
83
+ }
66
84
  static fetchBuiltInFiles(builtInPath) {
67
85
  var _a;
68
- if (!builtInPath) {
69
- try {
70
- // If arkanalyzer is used as dependency by other project, the base directory should be the module path.
71
- const moduleRoot = path_1.default.dirname(path_1.default.dirname(require.resolve('arkanalyzer')));
72
- builtInPath = path_1.default.join(moduleRoot, this.BUILT_IN_PATH);
73
- logger.debug(`arkanalyzer is used as dependency, so using builtin sdk file in ${builtInPath}.`);
74
- }
75
- catch (_b) {
76
- builtInPath = path_1.default.resolve(this.BUILT_IN_PATH);
77
- logger.debug(`use builtin sdk file in ${builtInPath}.`);
78
- }
79
- this.BUILT_IN_SDK.path = builtInPath;
80
- }
81
86
  const filePath = path_1.default.resolve(builtInPath, (_a = this.esVersionMap.get(this.esVersion)) !== null && _a !== void 0 ? _a : '');
82
87
  if (!fs_1.default.existsSync(filePath)) {
83
88
  logger.error(`built in directory ${filePath} is not exist, please check!`);
@@ -261,8 +266,3 @@ SdkUtils.esVersionMap = new Map([
261
266
  SdkUtils.sdkImportMap = new Map();
262
267
  SdkUtils.BUILT_IN_NAME = 'built-in';
263
268
  SdkUtils.BUILT_IN_PATH = 'node_modules/ohos-typescript/lib';
264
- SdkUtils.BUILT_IN_SDK = {
265
- moduleName: '',
266
- name: `${SdkUtils.BUILT_IN_NAME}`,
267
- path: ''
268
- };
@@ -1 +1 @@
1
- {"version":3,"file":"TypeInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/TypeInference.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAwD,IAAI,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EASH,YAAY,EACZ,WAAW,EAOX,IAAI,EACJ,oBAAoB,EAKvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAiB,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAuBtC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAsB,MAAM,uBAAuB,CAAC;AAIhG,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;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