├── .gitignore ├── .travis.yml ├── Makefile ├── README.md ├── Untitled ├── WALA.iml ├── apps ├── HelloCordova.apk ├── HelloHybrid.apk ├── HelloScript.apk ├── HelloScript22.apk ├── HelloScript_simple.apk ├── HelloScript_test-2.apk ├── HybridAPIArgNum.apk ├── NormalAliasFlowTest.apk ├── NormalAliasFlowTest_objfield1.apk └── NormalAliasFlowTest_objfield_false.apk ├── build-maven-jars.py ├── build.gradle ├── build.xml ├── change-version.py ├── data ├── .DS_Store ├── android.jar └── android_stub.jar ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── kr.ac.kaist.wala.hybridroid.frontend └── src │ └── kr │ └── ac │ └── kaist │ └── wala │ └── hybridroid │ └── frontend │ ├── Driver.java │ ├── JSONOut.java │ ├── Shell.java │ └── bridge │ ├── BridgeInfo.java │ ├── ClassInfo.java │ └── MethodInfo.java ├── kr.ac.kaist.wala.hybridroid.test.data ├── ConstantValueTest.apk ├── annotation │ └── AnnotationTest.apk └── callgraph │ ├── bridgefield │ └── BridgeFieldTest.apk │ ├── reachability │ ├── DualReachableMethodTest.apk │ ├── DynamicJSExecutionTest.apk │ ├── MultiplePageLoadTest.apk │ ├── ReachableMethodTest.apk │ └── UnreachableMethodTest.apk │ ├── subwebview │ └── SubWebViewTest.apk │ └── webview │ ├── MultipleWebViewAndDiffBridgeTest.apk │ └── MultipleWebViewTest.apk ├── kr.ac.kaist.wala.hybridroid.test ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── META-INF │ └── MANIFEST.MF ├── build.gradle ├── build.properties ├── pom.xml ├── src │ └── test │ │ └── java │ │ └── kr │ │ └── ac │ │ └── kaist │ │ └── wala │ │ └── hybridroid │ │ └── test │ │ ├── FileCollector.java │ │ ├── TestConfig.java │ │ ├── annotation │ │ └── AnnotationTest.java │ │ └── callgraph │ │ ├── BridgeFieldTest.java │ │ ├── DynamicJSExectionTest.java │ │ ├── MultipleHTMLLoadTest.java │ │ ├── MultipleWebViewTest.java │ │ ├── ReachableBridgeTest.java │ │ └── SubClassWebViewTest.java └── test.config ├── kr.ac.kaist.wala.hybridroid.types ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs └── kr.ac.kaist.wala.hybridroid.types.iml ├── kr.ac.kaist.wala.hybridroid.util ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── META-INF │ └── MANIFEST.MF ├── build.gradle ├── build.properties ├── build.xml ├── pom.xml └── src │ └── kr │ └── ac │ └── kaist │ └── wala │ └── hybridroid │ └── util │ ├── data │ ├── None.java │ ├── Option.java │ ├── Pair.java │ └── Some.java │ ├── debug │ └── Debug.java │ ├── file │ ├── DummyFileManager.java │ ├── FileCollector.java │ ├── FilePrinter.java │ ├── FileWriter.java │ ├── OnlineFileReader.java │ └── YMLParser.java │ ├── graph │ └── visualize │ │ └── Visualizer.java │ ├── print │ ├── AsyncPrinter.java │ └── IRPrinter.java │ └── timer │ └── Timer.java ├── kr.ac.kaist.wala.hybridroid ├── .#Untitled ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── META-INF │ └── MANIFEST.MF ├── Untitled ├── build.gradle ├── build.properties ├── build.xml ├── cg_new.dex ├── dat │ └── wala.properties ├── libs │ └── apktool_2.3.0.jar ├── pom.xml ├── src │ └── kr │ │ └── ac │ │ └── kaist │ │ └── wala │ │ └── hybridroid │ │ ├── analysis │ │ ├── AnalysisScopeBuilder.java │ │ ├── FieldDefAnalysis.java │ │ ├── HybridCFGAnalysis.java │ │ ├── resource │ │ │ ├── AndroidDecompiler.java │ │ │ ├── AndroidResourceAnalysis.java │ │ │ ├── SmaliParser.java │ │ │ └── XMLStringResourceReader.java │ │ └── string │ │ │ ├── AndroidStringAnalysis.java │ │ │ ├── ArgumentHotspot.java │ │ │ ├── Hotspot.java │ │ │ ├── StringAnalysis.java │ │ │ ├── StringAnalysisResult.java │ │ │ ├── constraint │ │ │ ├── AbstractConstraintEdge.java │ │ │ ├── AppendOpNode.java │ │ │ ├── AssignOpNode.java │ │ │ ├── BinaryOpNode.java │ │ │ ├── ConstBox.java │ │ │ ├── ConstType.java │ │ │ ├── ConstraintGraph.java │ │ │ ├── ConstraintVisitor.java │ │ │ ├── IBox.java │ │ │ ├── IBoxVisitor.java │ │ │ ├── IConstraintEdge.java │ │ │ ├── IConstraintMonitor.java │ │ │ ├── IConstraintNode.java │ │ │ ├── IOperatorNode.java │ │ │ ├── IndexOfOpNode.java │ │ │ ├── InteractionConstraintMonitor.java │ │ │ ├── JoinOpNode.java │ │ │ ├── LengthOpNode.java │ │ │ ├── OrderedEdge.java │ │ │ ├── ParamBox.java │ │ │ ├── PropagationEdge.java │ │ │ ├── ReplaceOpNode.java │ │ │ ├── SubstringOpNode.java │ │ │ ├── ToStringOpNode.java │ │ │ ├── UnaryOpNode.java │ │ │ ├── UriCodecDecodeOpNode.java │ │ │ ├── UriGetQueryParameterOpNode.java │ │ │ ├── UriParseOpNode.java │ │ │ ├── VarBox.java │ │ │ └── solver │ │ │ │ ├── ForwardSetSolver.java │ │ │ │ ├── IStringConstraintSolver.java │ │ │ │ ├── InteractiveSolverMonitor.java │ │ │ │ ├── IterationSolverMonitor.java │ │ │ │ ├── domain │ │ │ │ ├── BooleanDomain.java │ │ │ │ ├── DoubleSetDomain.java │ │ │ │ ├── IBooleanDomain.java │ │ │ │ ├── IDomain.java │ │ │ │ ├── IDomainOp.java │ │ │ │ ├── IDoubleDomain.java │ │ │ │ ├── IIntegerDomain.java │ │ │ │ ├── ILongDomain.java │ │ │ │ ├── IStringDomain.java │ │ │ │ ├── IntegerSetDomain.java │ │ │ │ ├── LongSetDomain.java │ │ │ │ ├── StringSetDomain.java │ │ │ │ └── value │ │ │ │ │ ├── BooleanBotValue.java │ │ │ │ │ ├── BooleanTopValue.java │ │ │ │ │ ├── BotValue.java │ │ │ │ │ ├── DoubleBotValue.java │ │ │ │ │ ├── DoubleTopValue.java │ │ │ │ │ ├── IBooleanValue.java │ │ │ │ │ ├── IDoubleValue.java │ │ │ │ │ ├── IIntegerValue.java │ │ │ │ │ ├── ILongValue.java │ │ │ │ │ ├── IStringValue.java │ │ │ │ │ ├── IValue.java │ │ │ │ │ ├── IntegerBotValue.java │ │ │ │ │ ├── IntegerTopValue.java │ │ │ │ │ ├── LongBotValue.java │ │ │ │ │ ├── LongTopValue.java │ │ │ │ │ ├── StringBotValue.java │ │ │ │ │ ├── StringTopValue.java │ │ │ │ │ └── TopValue.java │ │ │ │ └── model │ │ │ │ ├── AppendOpSetModel.java │ │ │ │ ├── IOperationModel.java │ │ │ │ ├── ISolverMonitor.java │ │ │ │ ├── IndexOfOpSetModel.java │ │ │ │ ├── JoinOpSetModel.java │ │ │ │ ├── LengthOpSetModel.java │ │ │ │ ├── ReplaceOpSetModel.java │ │ │ │ ├── SubstringOpSetModel.java │ │ │ │ ├── ToStringOpSetModel.java │ │ │ │ ├── UriCodecDecodeOpSetModel.java │ │ │ │ ├── UriGetQueryParameterOpSetModel.java │ │ │ │ └── UriParseOpSetModel.java │ │ │ ├── model │ │ │ ├── AbstractClassModel.java │ │ │ ├── CharsetProviderClassModel.java │ │ │ ├── IClassModel.java │ │ │ ├── IMethodModel.java │ │ │ ├── ObjectClassModel.java │ │ │ ├── StringBufferClassModel.java │ │ │ ├── StringBuilderClassModel.java │ │ │ ├── StringClassModel.java │ │ │ ├── StringModel.java │ │ │ ├── UriClassModel.java │ │ │ └── UriCodecClassModel.java │ │ │ └── resource │ │ │ └── model │ │ │ └── ContextClassModel.java │ │ ├── appinfo │ │ ├── ManifestInfo.java │ │ ├── XMLManifestReader.java │ │ └── properties │ │ │ └── Property.java │ │ ├── callback │ │ └── CallbackAndroidJavaVisitor.java │ │ ├── callgraph │ │ ├── AndroidHybridAnalysisScope.java │ │ ├── AndroidHybridCallGraphBuilder.java │ │ ├── AndroidHybridMethodTargetSelector.java │ │ ├── AndroidMethodTargetSelector.java │ │ ├── HybridClassLoaderFactory.java │ │ ├── HybridContextSelector.java │ │ ├── HybridIRFactory.java │ │ ├── JavaJavaScriptHybridCallGraphBuilder.java │ │ ├── ResourceCallGraphBuilder.java │ │ └── graphutils │ │ │ ├── ConstraintGraphVisualizer.java │ │ │ ├── WalaCFGVisualizer.java │ │ │ └── WalaCGVisualizer.java │ │ ├── checker │ │ └── HybridAPIMisusesChecker.java │ │ ├── command │ │ └── CommandArguments.java │ │ ├── exception │ │ └── InternalError.java │ │ ├── models │ │ ├── AndroidHybridAppModel.java │ │ ├── Java60RegressionExclusions.txt │ │ ├── miniprologue.js │ │ ├── preamble.js │ │ └── prologue.js │ │ ├── pointer │ │ ├── InterfaceClass.java │ │ ├── JSCompatibleClassFilter.java │ │ ├── JavaCompatibleClassFilter.java │ │ ├── MockupClass.java │ │ ├── MockupInstanceKey.java │ │ └── ResourceInstanceKey.java │ │ ├── print │ │ ├── NodePrinter.java │ │ └── Printer.java │ │ ├── shell │ │ └── Shell.java │ │ ├── test │ │ ├── ModeledCallGraphForTaint.java │ │ ├── PrivateLeakageDetector.java │ │ └── TaintAnalysisForHybrid.java │ │ ├── types │ │ ├── AndroidJavaJavaScriptTypeMap.java │ │ └── HybriDroidTypes.java │ │ └── utils │ │ ├── LoaderUtils.java │ │ ├── LocalFileReader.java │ │ ├── TypeRefHelper.java │ │ ├── VisualizeCGTest.java │ │ └── Wrapper.java └── wala.properties ├── pom.xml ├── settings.gradle └── targets ├── e42 ├── e42.target └── pom.xml ├── e44 ├── e44.iml ├── e44.target └── pom.xml ├── e47 ├── e47.target └── pom.xml ├── pom.xml └── targets.iml /.gitignore: -------------------------------------------------------------------------------- 1 | *.config 2 | *.txt 3 | *.js 4 | *.html 5 | *.DS_Store 6 | *.class 7 | *.out 8 | *.swp 9 | *.dot 10 | *.svg 11 | */bin/ 12 | */bin/* 13 | *~ 14 | HybriDroid/tmp/ 15 | HybriDroid/cfg/ 16 | .metadata/ 17 | com.ibm.wala.cast.java.jdt.test/ 18 | com.ibm.wala.cast.java.polyglot/lib/ 19 | com.ibm.wala.cast.java.test.data/src/JLex/ 20 | com.ibm.wala.cast.java.test/testdata/ 21 | com.ibm.wala.cast.js.html.nu_validator/lib/ 22 | com.ibm.wala.cast.js.rhino.test/*.dump 23 | com.ibm.wala.cast.js.rhino.test/*.html* 24 | com.ibm.wala.cast.js.rhino.test/2009_swine_flu_outbreak 25 | com.ibm.wala.cast.js.rhino.test/?game* 26 | com.ibm.wala.cast.js.rhino.test/BunnyHunt 27 | com.ibm.wala.cast.js.rhino.test/digg_attack 28 | com.ibm.wala.cast.js.rhino.test/game.php* 29 | com.ibm.wala.cast.js.rhino.test/xxxx 30 | com.ibm.wala.cast.js.rhino/lib/ 31 | com.ibm.wala.cast.js.test.data/examples-src/ajaxslt/ 32 | com.ibm.wala.cast.js.test/examples-src/ajaxslt/ 33 | com.ibm.wala.cast.js/lib/ 34 | com.ibm.wala.core.testdata/*.jar 35 | com.ibm.wala.core.testdata/@dot/ 36 | com.ibm.wala.core.testdata/lib/ 37 | com.ibm.wala.core.tests/dat/wala.examples.properties 38 | com.ibm.wala.core.tests/report 39 | com.ibm.wala.core/@dot 40 | com.ibm.wala.core/com.ibm.wala.core*.jar 41 | com.ibm.wala.core/dat/wala.properties 42 | com.ibm.wala.dalvik/src/logback.xml 43 | com.ibm.wala.ide.jdt.test/testdata/ 44 | edu.kit.wala.smali.test/out/ 45 | target/ 46 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | android: 3 | components: 4 | - build-tools-28.0.3 5 | jdk: oraclejdk8 6 | before_install: 7 | - git clone --depth=50 https://github.com/wala/WALA WALA 8 | install: 9 | - pushd WALA 10 | - mvn clean install -DskipTests -B -q 11 | - popd 12 | script: 13 | - make test 14 | sudo: false 15 | cache: 16 | directories: 17 | - $HOME/.m2 18 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | BASH := bash 2 | GRD := gradle 3 | GRDW := gradlew 4 | MVN := mvn 5 | GIT := git 6 | 7 | WALA_DIR := WALA 8 | WALA_CORE := $(WALA_DIR)/com.ibm.wala.core 9 | WALA_RHINO :=$(WALA_DIR)/com.ibm.wala.cast.js.rhino 10 | WALA_UTIL := $(WALA_DIR)/com.ibm.wala.util 11 | WALA_NU := $(WALA_DIR)/com.ibm.wala.cast.js.html.nu_validator 12 | WALA_CAST := $(WALA_DIR)/com.ibm.wala.cast 13 | WALA_DALVIK := $(WALA_DIR)/com.ibm.wala.dalvik 14 | WALA_RHINO_TEST := $(WALA_DIR)/com.ibm.wala.cast.js.rhino.test 15 | WALA_SHRIKE := $(WALA_DIR)/com.ibm.wala.shrike 16 | WALA_JS := $(WALA_DIR)/com.ibm.wala.cast.js 17 | WALA_JS_TEST := $(WALA_DIR)/com.ibm.wala.cast.js.test 18 | WALA_JAVA := $(WALA_DIR)/com.ibm.wala.cast.java 19 | WALA_CORE_TEST := $(WALA_DIR)/com.ibm.wala.core.tests 20 | 21 | WALA_TARGETS := $(WALA_CORE)/target $(WALA_RHINO)/target $(WALA_UTIL)/target $(WALA_NU)/target $(WALA_CAST)/target $(WALA_DALVIK)/target $(WALA_RHINO_TEST)/target $(WALA_SHRIKE)/target $(WALA_JS)/target $(WALA_JS_TEST)/target $(WALA_JAVA)/target $(WALA_CORE_TEST)/target 22 | 23 | HYBRIDROID := kr.ac.kaist.wala.hybridroid/build/libs/kr.ac.kaist.wala.hybridroid.jar 24 | HYBRIDROID_TARGET := hybridroid.jar 25 | HYBRIDROID_TEST := kr.ac.kaist.wala.hybridroid.test 26 | 27 | $(HYBRIDROID_TARGET): $(HYBRIDROID) 28 | cp $(HYBRIDROID) $(HYBRIDROID_TARGET) 29 | 30 | $(HYBRIDROID): $(WALA_TARGETS) 31 | $(BASH) $(GRDW) build -x test 32 | 33 | $(WALA_TARGETS): $(WALA_DIR) 34 | $(MVN) clean install -DskipTests -B -q -f $(WALA_DIR)/pom.xml 35 | 36 | $(WALA_DIR): 37 | $(GIT) clone --depth=50 https://github.com/wala/WALA $(WALA_DIR) 38 | 39 | clean: 40 | $(BASH) $(GRDW) clean -PwalaDir=$(WALA_DIR) 41 | rm $(HYBRIDROID_TARGET) 42 | 43 | test: 44 | $(BASH) $(GRDW) cleanTest test -b $(HYBRIDROID_TEST)/build.gradle 45 | 46 | .PHONY: compile clean test 47 | .SILENT: compile $(WALA_TARGETS) $(WALA_DIR) clean $(HYBRIDROID_TARGET) $(HYBRIDROID) test 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HybriDroid [![Build Status](https://travis-ci.org/SunghoLee/HybriDroid.svg?branch=master)](https://travis-ci.org/SunghoLee/HybriDroid) 2 | 3 | A static analysis framework to analyze Android hybrid applications. 4 | 5 | ## Getting Started 6 | 7 | ### Prerequisites 8 | 9 | To build and execute HybriDroid, Gradle and Java are required. 10 | 11 | HybriDroid is tested under: 12 | 13 | * JDK 1.8.0 14 | * Gradle 4.3.1 15 | 16 | HybriDroid is built on top of WALA requiring Maven and wget. WALA is automatically downloaded in the HybriDroid compilation process but Maven and wget are needed before the compilation. 17 | 18 | ### Building HybriDroid 19 | 20 | HybriDroid is compiled as follow: 21 | 22 | ``` 23 | bash-3.2$ make 24 | ``` 25 | 26 | The ``Makefile`` clones WALA, compiles it, and compiles HybriDroid. When the compilation is done, ``hybridroid.jar`` is created in the root directory of HybriDroid project. 27 | 28 | ## Running HybriDroid 29 | 30 | Java Runtime directory and Android rt file must be set in ``wala.properties`` as follow before running HybriDroid. Android rt file is included in HybriDroid project. 31 | 32 | ``` 33 | // Java runtime directory 34 | java_runtime_dir = /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre/lib 35 | // Android rt directory 36 | android_rt_jar = /Users/leesh/Documents/repo/HybriDroid/data/android.jar 37 | ``` 38 | 39 | Then, HybriDroid is executed as follow: 40 | 41 | ``` 42 | java -jar hybridroid.jar -cfg -t HelloHybrid.apk -p wala.properties 43 | ``` 44 | 45 | ## WALA 46 | 47 | HybriDroid is implemented and integrated in WALA. For more details on WALA, see the WALA home page. 49 | 50 | The current version of WALA requires build-tools-26.0.2 of Android sdk. If an error occurs in the WALA compilation, download Android sdk and build-tools-26.0.2 as well as add ``android-sdk/tools/bin`` to your PATH. 51 | 52 | ## License 53 | 54 | This project is licensed under the Eclipse Public License v1.0 55 | -------------------------------------------------------------------------------- /WALA.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /apps/HelloCordova.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/apps/HelloCordova.apk -------------------------------------------------------------------------------- /apps/HelloHybrid.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/apps/HelloHybrid.apk -------------------------------------------------------------------------------- /apps/HelloScript.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/apps/HelloScript.apk -------------------------------------------------------------------------------- /apps/HelloScript22.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/apps/HelloScript22.apk -------------------------------------------------------------------------------- /apps/HelloScript_simple.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/apps/HelloScript_simple.apk -------------------------------------------------------------------------------- /apps/HelloScript_test-2.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/apps/HelloScript_test-2.apk -------------------------------------------------------------------------------- /apps/HybridAPIArgNum.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/apps/HybridAPIArgNum.apk -------------------------------------------------------------------------------- /apps/NormalAliasFlowTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/apps/NormalAliasFlowTest.apk -------------------------------------------------------------------------------- /apps/NormalAliasFlowTest_objfield1.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/apps/NormalAliasFlowTest_objfield1.apk -------------------------------------------------------------------------------- /apps/NormalAliasFlowTest_objfield_false.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/apps/NormalAliasFlowTest_objfield_false.apk -------------------------------------------------------------------------------- /build-maven-jars.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # script to build jars for maven central 4 | import sys 5 | import subprocess 6 | import os 7 | 8 | # action should be either 'install' (for local test) 9 | # or 'deploy' (for deployment to maven central). 10 | # if current version is SNAPSHOT, will only be deployed 11 | # to sonatype's staging servers. otherwise, will be 12 | # deployed to maven central 13 | action = sys.argv[1] 14 | 15 | # projects for which we should build jars, in order 16 | # will be prefixed with 'com.ibm.wala.' 17 | projects = [ 18 | "util", 19 | "shrike", 20 | "core", 21 | "cast", 22 | "cast.java", 23 | "cast.java.ecj", 24 | "cast.js", 25 | "cast.js.rhino" 26 | ] 27 | 28 | for proj in projects: 29 | full_proj = "com.ibm.wala." + proj 30 | print full_proj 31 | os.chdir(full_proj) 32 | mvnCmd = "mvn -f mvncentral.xml clean " + action 33 | try: 34 | subprocess.check_output(mvnCmd, shell=True) 35 | except subprocess.CalledProcessError as e: 36 | print "OUTPUT" 37 | print e.output 38 | raise 39 | os.chdir("..") 40 | 41 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | def wala = file("WALA") 2 | 3 | subprojects{ 4 | ext { 5 | wala_path = wala.getAbsolutePath() 6 | wala_version = "1.5.3" 7 | } 8 | } 9 | 10 | wrapper{ 11 | gradleVersion = "5.2.1" 12 | } 13 | 14 | -------------------------------------------------------------------------------- /change-version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # specify versions as version number, optionally followed by 4 | # '-SNAPSHOT' for a snapshot version 5 | import sys 6 | import subprocess 7 | 8 | oldVersion = sys.argv[1] 9 | newVersion = sys.argv[2] 10 | 11 | print oldVersion + " --> " + newVersion 12 | 13 | oldVersion = oldVersion.replace(".", "\.") 14 | newVersion = newVersion.replace(".", "\.") 15 | 16 | cleanCmd = "mvn clean -q" 17 | print cleanCmd 18 | subprocess.check_output(cleanCmd, shell=True) 19 | 20 | xmlCmd = "find -E ./ -regex \".*(pom|mvncentral)\.xml\" | xargs -n 1 perl -pi -e \'s/" + oldVersion + "/" + newVersion + "/g\'" 21 | print xmlCmd 22 | subprocess.check_output(xmlCmd, shell=True) 23 | 24 | oldIsSnapshot = oldVersion.endswith("SNAPSHOT") 25 | newIsSnapShot = newVersion.endswith("SNAPSHOT") 26 | 27 | bundleOld = oldVersion if not oldIsSnapshot else oldVersion.replace("-SNAPSHOT","\.qualifier") 28 | bundleNew = newVersion if not newIsSnapShot else newVersion.replace("-SNAPSHOT","\.qualifier") 29 | 30 | otherCmd = "find -E ./ -regex \".*(MANIFEST\.MF|feature\.xml)\" | xargs -n 1 perl -pi -e \'s/" + bundleOld + "/" + bundleNew + "/g\'" 31 | 32 | print otherCmd 33 | subprocess.check_output(otherCmd, shell=True) 34 | 35 | print "done" 36 | 37 | 38 | -------------------------------------------------------------------------------- /data/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/data/.DS_Store -------------------------------------------------------------------------------- /data/android.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/data/android.jar -------------------------------------------------------------------------------- /data/android_stub.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/data/android_stub.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS="-Xmx64m" 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.frontend/src/kr/ac/kaist/wala/hybridroid/frontend/JSONOut.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package kr.ac.kaist.wala.hybridroid.frontend; 5 | 6 | import kr.ac.kaist.wala.hybridroid.frontend.bridge.BridgeInfo; 7 | import kr.ac.kaist.wala.hybridroid.frontend.bridge.ClassInfo; 8 | import kr.ac.kaist.wala.hybridroid.frontend.bridge.MethodInfo; 9 | import kr.ac.kaist.wala.hybridroid.util.data.Pair; 10 | import org.json.simple.JSONArray; 11 | import org.json.simple.JSONObject; 12 | 13 | import java.io.File; 14 | import java.io.IOException; 15 | import java.util.HashMap; 16 | import java.util.HashSet; 17 | import java.util.Map; 18 | import java.util.Set; 19 | 20 | /** 21 | * @author Sungho Lee 22 | * 23 | */ 24 | public class JSONOut { 25 | private Map> m; 26 | 27 | public JSONOut(Map> m){ 28 | this.m = m; 29 | // System.out.println(m); 30 | } 31 | 32 | @SuppressWarnings("unchecked") 33 | public String toJSONString() throws IOException{ 34 | JSONObject outer = new JSONObject(); 35 | JSONObject js2bridge = new JSONObject(); 36 | JSONObject klass = new JSONObject(); 37 | 38 | Map>> jsBridgeMap = new HashMap>>(); 39 | Map classMap = new HashMap(); 40 | 41 | for(File f : m.keySet()){ 42 | Set bis = m.get(f); 43 | String jsPath = f.getCanonicalPath(); 44 | if(bis != null && !bis.isEmpty()){ 45 | for(BridgeInfo bi : bis){ 46 | String cn = bi.getClassInfo().getClassName(); 47 | if(!jsBridgeMap.containsKey(jsPath)) 48 | jsBridgeMap.put(jsPath, new HashSet>()); 49 | jsBridgeMap.get(jsPath).add(Pair.make(bi.getName(), cn)); 50 | classMap.put(cn, bi.getClassInfo()); 51 | } 52 | } 53 | } 54 | 55 | for(String n : jsBridgeMap.keySet()){ 56 | JSONObject bridge = new JSONObject(); 57 | 58 | Set> bridgeMap = jsBridgeMap.get(n); 59 | 60 | for(Pair p : bridgeMap){ 61 | String b = p.fst(); 62 | String o = p.snd(); 63 | if(!bridge.containsKey(b)) 64 | bridge.put(b, new JSONArray()); 65 | ((JSONArray)(bridge.get(b))).add(o); 66 | } 67 | js2bridge.put(n, bridge); 68 | } 69 | 70 | outer.put("js2bridge", js2bridge); 71 | 72 | for(String n : classMap.keySet()){ 73 | ClassInfo c = classMap.get(n); 74 | JSONArray methods = new JSONArray(); 75 | 76 | for(MethodInfo mi : c.getAllAccessibleMethods()){ 77 | JSONObject method = new JSONObject(); 78 | JSONArray params = new JSONArray(); 79 | method.put("name", mi.getName().toString()); 80 | for(int i = (mi.isStatic()? 0 : 1); i < mi.getNumberOfParameters(); i++){ 81 | String ptn = mi.getParameterType(i).getName().getClassName().toString(); 82 | params.add(ptn); 83 | } 84 | method.put("params", params); 85 | method.put("result", mi.getReturnType().getName().getClassName().toString()); 86 | methods.add(method); 87 | } 88 | klass.put(c.getClassName(), methods); 89 | } 90 | outer.put("classes", klass); 91 | return outer.toJSONString(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.frontend/src/kr/ac/kaist/wala/hybridroid/frontend/Shell.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package kr.ac.kaist.wala.hybridroid.frontend; 5 | 6 | import kr.ac.kaist.wala.hybridroid.frontend.bridge.BridgeInfo; 7 | 8 | import java.io.BufferedWriter; 9 | import java.io.File; 10 | import java.io.FileWriter; 11 | import java.io.IOException; 12 | import java.util.Map; 13 | import java.util.Set; 14 | 15 | /** 16 | * @author Sungho Lee 17 | * 18 | */ 19 | public class Shell { 20 | public static long START; 21 | 22 | static public void main(String[] args){ 23 | long start = System.currentTimeMillis(); 24 | START = start; 25 | 26 | Driver d = new Driver(); 27 | 28 | Map> m = d.analyzeBridgeMapping(args[0], args[1]); 29 | JSONOut out = new JSONOut(m); 30 | 31 | try { 32 | BufferedWriter bw = new BufferedWriter(new FileWriter(args[2])); 33 | bw.write(out.toJSONString()); 34 | bw.flush(); 35 | bw.close(); 36 | } catch (IOException e) { 37 | // TODO Auto-generated catch block 38 | e.printStackTrace(); 39 | } 40 | 41 | long end = System.currentTimeMillis(); 42 | System.out.println("#time: " + (end - start)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.frontend/src/kr/ac/kaist/wala/hybridroid/frontend/bridge/BridgeInfo.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.frontend.bridge; 12 | 13 | /** 14 | * Data structure denotes bridge information used for access from JavaScript to Java in hybrid applications. 15 | * @author Sungho Lee 16 | * 17 | */ 18 | public class BridgeInfo { 19 | private String name; 20 | private ClassInfo klass; 21 | 22 | public BridgeInfo(String name, ClassInfo klass){ 23 | this.name = name; 24 | this.klass = klass; 25 | } 26 | 27 | /** 28 | * Get the name of this bridge. 29 | * @return the name of this bridge. 30 | */ 31 | public String getName(){ 32 | return this.name; 33 | } 34 | 35 | /** 36 | * Get the class information of a Java object referred by this bridge. 37 | * @return the Java class information for this bridge. 38 | */ 39 | public ClassInfo getClassInfo(){ 40 | return this.klass; 41 | } 42 | 43 | public String toString(){ 44 | String res = ""; 45 | res = name + " -> " + klass; 46 | return res; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test.data/ConstantValueTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid.test.data/ConstantValueTest.apk -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test.data/annotation/AnnotationTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid.test.data/annotation/AnnotationTest.apk -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test.data/callgraph/bridgefield/BridgeFieldTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid.test.data/callgraph/bridgefield/BridgeFieldTest.apk -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test.data/callgraph/reachability/DualReachableMethodTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid.test.data/callgraph/reachability/DualReachableMethodTest.apk -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test.data/callgraph/reachability/DynamicJSExecutionTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid.test.data/callgraph/reachability/DynamicJSExecutionTest.apk -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test.data/callgraph/reachability/MultiplePageLoadTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid.test.data/callgraph/reachability/MultiplePageLoadTest.apk -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test.data/callgraph/reachability/ReachableMethodTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid.test.data/callgraph/reachability/ReachableMethodTest.apk -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test.data/callgraph/reachability/UnreachableMethodTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid.test.data/callgraph/reachability/UnreachableMethodTest.apk -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test.data/callgraph/subwebview/SubWebViewTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid.test.data/callgraph/subwebview/SubWebViewTest.apk -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test.data/callgraph/webview/MultipleWebViewAndDiffBridgeTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid.test.data/callgraph/webview/MultipleWebViewAndDiffBridgeTest.apk -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test.data/callgraph/webview/MultipleWebViewTest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid.test.data/callgraph/webview/MultipleWebViewTest.apk -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | kr.ac.kaist.wala.hybridroid.test 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.pde.PluginNature 27 | 28 | 29 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.8 12 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Test 4 | Bundle-SymbolicName: kr.ac.kaist.wala.hybridroid.test 5 | Bundle-Version: 0.0.1.qualifier 6 | Bundle-ClassPath: test.jar, 7 | libs/junit-4.11.jar 8 | Export-Package: kr.ac.kaist.wala.hybridroid.test, 9 | kr.ac.kaist.wala.hybridroid.test.annotation, 10 | kr.ac.kaist.wala.hybridroid.test.callgraph 11 | Require-Bundle: org.junit;bundle-version="4.11.0", 12 | com.ibm.wala.core;bundle-version="1.4.4", 13 | kr.ac.kaist.wala.hybridroid;bundle-version="0.0.1" 14 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | repositories { 4 | mavenCentral() 5 | } 6 | 7 | test { 8 | maxHeapSize = "8g" 9 | useJUnitPlatform() 10 | 11 | testLogging { 12 | events "passed", "started", "failed", "skipped" 13 | } 14 | 15 | reports { 16 | junitXml.enabled = false 17 | html.enabled = true 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation gradleApi() 23 | testImplementation ('junit:junit:3.8.1') 24 | testCompileOnly('junit:junit:4.12') 25 | testImplementation('org.junit.jupiter:junit-jupiter-api:5.1.0') 26 | testRuntimeOnly( 27 | 'org.junit.jupiter:junit-jupiter-engine:5.1.0', 28 | 'org.junit.vintage:junit-vintage-engine:5.1.0' 29 | ) 30 | testImplementation project(':kr.ac.kaist.wala.hybridroid') 31 | testImplementation files(wala_path + '/com.ibm.wala.cast.js.rhino/target/com.ibm.wala.cast.js.rhino-' + wala_version + '-SNAPSHOT.jar', 32 | wala_path + '/com.ibm.wala.util/target/com.ibm.wala.util-' + wala_version + '-SNAPSHOT.jar', 33 | wala_path + '/com.ibm.wala.cast.js.html.nu_validator/target/com.ibm.wala.cast.js.html.nu_validator-' + wala_version + '-SNAPSHOT.jar', 34 | wala_path + '/com.ibm.wala.cast/target/com.ibm.wala.cast-' + wala_version + '-SNAPSHOT.jar', 35 | wala_path + '/com.ibm.wala.dalvik/target/com.ibm.wala.dalvik-' + wala_version + '-SNAPSHOT.jar', 36 | wala_path + '/com.ibm.wala.cast.js.rhino.test/target/com.ibm.wala.cast.js.rhino.test-' + wala_version + '-SNAPSHOT.jar', 37 | wala_path + '/com.ibm.wala.shrike/target/com.ibm.wala.shrike-' + wala_version + '-SNAPSHOT.jar', 38 | wala_path + '/com.ibm.wala.cast.js/target/com.ibm.wala.cast.js-' + wala_version + '-SNAPSHOT.jar', 39 | wala_path + '/com.ibm.wala.cast.js.test/target/com.ibm.wala.cast.js.test-' + wala_version + '-SNAPSHOT.jar', 40 | wala_path + '/com.ibm.wala.cast.java/target/com.ibm.wala.cast.java-' + wala_version + '-SNAPSHOT.jar', 41 | wala_path + '/com.ibm.wala.core/target/com.ibm.wala.core-' + wala_version + '-SNAPSHOT.jar', 42 | wala_path + '/com.ibm.wala.core.tests/target/com.ibm.wala.core.tests-' + wala_version + '-SNAPSHOT.jar') 43 | testImplementation group: 'org.smali', name: 'dexlib2', version: '2.2.4' 44 | } 45 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test/build.properties: -------------------------------------------------------------------------------- 1 | source.test.jar = src/ 2 | bin.includes = META-INF/,\ 3 | test.jar 4 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | kr.ac.kaist.wala 7 | HybridDroid 8 | 0.0.1-SNAPSHOT 9 | 10 | kr.ac.kaist.wala.hybridroid.test 11 | eclipse-plugin 12 | 13 | 14 | 15 | kr.ac.kaist.wala 16 | kr.ac.kaist.wala.hybridroid 17 | 0.0.1-SNAPSHOT 18 | 19 | 20 | 21 | junit 22 | junit 23 | 4.11 24 | test 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-surefire-plugin 33 | 34 | 35 | test 36 | test 37 | 38 | ${project.build.outputDirectory} 39 | -Xmx2G -ea 40 | true 41 | 2 42 | false 43 | 44 | 45 | test 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test/src/test/java/kr/ac/kaist/wala/hybridroid/test/FileCollector.java: -------------------------------------------------------------------------------- 1 | package kr.ac.kaist.wala.hybridroid.test; 2 | 3 | import java.io.File; 4 | import java.io.FileFilter; 5 | 6 | public class FileCollector { 7 | public static File[] getAPKsInDir(String dirPath){ 8 | File dir = new File(dirPath); 9 | 10 | return dir.listFiles(new FileFilter(){ 11 | @Override 12 | public boolean accept(File pathname) { 13 | // TODO Auto-generated method stub 14 | return pathname.getName().endsWith(".apk"); 15 | }}); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test/src/test/java/kr/ac/kaist/wala/hybridroid/test/TestConfig.java: -------------------------------------------------------------------------------- 1 | package kr.ac.kaist.wala.hybridroid.test; 2 | 3 | import com.ibm.wala.ipa.cha.ClassHierarchyException; 4 | import com.ibm.wala.util.CancelException; 5 | import kr.ac.kaist.wala.hybridroid.test.annotation.AnnotationTest; 6 | import kr.ac.kaist.wala.hybridroid.test.callgraph.*; 7 | import org.junit.runner.JUnitCore; 8 | import org.junit.runner.Result; 9 | import org.junit.runner.notification.Failure; 10 | 11 | import java.io.File; 12 | import java.io.FileInputStream; 13 | import java.io.FileNotFoundException; 14 | import java.io.IOException; 15 | import java.util.Properties; 16 | import java.io.PrintStream; 17 | import java.io.ByteArrayOutputStream; 18 | 19 | public class TestConfig { 20 | 21 | public static Properties testProperties; 22 | public static String TEST_DIR = "test_dir"; 23 | public static String LIB_JAR = "android_jar"; 24 | 25 | static{ 26 | testProperties = new Properties(); 27 | try { 28 | testProperties.load(new FileInputStream(new File("test.config"))); 29 | } catch (FileNotFoundException e) { 30 | // TODO Auto-generated catch block 31 | System.out.println("Working Dir: " + new File(".").getAbsolutePath()); 32 | e.printStackTrace(); 33 | System.exit(-1); 34 | } catch (IOException e) { 35 | // TODO Auto-generated catch block 36 | e.printStackTrace(); 37 | } 38 | } 39 | 40 | public static String getTestDir(){ 41 | return testProperties.getProperty(TEST_DIR); 42 | } 43 | 44 | public static String getLibPath(){ 45 | return testProperties.getProperty(LIB_JAR); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test/src/test/java/kr/ac/kaist/wala/hybridroid/test/annotation/AnnotationTest.java: -------------------------------------------------------------------------------- 1 | package kr.ac.kaist.wala.hybridroid.test.annotation; 2 | 3 | import com.ibm.wala.ipa.cha.ClassHierarchyException; 4 | import com.ibm.wala.util.CancelException; 5 | import kr.ac.kaist.wala.hybridroid.analysis.HybridCFGAnalysis; 6 | import kr.ac.kaist.wala.hybridroid.test.FileCollector; 7 | import kr.ac.kaist.wala.hybridroid.test.TestConfig; 8 | import org.junit.Ignore; 9 | import org.junit.Test; 10 | 11 | import java.io.File; 12 | import java.io.IOException; 13 | 14 | import static org.junit.Assert.assertEquals; 15 | import static org.junit.Assert.assertTrue; 16 | 17 | public class AnnotationTest { 18 | 19 | public static String TEST_DIR = "annotation"; 20 | 21 | 22 | @Test 23 | public void missingAnnotationMethodShouldInvisible() throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException{ 24 | File[] tests = FileCollector.getAPKsInDir(TestConfig.getTestDir() + File.separator + TEST_DIR); 25 | boolean AnnotationTest_apk = false; 26 | for(File f : tests){ 27 | String testName = f.getName(); 28 | HybridCFGAnalysis cfgAnalysis = new HybridCFGAnalysis(); 29 | cfgAnalysis.main(f.getCanonicalPath(), TestConfig.getLibPath()); 30 | System.out.println("name: DONE??"); 31 | for(String s: cfgAnalysis.getWarnings()){ 32 | switch(testName){ 33 | case "AnnotationTest.apk": 34 | AnnotationTest_apk = true; 35 | assertEquals(testName + ": ", "[Error] the [[JAVA_JS_BRIDGE:],] is not matched.", s); 36 | break; 37 | } 38 | } 39 | } 40 | 41 | assertTrue(AnnotationTest_apk); 42 | } 43 | 44 | 45 | @Test 46 | public void ignoreAnnotationInfoBeforeKitkat(){ 47 | //TODO: implement test apps 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.test/test.config: -------------------------------------------------------------------------------- 1 | test_dir = ../kr.ac.kaist.wala.hybridroid.test.data 2 | android_jar = ../data/android.jar 3 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.types/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.types/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | kr.ac.kaist.wala.hybridroid.types 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.types/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.8 12 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.types/kr.ac.kaist.wala.hybridroid.types.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | kr.ac.kaist.wala.hybridroid.util 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.pde.PluginNature 27 | 28 | 29 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.7 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.7 12 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Util 4 | Bundle-SymbolicName: kr.ac.kaist.wala.hybridroid.util 5 | Bundle-Version: 0.0.1.qualifier 6 | Bundle-ClassPath: util.jar 7 | Require-Bundle: com.ibm.wala.core, 8 | com.ibm.wala.dalvik 9 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | repositories { 4 | } 5 | 6 | sourceSets { 7 | main { 8 | java { 9 | srcDir 'src' 10 | } 11 | } 12 | test { 13 | java { 14 | srcDir 'test' 15 | } 16 | } 17 | } 18 | 19 | dependencies { 20 | implementation files(wala_path + '/com.ibm.wala.util/target/com.ibm.wala.util-' + wala_version + '-SNAPSHOT.jar', 21 | wala_path + '/com.ibm.wala.dalvik/target/com.ibm.wala.dalvik-' + wala_version + '-SNAPSHOT.jar', 22 | wala_path + '/com.ibm.wala.core/target/com.ibm.wala.core-' + wala_version + '-SNAPSHOT.jar') 23 | } 24 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/build.properties: -------------------------------------------------------------------------------- 1 | source.util.jar = src/ 2 | bin.includes = META-INF/,\ 3 | util.jar 4 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | kr.ac.kaist.wala 7 | HybridDroid 8 | 0.0.1-SNAPSHOT 9 | 10 | kr.ac.kaist.wala.hybridroid.util 11 | eclipse-plugin 12 | 13 | 14 | 15 | com.ibm.wala 16 | com.ibm.wala.util 17 | 1.5.0-SNAPSHOT 18 | 19 | 20 | 21 | com.ibm.wala 22 | com.ibm.wala.core 23 | 1.5.0-SNAPSHOT 24 | 25 | 26 | 27 | com.ibm.wala 28 | com.ibm.wala.dalvik 29 | 1.5.0-SNAPSHOT 30 | 31 | 32 | 33 | 34 | 35 | 36 | maven-dependency-plugin 37 | 38 | 39 | 40 | copy 41 | 42 | 43 | 44 | 45 | org.apache.commons 46 | commons-lang3 47 | 3.7 48 | jar 49 | false 50 | 51 | 52 | ${basedir}/lib 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/data/None.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002 - 2006 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.util.data; 12 | 13 | public class None implements Option { 14 | 15 | @Override 16 | public boolean isSome() { 17 | // TODO Auto-generated method stub 18 | return false; 19 | } 20 | 21 | @Override 22 | public boolean isNone() { 23 | // TODO Auto-generated method stub 24 | return true; 25 | } 26 | 27 | @Override 28 | public T get() { 29 | // TODO Auto-generated method stub 30 | throw new InternalError("'None' object can not be gotten."); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/data/Option.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002 - 2006 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.util.data; 12 | 13 | public interface Option { 14 | 15 | public boolean isSome(); 16 | public boolean isNone(); 17 | public T get(); 18 | } 19 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/data/Pair.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002 - 2006 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.util.data; 12 | 13 | public class Pair { 14 | private X fst; 15 | private Y snd; 16 | 17 | static public Pair make(X fst, Y snd){ 18 | return new Pair(fst, snd); 19 | } 20 | 21 | private Pair(X fst, Y snd){ 22 | this.fst = fst; 23 | this.snd = snd; 24 | } 25 | 26 | public X fst(){ 27 | return fst; 28 | } 29 | 30 | public Y snd(){ 31 | return snd; 32 | } 33 | 34 | @Override 35 | public int hashCode(){ 36 | return fst.hashCode() + snd.hashCode(); 37 | } 38 | 39 | @Override 40 | public boolean equals(Object o){ 41 | if(o instanceof Pair){ 42 | if(fst.equals(((Pair) o).fst()) && snd.equals(((Pair) o).snd())) 43 | return true; 44 | } 45 | 46 | return false; 47 | } 48 | 49 | @Override 50 | public String toString(){ 51 | return "[ " + fst + ", " + snd + "]"; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/data/Some.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002 - 2006 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.util.data; 12 | 13 | public class Some implements Option { 14 | 15 | private T o; 16 | 17 | public Some(T o){ 18 | this.o = o; 19 | } 20 | 21 | @Override 22 | public boolean isSome() { 23 | // TODO Auto-generated method stub 24 | return true; 25 | } 26 | 27 | @Override 28 | public boolean isNone() { 29 | // TODO Auto-generated method stub 30 | return false; 31 | } 32 | 33 | @Override 34 | public T get() { 35 | // TODO Auto-generated method stub 36 | return o; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/debug/Debug.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002 - 2006 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.util.debug; 12 | 13 | public class Debug { 14 | public static void setDebuggable(Object o, boolean t){ 15 | 16 | } 17 | 18 | public static void printMsg(String s){ 19 | 20 | } 21 | 22 | public static void temporaryStop(){ 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/file/DummyFileManager.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002 - 2006 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.util.file; 12 | 13 | import java.io.File; 14 | import java.util.HashSet; 15 | import java.util.Set; 16 | 17 | public class DummyFileManager { 18 | private static Set dummies = new HashSet(); 19 | 20 | public static void addDummyFile(File f){ 21 | dummies.add(f); 22 | } 23 | 24 | // public static void removeAllDummies(){ 25 | // for(dummies.) 26 | // 27 | // } 28 | } 29 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/file/FileCollector.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002 - 2006 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.util.file; 12 | 13 | import java.io.File; 14 | import java.util.HashSet; 15 | import java.util.Set; 16 | 17 | public class FileCollector { 18 | public static Set collectFiles(File dir, String... exts){ 19 | Set res = new HashSet(); 20 | for(File f : dir.listFiles()){ 21 | if(f.isDirectory()) 22 | res.addAll(collectFiles(f, exts)); 23 | else{ 24 | for(String ext : exts) 25 | if(f.getName().endsWith(ext)) 26 | res.add(f); 27 | } 28 | } 29 | return res; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/file/FilePrinter.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002 - 2006 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.util.file; 12 | 13 | import kr.ac.kaist.wala.hybridroid.util.print.AsyncPrinter; 14 | 15 | import java.io.*; 16 | 17 | public class FilePrinter { 18 | 19 | public static void print(File f, OutputStream os) throws InternalError{ 20 | if(!f.exists()){ 21 | try { 22 | throw new InternalError("the file does not exsit: " + f.getCanonicalPath()); 23 | } catch (IOException e) { 24 | // TODO Auto-generated catch block 25 | e.printStackTrace(); 26 | } 27 | } 28 | 29 | BufferedReader br = null; 30 | BufferedWriter bw = null; 31 | try { 32 | br = new BufferedReader(new InputStreamReader(new FileInputStream(f))); 33 | bw = new BufferedWriter(new OutputStreamWriter(os)); 34 | 35 | String s = null; 36 | 37 | while ((s = br.readLine()) != null) { 38 | bw.write(s + "\n"); 39 | } 40 | bw.flush(); 41 | } catch (IOException e) { 42 | 43 | } finally { 44 | try { 45 | if (br != null) 46 | br.close(); 47 | if (bw != null) 48 | bw.close(); 49 | } catch (IOException e) { 50 | // TODO Auto-generated catch block 51 | e.printStackTrace(); 52 | } 53 | } 54 | } 55 | 56 | public static void printUsingShell(File f, String path){ 57 | if(!f.exists()){ 58 | try { 59 | throw new InternalError("the file does not exsit: " + f.getCanonicalPath()); 60 | } catch (IOException e) { 61 | // TODO Auto-generated catch block 62 | e.printStackTrace(); 63 | } 64 | } 65 | 66 | Runtime r = Runtime.getRuntime(); 67 | try { 68 | System.out.println("cp " + f.getCanonicalPath() + " " + path); 69 | Process p = r.exec("cp " + f.getCanonicalPath() + " " + path); 70 | AsyncPrinter errPinter = new AsyncPrinter(p.getErrorStream(), AsyncPrinter.PRINT_ERR); 71 | AsyncPrinter outPinter = new AsyncPrinter(p.getInputStream(), AsyncPrinter.PRINT_OUT); 72 | errPinter.run(); 73 | outPinter.run(); 74 | p.waitFor(); 75 | } catch (IOException e) { 76 | e.printStackTrace(); 77 | } catch (InterruptedException e) { 78 | e.printStackTrace(); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/file/OnlineFileReader.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002 - 2006 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.util.file; 12 | 13 | import java.io.BufferedReader; 14 | import java.io.IOException; 15 | import java.io.InputStreamReader; 16 | import java.net.URL; 17 | 18 | public class OnlineFileReader { 19 | private String path; 20 | 21 | public OnlineFileReader(String path){ 22 | this.path = path; 23 | } 24 | 25 | public String readData() throws IOException{ 26 | String res = ""; 27 | 28 | URL url = new URL(path); 29 | 30 | BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream())); 31 | 32 | String s = null; 33 | 34 | boolean isFirstLine = true; 35 | 36 | while((s = br.readLine()) != null){ 37 | if(!isFirstLine) 38 | res += "\n"; 39 | 40 | res += s; 41 | 42 | if(isFirstLine) 43 | isFirstLine = false; 44 | } 45 | br.close(); 46 | 47 | return res; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/print/AsyncPrinter.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002 - 2006 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.util.print; 12 | 13 | import java.io.BufferedReader; 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | import java.io.InputStreamReader; 17 | import java.io.PrintStream; 18 | 19 | /** 20 | * Print messages from input stream asynchronously. This supports two type of 21 | * message; Standard-out and Standard-error. 22 | * 23 | * @author Sungho Lee 24 | */ 25 | public class AsyncPrinter extends Thread { 26 | static public final int PRINT_OUT = 1; 27 | static public final int PRINT_ERR = 2; 28 | 29 | private BufferedReader reader; 30 | private PrintStream printer; 31 | 32 | /** 33 | * Unique constructor for AsyncPrinter. 34 | * @param reader the input stream for printing. 35 | * @param type the type of printing. now, only support standard-out and standard-error. 36 | */ 37 | public AsyncPrinter(InputStream reader, int type){ 38 | this.reader = new BufferedReader(new InputStreamReader(reader)); 39 | setPrinter(type); 40 | } 41 | 42 | /** 43 | * Set printing type for AsyncPrinter. 44 | * @param type the type of printing. now, only support standard-out and standard-error. 45 | */ 46 | private void setPrinter(int type){ 47 | switch(type){ 48 | case PRINT_OUT: 49 | printer = System.out; 50 | break; 51 | case PRINT_ERR: 52 | printer = System.err; 53 | break; 54 | default: 55 | 56 | } 57 | } 58 | 59 | /** 60 | * Start printing messages from the input stream. Must stop this operation 61 | * using stop method when no more need to print messages for preventing 62 | * the resource waste. 63 | */ 64 | @Override 65 | public void run() { 66 | // TODO Auto-generated method stub 67 | String s; 68 | 69 | try { 70 | while ((s = reader.readLine()) != null) 71 | printer.println(s); 72 | } catch (IOException e) { 73 | // TODO Auto-generated catch block 74 | e.printStackTrace(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/print/IRPrinter.java: -------------------------------------------------------------------------------- 1 | package kr.ac.kaist.wala.hybridroid.util.print; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.File; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Iterator; 8 | 9 | import com.ibm.wala.dalvik.classLoader.DexIRFactory; 10 | import com.ibm.wala.ipa.callgraph.CGNode; 11 | import com.ibm.wala.ipa.callgraph.CallGraph; 12 | import com.ibm.wala.ipa.callgraph.impl.Everywhere; 13 | import com.ibm.wala.ssa.IR; 14 | import com.ibm.wala.ssa.SSAInstruction; 15 | import com.ibm.wala.ssa.SSAOptions; 16 | 17 | /** 18 | * Created by leesh on 07/03/2017. 19 | */ 20 | public class IRPrinter { 21 | 22 | public static void printIR(CallGraph cg, String out, Filter f){ 23 | if(f == null) 24 | f = defaultFilter(); 25 | 26 | File outFile = new File(out); 27 | try { 28 | BufferedWriter bw = new BufferedWriter(new FileWriter(outFile)); 29 | for(CGNode n : cg) { 30 | if(!f.filter(n)) 31 | continue; 32 | bw.write("N" + n.toString() + "\n"); 33 | bw.write("=======================================\n"); 34 | IR ir = makeIR(n); 35 | if(ir != null) { 36 | SSAInstruction[] insts = ir.getInstructions(); 37 | int index = 1; 38 | for (int i = 0; i < insts.length; i++) { 39 | SSAInstruction inst = insts[i]; 40 | if (inst != null) { 41 | bw.write("( " + (i) + " ) " + inst + "\n"); 42 | } 43 | } 44 | bw.write("[Succ]=================================\n"); 45 | Iterator iSucc = cg.getSuccNodes(n); 46 | while (iSucc.hasNext()) { 47 | CGNode succ = iSucc.next(); 48 | bw.write("\t" + succ + "\n"); 49 | } 50 | } 51 | bw.newLine(); 52 | bw.newLine(); 53 | } 54 | 55 | bw.flush(); 56 | bw.close(); 57 | } catch (IOException e) { 58 | e.printStackTrace(); 59 | } 60 | } 61 | 62 | private static IR makeIR(CGNode n){ 63 | IR ir = n.getIR(); 64 | 65 | if(ir == null){ 66 | DexIRFactory irFactory = new DexIRFactory(); 67 | try { 68 | ir = irFactory.makeIR(n.getMethod(), Everywhere.EVERYWHERE, SSAOptions.defaultOptions()); 69 | }catch(NullPointerException e){ 70 | return null; 71 | } 72 | } 73 | return ir; 74 | } 75 | 76 | public interface Filter{ 77 | boolean filter(CGNode n); 78 | } 79 | 80 | static public Filter defaultFilter(){ 81 | return new Filter() { 82 | @Override 83 | public boolean filter(CGNode n) { 84 | return true; 85 | } 86 | }; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid.util/src/kr/ac/kaist/wala/hybridroid/util/timer/Timer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002 - 2006 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.util.timer; 12 | 13 | public class Timer { 14 | private long start; 15 | private long end; 16 | static public Timer start(){ 17 | return new Timer(System.currentTimeMillis()); 18 | } 19 | 20 | private Timer(long start){ 21 | this.start = start; 22 | } 23 | 24 | public long end(){ 25 | this.end = System.currentTimeMillis(); 26 | return end - start; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/.#Untitled: -------------------------------------------------------------------------------- 1 | leesh@Sunghoui-iMac.local.1047 -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | kr.ac.kaist.wala.hybridroid 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.pde.PluginNature 27 | 28 | 29 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'application' 3 | 4 | mainClassName = 'kr/ac/kaist/wala/hybridroid/shell/Shell' 5 | 6 | repositories { 7 | mavenLocal() 8 | mavenCentral() 9 | maven { 10 | url "https://repo.eclipse.org/content/groups/releases/" 11 | } 12 | } 13 | 14 | sourceSets { 15 | main { 16 | java { 17 | srcDir 'src' 18 | } 19 | } 20 | test { 21 | java { 22 | srcDir 'test' 23 | } 24 | } 25 | } 26 | 27 | jar { 28 | manifest { 29 | attributes( 30 | 'Main-Class': 'kr.ac.kaist.wala.hybridroid.shell.Shell' 31 | ) 32 | } 33 | 34 | from({ (configurations.compileClasspath).collect { it.isDirectory() ? it : zipTree(it) } }){ 35 | exclude "META-INF/*.SF" 36 | exclude "META-INF/*.DSA" 37 | exclude "META-INF/*.RSA" 38 | } 39 | 40 | from('src'){ 41 | include '**/*.txt' 42 | include '**/*.js' 43 | } 44 | } 45 | 46 | dependencies { 47 | 48 | implementation project(':kr.ac.kaist.wala.hybridroid.util') 49 | implementation files(wala_path + '/com.ibm.wala.cast.js.rhino/target/com.ibm.wala.cast.js.rhino-' + wala_version + '-SNAPSHOT.jar', 50 | wala_path + '/com.ibm.wala.util/target/com.ibm.wala.util-' + wala_version + '-SNAPSHOT.jar', 51 | wala_path + '/com.ibm.wala.cast.js.html.nu_validator/target/com.ibm.wala.cast.js.html.nu_validator-' + wala_version + '-SNAPSHOT.jar', 52 | wala_path + '/com.ibm.wala.cast/target/com.ibm.wala.cast-' + wala_version + '-SNAPSHOT.jar', 53 | wala_path + '/com.ibm.wala.dalvik/target/com.ibm.wala.dalvik-' + wala_version + '-SNAPSHOT.jar', 54 | wala_path + '/com.ibm.wala.cast.js.rhino.test/target/com.ibm.wala.cast.js.rhino.test-' + wala_version + '-SNAPSHOT.jar', 55 | wala_path + '/com.ibm.wala.shrike/target/com.ibm.wala.shrike-' + wala_version + '-SNAPSHOT.jar', 56 | wala_path + '/com.ibm.wala.cast.js/target/com.ibm.wala.cast.js-' + wala_version + '-SNAPSHOT.jar', 57 | wala_path + '/com.ibm.wala.cast.js.test/target/com.ibm.wala.cast.js.test-' + wala_version + '-SNAPSHOT.jar', 58 | wala_path + '/com.ibm.wala.cast.java/target/com.ibm.wala.cast.java-' + wala_version + '-SNAPSHOT.jar', 59 | wala_path + '/com.ibm.wala.core/target/com.ibm.wala.core-' + wala_version + '-SNAPSHOT.jar', 60 | wala_path + '/com.ibm.wala.core.tests/target/com.ibm.wala.core.tests-' + wala_version + '-SNAPSHOT.jar', 61 | 'libs/apktool_2.3.0.jar') 62 | // https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 63 | implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.6' 64 | // https://mvnrepository.com/artifact/commons-cli/commons-cli 65 | implementation group: 'commons-cli', name: 'commons-cli', version: '1.4' 66 | implementation group: 'org.smali', name: 'dexlib2', version: '2.2.4' 67 | implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.20' 68 | implementation group: 'net.htmlparser.jericho', name: 'jericho-html', version: '3.2' 69 | implementation group: 'commons-io', name: 'commons-io', version: '2.4' 70 | implementation group: 'org.mozilla', name: 'rhino', version: '1.7.10' 71 | } 72 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/build.properties: -------------------------------------------------------------------------------- 1 | source.hybridroid.jar = src/ 2 | bin.includes = META-INF/,\ 3 | hybridroid.jar,\ 4 | lib/commons-cli-1.4.jar,\ 5 | lib/commons-lang3-3.7.jar,\ 6 | libs/apktool_2.3.0.jar 7 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/libs/apktool_2.3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunghoLee/HybriDroid/a5bc657e952a290d0121e79343b6fa39554ce012/kr.ac.kaist.wala.hybridroid/libs/apktool_2.3.0.jar -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/ArgumentHotspot.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string; 12 | 13 | import com.ibm.wala.types.ClassLoaderReference; 14 | import com.ibm.wala.types.Selector; 15 | import com.ibm.wala.types.TypeReference; 16 | 17 | public class ArgumentHotspot implements Hotspot { 18 | private TypeReference cDescriptor; 19 | private Selector mSelector; 20 | private int argIndex; 21 | 22 | public ArgumentHotspot(ClassLoaderReference cRef, String cDescriptor, String mDescriptor, int argIndex){ 23 | this.argIndex = argIndex; 24 | 25 | this.cDescriptor = TypeReference.findOrCreateClass(cRef, cDescriptor.substring(0, cDescriptor.lastIndexOf("/")), cDescriptor.substring(cDescriptor.lastIndexOf("/")+1)); 26 | this.mSelector = Selector.make(mDescriptor); 27 | } 28 | 29 | public TypeReference getClassDescriptor() { 30 | return this.cDescriptor; 31 | } 32 | 33 | public Selector getMethodDescriptor() { 34 | return this.mSelector; 35 | } 36 | 37 | public int getArgIndex() { 38 | return argIndex; 39 | } 40 | 41 | @Override 42 | public int index(){ 43 | return getArgIndex(); 44 | } 45 | 46 | @Override 47 | public String toString(){ 48 | return "ArgSpot[" + cDescriptor + " " + mSelector + " (@" + argIndex + ")]"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/Hotspot.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string; 12 | 13 | public interface Hotspot { 14 | public String toString(); 15 | public int index(); 16 | } 17 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/StringAnalysis.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string; 12 | 13 | import java.util.List; 14 | 15 | public interface StringAnalysis { 16 | 17 | public void addAnalysisScope(String path); 18 | public void analyze(List hotspots) throws Exception; 19 | } 20 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/StringAnalysisResult.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string; 12 | 13 | import com.ibm.wala.types.MethodReference; 14 | import com.ibm.wala.util.collections.Pair; 15 | 16 | import java.util.HashMap; 17 | import java.util.Map; 18 | 19 | public class StringAnalysisResult { 20 | private int methodNum; 21 | private int callSiteNum; 22 | private int posNum; 23 | private Map methodNumMap; 24 | private Map, Integer> callSiteMap; 25 | private Map, Integer> posMap; 26 | private Map valueMap; 27 | 28 | public StringAnalysisResult(){ 29 | methodNumMap = new HashMap(); 30 | callSiteMap = new HashMap, Integer>(); 31 | posMap = new HashMap, Integer>(); 32 | valueMap = new HashMap(); 33 | methodNum = 1; 34 | callSiteNum = 1; 35 | posNum = 1; 36 | } 37 | 38 | public void setResult(MethodReference caller, int instIndex, int argPos, String v){ 39 | if(!methodNumMap.containsKey(caller)) 40 | methodNumMap.put(caller, methodNum++); 41 | 42 | int iCaller = methodNumMap.get(caller); 43 | Pair pCallSite = Pair.make(iCaller, instIndex); 44 | 45 | if(!callSiteMap.containsKey(pCallSite)) 46 | callSiteMap.put(pCallSite, callSiteNum++); 47 | 48 | int iCallSite = callSiteMap.get(pCallSite); 49 | Pair pPos = Pair.make(iCallSite, argPos); 50 | 51 | if(!posMap.containsKey(pPos)) 52 | posMap.put(pPos, posNum++); 53 | 54 | int iPos = posMap.get(pPos); 55 | 56 | valueMap.put(iPos, new StringValue(v)); 57 | } 58 | 59 | public StringValue getValueAt(MethodReference mr, int instIndex, int argPos){ 60 | if(methodNumMap.containsKey(mr)){ 61 | int iMr = methodNumMap.get(mr); 62 | Pair pCallSite = Pair.make(iMr, instIndex); 63 | if(callSiteMap.containsKey(pCallSite)){ 64 | int iCallSite = callSiteMap.get(pCallSite); 65 | Pair pPos = Pair.make(iCallSite, argPos); 66 | if(posMap.containsKey(pPos)){ 67 | int iPos = posMap.get(pPos); 68 | if(valueMap.containsKey(iPos)){ 69 | return valueMap.get(iPos); 70 | } 71 | } 72 | } 73 | } 74 | 75 | return new StringValue(); 76 | } 77 | 78 | class StringValue{ 79 | private String v; 80 | 81 | public StringValue(){ 82 | 83 | } 84 | 85 | public StringValue(String v){ 86 | this.v = v; 87 | } 88 | 89 | public boolean isDecided(){ 90 | return v != null; 91 | } 92 | 93 | public String value(){ 94 | return v; 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/AbstractConstraintEdge.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | public class AbstractConstraintEdge implements IConstraintEdge{ 14 | private IConstraintNode from; 15 | private IConstraintNode to; 16 | 17 | protected AbstractConstraintEdge(IConstraintNode from, IConstraintNode to){ 18 | this.from = from; 19 | this.to = to; 20 | } 21 | 22 | @Override 23 | public IConstraintNode from(){ 24 | return from; 25 | } 26 | 27 | @Override 28 | public IConstraintNode to(){ 29 | return to; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/AppendOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.AppendOpSetModel; 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.IOperationModel; 16 | 17 | public class AppendOpNode implements IOperatorNode { 18 | static private IOperationModel m; 19 | 20 | static{ 21 | m = AppendOpSetModel.getInstance(); 22 | } 23 | 24 | public AppendOpNode(){} 25 | 26 | @Override 27 | public String toString(){ 28 | return "append"; 29 | } 30 | 31 | @Override 32 | public IValue apply(IValue... args) { 33 | // TODO Auto-generated method stub 34 | return m.apply(args); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/AssignOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import com.ibm.wala.util.debug.Assertions; 14 | 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 16 | 17 | public class AssignOpNode implements IOperatorNode { 18 | public AssignOpNode(){ 19 | } 20 | 21 | @Override 22 | public String toString(){ 23 | return "="; 24 | } 25 | 26 | @Override 27 | public IValue apply(IValue... args) { 28 | // TODO Auto-generated method stub 29 | if(args.length != 1) 30 | Assertions.UNREACHABLE("AssignOpNode must have only one predecessor: " + args); 31 | 32 | return args[0]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/BinaryOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | 15 | public class BinaryOpNode implements IOperatorNode { 16 | public static enum BinaryOperator{ 17 | PLUS{ 18 | @Override 19 | public String toString(){ 20 | return "+"; 21 | } 22 | }, 23 | MINUS{ 24 | @Override 25 | public String toString(){ 26 | return "-"; 27 | } 28 | }, 29 | MULTIPLY{ 30 | @Override 31 | public String toString(){ 32 | return "X"; 33 | } 34 | }, 35 | DIVIDE{ 36 | @Override 37 | public String toString(){ 38 | return "/"; 39 | } 40 | }, 41 | AND{ 42 | @Override 43 | public String toString(){ 44 | return "&&"; 45 | } 46 | }, 47 | OR{ 48 | @Override 49 | public String toString(){ 50 | return "||"; 51 | } 52 | } 53 | }; 54 | 55 | private BinaryOperator o; 56 | 57 | public BinaryOpNode(BinaryOperator o){ 58 | this.o = o; 59 | } 60 | 61 | @Override 62 | public String toString(){ 63 | return o.toString(); 64 | } 65 | 66 | @Override 67 | public IValue apply(IValue... args) { 68 | // TODO Auto-generated method stub 69 | return null; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/ConstBox.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import com.ibm.wala.ipa.callgraph.CGNode; 14 | 15 | public class ConstBox implements IBox { 16 | private CGNode node; 17 | private Object value; 18 | private ConstType type; 19 | 20 | public ConstBox(CGNode node, Object value, ConstType type){ 21 | this.node = node; 22 | this.value = value; 23 | this.type = type; 24 | } 25 | 26 | private ConstType getConstType(Object v){ 27 | if(v instanceof String) 28 | return ConstType.STRING; 29 | else if(v instanceof Boolean) 30 | return ConstType.BOOL; 31 | else if(v instanceof Integer) 32 | return ConstType.INT; 33 | else if(v instanceof Double) 34 | return ConstType.DOUBLE; 35 | else if(v instanceof Float) 36 | return ConstType.DOUBLE; 37 | else if(v instanceof Long) 38 | return ConstType.LONG; 39 | 40 | return ConstType.UNKNOWN; 41 | } 42 | 43 | @Override 44 | public String toString(){ 45 | String str = "ConstBox[value: "; 46 | str += value.toString().replace("\"", "\\\""); 47 | str += ", type: " + type + "] declared in "; 48 | str += node.getMethod().getName().toString(); 49 | return str; 50 | } 51 | 52 | public Object getValue(){ 53 | return value; 54 | } 55 | 56 | public ConstType getType(){ 57 | return type; 58 | } 59 | 60 | @Override 61 | public T visit(IBoxVisitor v){ 62 | return v.visit(this); 63 | } 64 | 65 | @Override 66 | public CGNode getNode() { 67 | // TODO Auto-generated method stub 68 | return node; 69 | } 70 | 71 | @Override 72 | public int hashCode(){ 73 | return node.hashCode() + value.hashCode() + type.hashCode(); 74 | } 75 | 76 | @Override 77 | public boolean equals(Object o){ 78 | if(o instanceof ConstBox){ 79 | ConstBox v = (ConstBox)o; 80 | if(node.equals(v.getNode()) && value.equals(v.getValue()) && type.equals(v.getType())) 81 | return true; 82 | } 83 | return false; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/ConstType.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | public enum ConstType { 14 | STRING, 15 | INT, 16 | BOOL, 17 | DOUBLE, 18 | LONG, 19 | LONG_TOP, 20 | LONG_BOT, 21 | STRING_TOP, 22 | STRING_BOT, 23 | INT_TOP, 24 | BOOL_TOP, 25 | DOUBLE_TOP, 26 | UNKNOWN; 27 | 28 | private String name; 29 | 30 | static{ 31 | STRING.name = "String"; 32 | INT.name = "int"; 33 | BOOL.name = "bool"; 34 | DOUBLE.name = "double"; 35 | STRING_TOP.name = "StringTop"; 36 | INT_TOP.name = "IntTop"; 37 | BOOL_TOP.name = "BoolTop"; 38 | DOUBLE_TOP.name = "DoubleTop"; 39 | UNKNOWN.name = "unknown"; 40 | } 41 | 42 | public String toString(){ 43 | return name; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/IBox.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import com.ibm.wala.ipa.callgraph.CGNode; 14 | 15 | public interface IBox extends IConstraintNode { 16 | public T visit(IBoxVisitor v); 17 | public CGNode getNode(); 18 | } 19 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/IBoxVisitor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | public interface IBoxVisitor { 14 | public T visit(VarBox b); 15 | public T visit(ParamBox b); 16 | public T visit(ConstBox b); 17 | } 18 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/IConstraintEdge.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | public interface IConstraintEdge { 14 | public IConstraintNode from(); 15 | public IConstraintNode to(); 16 | } 17 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/IConstraintMonitor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import java.util.Set; 14 | 15 | public interface IConstraintMonitor { 16 | public void monitor(int iter, ConstraintGraph graph, IBox b, Set res); 17 | } 18 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/IConstraintNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | public interface IConstraintNode { 14 | @Override 15 | public String toString(); 16 | } 17 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/IOperatorNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | 15 | public interface IOperatorNode extends IConstraintNode { 16 | public IValue apply(IValue... args); 17 | } 18 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/IndexOfOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.IOperationModel; 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.IndexOfOpSetModel; 16 | 17 | public class IndexOfOpNode implements IOperatorNode { 18 | 19 | private static IOperationModel m; 20 | 21 | static{ 22 | m = IndexOfOpSetModel.getInstance(); 23 | } 24 | 25 | public IndexOfOpNode(){} 26 | 27 | @Override 28 | public String toString(){ 29 | return "indexOf"; 30 | } 31 | 32 | @Override 33 | public IValue apply(IValue... args) { 34 | // TODO Auto-generated method stub 35 | return m.apply(args); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/JoinOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.IOperationModel; 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.JoinOpSetModel; 16 | 17 | public class JoinOpNode implements IOperatorNode { 18 | 19 | private static IOperationModel m; 20 | 21 | static{ 22 | m = JoinOpSetModel.getInstance(); 23 | } 24 | 25 | public JoinOpNode(){ 26 | } 27 | 28 | @Override 29 | public String toString(){ 30 | return "join"; 31 | } 32 | 33 | @Override 34 | public IValue apply(IValue... args) { 35 | // TODO Auto-generated method stub 36 | return m.apply(args); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/LengthOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.IOperationModel; 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.LengthOpSetModel; 16 | 17 | public class LengthOpNode implements IOperatorNode { 18 | 19 | private static IOperationModel m; 20 | 21 | static{ 22 | m = LengthOpSetModel.getInstance(); 23 | } 24 | 25 | public LengthOpNode(){} 26 | 27 | @Override 28 | public String toString(){ 29 | return "length"; 30 | } 31 | 32 | @Override 33 | public IValue apply(IValue... args) { 34 | // TODO Auto-generated method stub 35 | return m.apply(args); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/OrderedEdge.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | public class OrderedEdge extends AbstractConstraintEdge { 14 | private int order; 15 | 16 | public OrderedEdge(IConstraintNode from, IConstraintNode to, int order){ 17 | super(from, to); 18 | this.order = order; 19 | } 20 | 21 | public int getOrder(){ 22 | return order; 23 | } 24 | 25 | @Override 26 | public String toString(){ 27 | return from() + " -> " + to() + " (order: " + order + ")"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/ParamBox.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import com.ibm.wala.ipa.callgraph.CGNode; 14 | 15 | public class ParamBox implements IBox { 16 | private CGNode node; 17 | private int var; 18 | 19 | public ParamBox(CGNode node, int var){ 20 | if(var < 1) 21 | throw new InternalError("parameter variable cannot be less than 1: var[" + var + "] in " + node); 22 | this.node = node; 23 | this.var = var; 24 | } 25 | 26 | @Override 27 | public String toString(){ 28 | String str = "ParamBox["; 29 | str += var; 30 | str += "] of " + node.getMethod().getName().toString(); 31 | return str; 32 | } 33 | 34 | public int getVar(){ 35 | return var; 36 | } 37 | 38 | @Override 39 | public T visit(IBoxVisitor v){ 40 | return v.visit(this); 41 | } 42 | 43 | @Override 44 | public CGNode getNode() { 45 | // TODO Auto-generated method stub 46 | return node; 47 | } 48 | 49 | @Override 50 | public int hashCode(){ 51 | return node.hashCode() + var; 52 | } 53 | 54 | @Override 55 | public boolean equals(Object o){ 56 | if(o instanceof ParamBox){ 57 | ParamBox v = (ParamBox)o; 58 | if(node.equals(v.getNode()) && var == v.getVar()) 59 | return true; 60 | } 61 | return false; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/PropagationEdge.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | public class PropagationEdge extends AbstractConstraintEdge { 14 | public PropagationEdge(IConstraintNode from, IConstraintNode to){ 15 | super(from, to); 16 | } 17 | 18 | @Override 19 | public String toString(){ 20 | return from() + " -> " + to(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/ReplaceOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.IOperationModel; 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.ReplaceOpSetModel; 16 | 17 | public class ReplaceOpNode implements IOperatorNode { 18 | private static IOperationModel m ; 19 | 20 | static{ 21 | m = ReplaceOpSetModel.getInstance(); 22 | } 23 | 24 | public ReplaceOpNode(){} 25 | 26 | @Override 27 | public String toString(){ 28 | return "replace"; 29 | } 30 | 31 | @Override 32 | public IValue apply(IValue... args) { 33 | // TODO Auto-generated method stub 34 | return m.apply(args); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/SubstringOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.IOperationModel; 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.SubstringOpSetModel; 16 | 17 | public class SubstringOpNode implements IOperatorNode { 18 | 19 | private static IOperationModel m; 20 | 21 | static{ 22 | m = SubstringOpSetModel.getInstance(); 23 | } 24 | public SubstringOpNode(){} 25 | 26 | @Override 27 | public String toString(){ 28 | return "subString"; 29 | } 30 | 31 | @Override 32 | public IValue apply(IValue... args) { 33 | // TODO Auto-generated method stub 34 | return m.apply(args); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/ToStringOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.IOperationModel; 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.ToStringOpSetModel; 16 | 17 | public class ToStringOpNode implements IOperatorNode { 18 | 19 | private static IOperationModel m; 20 | 21 | static{ 22 | m = ToStringOpSetModel.getInstance(); 23 | } 24 | 25 | public ToStringOpNode(){} 26 | 27 | @Override 28 | public String toString(){ 29 | return "toString"; 30 | } 31 | 32 | @Override 33 | public IValue apply(IValue... args) { 34 | // TODO Auto-generated method stub 35 | return m.apply(args); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/UnaryOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | 15 | public class UnaryOpNode implements IOperatorNode { 16 | public static enum UnaryOperator{ 17 | MINUS{ 18 | @Override 19 | public String toString(){ 20 | return "-"; 21 | } 22 | }, 23 | NOT{ 24 | @Override 25 | public String toString(){ 26 | return "!"; 27 | } 28 | } 29 | }; 30 | 31 | private UnaryOperator o; 32 | 33 | public UnaryOpNode(UnaryOperator o){ 34 | this.o = o; 35 | } 36 | 37 | @Override 38 | public String toString(){ 39 | return o.toString(); 40 | } 41 | 42 | @Override 43 | public IValue apply(IValue... args) { 44 | // TODO Auto-generated method stub 45 | return null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/UriCodecDecodeOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.IOperationModel; 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.UriCodecDecodeOpSetModel; 16 | 17 | public class UriCodecDecodeOpNode implements IOperatorNode { 18 | private static IOperationModel m; 19 | 20 | static{ 21 | m = UriCodecDecodeOpSetModel.getInstance(); 22 | } 23 | 24 | public UriCodecDecodeOpNode(){} 25 | 26 | @Override 27 | public String toString(){ 28 | return "UriCodec.decode"; 29 | } 30 | 31 | @Override 32 | public IValue apply(IValue... args) { 33 | // TODO Auto-generated method stub 34 | return m.apply(args); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/UriGetQueryParameterOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.IOperationModel; 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.UriGetQueryParameterOpSetModel; 16 | 17 | public class UriGetQueryParameterOpNode implements IOperatorNode { 18 | private static IOperationModel m; 19 | 20 | static{ 21 | m = UriGetQueryParameterOpSetModel.getInstance(); 22 | } 23 | 24 | public UriGetQueryParameterOpNode(){} 25 | 26 | @Override 27 | public String toString(){ 28 | return "Uri.getQueryParameter"; 29 | } 30 | 31 | @Override 32 | public IValue apply(IValue... args) { 33 | // TODO Auto-generated method stub 34 | return m.apply(args); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/UriParseOpNode.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.IOperationModel; 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.UriParseOpSetModel; 16 | 17 | public class UriParseOpNode implements IOperatorNode { 18 | 19 | private static IOperationModel m; 20 | 21 | static{ 22 | m = UriParseOpSetModel.getInstance(); 23 | } 24 | 25 | public UriParseOpNode(){} 26 | 27 | @Override 28 | public String toString(){ 29 | return "Uri.parse"; 30 | } 31 | 32 | @Override 33 | public IValue apply(IValue... args) { 34 | // TODO Auto-generated method stub 35 | return m.apply(args); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/VarBox.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint; 12 | 13 | import com.ibm.wala.ipa.callgraph.CGNode; 14 | 15 | public class VarBox implements IBox { 16 | private CGNode node; 17 | private int iindex; 18 | private int var; 19 | 20 | public VarBox(CGNode node, int iindex, int var){ 21 | if(var < 1){ 22 | String msg = "variable cannot be less than 1: var[" + var + "] in " + node; 23 | if(iindex > -1) 24 | msg += "\nat " + node.getIR().getInstructions()[iindex]; 25 | throw new InternalError(msg); 26 | } 27 | 28 | this.node = node; 29 | this.iindex = iindex; 30 | this.var = var; 31 | } 32 | 33 | @Override 34 | public String toString(){ 35 | String str = "VarBox["; 36 | // SSAInstruction inst = node.getIR().getInstructions()[iindex]; 37 | str += var; 38 | str += "] ";//@ " + inst; 39 | str += " in " + node /*.getMethod().getName().toString()*/ + " of " + node.getMethod().getDeclaringClass().getName().getClassName(); 40 | return str; 41 | } 42 | 43 | public int getVar(){ 44 | return var; 45 | } 46 | 47 | public int getIndex(){ 48 | return iindex; 49 | } 50 | 51 | @Override 52 | public T visit(IBoxVisitor v){ 53 | return v.visit(this); 54 | } 55 | 56 | @Override 57 | public CGNode getNode() { 58 | // TODO Auto-generated method stub 59 | return node; 60 | } 61 | 62 | @Override 63 | public int hashCode(){ 64 | return node.hashCode() + var; 65 | } 66 | 67 | @Override 68 | public boolean equals(Object o){ 69 | if(o instanceof VarBox){ 70 | VarBox v = (VarBox)o; 71 | if(node.equals(v.getNode()) && var == v.getVar()) 72 | return true; 73 | } 74 | return false; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/IStringConstraintSolver.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.ConstraintGraph; 14 | 15 | import java.util.Map; 16 | 17 | public interface IStringConstraintSolver { 18 | public Map solve(ConstraintGraph graph); 19 | } 20 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/IterationSolverMonitor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver; 12 | 13 | import java.util.Queue; 14 | 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.IConstraintNode; 16 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 17 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model.ISolverMonitor; 18 | 19 | public class IterationSolverMonitor implements ISolverMonitor { 20 | 21 | private int iter = 1; 22 | @Override 23 | public void monitor(Queue worklist, IConstraintNode n, IValue preV, IValue newV, boolean isUpdate) { 24 | // TODO Auto-generated method stub 25 | String print = "#" + (iter++) + ": "; 26 | print += "(" + worklist.size() + ")"; 27 | print += n +" "; 28 | print += preV + " => " + newV + " [" + isUpdate + "]"; 29 | // System.out.println(print); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/IBooleanDomain.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.BooleanBotValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.BooleanTopValue; 15 | 16 | public interface IBooleanDomain extends IDomain { 17 | public static BooleanTopValue TOP = BooleanTopValue.getInstance(); 18 | public static BooleanBotValue BOT = BooleanBotValue.getInstance(); 19 | } 20 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/IDomain.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.BotValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.TopValue; 16 | 17 | public interface IDomain { 18 | public static TopValue TOP = TopValue.getInstance(); 19 | public static BotValue BOT = BotValue.getInstance(); 20 | public IDomainOp getOperator(); 21 | public boolean isInstanceof(IValue v); 22 | } 23 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/IDomainOp.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | 15 | import java.util.Set; 16 | 17 | public interface IDomainOp { 18 | public IValue alpha(S cv); 19 | public IValue alpha(Set cv); 20 | public T gamma(IValue v); 21 | } 22 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/IDoubleDomain.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.DoubleBotValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.DoubleTopValue; 15 | 16 | public interface IDoubleDomain extends IDomain { 17 | public static DoubleTopValue TOP = DoubleTopValue.getInstance(); 18 | public static DoubleBotValue BOT = DoubleBotValue.getInstance(); 19 | } 20 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/IIntegerDomain.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IntegerBotValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IntegerTopValue; 15 | 16 | public interface IIntegerDomain extends IDomain { 17 | public static IntegerTopValue TOP = IntegerTopValue.getInstance(); 18 | public static IntegerBotValue BOT = IntegerBotValue.getInstance(); 19 | } 20 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/ILongDomain.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.LongBotValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.LongTopValue; 15 | 16 | public interface ILongDomain extends IDomain { 17 | public static LongTopValue TOP = LongTopValue.getInstance(); 18 | public static LongBotValue BOT = LongBotValue.getInstance(); 19 | } 20 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/IStringDomain.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.StringBotValue; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.StringTopValue; 15 | 16 | public interface IStringDomain extends IDomain{ 17 | public static StringTopValue TOP = StringTopValue.getInstance(); 18 | public static StringBotValue BOT = StringBotValue.getInstance(); 19 | } 20 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/BooleanBotValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public class BooleanBotValue extends TopValue implements IBooleanValue { 14 | 15 | private static BooleanBotValue instance; 16 | public static BooleanBotValue getInstance(){ 17 | if(instance == null) 18 | instance = new BooleanBotValue(); 19 | return instance; 20 | } 21 | 22 | private BooleanBotValue(){} 23 | 24 | @Override 25 | public IValue clone() { 26 | // TODO Auto-generated method stub 27 | return this; 28 | } 29 | 30 | @Override 31 | public IValue weakUpdate(IValue v) { 32 | // TODO Auto-generated method stub 33 | if(v instanceof IBooleanValue) 34 | return v; 35 | else if(v instanceof BotValue) 36 | return this; 37 | return TopValue.getInstance(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/BooleanTopValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public class BooleanTopValue extends TopValue implements IBooleanValue { 14 | private static BooleanTopValue instance; 15 | public static BooleanTopValue getInstance(){ 16 | if(instance == null) 17 | instance = new BooleanTopValue(); 18 | return instance; 19 | } 20 | 21 | private BooleanTopValue(){} 22 | 23 | @Override 24 | public IValue clone() { 25 | // TODO Auto-generated method stub 26 | return this; 27 | } 28 | 29 | @Override 30 | public IValue weakUpdate(IValue v) { 31 | // TODO Auto-generated method stub 32 | if(v instanceof IBooleanValue) 33 | return this; 34 | else if(v instanceof BotValue) 35 | return this; 36 | else 37 | return TopValue.getInstance(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/BotValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.IDomain; 14 | 15 | public class BotValue implements IValue { 16 | 17 | private static BotValue instance; 18 | public static BotValue getInstance(){ 19 | if(instance == null) 20 | instance = new BotValue(); 21 | return instance; 22 | } 23 | 24 | protected BotValue(){} 25 | 26 | @Override 27 | public IValue clone() { 28 | // TODO Auto-generated method stub 29 | return this; 30 | } 31 | 32 | @Override 33 | public IValue weakUpdate(IValue v) { 34 | // TODO Auto-generated method stub 35 | return v; 36 | } 37 | 38 | @Override 39 | public IDomain getDomain() { 40 | // TODO Auto-generated method stub 41 | return null; 42 | } 43 | 44 | @Override 45 | public String toString(){ 46 | return "BOT"; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/DoubleBotValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public class DoubleBotValue extends BotValue implements IDoubleValue { 14 | 15 | private static DoubleBotValue instance; 16 | public static DoubleBotValue getInstance(){ 17 | if(instance == null) 18 | instance = new DoubleBotValue(); 19 | return instance; 20 | } 21 | 22 | private DoubleBotValue(){} 23 | 24 | @Override 25 | public IValue clone() { 26 | // TODO Auto-generated method stub 27 | return this; 28 | } 29 | 30 | @Override 31 | public IValue weakUpdate(IValue v) { 32 | // TODO Auto-generated method stub 33 | if(v instanceof IDoubleValue) 34 | return v; 35 | else if(v instanceof BotValue) 36 | return this; 37 | else 38 | return TopValue.getInstance(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/DoubleTopValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public class DoubleTopValue extends TopValue implements IDoubleValue { 14 | private static DoubleTopValue instance; 15 | public static DoubleTopValue getInstance(){ 16 | if(instance == null) 17 | instance = new DoubleTopValue(); 18 | return instance; 19 | } 20 | 21 | private DoubleTopValue(){} 22 | 23 | @Override 24 | public IValue clone() { 25 | // TODO Auto-generated method stub 26 | return this; 27 | } 28 | 29 | @Override 30 | public IValue weakUpdate(IValue v) { 31 | // TODO Auto-generated method stub 32 | if(v instanceof IDoubleValue) 33 | return this; 34 | else if(v instanceof BotValue) 35 | return this; 36 | else 37 | return TopValue.getInstance(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/IBooleanValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public interface IBooleanValue extends IValue { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/IDoubleValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public interface IDoubleValue extends IValue { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/IIntegerValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public interface IIntegerValue extends IValue { 14 | } 15 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/ILongValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public interface ILongValue extends IValue { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/IStringValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public interface IStringValue extends IValue { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/IValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.IDomain; 14 | 15 | public interface IValue { 16 | public IValue clone(); 17 | public IValue weakUpdate(IValue v); 18 | public IDomain getDomain(); 19 | } 20 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/IntegerBotValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public class IntegerBotValue extends BotValue implements IIntegerValue { 14 | 15 | private static IntegerBotValue instance; 16 | public static IntegerBotValue getInstance(){ 17 | if(instance == null) 18 | instance = new IntegerBotValue(); 19 | return instance; 20 | } 21 | 22 | private IntegerBotValue(){} 23 | 24 | @Override 25 | public IValue clone() { 26 | // TODO Auto-generated method stub 27 | return this; 28 | } 29 | 30 | @Override 31 | public IValue weakUpdate(IValue v) { 32 | // TODO Auto-generated method stub 33 | if(v instanceof IIntegerValue) 34 | return v; 35 | else if(v instanceof BotValue) 36 | return this; 37 | else 38 | return TopValue.getInstance(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/IntegerTopValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public class IntegerTopValue extends TopValue implements IIntegerValue { 14 | 15 | private static IntegerTopValue instance; 16 | public static IntegerTopValue getInstance(){ 17 | if(instance == null) 18 | instance = new IntegerTopValue(); 19 | return instance; 20 | } 21 | 22 | private IntegerTopValue(){} 23 | 24 | @Override 25 | public IValue clone() { 26 | // TODO Auto-generated method stub 27 | return this; 28 | } 29 | 30 | @Override 31 | public IValue weakUpdate(IValue v) { 32 | // TODO Auto-generated method stub 33 | if(v instanceof IIntegerValue) 34 | return this; 35 | else if(v instanceof BotValue) 36 | return this; 37 | else 38 | return TopValue.getInstance(); 39 | } 40 | 41 | @Override 42 | public String toString(){ 43 | return "IntegerTop"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/LongBotValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public class LongBotValue extends BotValue implements ILongValue { 14 | private static LongBotValue instance; 15 | public static LongBotValue getInstance(){ 16 | if(instance == null) 17 | instance = new LongBotValue(); 18 | return instance; 19 | } 20 | 21 | private LongBotValue(){} 22 | 23 | @Override 24 | public IValue clone() { 25 | // TODO Auto-generated method stub 26 | return this; 27 | } 28 | 29 | @Override 30 | public IValue weakUpdate(IValue v) { 31 | // TODO Auto-generated method stub 32 | if(v instanceof ILongValue) 33 | return v; 34 | else if(v instanceof BotValue) 35 | return this; 36 | else 37 | return TopValue.getInstance(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/LongTopValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public class LongTopValue extends TopValue implements ILongValue { 14 | 15 | private static LongTopValue instance; 16 | public static LongTopValue getInstance(){ 17 | if(instance == null) 18 | instance = new LongTopValue(); 19 | return instance; 20 | } 21 | 22 | private LongTopValue(){} 23 | 24 | @Override 25 | public IValue clone() { 26 | // TODO Auto-generated method stub 27 | return this; 28 | } 29 | 30 | @Override 31 | public IValue weakUpdate(IValue v) { 32 | // TODO Auto-generated method stub 33 | if(v instanceof ILongValue) 34 | return this; 35 | else if(v instanceof BotValue) 36 | return this; 37 | else 38 | return TopValue.getInstance(); 39 | } 40 | 41 | @Override 42 | public String toString(){ 43 | return "LongTop"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/StringBotValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public class StringBotValue extends BotValue implements IStringValue { 14 | 15 | private static StringBotValue instance; 16 | public static StringBotValue getInstance(){ 17 | if(instance == null) 18 | instance = new StringBotValue(); 19 | return instance; 20 | } 21 | 22 | private StringBotValue(){} 23 | 24 | @Override 25 | public IValue clone() { 26 | // TODO Auto-generated method stub 27 | return this; 28 | } 29 | 30 | @Override 31 | public IValue weakUpdate(IValue v) { 32 | // TODO Auto-generated method stub 33 | if(v instanceof IStringValue) 34 | return v; 35 | else if(v instanceof BotValue) 36 | return this; 37 | return TopValue.getInstance(); 38 | } 39 | 40 | @Override 41 | public String toString(){ 42 | return "StringBot"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/StringTopValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | public class StringTopValue extends TopValue implements IStringValue { 14 | 15 | private static StringTopValue instance; 16 | public static StringTopValue getInstance(){ 17 | if(instance == null) 18 | instance = new StringTopValue(); 19 | return instance; 20 | } 21 | 22 | private StringTopValue(){ 23 | } 24 | 25 | @Override 26 | public IStringValue clone() { 27 | // TODO Auto-generated method stub 28 | return this; 29 | } 30 | 31 | @Override 32 | public IValue weakUpdate(IValue v) { 33 | // TODO Auto-generated method stub 34 | if(v instanceof IStringValue) 35 | return this; 36 | else if(v instanceof BotValue) 37 | return this; 38 | else 39 | return TopValue.getInstance(); 40 | } 41 | 42 | @Override 43 | public String toString(){ 44 | return "StringTop"; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/domain/value/TopValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.IDomain; 14 | 15 | public class TopValue implements IValue { 16 | 17 | private static TopValue instance; 18 | public static TopValue getInstance(){ 19 | if(instance == null) 20 | instance = new TopValue(); 21 | return instance; 22 | } 23 | 24 | protected TopValue(){} 25 | 26 | @Override 27 | public IValue clone() { 28 | // TODO Auto-generated method stub 29 | return this; 30 | } 31 | 32 | @Override 33 | public IValue weakUpdate(IValue v) { 34 | // TODO Auto-generated method stub 35 | return this; 36 | } 37 | 38 | @Override 39 | public IDomain getDomain(){ 40 | return null; 41 | } 42 | 43 | @Override 44 | public String toString(){ 45 | return "TOP"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/model/IOperationModel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | 15 | public interface IOperationModel { 16 | public static boolean CRASH = true; 17 | public IValue apply(IValue... args); 18 | } 19 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/model/ISolverMonitor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model; 12 | 13 | import java.util.Queue; 14 | 15 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.IConstraintNode; 16 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 17 | 18 | public interface ISolverMonitor { 19 | public void monitor(Queue worklist, IConstraintNode n, IValue preV, IValue newV, boolean isUpdate); 20 | } 21 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/model/JoinOpSetModel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | 15 | public class JoinOpSetModel implements IOperationModel { 16 | 17 | private static JoinOpSetModel instance; 18 | 19 | public static JoinOpSetModel getInstance(){ 20 | if(instance == null) 21 | instance = new JoinOpSetModel(); 22 | return instance; 23 | } 24 | 25 | @Override 26 | public IValue apply(IValue... args) { 27 | // TODO Auto-generated method stub 28 | if(args.length < 2) 29 | throw new InternalError("Join operation must have two in-edge at least."); 30 | 31 | IValue arg = args[0].clone(); 32 | 33 | for(int i=1; i cons = (Set)arg.getDomain().getOperator().gamma(arg); 51 | Set strCons = new HashSet(); 52 | for(Object con : cons){ 53 | strCons.add(String.valueOf(con)); 54 | } 55 | return StringSetDomain.op().alpha(strCons); 56 | }else if(arg instanceof IntegerSetValue){ 57 | Set cons = (Set)arg.getDomain().getOperator().gamma(arg); 58 | Set strCons = new HashSet(); 59 | for(Integer con : cons){ 60 | strCons.add(String.valueOf(con)); 61 | } 62 | return StringSetDomain.op().alpha(strCons); 63 | }else 64 | if(CRASH) 65 | Assertions.UNREACHABLE("incorrect arg(arg: " + arg.getClass().getName() + ")"); 66 | else 67 | return BotValue.getInstance(); 68 | return null; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/constraint/solver/model/UriParseOpSetModel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.model; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.solver.domain.value.IValue; 14 | 15 | public class UriParseOpSetModel implements IOperationModel{ 16 | private static UriParseOpSetModel instance; 17 | 18 | public static UriParseOpSetModel getInstance(){ 19 | if(instance == null) 20 | instance = new UriParseOpSetModel(); 21 | return instance; 22 | } 23 | 24 | @Override 25 | public IValue apply(IValue... args) { 26 | // TODO Auto-generated method stub 27 | if(args.length != 1) 28 | throw new InternalError("UriParse method must have only one in-edge."); 29 | 30 | // just pass the string value. 31 | return args[0].clone(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/model/AbstractClassModel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.model; 12 | 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | import com.ibm.wala.types.Selector; 17 | 18 | abstract public class AbstractClassModel implements IClassModel { 19 | protected Map methodMap; 20 | 21 | protected AbstractClassModel(){ 22 | methodMap = new HashMap(); 23 | init(); 24 | } 25 | 26 | abstract protected void init(); 27 | 28 | @Override 29 | public IMethodModel getMethod(Selector mSelector) { 30 | // TODO Auto-generated method stub 31 | if(methodMap.containsKey(mSelector)) 32 | return methodMap.get(mSelector); 33 | // System.err.println("Unkwon method: " + mSelector); 34 | return null; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/model/CharsetProviderClassModel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.model; 12 | 13 | import com.ibm.wala.ipa.callgraph.CGNode; 14 | import com.ibm.wala.ssa.SSAInvokeInstruction; 15 | import com.ibm.wala.types.Selector; 16 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.ConstraintGraph; 17 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.IBox; 18 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.ToStringOpNode; 19 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.VarBox; 20 | 21 | import java.util.HashSet; 22 | import java.util.Set; 23 | 24 | public class CharsetProviderClassModel extends AbstractClassModel { 25 | private static CharsetProviderClassModel instance; 26 | 27 | public static CharsetProviderClassModel getInstance(){ 28 | if(instance == null) 29 | instance = new CharsetProviderClassModel(); 30 | return instance; 31 | } 32 | 33 | protected void init(){ 34 | methodMap.put(Selector.make("charsetForName(Ljava/lang/String;)Ljava/nio/charset/Charset;"), new CharsetForName()); 35 | // methodMap.put(Selector.make("toString()Ljava/lang/String;"), new ToString1()); 36 | // methodMap.put(Selector.make("charsetForName(Ljava/lang/String;)Ljava/nio/charset/Charset;"), new ToString1()); 37 | //charsetForName(Ljava/lang/String;)Ljava/nio/charset/Charset; 38 | } 39 | 40 | //charsetForName(Ljava/lang/String;)Ljava/nio/charset/Charset; 41 | class CharsetForName implements IMethodModel>{ 42 | @Override 43 | public Set draw(ConstraintGraph graph, IBox def, CGNode caller, 44 | SSAInvokeInstruction invokeInst) { 45 | Set boxSet = new HashSet(); 46 | int objVar = invokeInst.getUse(0); 47 | IBox objBox = new VarBox(caller, invokeInst.iindex, objVar); 48 | if(graph.addEdge(new ToStringOpNode(), def, objBox)){ 49 | boxSet.add(objBox); 50 | } 51 | return boxSet; 52 | } 53 | 54 | @Override 55 | public String toString(){ 56 | return "Constraint Graph Method Model: CharsetProvider.charsetForName(Ljava/lang/String;)Ljava/nio/charset/Charset;"; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/model/IClassModel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.model; 12 | 13 | import com.ibm.wala.types.Selector; 14 | 15 | public interface IClassModel { 16 | public IMethodModel getMethod(Selector mSelector); 17 | } 18 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/model/IMethodModel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.model; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.ConstraintGraph; 14 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.IBox; 15 | 16 | import com.ibm.wala.ipa.callgraph.CGNode; 17 | import com.ibm.wala.ssa.SSAInvokeInstruction; 18 | 19 | public interface IMethodModel { 20 | public T draw(ConstraintGraph graph, IBox def, CGNode caller, SSAInvokeInstruction invokeInst); 21 | } 22 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/model/ObjectClassModel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.model; 12 | 13 | import java.util.HashSet; 14 | import java.util.Set; 15 | 16 | import com.ibm.wala.ipa.callgraph.CGNode; 17 | import com.ibm.wala.ssa.SSAInvokeInstruction; 18 | import com.ibm.wala.types.Selector; 19 | 20 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.ConstraintGraph; 21 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.IBox; 22 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.ToStringOpNode; 23 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.VarBox; 24 | 25 | public class ObjectClassModel extends AbstractClassModel{ 26 | private static ObjectClassModel instance; 27 | 28 | public static ObjectClassModel getInstance(){ 29 | if(instance == null) 30 | instance = new ObjectClassModel(); 31 | return instance; 32 | } 33 | 34 | protected void init(){ 35 | methodMap.put(Selector.make("toString(V)Ljava/lang/String;"), new ToString1()); 36 | methodMap.put(Selector.make("toString()Ljava/lang/String;"), new ToString1()); 37 | // methodMap.put(Selector.make("charsetForName(Ljava/lang/String;)Ljava/nio/charset/Charset;"), new ToString1()); 38 | //charsetForName(Ljava/lang/String;)Ljava/nio/charset/Charset; 39 | } 40 | 41 | //toString(V)Ljava/lang/String; 42 | //toString()Ljava/lang/String; 43 | class ToString1 implements IMethodModel>{ 44 | @Override 45 | public Set draw(ConstraintGraph graph, IBox def, CGNode caller, 46 | SSAInvokeInstruction invokeInst) { 47 | Set boxSet = new HashSet(); 48 | int objVar = invokeInst.getUse(0); 49 | IBox objBox = new VarBox(caller, invokeInst.iindex, objVar); 50 | if(graph.addEdge(new ToStringOpNode(), def, objBox)){ 51 | boxSet.add(objBox); 52 | } 53 | return boxSet; 54 | } 55 | 56 | @Override 57 | public String toString(){ 58 | return "Constraint Graph Method Model: Object.toString"; 59 | } 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/model/UriClassModel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.model; 12 | 13 | import java.util.HashSet; 14 | import java.util.Set; 15 | 16 | import com.ibm.wala.ipa.callgraph.CGNode; 17 | import com.ibm.wala.ssa.SSAInvokeInstruction; 18 | import com.ibm.wala.types.Selector; 19 | 20 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.ConstraintGraph; 21 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.IBox; 22 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.ToStringOpNode; 23 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.VarBox; 24 | 25 | public class UriClassModel extends AbstractClassModel{ 26 | private static UriClassModel instance; 27 | 28 | public static UriClassModel getInstance(){ 29 | if(instance == null) 30 | instance = new UriClassModel(); 31 | return instance; 32 | } 33 | 34 | protected void init(){ 35 | methodMap.put(Selector.make("toString()Ljava/lang/String;"), new ToString()); 36 | // methodMap.put("getQueryParameter", new GetQueryParameter()); 37 | // methodMap.put("parse", new Parse()); 38 | 39 | } 40 | 41 | //toString()Ljava/lang/String; 42 | class ToString implements IMethodModel>{ 43 | 44 | @Override 45 | public Set draw(ConstraintGraph graph, IBox def, CGNode caller, SSAInvokeInstruction invokeInst) { 46 | // TODO Auto-generated method stub 47 | Set boxSet = new HashSet(); 48 | int uriVar = invokeInst.getUse(0); 49 | IBox uriBox = new VarBox(caller, invokeInst.iindex, uriVar); 50 | if(graph.addEdge(new ToStringOpNode(), def, uriBox)){ 51 | boxSet.add(uriBox); 52 | } 53 | return boxSet; 54 | } 55 | 56 | @Override 57 | public String toString(){ 58 | return "Constraint Graph Method Model: Uri.toString()Ljava/lang/String;"; 59 | } 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/analysis/string/model/UriCodecClassModel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.analysis.string.model; 12 | 13 | import java.util.HashSet; 14 | import java.util.Set; 15 | 16 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.ConstraintGraph; 17 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.IBox; 18 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.UriCodecDecodeOpNode; 19 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.VarBox; 20 | 21 | import com.ibm.wala.ipa.callgraph.CGNode; 22 | import com.ibm.wala.ssa.SSAInvokeInstruction; 23 | import com.ibm.wala.types.Selector; 24 | 25 | public class UriCodecClassModel extends AbstractClassModel{ 26 | private static UriCodecClassModel instance; 27 | 28 | public static UriCodecClassModel getInstance(){ 29 | if(instance == null) 30 | instance = new UriCodecClassModel(); 31 | return instance; 32 | } 33 | 34 | protected void init(){ 35 | methodMap.put(Selector.make("decode(Ljava/lang/String;ZLjava/nio/charset/Charset;Z)Ljava/lang/String;"), new Decode()); 36 | } 37 | 38 | //decode(Ljava/lang/String;ZLjava/nio/charset/Charset;Z)Ljava/lang/String; 39 | class Decode implements IMethodModel>{ 40 | 41 | @Override 42 | public Set draw(ConstraintGraph graph, IBox def, CGNode caller, 43 | SSAInvokeInstruction invokeInst) { 44 | Set boxSet = new HashSet(); 45 | int stringVar = invokeInst.getUse(0); 46 | int convertPlusVar = invokeInst.getUse(1); 47 | int charsetVar = invokeInst.getUse(2); 48 | int throwVar = invokeInst.getUse(3); 49 | 50 | IBox stringBox = new VarBox(caller, invokeInst.iindex, stringVar); 51 | IBox convertPlusBox = new VarBox(caller, invokeInst.iindex, convertPlusVar); 52 | IBox charsetBox = new VarBox(caller, invokeInst.iindex, charsetVar); 53 | IBox throwBox = new VarBox(caller, invokeInst.iindex, throwVar); 54 | 55 | if(graph.addEdge(new UriCodecDecodeOpNode(), def, stringBox, convertPlusBox, charsetBox, throwBox)){ 56 | boxSet.add(stringBox); 57 | boxSet.add(convertPlusBox); 58 | boxSet.add(charsetBox); 59 | boxSet.add(throwBox); 60 | } 61 | return boxSet; 62 | } 63 | 64 | @Override 65 | public String toString(){ 66 | return "Constraint Graph Method Model: UriCodec.decode(Ljava/lang/String;ZLjava/nio/charset/Charset;Z)Ljava/lang/String;"; 67 | } 68 | 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/appinfo/ManifestInfo.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.appinfo; 12 | 13 | import kr.ac.kaist.wala.hybridroid.appinfo.properties.Property; 14 | 15 | import java.util.ArrayList; 16 | import java.util.HashSet; 17 | import java.util.List; 18 | import java.util.Set; 19 | 20 | 21 | public class ManifestInfo { 22 | private Property root; 23 | 24 | public ManifestInfo(Property root){ 25 | this.root = root; 26 | } 27 | 28 | public String getPackageName(){ 29 | return root.getAttributeValue("package"); 30 | } 31 | 32 | public Set getActivityNames(){ 33 | Set names = new HashSet(); 34 | Set activityProps = getProperties(Property.ACTIVITY); 35 | for(Property activityProp : activityProps){ 36 | names.add(Property.tagToString(activityProp.getTag())); 37 | } 38 | return names; 39 | } 40 | 41 | public Set getProperties(String name){ 42 | return getProperties(Property.nameToTag(name)); 43 | } 44 | 45 | public Set getProperties(int tag){ 46 | Set result = new HashSet(); 47 | List bfs = new ArrayList(); 48 | bfs.add(root); 49 | 50 | while(!bfs.isEmpty()){ 51 | Property prop = bfs.get(0); 52 | bfs.remove(0); 53 | if(prop.getTag() == tag) 54 | result.add(prop); 55 | bfs.addAll(prop.getChildren()); 56 | } 57 | return result; 58 | } 59 | 60 | public String getAttribute(Property p, String name){ 61 | if(p.isDefinedAttribute(name)) 62 | return p.getAttributeValue(name); 63 | else 64 | return null; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/callback/CallbackAndroidJavaVisitor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.callback; 12 | 13 | import com.ibm.wala.ipa.callgraph.CGNode; 14 | import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder; 15 | 16 | import kr.ac.kaist.wala.hybridroid.analysis.resource.AndroidResourceAnalysis; 17 | import kr.ac.kaist.wala.hybridroid.callgraph.ResourceCallGraphBuilder.ResourceVisitor; 18 | 19 | /** 20 | * @author Sungho Lee 21 | * 22 | */ 23 | public class CallbackAndroidJavaVisitor extends ResourceVisitor { 24 | 25 | /** 26 | * @param builder 27 | * @param node 28 | * @param ara 29 | */ 30 | public CallbackAndroidJavaVisitor(SSAPropagationCallGraphBuilder builder, CGNode node, 31 | AndroidResourceAnalysis ara) { 32 | super(builder, node, ara); 33 | // TODO Auto-generated constructor stub 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/callgraph/AndroidHybridMethodTargetSelector.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.callgraph; 12 | 13 | import com.ibm.wala.cast.ipa.callgraph.CrossLanguageMethodTargetSelector; 14 | import com.ibm.wala.classLoader.CallSiteReference; 15 | import com.ibm.wala.classLoader.IClass; 16 | import com.ibm.wala.classLoader.IMethod; 17 | import com.ibm.wala.ipa.callgraph.CGNode; 18 | import com.ibm.wala.ipa.callgraph.MethodTargetSelector; 19 | import com.ibm.wala.util.strings.Atom; 20 | import kr.ac.kaist.wala.hybridroid.pointer.MockupClass; 21 | 22 | import java.util.Map; 23 | 24 | public class AndroidHybridMethodTargetSelector extends 25 | CrossLanguageMethodTargetSelector { 26 | public static boolean DEBUG = false; 27 | 28 | public AndroidHybridMethodTargetSelector( 29 | Map languageSelectors) { 30 | super(languageSelectors); 31 | } 32 | 33 | @Override 34 | public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, 35 | IClass receiver) { 36 | 37 | if(receiver instanceof MockupClass){ 38 | IMethod target = ((MockupClass)receiver).getMethod(); 39 | if(DEBUG){ 40 | System.err.println("@caller: " + caller); 41 | System.err.println("@site: " + site); 42 | System.err.println("@receiver: " + receiver); 43 | System.err.println("@target: " + target); 44 | } 45 | return target; 46 | } 47 | // else if(caller.getMethod().getDeclaringClass().getClassLoader().getReference().equals(ClassLoaderReference.Application)){ 48 | // return super.getCalleeTarget(caller, site, receiver); 49 | // } 50 | else{ 51 | return super.getCalleeTarget(caller, site, receiver); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/callgraph/HybridClassLoaderFactory.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.callgraph; 12 | 13 | import com.ibm.wala.cast.js.loader.JavaScriptLoader; 14 | import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory; 15 | import com.ibm.wala.cast.js.translator.JavaScriptTranslatorFactory; 16 | import com.ibm.wala.cast.js.types.JavaScriptTypes; 17 | import com.ibm.wala.classLoader.ClassLoaderFactoryImpl; 18 | import com.ibm.wala.classLoader.IClassLoader; 19 | import com.ibm.wala.ipa.callgraph.AnalysisScope; 20 | import com.ibm.wala.ipa.cha.IClassHierarchy; 21 | import com.ibm.wala.types.ClassLoaderReference; 22 | import com.ibm.wala.util.config.SetOfClasses; 23 | 24 | import java.io.IOException; 25 | 26 | public class HybridClassLoaderFactory extends ClassLoaderFactoryImpl { 27 | 28 | private final JavaScriptTranslatorFactory jsTranslatorFactory; 29 | 30 | public HybridClassLoaderFactory( 31 | JavaScriptTranslatorFactory jsTranslatorFactory, 32 | SetOfClasses exclusions) 33 | { 34 | super(exclusions); 35 | this.jsTranslatorFactory = jsTranslatorFactory; 36 | } 37 | 38 | public HybridClassLoaderFactory() { 39 | this(new CAstRhinoTranslatorFactory(), null); 40 | } 41 | 42 | @Override 43 | protected IClassLoader 44 | makeNewClassLoader(ClassLoaderReference classLoaderReference, 45 | IClassHierarchy cha, 46 | IClassLoader parent, 47 | AnalysisScope scope) 48 | throws IOException 49 | { 50 | if (classLoaderReference.equals(JavaScriptTypes.jsLoader)) { 51 | JavaScriptLoader L = new JavaScriptLoader(cha, jsTranslatorFactory); 52 | L.init(scope.getModules(classLoaderReference)); 53 | return L; 54 | 55 | } else { 56 | return super.makeNewClassLoader(classLoaderReference, cha, parent, scope); 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/callgraph/HybridContextSelector.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.callgraph; 12 | 13 | import com.ibm.wala.cast.js.types.JavaScriptTypes; 14 | import com.ibm.wala.classLoader.CallSiteReference; 15 | import com.ibm.wala.classLoader.IMethod; 16 | import com.ibm.wala.ipa.callgraph.CGNode; 17 | import com.ibm.wala.ipa.callgraph.Context; 18 | import com.ibm.wala.ipa.callgraph.ContextSelector; 19 | import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; 20 | import com.ibm.wala.util.intset.IntSet; 21 | 22 | public class HybridContextSelector implements ContextSelector { 23 | 24 | private ContextSelector delegateForJava; 25 | private ContextSelector delegateForJS; 26 | 27 | public HybridContextSelector(ContextSelector delegateForJava, ContextSelector delegateForJS){ 28 | this.delegateForJava = delegateForJava; 29 | this.delegateForJS = delegateForJS; 30 | } 31 | 32 | @Override 33 | public Context getCalleeTarget(CGNode caller, CallSiteReference site, IMethod callee, 34 | InstanceKey[] actualParameters) { 35 | // TODO Auto-generated method stub 36 | if(isJavaMethod(caller.getMethod())) 37 | return delegateForJava.getCalleeTarget(caller, site, callee, actualParameters); 38 | else 39 | return delegateForJS.getCalleeTarget(caller, site, callee, actualParameters); 40 | } 41 | 42 | @Override 43 | public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) { 44 | // TODO Auto-generated method stub 45 | if(isJavaMethod(caller.getMethod())) 46 | return delegateForJava.getRelevantParameters(caller, site); 47 | else 48 | return delegateForJS.getRelevantParameters(caller, site); 49 | } 50 | 51 | private boolean isJavaMethod(IMethod m){ 52 | if(m.getDeclaringClass().getClassLoader().equals(JavaScriptTypes.jsLoader)) 53 | return false; 54 | return true; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/callgraph/HybridIRFactory.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.callgraph; 12 | 13 | import com.ibm.wala.cast.ir.ssa.AstIRFactory; 14 | import com.ibm.wala.classLoader.IMethod; 15 | import com.ibm.wala.dalvik.classLoader.DexIMethod; 16 | import com.ibm.wala.dalvik.classLoader.DexIRFactory; 17 | import com.ibm.wala.ipa.callgraph.Context; 18 | import com.ibm.wala.ssa.DefaultIRFactory; 19 | import com.ibm.wala.ssa.IR; 20 | import com.ibm.wala.ssa.IRFactory; 21 | import com.ibm.wala.ssa.SSAInvokeInstruction; 22 | import com.ibm.wala.ssa.SSAOptions; 23 | 24 | public class HybridIRFactory extends DefaultIRFactory { 25 | 26 | private IRFactory jsIRFactory; 27 | private IRFactory dexIRFactory; 28 | 29 | public HybridIRFactory(){ 30 | jsIRFactory = AstIRFactory.makeDefaultFactory(); 31 | dexIRFactory = new DexIRFactory(); 32 | SSAInvokeInstruction a; 33 | } 34 | 35 | @Override 36 | public IR makeIR(IMethod method, Context c, SSAOptions options) 37 | throws IllegalArgumentException { 38 | // TODO Auto-generated method stub 39 | if(method instanceof DexIMethod) 40 | return dexIRFactory.makeIR(method, c, options); 41 | else 42 | return jsIRFactory.makeIR(method, c, options); 43 | } 44 | 45 | @Override 46 | public boolean contextIsIrrelevant(IMethod method) { 47 | // TODO Auto-generated method stub 48 | if(method instanceof DexIMethod) 49 | return dexIRFactory.contextIsIrrelevant(method); 50 | else 51 | return jsIRFactory.contextIsIrrelevant(method); 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/callgraph/graphutils/ConstraintGraphVisualizer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.callgraph.graphutils; 12 | 13 | import kr.ac.kaist.wala.hybridroid.analysis.string.constraint.*; 14 | import kr.ac.kaist.wala.hybridroid.util.graph.visualize.Visualizer; 15 | import kr.ac.kaist.wala.hybridroid.util.graph.visualize.Visualizer.BoxType; 16 | 17 | import java.io.File; 18 | 19 | public class ConstraintGraphVisualizer { 20 | private Visualizer vis; 21 | public ConstraintGraphVisualizer(){ 22 | } 23 | 24 | public File visualize(ConstraintGraph graph, String out, IBox... spots){ 25 | vis = Visualizer.getInstance(); 26 | vis.clear(); 27 | vis.setType(Visualizer.GraphType.Digraph); 28 | 29 | if(spots != null) 30 | for(IBox spot : spots) 31 | vis.setColor(spot, Visualizer.BoxColor.RED); 32 | 33 | for(IConstraintNode from : graph){ 34 | if(from instanceof IBox){ 35 | vis.setShape(from, Visualizer.BoxType.RECT); 36 | }else{ 37 | vis.setShape(from, BoxType.CIRCLE); 38 | } 39 | for(IConstraintEdge outEdge : graph.getOutEdges(from)){ 40 | IConstraintNode to = outEdge.to(); 41 | 42 | if(to instanceof IBox){ 43 | vis.setShape(to, BoxType.RECT); 44 | }else{ 45 | vis.setShape(to, BoxType.CIRCLE); 46 | } 47 | 48 | if(outEdge instanceof OrderedEdge) 49 | vis.fromAtoB(from, to, ((OrderedEdge)outEdge).getOrder() + ""); 50 | else 51 | vis.fromAtoB(from, to); 52 | } 53 | } 54 | vis.printGraph(out); 55 | File outFile = new File(out); 56 | return outFile; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/callgraph/graphutils/WalaCFGVisualizer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.callgraph.graphutils; 12 | 13 | import com.ibm.wala.ssa.ISSABasicBlock; 14 | import com.ibm.wala.ssa.SSACFG; 15 | import com.ibm.wala.ssa.SSAInstruction; 16 | import kr.ac.kaist.wala.hybridroid.util.graph.visualize.Visualizer; 17 | import kr.ac.kaist.wala.hybridroid.util.graph.visualize.Visualizer.GraphType; 18 | 19 | import java.io.File; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | public class WalaCFGVisualizer { 24 | 25 | private Map labelMap; 26 | 27 | public WalaCFGVisualizer(){ 28 | labelMap = new HashMap(); 29 | } 30 | 31 | public File visualize(SSACFG cfg, String out){ 32 | Visualizer vis = Visualizer.getInstance(); 33 | vis.clear(); 34 | vis.setType(GraphType.Digraph); 35 | 36 | for(ISSABasicBlock node : cfg){ 37 | for(ISSABasicBlock predNode : cfg.getNormalPredecessors(node)){ 38 | vis.fromAtoB(getLabel(cfg, predNode), getLabel(cfg, node)); 39 | } 40 | } 41 | vis.printGraph(out); 42 | File outFile = new File(out); 43 | return outFile; 44 | } 45 | 46 | private String getLabel(SSACFG cfg, ISSABasicBlock node){ 47 | String label = ""; 48 | 49 | if(labelMap.containsKey(node)) 50 | return labelMap.get(node); 51 | 52 | label += node.toString() + "\\l"; 53 | 54 | if(node.isEntryBlock()) 55 | label += "entry\\l"; 56 | if(node.isExitBlock()) 57 | label += "exit\\l"; 58 | else{ 59 | int firstIndex = node.getFirstInstructionIndex(); 60 | SSAInstruction firstInst = null; 61 | if(!(firstIndex < 0)) 62 | firstInst = cfg.getInstructions()[firstIndex]; 63 | 64 | int lastIndex = node.getLastInstructionIndex(); 65 | 66 | SSAInstruction lastInst = null; 67 | if(!(lastIndex < 0)) 68 | lastInst = node.getLastInstruction(); 69 | 70 | label += "[" + firstIndex + "] " + firstInst + "\\l"; 71 | label += "...\\l"; 72 | label += "[" + lastIndex + "] " + lastInst + "\\l"; 73 | } 74 | labelMap.put(node, label); 75 | return label; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/exception/InternalError.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.exception; 12 | 13 | public class InternalError extends Exception { 14 | 15 | /** 16 | * 17 | */ 18 | private static final long serialVersionUID = 363458200365316710L; 19 | private String msg; 20 | public InternalError(String msg){ 21 | this.msg = msg; 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | // TODO Auto-generated method stub 27 | return msg; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/models/Java60RegressionExclusions.txt: -------------------------------------------------------------------------------- 1 | java\/awt\/.* 2 | javax\/swing\/.* 3 | sun\/awt\/.* 4 | sun\/swing\/.* 5 | com\/sun\/.* 6 | sun\/.* 7 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/models/miniprologue.js: -------------------------------------------------------------------------------- 1 | // the internal primitive mechanism 2 | primitive = new Primitives(); 3 | 4 | // core definitions needed to make anything work, even what follows 5 | Object = primitive("NewObject"); 6 | Function = primitive("NewFunction"); 7 | Array = primitive("NewArray"); 8 | String = primitive("NewString"); 9 | Number = primitive("NewNumber"); 10 | RegExp = primitive("NewRegExp"); 11 | 12 | /************************************************************************/ 13 | /* Global properties, see spec 15.1 */ 14 | /************************************************************************/ 15 | 16 | undefined = primitive("NewUndefined"); 17 | 18 | eval = function eval (x) { 19 | return primitive("GlobalEval", x); 20 | }; 21 | 22 | parseInt = function parseInt (string, radix) { 23 | return primitive("GlobalParseInt", string, radix); 24 | }; 25 | 26 | parseFloat = function parseFloat (string) { 27 | return primitive("GlobalParseFloat", string); 28 | }; 29 | 30 | isNaN = function isNaN (number) { 31 | return primitive("GlobalIsNaN", number) 32 | }; 33 | 34 | isFinite = function isFinite (number) { 35 | return primitive("GlobalIsFinite", number); 36 | }; 37 | 38 | decodeURI = primitive("GlobalDecodeURI"); 39 | 40 | decodeURIComponent = primitive("GlobalDecodeURIComponent"); 41 | 42 | encodeURI = primitive("GlobalEncodeURI"); 43 | 44 | encodeURIComponent = primitive("GlobalEncodeURIComponent"); 45 | 46 | 47 | /************************************************************************/ 48 | /* Object properties, see spec 15.2 */ 49 | /************************************************************************/ 50 | 51 | Object.prototype = { 52 | 53 | prototype: null, 54 | 55 | constructor: Object, 56 | 57 | toString: function toString() { 58 | return primitive("ObjectToString", this); 59 | }, 60 | 61 | toLocaleString: function toLocaleString() { 62 | return primitive("ObjectToLocaleString", this); 63 | }, 64 | 65 | valueOf: function valueOf() { return this }, 66 | 67 | hasOwnProperty: function hasOwnProperty (V) { 68 | return primitive("ObjectHasOwnProperty", this, V); 69 | }, 70 | 71 | isPrototypeOf: function isPrototypeOf (V) { 72 | return primitive("ObjectIsPrototypeOf", this, V); 73 | }, 74 | 75 | propertyIsEnumerable: function propertyIsEnumerable (V) { 76 | return primitive("ObjectPropertyIsEnumerable", this, V); 77 | } 78 | }; 79 | 80 | 81 | /************************************************************************/ 82 | /* Function properties, see spec 15.3 */ 83 | /************************************************************************/ 84 | 85 | Function.prototype = { 86 | 87 | constructor: Function, 88 | 89 | toString: function functionToString() { 90 | return primitive("FunctionToString", this); 91 | }, 92 | 93 | apply: function functionApply (thisArg, argArray) { 94 | return primitive("FunctionApply", this, thisArg, argArray); 95 | }, 96 | 97 | call: function functionCall (thisArg) { 98 | arguments.shift(); 99 | return primitive("FunctionApply", this, thisArg, arguments); 100 | } 101 | }; 102 | 103 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/pointer/MockupInstanceKey.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.pointer; 12 | 13 | import com.ibm.wala.classLoader.IClass; 14 | import com.ibm.wala.classLoader.IMethod; 15 | import com.ibm.wala.classLoader.NewSiteReference; 16 | import com.ibm.wala.ipa.callgraph.CGNode; 17 | import com.ibm.wala.ipa.callgraph.CallGraph; 18 | import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; 19 | import com.ibm.wala.util.collections.Pair; 20 | 21 | import java.util.Iterator; 22 | 23 | public final class MockupInstanceKey implements InstanceKey { 24 | private IClass mockupClass; 25 | 26 | public MockupInstanceKey(IMethod method){ 27 | this.mockupClass = MockupClass.findOrCreateMockup(method); 28 | } 29 | 30 | @Override 31 | public IClass getConcreteType() { 32 | // TODO Auto-generated method stub 33 | return mockupClass; 34 | } 35 | 36 | @Override 37 | public Iterator> getCreationSites( 38 | CallGraph CG) { 39 | // TODO Auto-generated method stub 40 | throw new UnsupportedOperationException(); 41 | } 42 | 43 | @Override 44 | public int hashCode() { 45 | // TODO Auto-generated method stub 46 | return mockupClass.hashCode(); 47 | } 48 | 49 | @Override 50 | public boolean equals(Object obj) { 51 | // TODO Auto-generated method stub 52 | //instanceof is possible because this class is final. 53 | if(obj instanceof MockupInstanceKey){ 54 | return ((MockupInstanceKey)obj).getConcreteType().equals(mockupClass); 55 | } 56 | return false; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/pointer/ResourceInstanceKey.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.pointer; 12 | 13 | import com.ibm.wala.classLoader.IClass; 14 | import com.ibm.wala.classLoader.NewSiteReference; 15 | import com.ibm.wala.ipa.callgraph.CGNode; 16 | import com.ibm.wala.ipa.callgraph.CallGraph; 17 | import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; 18 | import com.ibm.wala.util.collections.Pair; 19 | 20 | import java.util.ArrayList; 21 | import java.util.Iterator; 22 | import java.util.List; 23 | 24 | public class ResourceInstanceKey implements InstanceKey { 25 | 26 | private CGNode node; 27 | private IClass declaredType; 28 | private int iindex; 29 | private NewSiteReference refSite; 30 | private int resNum; 31 | 32 | public ResourceInstanceKey(CGNode node, IClass declaredType, int iindex, int resNum){ 33 | this.node = node; 34 | this.declaredType = declaredType; 35 | this.iindex = iindex; 36 | this.resNum = resNum; 37 | this.refSite = NewSiteReference.make(iindex, declaredType.getReference()); 38 | } 39 | 40 | @Override 41 | public IClass getConcreteType() { 42 | // TODO Auto-generated method stub 43 | return declaredType; 44 | } 45 | 46 | @Override 47 | public Iterator> getCreationSites(CallGraph CG) { 48 | // TODO Auto-generated method stub 49 | List> l = new ArrayList>(); 50 | l.add(Pair.make(node, refSite)); 51 | return l.iterator(); 52 | } 53 | 54 | @Override 55 | public int hashCode(){ 56 | return node.hashCode() + resNum; 57 | } 58 | 59 | @Override 60 | public boolean equals(Object o){ 61 | if(o instanceof ResourceInstanceKey){ 62 | ResourceInstanceKey rik = (ResourceInstanceKey) o; 63 | // ResourceInstanceKeys are equal when the resource numbers are same; 64 | if(rik.resNum == resNum){ 65 | return true; 66 | } 67 | } 68 | return false; 69 | } 70 | 71 | @Override 72 | public String toString(){ 73 | return "Resource #" + resNum; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/print/NodePrinter.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.print; 12 | 13 | import com.ibm.wala.ipa.callgraph.CGNode; 14 | import com.ibm.wala.ssa.SSAInstruction; 15 | 16 | public class NodePrinter { 17 | public static void printInsts(CGNode node){ 18 | int index = 1; 19 | System.out.println("----"); 20 | System.out.println("=> " + node ); 21 | System.out.println("----"); 22 | for(SSAInstruction inst : node.getIR().getInstructions()){ 23 | System.out.println("(" + (index++) +") " + inst); 24 | } 25 | System.out.println("----"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/print/Printer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.print; 12 | 13 | import java.io.BufferedReader; 14 | import java.io.BufferedWriter; 15 | import java.io.File; 16 | import java.io.FileOutputStream; 17 | import java.io.IOException; 18 | import java.io.InputStreamReader; 19 | import java.io.OutputStreamWriter; 20 | 21 | public class Printer { 22 | 23 | private BufferedWriter writer; 24 | 25 | public Printer(String output) throws Exception{ 26 | if(output == null){ 27 | throw new Exception(){ 28 | /** 29 | * 30 | */ 31 | private static final long serialVersionUID = -2117251529449831113L; 32 | 33 | @Override 34 | public String getMessage() { 35 | // TODO Auto-generated method stub 36 | return " output file cannot be null"; 37 | } 38 | }; 39 | 40 | }else{ 41 | File outfile = new File(output); 42 | if(outfile.exists()){ 43 | System.out.print(outfile.getCanonicalPath() + " exist. overwrite it (y/n)? "); 44 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 45 | 46 | String s; 47 | 48 | while((s = br.readLine()) != null){ 49 | if(s.equalsIgnoreCase("y") || s.equalsIgnoreCase("yes")){ 50 | outfile.delete(); 51 | outfile.createNewFile(); 52 | break; 53 | }else if(s.equalsIgnoreCase("n") || s.equalsIgnoreCase("no")) 54 | System.exit(0); 55 | else 56 | System.out.print(outfile.getCanonicalPath() + " exist. overwrite it (y/n)? "); 57 | } 58 | }else{ 59 | outfile.createNewFile(); 60 | } 61 | writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile))); 62 | } 63 | } 64 | 65 | public Printer(){ 66 | writer = new BufferedWriter(new OutputStreamWriter(System.out)); 67 | } 68 | 69 | public void println(String msg){ 70 | try { 71 | writer.write(msg + "\n"); 72 | writer.flush(); 73 | } catch (IOException e) { 74 | // TODO Auto-generated catch block 75 | e.printStackTrace(); 76 | } 77 | } 78 | 79 | public void print(String msg){ 80 | try { 81 | writer.write(msg); 82 | writer.flush(); 83 | } catch (IOException e) { 84 | // TODO Auto-generated catch block 85 | e.printStackTrace(); 86 | } 87 | } 88 | 89 | @Override 90 | public void finalize(){ 91 | try { 92 | writer.close(); 93 | } catch (IOException e) { 94 | // TODO Auto-generated catch block 95 | e.printStackTrace(); 96 | } 97 | } 98 | 99 | } 100 | 101 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/utils/LoaderUtils.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.utils; 12 | 13 | import com.ibm.wala.classLoader.IClass; 14 | import com.ibm.wala.classLoader.IMethod; 15 | import com.ibm.wala.ipa.callgraph.CGNode; 16 | import com.ibm.wala.types.ClassLoaderReference; 17 | 18 | public class LoaderUtils { 19 | 20 | public static boolean fromLoader(CGNode node, ClassLoaderReference clr) { 21 | IClass declClass = node.getMethod().getDeclaringClass(); 22 | 23 | ClassLoaderReference nodeClRef = 24 | declClass.getClassLoader().getReference(); 25 | 26 | return nodeClRef.equals(clr); 27 | } 28 | 29 | public static boolean fromLoader(IMethod method, ClassLoaderReference clr) { 30 | IClass declClass = method.getDeclaringClass(); 31 | 32 | ClassLoaderReference nodeClRef = 33 | declClass.getClassLoader().getReference(); 34 | 35 | return nodeClRef.equals(clr); 36 | } 37 | 38 | public static boolean fromLoader(IClass declClass, ClassLoaderReference clr) { 39 | ClassLoaderReference nodeClRef = 40 | declClass.getClassLoader().getReference(); 41 | 42 | return nodeClRef.equals(clr); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/utils/LocalFileReader.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.utils; 12 | 13 | import java.io.File; 14 | import java.io.FilenameFilter; 15 | import java.net.URI; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | import java.util.Properties; 19 | 20 | import static com.ibm.wala.properties.WalaProperties.ANDROID_RT_JAVA_JAR; 21 | import static com.ibm.wala.properties.WalaProperties.DROIDEL_ANDROID_JAR; 22 | 23 | public class LocalFileReader { 24 | public static URI[] androidDexLibs(Properties walaProperties) { 25 | List libs = new ArrayList(); 26 | File libFile = new File(walaProperties.getProperty(ANDROID_RT_JAVA_JAR)); 27 | System.err.println("#lib: "+libFile.getAbsolutePath()+"("+((libFile.isDirectory())? "Dir" : "File")+")"); 28 | if(libFile.isFile()) 29 | return new URI[]{androidJar(walaProperties)}; 30 | for(File lib : libFile.listFiles(new FilenameFilter() { 31 | @Override 32 | public boolean accept(File dir, String name) { 33 | return name.endsWith("dex"); 34 | } 35 | })) { 36 | libs.add(lib.toURI()); 37 | } 38 | return libs.toArray(new URI[ libs.size() ]); 39 | } 40 | 41 | public static URI androidJar(Properties walaProperties) { 42 | File libFile = new File(walaProperties.getProperty(ANDROID_RT_JAVA_JAR)); 43 | System.err.println("#lib: "+libFile.getAbsolutePath()+"("+libFile.exists()+")"); 44 | 45 | return libFile.toURI(); 46 | } 47 | 48 | public static File droidelAndroidLib(Properties walaProperties) { 49 | File libFile = new File(walaProperties.getProperty(DROIDEL_ANDROID_JAR)); 50 | System.err.println("#android_lib: "+libFile.getAbsolutePath()); 51 | return libFile; 52 | } 53 | 54 | public static URI[] androidJarLibs(Properties walaProperties) { 55 | List libs = new ArrayList(); 56 | File libFile = new File(walaProperties.getProperty(ANDROID_RT_JAVA_JAR)); 57 | System.err.println("#lib: "+libFile.getAbsolutePath()+"("+libFile.isDirectory()+")"); 58 | for(File lib : libFile.listFiles(new FilenameFilter() { 59 | @Override 60 | public boolean accept(File dir, String name) { 61 | return name.endsWith("jar"); 62 | } 63 | })) { 64 | libs.add(lib.toURI()); 65 | } 66 | return libs.toArray(new URI[ libs.size() ]); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/utils/TypeRefHelper.java: -------------------------------------------------------------------------------- 1 | package kr.ac.kaist.wala.hybridroid.utils; 2 | 3 | import com.ibm.wala.types.ClassLoaderReference; 4 | import com.ibm.wala.types.TypeName; 5 | import com.ibm.wala.types.TypeReference; 6 | 7 | /** 8 | * Created by leesh on 08/11/2017. 9 | */ 10 | public class TypeRefHelper { 11 | public static TypeReference findTypeReferenceByName(TypeName tn, ClassLoaderReference clr, boolean isCLRFixed){ 12 | TypeReference tr = TypeReference.find(clr, tn); 13 | 14 | if(tr == null && !isCLRFixed) 15 | tr = TypeReference.find((clr.equals(ClassLoaderReference.Primordial))? ClassLoaderReference.Application : ClassLoaderReference.Primordial, tn); 16 | 17 | return tr; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /kr.ac.kaist.wala.hybridroid/src/kr/ac/kaist/wala/hybridroid/utils/Wrapper.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 IBM Corporation and KAIST. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * KAIST - initial API and implementation 10 | *******************************************************************************/ 11 | package kr.ac.kaist.wala.hybridroid.utils; 12 | 13 | public class Wrapper { 14 | private T obj; 15 | 16 | public Wrapper(){ 17 | } 18 | 19 | public Wrapper(T obj){ 20 | this.obj = obj; 21 | } 22 | 23 | public void setObject(T obj){ 24 | this.obj = obj; 25 | } 26 | 27 | public T getObject(){ 28 | return obj; 29 | } 30 | 31 | public boolean has(){ 32 | return obj != null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include 'kr.ac.kaist.wala.hybridroid', 'kr.ac.kaist.wala.hybridroid.frontend', 'kr.ac.kaist.wala.hybridroid.util', 'kr.ac.kaist.wala.hybridroid.test' 2 | -------------------------------------------------------------------------------- /targets/e42/e42.target: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /targets/e42/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.ibm.wala.target 7 | targets 8 | 1.3.10-SNAPSHOT 9 | 10 | e42 11 | eclipse-target-definition 12 | 13 | -------------------------------------------------------------------------------- /targets/e44/e44.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /targets/e44/e44.target: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /targets/e44/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | kr.ac.kaist.wala.hybridroid.target 7 | targets 8 | 0.0.1-SNAPSHOT 9 | 10 | e44 11 | eclipse-target-definition 12 | 13 | -------------------------------------------------------------------------------- /targets/e47/e47.target: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /targets/e47/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | kr.ac.kaist.wala.hybridroid.target 7 | targets 8 | 0.0.1-SNAPSHOT 9 | 10 | e47 11 | eclipse-target-definition 12 | 13 | -------------------------------------------------------------------------------- /targets/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | kr.ac.kaist.wala 7 | HybridDroid 8 | 0.0.1-SNAPSHOT 9 | 10 | kr.ac.kaist.wala.hybridroid.target 11 | targets 12 | pom 13 | 14 | 15 | e47 16 | 17 | 18 | -------------------------------------------------------------------------------- /targets/targets.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | --------------------------------------------------------------------------------