arkanalyzer 1.0.28 → 1.0.30

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 (88) hide show
  1. package/lib/Config.d.ts.map +1 -1
  2. package/lib/Config.js +9 -1
  3. package/lib/Scene.d.ts +7 -0
  4. package/lib/Scene.d.ts.map +1 -1
  5. package/lib/Scene.js +196 -173
  6. package/lib/VFG/builder/DVFGBuilder.d.ts.map +1 -1
  7. package/lib/VFG/builder/DVFGBuilder.js +11 -6
  8. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +3 -1
  9. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
  10. package/lib/callgraph/algorithm/AbstractAnalysis.js +18 -10
  11. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
  12. package/lib/callgraph/algorithm/RapidTypeAnalysis.js +8 -7
  13. package/lib/callgraph/common/Statistics.d.ts.map +1 -1
  14. package/lib/callgraph/common/Statistics.js +25 -24
  15. package/lib/callgraph/model/CallGraph.d.ts +1 -1
  16. package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
  17. package/lib/callgraph/model/CallGraph.js +6 -3
  18. package/lib/callgraph/pointerAnalysis/Context.d.ts.map +1 -1
  19. package/lib/callgraph/pointerAnalysis/Context.js +0 -1
  20. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  21. package/lib/callgraph/pointerAnalysis/Pag.js +26 -26
  22. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +4 -0
  23. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
  24. package/lib/callgraph/pointerAnalysis/PagBuilder.js +138 -108
  25. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
  26. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +15 -14
  27. package/lib/core/base/Expr.d.ts.map +1 -1
  28. package/lib/core/base/Expr.js +6 -4
  29. package/lib/core/base/Type.d.ts +10 -1
  30. package/lib/core/base/Type.d.ts.map +1 -1
  31. package/lib/core/base/Type.js +18 -1
  32. package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
  33. package/lib/core/common/ArkValueTransformer.js +3 -1
  34. package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
  35. package/lib/core/common/DummyMainCreater.js +17 -20
  36. package/lib/core/common/IRInference.d.ts.map +1 -1
  37. package/lib/core/common/IRInference.js +18 -10
  38. package/lib/core/common/TypeInference.d.ts.map +1 -1
  39. package/lib/core/common/TypeInference.js +13 -2
  40. package/lib/core/dataflow/DataflowSolver.d.ts +1 -0
  41. package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -1
  42. package/lib/core/dataflow/DataflowSolver.js +21 -17
  43. package/lib/core/dataflow/ReachingDef.d.ts.map +1 -1
  44. package/lib/core/dataflow/ReachingDef.js +6 -0
  45. package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -1
  46. package/lib/core/dataflow/UndefinedVariable.js +0 -25
  47. package/lib/core/graph/Cfg.d.ts +1 -0
  48. package/lib/core/graph/Cfg.d.ts.map +1 -1
  49. package/lib/core/graph/Cfg.js +49 -45
  50. package/lib/core/graph/DominanceFinder.js +19 -19
  51. package/lib/core/graph/builder/ViewTreeBuilder.d.ts +1 -0
  52. package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
  53. package/lib/core/graph/builder/ViewTreeBuilder.js +34 -31
  54. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  55. package/lib/core/model/ArkMethod.js +13 -6
  56. package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
  57. package/lib/core/model/builder/builderUtils.js +72 -63
  58. package/lib/save/serializeArkIR.d.ts.map +1 -1
  59. package/lib/save/serializeArkIR.js +11 -24
  60. package/lib/save/source/SourceBody.js +10 -10
  61. package/lib/save/source/SourceFilePrinter.d.ts +1 -0
  62. package/lib/save/source/SourceFilePrinter.d.ts.map +1 -1
  63. package/lib/save/source/SourceFilePrinter.js +11 -8
  64. package/lib/save/source/SourceNamespace.d.ts +1 -0
  65. package/lib/save/source/SourceNamespace.d.ts.map +1 -1
  66. package/lib/save/source/SourceNamespace.js +11 -8
  67. package/lib/save/source/SourceStmt.d.ts +1 -0
  68. package/lib/save/source/SourceStmt.d.ts.map +1 -1
  69. package/lib/save/source/SourceStmt.js +37 -35
  70. package/lib/save/source/SourceTransformer.d.ts +2 -0
  71. package/lib/save/source/SourceTransformer.d.ts.map +1 -1
  72. package/lib/save/source/SourceTransformer.js +64 -54
  73. package/lib/transformer/StaticSingleAssignmentFormer.d.ts +5 -0
  74. package/lib/transformer/StaticSingleAssignmentFormer.d.ts.map +1 -1
  75. package/lib/transformer/StaticSingleAssignmentFormer.js +119 -101
  76. package/lib/utils/CfgStructualAnalysis.d.ts +1 -0
  77. package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -1
  78. package/lib/utils/CfgStructualAnalysis.js +28 -24
  79. package/lib/utils/FileUtils.d.ts.map +1 -1
  80. package/lib/utils/FileUtils.js +14 -12
  81. package/lib/utils/callGraphUtils.d.ts.map +1 -1
  82. package/lib/utils/callGraphUtils.js +26 -23
  83. package/lib/utils/entryMethodUtils.d.ts.map +1 -1
  84. package/lib/utils/entryMethodUtils.js +11 -8
  85. package/lib/utils/pathTransfer.d.ts +1 -0
  86. package/lib/utils/pathTransfer.d.ts.map +1 -1
  87. package/lib/utils/pathTransfer.js +10 -1
  88. package/package.json +2 -2
