connglli / ELEGANT

ELEGANT - a tool to Effectively LocatE fraGmentAtion-iNduced compaTibility issues.
MIT License
3 stars 0 forks source link

weekly report: 2018.03.21-2018.03.27 #16

Closed connglli closed 6 years ago

connglli commented 6 years ago

周报

这周的工作就按照上周所说的:

  1. 根据之前的 weekly report (第 4 份) 重新对比了从 empirical study 中获取到的 api context pair,并做了重新整理(目前只是重新修改和整理了之前已经发现的,对之前没能发现的这周也暂时没有分析,这是后续的工作)。
  2. 对目前已经构建好的所有 app,关掉 validate 阶段(每个都是 detect/validate/generate 三个阶段,分别做 call site tree 生成、剪枝和生成 issue 的工作),一个个地查看能否发现论文和 github issues 中提到的问题。

因为这周的工作比较零碎,所以以单条列在下面,其中 :white_check_mark: 表示发现并已经完成的部分,:exclamation: 根据优先级(越多表示优先级越高)表示发现并且正在进行/还未进行的工作。

  1. :white_check_mark: 需要在 ApiContext 的 context 里加入新的标记

    • message:string 用于打印一些针对该 acpair 想要输出的信息。
    • important:string 当非空时,表示通知 ficfinder,当 important 对应的 context 的条件检测到时,不需要进行 validate,如果 detect 到,直接报告。

    如:

    {
       "api": {
           "@type": "method",
           "pkg": "android.view",
           "iface": "View",
           "method": "setFocusableInTouchMode",
           "ret": {
               "pkg": "",
               "iface": "void"
           },
           "paramList": [
               {
                   "pkg": "",
                   "iface": "boolean"
               }
           ]
       },
       "context": {
           "min_api_level": 8,
           "important": "min_api_level",
           "message": "this api is recommended to be used together with `void setFocusable(boolean)` when your app is running on Froyo(2.2) or lower. Check https://issuetracker.google.com/issues/36908479 for more help"
       }
    },
    {
       "api": {
           "@type": "method",
           "pkg": "android.widget",
           "iface": "RemoteViews",
           "method": "setViewVisibility",
           "ret": {
               "pkg": "",
               "iface": "void"
           },
           "paramList": [
               {
                   "pkg": "",
                   "iface": "int"
               },
               {
                   "pkg": "",
                   "iface": "int"
               }
           ]
       },
       "context": {
           "min_api_level": 8,
           "important": "min_api_level",
           "message": "this api is not recommended to be used together with progress bar when your app is running on Froyo(2.2) or lower. If you have to use it on Froyo(2.2) or lower, try to wrap the progress bar in a LinearLayout or FrameLayout and use setViewVisibility() to make the Layout INVISIBLE/GONE instead of the progress bar. Check https://issuetracker.google.com/issues/36921090 for more help"
       }
    },
    {
       "api": {
           "@type": "method",
           "pkg": "android.content",
           "iface": "ContentProvider",
           "method": "query",
           "ret": {
               "pkg": "android.database",
               "iface": "Cursor"
           },
           "paramList": [
               {
                   "pkg": "android.net",
                   "iface": "Uri"
               },
               {
                   "pkg": "java.lang",
                   "iface": "String[]"
               },
               {
                   "pkg": "android.os",
                   "iface": "Bundle"
               },
               {
                   "pkg": "android.os",
                   "iface": "CancellationSignal"
               }
           ]
       },
       "context": {
           "max_api_level": 23,
           "important": "max_api_level",
           "message": "this api is recommended to be used together with the permission controll when your app is running on android 23 or higher. Check https://github.com/ankidroid/Anki-Android/commit/f5fab36ce309ce2d1e327cfc3fb59db85c609f96 for more help"
       }
    },
    {
       "api": {
           "@type": "method",
           "pkg": "android.content",
           "iface": "ContentProvider",
           "method": "update",
           "ret": {
               "pkg": "",
               "iface": "int"
           },
           "paramList": [
               {
                   "pkg": "android.net",
                   "iface": "Uri"
               },
               {
                   "pkg": "android.content",
                   "iface": "ContentValues"
               },
               {
                   "pkg": "java.lang",
                   "iface": "String"
               },
               {
                   "pkg": "java.lang",
                   "iface": "String[]"
               }
           ]
       },
       "context": {
           "max_api_level": 23,
           "important": "max_api_level",
           "message": "this api is recommended to be used together with the permission controll when your app is running on android 23 or higher. Check https://github.com/ankidroid/Anki-Android/commit/f5fab36ce309ce2d1e327cfc3fb59db85c609f96 for more help"
       }
    },
    {
       "api": {
           "@type": "method",
           "pkg": "android.content",
           "iface": "ContentProvider",
           "method": "insert",
           "ret": {
               "pkg": "android.net",
               "iface": "Uri"
           },
           "paramList": [
               {
                   "pkg": "android.net",
                   "iface": "Uri"
               },
               {
                   "pkg": "java.lang",
                   "iface": "String"
               },
               {
                   "pkg": "java.lang",
                   "iface": "String[]"
               }
           ]
       },
       "context": {
           "max_api_level": 23,
           "important": "max_api_level",
           "message": "this api is recommended to be used together with the permission controll when your app is running on android 23 or higher. Check https://github.com/ankidroid/Anki-Android/commit/f5fab36ce309ce2d1e327cfc3fb59db85c609f96 for more help"
       }
    },
    {
       "api": {
           "@type": "method",
           "pkg": "android.content",
           "iface": "ContentProvider",
           "method": "delete",
           "ret": {
               "pkg": "",
               "iface": "int"
           },
           "paramList": [
               {
                   "pkg": "android.net",
                   "iface": "Uri"
               },
               {
                   "pkg": "android.content",
                   "iface": "ContentValues"
               },
           ]
       },
       "context": {
           "max_api_level": 23,
           "important": "max_api_level",
           "message": "this api is recommended to be used together with the permission controll when your app is running on android 23 or higher. Check https://github.com/ankidroid/Anki-Android/commit/f5fab36ce309ce2d1e327cfc3fb59db85c609f96 for more help"
       }
    },
    {
       "api": {
           "@type": "method",
           "pkg": "android.content",
           "iface": "ContentProvider",
           "method": "bulkInsert",
           "ret": {
               "pkg": "",
               "iface": "int"
           },
           "paramList": [
               {
                   "pkg": "android.net",
                   "iface": "Uri"
               },
               {
                   "pkg": "android.content",
                   "iface": "ContentValues[]"
               },
           ]
       },
       "context": {
           "max_api_level": 23,
           "important": "max_api_level",
           "message": "this api is recommended to be used together with the permission controll when your app is running on android 23 or higher. Check https://github.com/ankidroid/Anki-Android/commit/f5fab36ce309ce2d1e327cfc3fb59db85c609f96 for more help"
       }
    },
    {
       "api": {
           "@type": "method",
           "pkg": "android.content",
           "iface": "ContentValues",
           "method": "put",
           "ret": {
               "pkg": "",
               "iface": "void"
           },
           "paramList": [
               {
                   "pkg": "java.lang",
                   "iface": "String"
               },
               {
                   "pkg": "java.lang",
                   "iface": "Short"
               }
           ]
       },
       "context": {
           "bad_devices": [
               "saga"
           ],
           "important": "bad_devices",
           "message": "this api is recommended to be used together with cv.put(Data.RAW_CONTACT_ID, someId) when your app is running one HTC desire S series. Check https://github.com/r3gis3r/CSipSimple/blob/340eea18b5143d1ff0c33c5fab4b5be272689203/src/com/csipsimple/utils/CallLogHelper.java for more help"
       }
    },

    其他的还有 setFocusable/setFocusableInTouchMode

  2. :white_check_mark: 所有的 IssueHandle 改一下,统一放到一块儿,ApiContext 加一个 report(Out) 方法,用于对 ApiContext 进行报告,IssueHandle 仅仅报告 Issue 相关的,而不报告 ApiContext 相关的。改成类似于:

    model.report(out);
    out.out(...);
    
    // 加一句
    out.out("Ignore it if it does not happen in your project.");
  3. :white_check_mark: 与 2 相关,需要加一个配置选项—out 用于对 technique report 进行重定向输出。

    • stdout: System.out
    • stderr: System.err
    • file: new PrintStream("file")
  4. :white_check_mark: 与 2 相关,PubSub 加入默认实现,即 Tracker 的实现,放到 utils 下,同时修改 Tracker 仅继承自 PubSub 而已,放到 core.finder 下。

  5. :white_check_mark: 与 2 相关,加入一个默认的 Handle 类,在 core.trackertracker 中其中包含域 PrintStream out 用于输出,把所有的 IssueHandle 继承自它。

  6. :white_check_mark: 结构:

    core +- finder - pfinder, rfinder, ...
        +- tracker - Tracker, Issue, Handle
        +- env - Env
        `- config - ConfigParser(=> Parser)
  7. :white_check_mark: 根据 valgrind 的输出格式重新整理输出格式,方便开发者查阅,主要是进行 api 合并。

  8. :exclamation: 加一个 max_version 选项,用于配置当前最大 android 版本环境。

  9. :exclamation::exclamation: program slicing 的时候还需要加入 <clinit> (类的 static 代码块) 的代码,有些开发者会利用这个特性检查是否可用。

  10. :exclamation::exclamation: 主要的问题:1. acpair 分析的还是少,不够。 2. program slicing 还是有问题。

  11. :exclamation::exclamation::exclamation: ==任务== 注释掉 validate() 只用 detectgenerate 先查看能报出多少 ,解决后再考虑 validate 的问题。

  12. :exclamation: PrintStream.close() 别忘了。

  13. :exclamation: 把测试代码放到 fic-finder/test 下,不要太分散。

  14. :exclamation: 加一个verbose 选项,用于输出所有的调用链信息,如果没有 verbose 仅输出最近一次的调用(即调用点,从而简化输出)。

  15. :exclamation::exclamation: 优化:Issue里存的调用链不要用链表了,用树表示,既方便 13,又省内存。

  16. :exclamation: 升级 Soot 到 3.0.0,FlowDroid 到 develop 版本,使用最新的日志系统,把 Soot 和 FlowDroid 输出的所有 debug 的东西都给关了。

  17. :exclamation: 找一个可以移除第三方库代码的 jar 工具,用到 Soots.findCallSites 里。

针对现在构建成功的 App,检测以及未检测到的 API 及其原因记录(按 11 所述,仅仅使用 detect 阶段,屏蔽 validate 阶段):

  1. IrssiNotifier/AnkiDroid/Kore/BankDroid 论文中没有发现问题,暂没测试。
  2. AnternaPod
    1. :white_check_mark: AsyncTask.execute 对 empirical 分析不准确,以及对 android api doc 阅读不仔细,导致之前的 model.json 里没加入。android api doc 里显示这个 API 在 API level 1 就加入了,但同时也显示,从 API level 11 开始,这个 API 不提供真正的并行能力。
    2. :white_check_mark: AlarmManager.set 对 empirical 分析不准确,以及对 android api doc 阅读不仔细,导致之前的 model.json 里没加入;findCallSites 方法错误地把其所在的类当成第三方库过滤掉了。android api doc 里显示这个 API 在 API level 19 后无法保证设置时间的准确性,在对时间准确性要求极高的 app 中不应该使用这个 API,应该考虑使用 setExact/setWindow
    3. :exclamation: support.v7.setSupportActionBar 对 empirical 分析不准确,这是一个 device specific 的 API,导致之前的 model.json 里没加入。这个 API 会使得部分三星手机挂掉。
  3. AnySoftKeyboard
    1. :white_check_mark: AsyncTask.execute 同 AnternaPod.1。
  4. Transdroid
    1. :exclamation: support.v7.setSupportActionBar 同 AnternaPad.1
  5. k-9
    1. :white_check_mark: AlarmManager.set 同 AnternaPad.2
  6. PactrackDroid
    1. :white_check_mark: ConnectivityManager.getBackgroundDataSetting 这一条之前的版本可以发现。
  7. QKSMS
    1. :white_check_mark: Resources.getDrawable 对 empirical 分析不准确,导致之前的 model.json 里没加入。这个 API 在 API level 22 被废弃。
    2. :exclamation: android.text.format.Time 是一个 iface,暂时还没考虑。
    3. :exclamation: support.v7.setSupportActionBar 同 AnternaPad.1
  8. PocketHub
    1. :exclamation: support.v7.setSupportActionBar 同 AnternaPad.1
  9. 1Sheeld
    1. :white_check_mark: AlarmManager.set 同 AnternaPad.2
  10. ConnectBot
    1. :white_check_mark: MenuItem.setShowAsAction 这一条之前的版本可以发现
  11. Conversations
    1. :white_check_mark: AlarmManager.set 同 AnternaPad.2
    2. :white_check_mark: KeyChain.getPrivateKey 对 empirical 分析不准确,导致之前的 model.json 里没加入。这是一个 android system bug,在 android < 4.2 的机器上,使用这个 API,只要不维持一个对其返回值的引用,而是仅仅获取(调用)一下的话,一旦后续有 GC 操作,将引起 app 的 crash。
  12. WordPress
    1. :white_check_mark: AsyncTask.execute 同 AnternaPad.1

一些根据以前的 weekly report 又重新整理但还未能成功加入 models 的 api(这些 api 后续仍然需要继续分析整理,根据现在的测试结果,有一大部分未能发现的问题都是因为 api context 库不足引起的。):

  1. #14 RadioButton 的 setText 在 <= 16 时不能对齐
  2. #61 ContentResolver 的 insert 方法需要加一个 IllegalArgumentException 捕获
  3. #146 Notification 的 number 在 android >= 11 时不显示,应该使用 Builder.setNumber() 让它显示
  4. #62 ContentValues.put 在 HTC Desire S 上需要 personId