@@ -92,15 +92,16 @@ class SceneManager {
92
92
  }
93
93
  getMethod(method) {
94
94
  let targetMethod = this._scene.getMethod(method);
95
- if (targetMethod == null) {
96
- // 支持SDK调用解析
97
- let file = this._scene.getFile(method.getDeclaringClassSignature().getDeclaringFileSignature());
98
- if (file) {
99
- const methods = ModelUtils_1.ModelUtils.getAllMethodsInFile(file);
100
- for (let methodUnderFile of methods) {
101
- if (method.toString() === methodUnderFile.getSignature().toString()) {
102
- return methodUnderFile;
103
- }
95
+ if (targetMethod != null) {
96
+ return targetMethod;
97
+ }
98
+ // 支持SDK调用解析
99
+ let file = this._scene.getFile(method.getDeclaringClassSignature().getDeclaringFileSignature());
100
+ if (file) {
101
+ const methods = ModelUtils_1.ModelUtils.getAllMethodsInFile(file);
102
+ for (let methodUnderFile of methods) {
103
+ if (method.toString() === methodUnderFile.getSignature().toString()) {
104
+ return methodUnderFile;
104
105
  }
105
106
  }
106
107
  }
@@ -110,14 +111,15 @@ class SceneManager {
110
111
  if (typeof arkClass.getClassName() === "undefined")
111
112
  return null;
112
113
  let classInstance = this._scene.getClass(arkClass);
113
- if (classInstance == null) {
114
- let sdkOrTargetProjectFile = this._scene.getFile(arkClass.getDeclaringFileSignature());
115
- // TODO: support get sdk class, targetProject class waiting to be supported
116
- if (sdkOrTargetProjectFile != null) {
117
- for (let classUnderFile of ModelUtils_1.ModelUtils.getAllClassesInFile(sdkOrTargetProjectFile)) {
118
- if (classUnderFile.getSignature().toString() === arkClass.toString()) {
119
- return classUnderFile;
120
- }
114
+ if (classInstance != null) {
115
+ return classInstance;
116
+ }
117
+ let sdkOrTargetProjectFile = this._scene.getFile(arkClass.getDeclaringFileSignature());
118
+ // TODO: support get sdk class, targetProject class waiting to be supported
119
+ if (sdkOrTargetProjectFile != null) {
120
+ for (let classUnderFile of ModelUtils_1.ModelUtils.getAllClassesInFile(sdkOrTargetProjectFile)) {
121
+ if (classUnderFile.getSignature().toString() === arkClass.toString()) {
122
+ return classUnderFile;
121
123
  }
122
124
  }
123
125
  }
@@ -132,12 +134,13 @@ class SceneManager {
132
134
  if (tempClass == null)
133
135
  continue;
134
136
  let firstLevelSubclasses = Array.from(tempClass.getExtendedClasses().values());
135
- if (firstLevelSubclasses) {
136
- for (let subclass of firstLevelSubclasses) {
137
- if (!isItemRegistered(subclass, extendedClasses, (a, b) => a.getSignature().toString() === b.getSignature().toString())) {
138
- // 子类未处理,加入到classList
139
- classList.push(subclass);
140
- }
137
+ if (!firstLevelSubclasses) {
138
+ continue;
139
+ }
140
+ for (let subclass of firstLevelSubclasses) {
141
+ if (!isItemRegistered(subclass, extendedClasses, (a, b) => a.getSignature().toString() === b.getSignature().toString())) {
142
+ // 子类未处理,加入到classList
143
+ classList.push(subclass);
141
144
  }
142
145
  }
143
146
  // 当前类处理完毕,标记为已处理
@@ -1 +1 @@
1
- {"version":3,"file":"entryMethodUtils.d.ts","sourceRoot":"","sources":["../../src/utils/entryMethodUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,eAAO,MAAM,qBAAqB,EAAE,MAAM,EA2BvC,CAAC;AACJ,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAiBtC,CAAC;AAEJ,eAAO,MAAM,+BAA+B,EAAE,MAAM,EAkBnD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,CAcpF;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,QAS5C"}
1
+ {"version":3,"file":"entryMethodUtils.d.ts","sourceRoot":"","sources":["../../src/utils/entryMethodUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,eAAO,MAAM,qBAAqB,EAAE,MAAM,EA2BvC,CAAC;AACJ,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAiBtC,CAAC;AAEJ,eAAO,MAAM,+BAA+B,EAAE,MAAM,EAkBnD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,CAkBpF;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,QAS5C"}
@@ -83,14 +83,17 @@ exports.COMPONENT_LIFECYCLE_METHOD_NAME = [
83
83
  ];
84
84
  function getCallbackMethodFromStmt(stmt, scene) {
85
85
  const invokeExpr = stmt.getInvokeExpr();
86
- if (invokeExpr && invokeExpr.getMethodSignature().getDeclaringClassSignature().getClassName() === '' && exports.CALLBACK_METHOD_NAME.includes(invokeExpr.getMethodSignature().getMethodSubSignature().getMethodName())) {
87
- for (const arg of invokeExpr.getArgs()) {
88
- const argType = arg.getType();
89
- if (argType instanceof Type_1.FunctionType) {
90
- const cbMethod = scene.getMethod(argType.getMethodSignature());
91
- if (cbMethod) {
92
- return cbMethod;
93
- }
86
+ if (invokeExpr === undefined ||
87
+ invokeExpr.getMethodSignature().getDeclaringClassSignature().getClassName() !== '' ||
88
+ !exports.CALLBACK_METHOD_NAME.includes(invokeExpr.getMethodSignature().getMethodSubSignature().getMethodName())) {
89
+ return null;
90
+ }
91
+ for (const arg of invokeExpr.getArgs()) {
92
+ const argType = arg.getType();
93
+ if (argType instanceof Type_1.FunctionType) {
94
+ const cbMethod = scene.getMethod(argType.getMethodSignature());
95
+ if (cbMethod) {
96
+ return cbMethod;
94
97
  }
95
98
  }
96
99
  }
@@ -1,2 +1,3 @@
1
1
  export declare function transfer2UnixPath(path2Do: string): string;
2
+ export declare function getArkAnalyzerModulePath(moduleName: string): string | null;
2
3
  //# sourceMappingURL=pathTransfer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pathTransfer.d.ts","sourceRoot":"","sources":["../../src/utils/pathTransfer.ts"],"names":[],"mappings":"AAiBA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,UAEhD"}
1
+ {"version":3,"file":"pathTransfer.d.ts","sourceRoot":"","sources":["../../src/utils/pathTransfer.ts"],"names":[],"mappings":"AAiBA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,UAEhD;AAED,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM1E"}
@@ -17,9 +17,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.transfer2UnixPath = void 0;
20
+ exports.getArkAnalyzerModulePath = exports.transfer2UnixPath = void 0;
21
21
  const path_1 = __importDefault(require("path"));
22
22
  function transfer2UnixPath(path2Do) {
23
23
  return path_1.default.posix.join(...path2Do.split(/\\/));
24
24
  }
25
25
  exports.transfer2UnixPath = transfer2UnixPath;
26
+ function getArkAnalyzerModulePath(moduleName) {
27
+ try {
28
+ return path_1.default.dirname(path_1.default.dirname(require.resolve(moduleName)));
29
+ }
30
+ catch (e) {
31
+ return null;
32
+ }
33
+ }
34
+ exports.getArkAnalyzerModulePath = getArkAnalyzerModulePath;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arkanalyzer",
3
- "version": "1.0.28",
4
- "commit_id": "877281e0",
3
+ "version": "1.0.30",
4
+ "commit_id": "564ef96e",
5
5
  "files": [
6
6
  "docs",
7
7
  "lib",