├── .classpath ├── .gitignore ├── .project ├── .settings ├── org.eclipse.jdt.core.prefs └── org.eclipse.m2e.core.prefs ├── LICENSE ├── README.md ├── commands.txt ├── docs ├── Consideraciones.md ├── css │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map │ ├── codemirror.css │ ├── navbar-top-fixed.css │ └── style.css ├── img │ ├── LogoLargo.png │ ├── MutAPK_logo.png │ ├── MutAPK_name_logo_oscuro.png │ ├── droidpool.ico │ ├── droidpool.png │ ├── horizontalLightBrackgrounds.png │ ├── mutapkArchitecture.png │ ├── tsdl.ico │ ├── tsdlFondosOscuros.png │ └── uniandesTransparenteAmarillo.png ├── index.html ├── js │ ├── bootstrap.min.js │ ├── codemirror.js │ └── popper.min.js ├── mode │ ├── clike.js │ └── xml.js └── video.html ├── extra ├── antlr-3.5.2-runtime.jar ├── apktool.jar ├── commons-io-2.4.jar ├── materialistic.jks ├── smaliLexer.flex └── uber-apk-signer.jar ├── operators.properties ├── pom.xml ├── src ├── main │ ├── java │ │ └── edu │ │ │ └── uniandes │ │ │ └── tsdl │ │ │ ├── antlr │ │ │ ├── smaliParser.java │ │ │ └── smaliParser.tokens │ │ │ ├── jflex │ │ │ └── smaliFlexLexer.java │ │ │ ├── mutapk │ │ │ ├── MutAPK.java │ │ │ ├── detectors │ │ │ │ ├── MutationLocationDetector.java │ │ │ │ ├── MutationLocationListBuilder.java │ │ │ │ ├── TextBasedDetector.java │ │ │ │ ├── code │ │ │ │ │ └── visitors │ │ │ │ │ │ ├── APICallVO.java │ │ │ │ │ │ ├── ClassInstanceVisitor.java │ │ │ │ │ │ ├── MethodCallVO.java │ │ │ │ │ │ ├── MethodCallVisitor.java │ │ │ │ │ │ ├── MethodDeclarationVO.java │ │ │ │ │ │ ├── MethodDeclarationVisitor.java │ │ │ │ │ │ └── TreeVisitorInstance.java │ │ │ │ └── xml │ │ │ │ │ ├── ActivityNotDefinedDetector.java │ │ │ │ │ ├── InvalidActivityNameDetector.java │ │ │ │ │ ├── InvalidColorDetector.java │ │ │ │ │ ├── InvalidLabelDetector.java │ │ │ │ │ ├── MissingPermissionDetector.java │ │ │ │ │ ├── SDKVersionDetector.java │ │ │ │ │ ├── WrongMainActivityDetector.java │ │ │ │ │ └── WrongStringResourceDetector.java │ │ │ ├── exception │ │ │ │ └── MutAPKException.java │ │ │ ├── hashfunction │ │ │ │ └── sha3 │ │ │ │ │ ├── ApkHash.java │ │ │ │ │ ├── ApkHashOrder.java │ │ │ │ │ ├── ApkHashSeparator.java │ │ │ │ │ └── Sha3.java │ │ │ ├── helper │ │ │ │ ├── APKToolWrapper.java │ │ │ │ ├── ASTHelper.java │ │ │ │ ├── CallGraphHelper.java │ │ │ │ ├── FileHelper.java │ │ │ │ ├── Helper.java │ │ │ │ ├── HexadecimalGenerator.java │ │ │ │ ├── IntegerGenerator.java │ │ │ │ ├── StringGenerator.java │ │ │ │ ├── StringMutator.java │ │ │ │ └── VisitableCommonTree.java │ │ │ ├── model │ │ │ │ ├── CallGraphNode.java │ │ │ │ ├── MutationType.java │ │ │ │ ├── SmaliAST.java │ │ │ │ └── location │ │ │ │ │ ├── ASTMutationLocation.java │ │ │ │ │ ├── InvalidColorMutationLocation.java │ │ │ │ │ └── MutationLocation.java │ │ │ ├── operators │ │ │ │ ├── MutationOperator.java │ │ │ │ ├── MutationOperatorFactory.java │ │ │ │ ├── OperatorBundle.java │ │ │ │ ├── activity │ │ │ │ │ ├── ActivityNotDefined.java │ │ │ │ │ ├── DifferentActivityIntentDefinition.java │ │ │ │ │ ├── InvalidActivityName.java │ │ │ │ │ ├── InvalidKeyIntentPutExtra.java │ │ │ │ │ ├── InvalidLabel.java │ │ │ │ │ ├── NullIntent.java │ │ │ │ │ ├── NullValueIntentPutExtra.java │ │ │ │ │ └── WrongMainActivity.java │ │ │ │ ├── backend │ │ │ │ │ ├── LengthyBackEndService.java │ │ │ │ │ └── LongConnectionTimeOut.java │ │ │ │ ├── connectivity │ │ │ │ │ ├── BluetoothAdapterAlwaysEnabled.java │ │ │ │ │ └── NullBluetoothAdapter.java │ │ │ │ ├── data │ │ │ │ │ ├── android │ │ │ │ │ │ ├── InvalidURI.java │ │ │ │ │ │ └── NullGPSLocation.java │ │ │ │ │ └── general │ │ │ │ │ │ ├── InvalidDate.java │ │ │ │ │ │ ├── NullBackEndServiceReturn.java │ │ │ │ │ │ └── NullMethodCallArgument.java │ │ │ │ ├── db │ │ │ │ │ ├── android │ │ │ │ │ │ └── ClosingNullCursor.java │ │ │ │ │ └── general │ │ │ │ │ │ ├── InvalidIndexQueryParameter.java │ │ │ │ │ │ └── InvalidSQLQuery.java │ │ │ │ ├── gui │ │ │ │ │ └── android │ │ │ │ │ │ ├── FindViewByIdReturnsNull.java │ │ │ │ │ │ ├── InvalidColor.java │ │ │ │ │ │ ├── InvalidIDFindView.java │ │ │ │ │ │ ├── InvalidViewFocus.java │ │ │ │ │ │ └── ViewComponentNotVisible.java │ │ │ │ ├── image │ │ │ │ │ └── OOMLargeImage.java │ │ │ │ ├── io │ │ │ │ │ ├── InvalidFilePath.java │ │ │ │ │ └── NullStream.java │ │ │ │ ├── programming │ │ │ │ │ └── android │ │ │ │ │ │ ├── MissingPermissionManifest.java │ │ │ │ │ │ ├── SDKVersion.java │ │ │ │ │ │ └── WrongStringResource.java │ │ │ │ └── threading │ │ │ │ │ ├── LengthyGUICreation.java │ │ │ │ │ └── LengthyGUIListener.java │ │ │ ├── processors │ │ │ │ ├── MutationsProcessor.java │ │ │ │ ├── SourceCodeProcessor.java │ │ │ │ └── TextBasedDetectionsProcessor.java │ │ │ └── selector │ │ │ │ ├── InterfaceSelector.java │ │ │ │ ├── SelectorAmountMutants.java │ │ │ │ ├── SelectorAmountMutantsMethod.java │ │ │ │ ├── SelectorApkOldVSNewMethod.java │ │ │ │ ├── SelectorConfidenceInterval.java │ │ │ │ ├── SelectorConfidenceIntervalMethod.java │ │ │ │ ├── SelectorType.java │ │ │ │ └── TargetPopulation.java │ │ │ └── smali │ │ │ ├── InvalidToken.java │ │ │ ├── LexerErrorInterface.java │ │ │ ├── LiteralTools.java │ │ │ ├── OdexedInstructionException.java │ │ │ └── SemanticException.java │ └── resources │ │ ├── operator-types.properties │ │ └── parameters.json └── test │ └── java │ └── edu │ └── uniandes │ └── tsdl │ └── mutapk │ ├── hashfunction │ └── sha3 │ │ ├── ApkHashSeparatorTest.java │ │ └── Sha3Test.java │ └── selector │ ├── SelectorConfidenceIntervalTest.java │ └── TargetPopulationTest.java └── test ├── MutAPK-2.0.0.jar ├── apk ├── a2dp.Vol.apk ├── androtest-apks │ └── apks │ │ ├── a2dp.Vol.apk │ │ ├── aarddict.android.apk │ │ ├── be.ppareit.swiftp_free.apk │ │ ├── caldwell.ben.bites.apk │ │ ├── ch.blinkenlights.battery.apk │ │ ├── com.android.keepass.apk │ │ ├── com.android.lolcat.apk │ │ ├── com.android.spritemethodtest.apk │ │ ├── com.angrydoughnuts.android.alarmclock.apk │ │ ├── com.beust.android.translate.apk │ │ ├── com.bwx.bequick.apk │ │ ├── com.chmod0.manpages.apk │ │ ├── com.eleybourn.bookcatalogue.apk │ │ ├── com.evancharlton.mileage.apk │ │ ├── com.everysoft.autoanswer.apk │ │ ├── com.example.amazed.apk │ │ ├── com.example.android.musicplayer.apk │ │ ├── com.example.anycut.apk │ │ ├── com.gluegadget.hndroid.apk │ │ ├── com.google.android.opengles.spritetext.apk │ │ ├── com.google.android.opengles.triangle.apk │ │ ├── com.google.android.photostream.apk │ │ ├── com.hectorone.multismssender.apk │ │ ├── com.irahul.worldclock.apk │ │ ├── com.nloko.android.syncmypix.apk │ │ ├── com.teleca.jamendo.apk │ │ ├── com.tum.yahtzee.apk │ │ ├── cri.sanity.apk │ │ ├── de.homac.Mirrored.apk │ │ ├── edu.killerud.fileexplorer.apk │ │ ├── es.senselesssolutions.gpl.weightchart.apk │ │ ├── hiof.enigma.android.soundboard.apk │ │ ├── hu.vsza.adsdroid.apk │ │ ├── i4nc4mp.myLock.apk │ │ ├── in.shick.lockpatterngenerator.apk │ │ ├── info.bpace.munchlife.apk │ │ ├── jp.sblo.pandora.aGrep.apk │ │ ├── net.everythingandroid.timer.apk │ │ ├── net.fercanet.LNM.apk │ │ ├── net.jaqpot.netcounter.apk │ │ ├── net.mandaria.tippytipper.apk │ │ ├── net.sf.andbatdog.batterydog.apk │ │ ├── org.beide.bomber.apk │ │ ├── org.dnaq.dialer2.apk │ │ ├── org.jfedor.frozenbubble.apk │ │ ├── org.jtb.alogcat.apk │ │ ├── org.liberty.android.fantastischmemo.apk │ │ ├── org.passwordmaker.android.apk │ │ ├── org.scoutant.blokish.apk │ │ ├── org.smerty.zooborns.apk │ │ ├── org.tomdroid.apk │ │ ├── org.totschnig.myexpenses.apk │ │ ├── org.waxworlds.edam.importcontacts.apk │ │ └── org.wikipedia.apk ├── com.adobe.spark.post.apk ├── com.canva.editor.apk ├── com.evancharlton.mileage_3110.apk ├── com.example.android.xyztouristattractions.apk ├── com.google.android.photostream.apk ├── com.nloko.android.syncmypix.apk ├── io.github.hidroh.materialistic_75.apk ├── k9mail-debug.apk ├── myExpenses-acra-debug.apk └── org.totschnig.myexpenses_332.apk ├── extra ├── apktool.jar ├── materialistic.jks └── uber-apk-signer.jar ├── operators.properties ├── operators.propertiess └── parameters.json /.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 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | temp/ 3 | test/mutants 4 | pom.xml.tag 5 | pom.xml.releaseBackup 6 | pom.xml.versionsBackup 7 | pom.xml.next 8 | release.properties 9 | dependency-reduced-pom.xml 10 | buildNumber.properties 11 | .mvn/timing.properties 12 | test/temp/ 13 | test/mutantes/ 14 | .vscode/ 15 | .settings/ 16 | .classpath 17 | 18 | # Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) 19 | !/.mvn/wrapper/maven-wrapper.jar 20 | /target/ -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | MutAPK2 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 3 | org.eclipse.jdt.core.compiler.compliance=1.7 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.release=disabled 6 | org.eclipse.jdt.core.compiler.source=1.7 7 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 The Software Design Lab 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MutAPK 2 | MutAPK is a mutation analysis framework for Android applications over APK Files. 3 | MutAPK implements 35 mutation operators specifically for Android apps, covering the following categories: 4 | - Activity/Intents 5 | - Android Programming 6 | - Back-End Services 7 | - Connectivity 8 | - Data 9 | - Database 10 | - General Programming 11 | - GUI 12 | - I/O 13 | - Non-Functional Requirements 14 | 15 | The complete list of mutation operators and their specification is available at the [MutAPK website](http://thesoftwaredesignlab.github.io/MutAPK/). 16 | Given an Android App APK, MutAPK first extracts the Potential Fault Profile (PFP) and then automatically seeds mutants generating mutated copies of the App. 17 | 18 | # Compile 19 | Download and compile MutAPK with the following commands: 20 | ``` 21 | git clone https://github.com/TheSoftwareDesignLab/MutAPK.git 22 | cd MutAPK 23 | mvn clean 24 | mvn package 25 | ``` 26 | The generated runnable jar can be found in: ``MutAPK/target/MutAPK-2.0.0.jar`` 27 | 28 | # Usage 29 | To run MutAPK use the following command, specifying the path to the config file: 30 | ``` 31 | java -jar MutAPK-2.0.0.jar 32 | ``` 33 | 34 | ### JSON Configuration File 35 | 36 | MutAPK uses a JSON file to define the values to be used during execution, an example of this file can be found in ```./src/main/resources/parameters.json```. Following is the structure of the JSON file: 37 | 38 | ```json 39 | { 40 | "apkPath": "./apk/com.evancharlton.mileage_3110.apk", 41 | "appName": "com.evancharlton.mileage", 42 | "mutantsFolder": "./mutants", 43 | "operatorsDir": "./", 44 | "multithreadExec": "true", 45 | "extraPath": "./extra", 46 | "selectionStrategy": "all", 47 | "selectionParameters":{ 48 | "amountMutants":"34", 49 | "perOperator":"false", 50 | "confidenceLevel":"85", 51 | "marginError":"10", 52 | "baseAPKPath":"./" 53 | } 54 | } 55 | ``` 56 | 57 | Provide the following list of required arguments when running MutAPK: 58 | 1. ``APK path``: relative path of the apk to mutate; 59 | 2. ``AppPackage``: App main package name; 60 | 3. ``Output``: relative path of the folder where the mutantns will be created; 61 | 4. ``ExtraCompFolder``: relative path of the extra component folder (``MutAPK/extra/``); 62 | 5. ``operatorsDir``: relative path to the folder containing the operators.properties. 63 | 6. ``multithread`` : true or false, specifying whether the mutant generation should be multithreaded or not. 64 | 7. ``amountOfMutants`` : Amount of mutants to be generated [OptionalParameter] 65 | 66 | Mutation operators can be selected or deselected editing the ``operators.properties`` file. To deselect an operator, either comment (#) or delete the corresponding line. 67 | ### Example 68 | ``` 69 | cd MutAPK 70 | java -jar target/MutAPK-1.0.0.jar foo.apk or.foo.app mutants/ extra/ . true 71 | ``` 72 | 73 | ### Output 74 | The output directory will contain a log file that summarizes the mutant generation process and a folder for each generated mutant. 75 | The mutants folders are named with the corresponding mutant ID (i.e., numerical ID). The log file contains information about the mutation process as well as the type and location of each mutant generated. 76 | -------------------------------------------------------------------------------- /commands.txt: -------------------------------------------------------------------------------- 1 | WINDOWS: 2 | - mvn clean && mvn package && del test\MutAPK-0.0.1.jar && copy target\MutAPK-0.0.1.jar test 3 | - del test/temp/ && cp target/MutAPK-0.0.1.jar test/ && cd test/ && java -jar MutAPK-0.0.1.jar io.github.hidroh.materialistic_75.apk materialistic mutantes extra && cd .. 4 | - '/c/Program Files/Java/jdk1.8.0_77/bin/keytool.exe' -genkey -v -keystore materialistic.jks -keyalg RSA -keysize 2048 - validity 10000 -alias my-alias 5 | - cd test && c:\Users\caev0\AppData\Local\Android\sdk\build-tools\24.0.3\apksigner.bat sign -ks ..\materialistic.jks --out mutantes\materialistic-mutant2\signed-materialistic.apk mutantes\materialistic-mutant2\io.github.hidroh.materialistic_75.apk 6 | UNIX 7 | - mvn clean && mvn package && rm test/MutAPK-0.0.1.jar && cp target/MutAPK-0.0.1.jar 8 | - rm -rf test/temp/ && cp target/MutAPK-0.0.1.jar test/ && cd test/ && java -jar MutAPK-0.0.1.jar io.github.hidroh.materialistic_75.apk materialistic mutantes extra && cd .. -------------------------------------------------------------------------------- /docs/Consideraciones.md: -------------------------------------------------------------------------------- 1 | # NullBackendServiceReturn 2 | 3 | * Toca dividir el procesamiento de este operador entre usar HttpResponse como variables y usarlo como parametro 4 | * SMALI permite saber el tipo de datos usado en la respuesta de un método, por lo tanto se puede saber cuando se esta usando HttpResponse como parametro 5 | * De la siguiente forma se ve un HttpResponse como variable: 6 | ```java 7 | HttpResponse response = ... 8 | ``` 9 | ```smali 10 | .local v7, "response":Lorg/apache/http/HttpResponse; 11 | ``` 12 | ``` 13 | (I_LOCAL v7 "response" Lorg/apache/http/HttpResponse;) 14 | 113 15 | v7 16 | 187 17 | "response" 18 | 194 19 | Lorg/apache/http/HttpResponse; 20 | 15 21 | ``` 22 | * De la siguiente forma se ve un HttpResponse como parametro 23 | ```java 24 | testAuthenticationResponse(httpClient.executeOverride(request, httpContext)); 25 | ``` 26 | ```smali 27 | iget-object v8, v1, Lcom/fsck/k9/mail/store/webdav/WebDavStore;->httpContext:Lorg/apache/http/protocol/HttpContext; 28 | 29 | invoke-virtual {v3, v4, v8}, Lcom/fsck/k9/mail/store/webdav/WebDavHttpClient;->executeOverride(Lorg/apache/http/client/methods/HttpUriRequest;Lorg/apache/http/protocol/HttpContext;)Lorg/apache/http/HttpResponse; 30 | 31 | move-result-object v8 32 | 33 | invoke-direct {v1, v8}, Lcom/fsck/k9/mail/store/webdav/WebDavStore;->testAuthenticationResponse(Lorg/apache/http/HttpResponse;)Z 34 | ``` 35 | ``` 36 | (I_STATEMENT_FORMAT22c_FIELD iget-object v8 v1 Lcom/fsck/k9/mail/store/webdav/WebDavStore; httpContext Lorg/apache/http/protocol/HttpContext;) 37 | 148 38 | iget-object 39 | 60 40 | v8 41 | 187 42 | v1 43 | 187 44 | Lcom/fsck/k9/mail/store/webdav/WebDavStore; 45 | 15 46 | httpContext 47 | 191 48 | Lorg/apache/http/protocol/HttpContext; 49 | 15 50 | (I_STATEMENT_FORMAT35c_METHOD invoke-virtual (I_REGISTER_LIST v3 v4 v8) Lcom/fsck/k9/mail/store/webdav/WebDavHttpClient; executeOverride (I_METHOD_PROTOTYPE (I_METHOD_RETURN_TYPE Lorg/apache/http/HttpResponse;) Lorg/apache/http/client/methods/HttpUriRequest; Lorg/apache/http/protocol/HttpContext;)) 51 | 159 52 | invoke-virtual 53 | 75 54 | (I_REGISTER_LIST v3 v4 v8) 55 | 127 56 | v3 57 | 187 58 | v4 59 | 187 60 | v8 61 | 187 62 | Lcom/fsck/k9/mail/store/webdav/WebDavHttpClient; 63 | 15 64 | executeOverride 65 | 191 66 | (I_METHOD_PROTOTYPE (I_METHOD_RETURN_TYPE Lorg/apache/http/HttpResponse;) Lorg/apache/http/client/methods/HttpUriRequest; Lorg/apache/http/protocol/HttpContext;) 67 | 117 68 | (I_METHOD_RETURN_TYPE Lorg/apache/http/HttpResponse;) 69 | 118 70 | Lorg/apache/http/HttpResponse; 71 | 15 72 | Lorg/apache/http/client/methods/HttpUriRequest; 73 | 15 74 | Lorg/apache/http/protocol/HttpContext; 75 | 15 76 | (I_STATEMENT_FORMAT11x move-result-object v8) 77 | 136 78 | move-result-object 79 | 46 80 | v8 81 | 187 82 | (I_STATEMENT_FORMAT35c_METHOD invoke-direct (I_REGISTER_LIST v1 v8) Lcom/fsck/k9/mail/store/webdav/WebDavStore; testAuthenticationResponse (I_METHOD_PROTOTYPE (I_METHOD_RETURN_TYPE Z) Lorg/apache/http/HttpResponse;)) 83 | 159 84 | invoke-direct 85 | 75 86 | (I_REGISTER_LIST v1 v8) 87 | 127 88 | v1 89 | 187 90 | v8 91 | 187 92 | Lcom/fsck/k9/mail/store/webdav/WebDavStore; 93 | 15 94 | testAuthenticationResponse 95 | 191 96 | (I_METHOD_PROTOTYPE (I_METHOD_RETURN_TYPE Z) Lorg/apache/http/HttpResponse;) 97 | 117 98 | (I_METHOD_RETURN_TYPE Z) 99 | 118 100 | Z 101 | 185 102 | Lorg/apache/http/HttpResponse; 103 | 15 104 | ``` 105 | 106 | 107 | # ClosingNullCursor 108 | 109 | ``` 110 | invoke-interface {v8}, Landroid/database/Cursor;->close()V 111 | ``` 112 | 113 | ``` 114 | const/4 v8, 0x0 115 | 116 | invoke-interface {v8}, Landroid/database/Cursor;->close()V 117 | ``` -------------------------------------------------------------------------------- /docs/css/navbar-top-fixed.css: -------------------------------------------------------------------------------- 1 | /* Show it is fixed to the top */ 2 | body { 3 | min-height: 75rem; 4 | padding-top: 4.5rem; 5 | } 6 | 7 | #logo { 8 | width: 150px; 9 | height: auto; 10 | } 11 | 12 | .row { 13 | margin: 30px 0px; 14 | } 15 | -------------------------------------------------------------------------------- /docs/css/style.css: -------------------------------------------------------------------------------- 1 | 2 | .card.category>.card-header{ 3 | background-color: #9a031e !important; 4 | color: white; 5 | font-size: 1rem; 6 | } 7 | 8 | .card.category>.card-body{ 9 | background-color: #fdfdfd !important; 10 | } 11 | 12 | .card.operator { 13 | margin-bottom: 10px; 14 | } 15 | 16 | .card.operator>.card-header{ 17 | background-color: #343a40 !important; 18 | color: white; 19 | } 20 | 21 | .card.operator>.card-body{ 22 | background-color: #ffffff !important; 23 | } 24 | 25 | .jumbotron { 26 | margin-bottom: 0 !important; 27 | } -------------------------------------------------------------------------------- /docs/img/LogoLargo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/docs/img/LogoLargo.png -------------------------------------------------------------------------------- /docs/img/MutAPK_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/docs/img/MutAPK_logo.png -------------------------------------------------------------------------------- /docs/img/MutAPK_name_logo_oscuro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/docs/img/MutAPK_name_logo_oscuro.png -------------------------------------------------------------------------------- /docs/img/droidpool.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/docs/img/droidpool.ico -------------------------------------------------------------------------------- /docs/img/droidpool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/docs/img/droidpool.png -------------------------------------------------------------------------------- /docs/img/horizontalLightBrackgrounds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/docs/img/horizontalLightBrackgrounds.png -------------------------------------------------------------------------------- /docs/img/mutapkArchitecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/docs/img/mutapkArchitecture.png -------------------------------------------------------------------------------- /docs/img/tsdl.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/docs/img/tsdl.ico -------------------------------------------------------------------------------- /docs/img/tsdlFondosOscuros.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/docs/img/tsdlFondosOscuros.png -------------------------------------------------------------------------------- /docs/img/uniandesTransparenteAmarillo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/docs/img/uniandesTransparenteAmarillo.png -------------------------------------------------------------------------------- /docs/video.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /extra/antlr-3.5.2-runtime.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/extra/antlr-3.5.2-runtime.jar -------------------------------------------------------------------------------- /extra/apktool.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/extra/apktool.jar -------------------------------------------------------------------------------- /extra/commons-io-2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/extra/commons-io-2.4.jar -------------------------------------------------------------------------------- /extra/materialistic.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/extra/materialistic.jks -------------------------------------------------------------------------------- /extra/uber-apk-signer.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/extra/uber-apk-signer.jar -------------------------------------------------------------------------------- /operators.properties: -------------------------------------------------------------------------------- 1 | 1 = ActivityNotDefined 2 | 2 = DifferentActivityIntentDefinition 3 | 3 = InvalidActivityName 4 | 4 = InvalidKeyIntentPutExtra 5 | 5 = InvalidLabel 6 | 6 = NullIntent 7 | 7 = NullValueIntentPutExtra 8 | 8 = WrongMainActivity 9 | 9 = MissingPermissionManifest 10 | 10 = WrongStringResource 11 | 12 = SDKVersion 12 | 13 = LengthyBackEndService 13 | 14 = LongConnectionTimeOut 14 | 15 = BluetoothAdapterAlwaysEnabled 15 | 16 = NullBluetoothAdapter 16 | 17 = InvalidURI 17 | 18 = NullGPSLocation 18 | 19 = InvalidDate 19 | 20 = NullBackEndServiceReturn 20 | 22 = NullMethodCallArgument 21 | 23 = ClosingNullCursor 22 | 24 = InvalidIndexQueryParameter 23 | 25 = InvalidSQLQuery 24 | 26 = ViewComponentNotVisible 25 | 27 = FindViewByIdReturnsNull 26 | 28 = InvalidColor 27 | 29 = InvalidViewFocus 28 | 31 = InvalidIDFindView 29 | 32 = InvalidFilePath 30 | 33 = NullInputStream 31 | 35 = OOMLargeImage 32 | 36 = LengthyGUIListener 33 | 37 = NullOutputStream 34 | 38 = LengthyGUICreation 35 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/MutationLocationDetector.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors; 2 | 3 | import java.util.List; 4 | 5 | import edu.uniandes.tsdl.mutapk.model.MutationType; 6 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 7 | 8 | public abstract class MutationLocationDetector { 9 | 10 | //Folder path where the analysis starts 11 | protected String rootPath; 12 | protected MutationType type; 13 | 14 | public abstract List analyzeApp(String rootPath) throws Exception; 15 | 16 | public String getRootPath() { 17 | return rootPath; 18 | } 19 | 20 | public void setRootPath(String rootPath) { 21 | this.rootPath = rootPath; 22 | } 23 | 24 | public MutationType getType() { 25 | return type; 26 | } 27 | 28 | public void setType(MutationType type) { 29 | this.type = type; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/MutationLocationListBuilder.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map.Entry; 7 | 8 | import edu.uniandes.tsdl.mutapk.model.MutationType; 9 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 10 | 11 | public class MutationLocationListBuilder { 12 | 13 | 14 | public static List buildList(HashMap> locations){ 15 | List mutationLocationList = new ArrayList(); 16 | 17 | for(Entry> entry : locations.entrySet()){ 18 | assignMutationType(entry.getValue(), entry.getKey()); 19 | mutationLocationList.addAll(entry.getValue()); 20 | } 21 | 22 | return mutationLocationList; 23 | } 24 | 25 | private static void assignMutationType(List list, MutationType type){ 26 | for(MutationLocation loc : list){ 27 | if(loc != null){ 28 | loc.setType(type); 29 | } 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/TextBasedDetector.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors; 2 | 3 | import java.util.List; 4 | 5 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 6 | 7 | public abstract class TextBasedDetector extends MutationLocationDetector { 8 | 9 | 10 | public abstract List analyzeApp(String rootPath) throws Exception; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/code/visitors/APICallVO.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.code.visitors; 2 | 3 | import org.antlr.runtime.tree.CommonTree; 4 | 5 | public class APICallVO { 6 | 7 | private CommonTree tree; 8 | private int line; 9 | private int[] muTypes; 10 | 11 | public APICallVO(CommonTree tree, int line, int[] muTypes) { 12 | super(); 13 | this.tree = tree; 14 | this.line = line; 15 | this.muTypes = muTypes; 16 | } 17 | 18 | public CommonTree getTree() { 19 | return tree; 20 | } 21 | public void setTree(CommonTree tree) { 22 | this.tree = tree; 23 | } 24 | public int getLine() { 25 | return line; 26 | } 27 | public void setLine(int line) { 28 | this.line = line; 29 | } 30 | 31 | public int[] getMuTypes() { 32 | return muTypes; 33 | } 34 | 35 | public void setMuTypes(int[] muTypes) { 36 | this.muTypes = muTypes; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/code/visitors/ClassInstanceVisitor.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.code.visitors; 2 | 3 | import java.util.HashSet; 4 | 5 | import org.eclipse.jdt.core.dom.ASTVisitor; 6 | import org.eclipse.jdt.core.dom.ClassInstanceCreation; 7 | import org.eclipse.jdt.core.dom.IMethodBinding; 8 | 9 | public class ClassInstanceVisitor extends ASTVisitor{ 10 | 11 | private HashSet targetCalls; 12 | private HashSet calls; 13 | 14 | public ClassInstanceVisitor(){ 15 | calls = new HashSet(); 16 | targetCalls = new HashSet<>(); 17 | } 18 | 19 | public boolean visit(ClassInstanceCreation call){ 20 | 21 | 22 | 23 | IMethodBinding bind = null; 24 | String className = null; 25 | 26 | String methodName = ""; 27 | 28 | 29 | try{ 30 | if(call.getType() != null && call.getType().toString().equals("View.OnClickListener")){ 31 | className = "View"; 32 | methodName = "OnClickListener"; 33 | 34 | }else{ 35 | bind = call.resolveConstructorBinding(); 36 | className = bind.getName(); 37 | } 38 | }catch(Exception ex){ 39 | bind = null; 40 | } 41 | 42 | StringBuilder targetCall = new StringBuilder(); 43 | 44 | if(className != null ){ 45 | targetCall.append(className).append(".").append(methodName); 46 | 47 | if(targetCalls.contains(targetCall.toString())){ 48 | calls.add(new MethodCallVO(className, methodName, call.getStartPosition(), call.getLength())); 49 | } 50 | } 51 | return true; 52 | } 53 | 54 | public HashSet getTargetCalls() { 55 | return targetCalls; 56 | } 57 | 58 | public void setTargetCalls(HashSet targetCalls) { 59 | this.targetCalls = targetCalls; 60 | } 61 | 62 | public HashSet getCalls() { 63 | return calls; 64 | } 65 | 66 | public void setCalls(HashSet calls) { 67 | this.calls = calls; 68 | } 69 | 70 | 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/code/visitors/MethodCallVO.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.code.visitors; 2 | 3 | public class MethodCallVO { 4 | 5 | private String classQualifiedName; 6 | private String methodName; 7 | private int line; 8 | private int start; 9 | private int length; 10 | 11 | 12 | 13 | public MethodCallVO(String classQualifiedName, String methodName) { 14 | this.classQualifiedName = classQualifiedName; 15 | this.methodName = methodName; 16 | } 17 | 18 | 19 | 20 | public MethodCallVO(String classQualifiedName, String methodName, int start, int length) { 21 | super(); 22 | this.classQualifiedName = classQualifiedName; 23 | this.methodName = methodName; 24 | this.start = start; 25 | this.length = length; 26 | } 27 | 28 | 29 | 30 | 31 | 32 | 33 | public MethodCallVO(String classQualifiedName, String methodName, int line, int start, int length) { 34 | super(); 35 | this.classQualifiedName = classQualifiedName; 36 | this.methodName = methodName; 37 | this.line = line; 38 | this.start = start; 39 | this.length = length; 40 | } 41 | 42 | 43 | 44 | public String getClassQualifiedName() { 45 | return classQualifiedName; 46 | } 47 | public void setClassQualifiedName(String classQualifiedName) { 48 | this.classQualifiedName = classQualifiedName; 49 | } 50 | public String getMethodName() { 51 | return methodName; 52 | } 53 | public void setMethodName(String methodName) { 54 | this.methodName = methodName; 55 | } 56 | 57 | 58 | 59 | public int getLine() { 60 | return line; 61 | } 62 | 63 | 64 | 65 | public void setLine(int line) { 66 | this.line = line; 67 | } 68 | 69 | 70 | 71 | public int getStart() { 72 | return start; 73 | } 74 | 75 | 76 | 77 | public void setStart(int start) { 78 | this.start = start; 79 | } 80 | 81 | 82 | 83 | public int getLength() { 84 | return length; 85 | } 86 | 87 | 88 | 89 | public void setLength(int length) { 90 | this.length = length; 91 | } 92 | 93 | public String getFullName(){ 94 | return this.classQualifiedName+"."+this.getMethodName(); 95 | } 96 | 97 | 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/code/visitors/MethodCallVisitor.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.code.visitors; 2 | 3 | 4 | 5 | import java.util.HashSet; 6 | 7 | import org.eclipse.jdt.core.dom.ASTVisitor; 8 | import org.eclipse.jdt.core.dom.ITypeBinding; 9 | import org.eclipse.jdt.core.dom.MethodInvocation; 10 | 11 | public class MethodCallVisitor extends ASTVisitor{ 12 | 13 | 14 | private HashSet targetCalls; 15 | private HashSet calls; 16 | 17 | public MethodCallVisitor(){ 18 | calls = new HashSet(); 19 | targetCalls = new HashSet<>(); 20 | } 21 | 22 | public boolean visit(MethodInvocation call){ 23 | 24 | 25 | 26 | ITypeBinding bind = null; 27 | String className = null; 28 | 29 | String methodName = call.getName().getFullyQualifiedName(); 30 | 31 | 32 | try{ 33 | bind = ((MethodInvocation)call).getExpression().resolveTypeBinding(); 34 | className = bind.getName(); 35 | }catch(Exception ex){ 36 | bind = null; 37 | } 38 | 39 | StringBuilder targetCall = new StringBuilder(); 40 | 41 | if(className != null ){ 42 | targetCall.append(className).append(".").append(methodName); 43 | //For TESTING ONLY 44 | //System.out.println("SC CALL: "+targetCall); 45 | //for(String tc : targetCalls){ 46 | // System.out.println("T CALL: "+tc); 47 | //} 48 | 49 | if(targetCalls.contains(targetCall.toString())){ 50 | calls.add(new MethodCallVO(className, methodName, call.getStartPosition(), call.getLength())); 51 | } 52 | else if(targetCall.toString().contains("findViewById")){ 53 | // System.out.println(className +","+ methodName +","+ call.getStartPosition() +","+ call.getLength()); 54 | // System.exit(0); 55 | calls.add(new MethodCallVO("Activity", methodName, call.getStartPosition(), call.getLength())); 56 | } 57 | } 58 | return true; 59 | } 60 | 61 | public HashSet getCalls() { 62 | return calls; 63 | } 64 | 65 | public HashSet getTargetCalls() { 66 | return targetCalls; 67 | } 68 | 69 | public void setTargetCalls(HashSet targetCalls) { 70 | this.targetCalls = targetCalls; 71 | } 72 | 73 | 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/code/visitors/MethodDeclarationVO.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.code.visitors; 2 | 3 | public class MethodDeclarationVO { 4 | 5 | private String classQualifiedName; 6 | private String methodName; 7 | private int line; 8 | private int start; 9 | private int length; 10 | 11 | 12 | 13 | public MethodDeclarationVO(String classQualifiedName, String methodName) { 14 | this.classQualifiedName = classQualifiedName; 15 | this.methodName = methodName; 16 | } 17 | 18 | 19 | 20 | public MethodDeclarationVO(String classQualifiedName, String methodName, int start, int length) { 21 | super(); 22 | this.classQualifiedName = classQualifiedName; 23 | this.methodName = methodName; 24 | this.start = start; 25 | this.length = length; 26 | } 27 | 28 | 29 | 30 | 31 | 32 | 33 | public MethodDeclarationVO(String classQualifiedName, String methodName, int line, int start, int length) { 34 | super(); 35 | this.classQualifiedName = classQualifiedName; 36 | this.methodName = methodName; 37 | this.line = line; 38 | this.start = start; 39 | this.length = length; 40 | } 41 | 42 | 43 | 44 | public String getClassQualifiedName() { 45 | return classQualifiedName; 46 | } 47 | public void setClassQualifiedName(String classQualifiedName) { 48 | this.classQualifiedName = classQualifiedName; 49 | } 50 | public String getMethodName() { 51 | return methodName; 52 | } 53 | public void setMethodName(String methodName) { 54 | this.methodName = methodName; 55 | } 56 | 57 | 58 | 59 | public int getLine() { 60 | return line; 61 | } 62 | 63 | 64 | 65 | public void setLine(int line) { 66 | this.line = line; 67 | } 68 | 69 | 70 | 71 | public int getStart() { 72 | return start; 73 | } 74 | 75 | 76 | 77 | public void setStart(int start) { 78 | this.start = start; 79 | } 80 | 81 | 82 | 83 | public int getLength() { 84 | return length; 85 | } 86 | 87 | 88 | 89 | public void setLength(int length) { 90 | this.length = length; 91 | } 92 | 93 | public String getFullName(){ 94 | return this.classQualifiedName+"."+this.getMethodName(); 95 | } 96 | 97 | 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/code/visitors/MethodDeclarationVisitor.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.code.visitors; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Iterator; 5 | import java.util.List; 6 | 7 | import org.antlr.runtime.tree.CommonTree; 8 | import org.antlr.runtime.tree.TreeVisitor; 9 | import org.antlr.runtime.tree.TreeVisitorAction; 10 | 11 | import edu.uniandes.tsdl.antlr.smaliParser; 12 | 13 | public class MethodDeclarationVisitor extends TreeVisitor{ 14 | 15 | ArrayList calls; 16 | 17 | public MethodDeclarationVisitor() { 18 | this.calls = new ArrayList<>(); 19 | } 20 | 21 | @Override 22 | public Object visit(Object tt, TreeVisitorAction action) { 23 | CommonTree t = (CommonTree) tt; 24 | boolean result = isValidLocation(t); 25 | if(result) { 26 | processNode(t); 27 | return null; 28 | } 29 | return super.visit(t, action); 30 | } 31 | 32 | private void processNode(CommonTree t) { 33 | 34 | String unitName = t.getFirstChildWithType(smaliParser.CLASS_DESCRIPTOR).getText(); 35 | String methodName = t.getFirstChildWithType(smaliParser.SIMPLE_NAME).getText(); 36 | CommonTree methodProt = (CommonTree) t.getFirstChildWithType(smaliParser.I_METHOD_PROTOTYPE); 37 | String returnType = methodProt.getFirstChildWithType(smaliParser.I_METHOD_RETURN_TYPE).getChild(0).getText(); 38 | 39 | List parameters = (List) methodProt.getChildren(); 40 | 41 | String params = "("; 42 | for (Iterator iterator2 = parameters.iterator(); iterator2.hasNext();) { 43 | CommonTree commonTree = (CommonTree) iterator2.next(); 44 | 45 | if (commonTree.getType() != smaliParser.I_METHOD_RETURN_TYPE) { 46 | params += commonTree.getText(); 47 | } 48 | } 49 | params += ")"; 50 | calls.add(unitName+"&&"+methodName+params+returnType); 51 | } 52 | 53 | private boolean isValidLocation(CommonTree t) { 54 | 55 | // System.out.println(" "+t.getType()+ " - "+ t.getText()); 56 | // System.out.println(" "+t.toStringTree()); 57 | if (t.getType() == smaliParser.I_STATEMENT_FORMAT35c_METHOD || t.getType() == smaliParser.I_STATEMENT_FORMAT3rc_METHOD) { 58 | return true; 59 | } 60 | 61 | return false; 62 | } 63 | 64 | /** 65 | * @return the calls 66 | */ 67 | public ArrayList getCalls() { 68 | return calls; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/code/visitors/TreeVisitorInstance.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.code.visitors; 2 | 3 | import java.util.HashSet; 4 | 5 | import org.antlr.runtime.tree.CommonTree; 6 | import org.antlr.runtime.tree.TreeVisitor; 7 | import org.antlr.runtime.tree.TreeVisitorAction; 8 | 9 | import edu.uniandes.tsdl.mutapk.helper.ASTHelper; 10 | 11 | public class TreeVisitorInstance extends TreeVisitor{ 12 | 13 | private HashSet calls; 14 | 15 | public TreeVisitorInstance() { 16 | calls = new HashSet(); 17 | } 18 | 19 | @Override 20 | public Object visit(Object tt, TreeVisitorAction action) { 21 | CommonTree t = (CommonTree) tt; 22 | int[] muTypes = ASTHelper.isValidLocation(t); 23 | if(muTypes[0]!=-1){ 24 | // System.out.println(t.toStringTree()); 25 | // System.out.println(t.getChildIndex()); 26 | // System.out.println(t.getParent().getChild(t.getChildIndex()).toStringTree()); 27 | calls.add(new APICallVO(t, t.getLine(), muTypes)); 28 | } 29 | return super.visit(t, action); 30 | } 31 | 32 | 33 | 34 | public HashSet getCalls() { 35 | return calls; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/xml/ActivityNotDefinedDetector.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.xml; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Stack; 10 | 11 | import edu.uniandes.tsdl.mutapk.detectors.TextBasedDetector; 12 | import edu.uniandes.tsdl.mutapk.helper.Helper; 13 | import edu.uniandes.tsdl.mutapk.model.MutationType; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | 16 | public class ActivityNotDefinedDetector extends TextBasedDetector { 17 | 18 | public ActivityNotDefinedDetector(){ 19 | this.type = MutationType.ACTIVITY_NOT_DEFINED; 20 | } 21 | 22 | @Override 23 | public List analyzeApp(String rootPath) throws IOException { 24 | Stack stack = new Stack<>(); 25 | List locations = new ArrayList(); 26 | 27 | String path = rootPath+File.separator+Helper.MANIFEST; 28 | BufferedReader reader = new BufferedReader(new FileReader(new File(path))); 29 | String line = null; 30 | int startLine = 0; 31 | 32 | 33 | boolean isActivityTag = false; 34 | int currentLine = 0; 35 | while( (line = reader.readLine() ) != null){ 36 | 37 | if( line.contains("") || line.contains("-->"))){ 47 | stack.pop(); 48 | } 49 | 50 | if(isActivityTag && stack.isEmpty()){ 51 | locations.add(MutationLocation.buildLocation(path, startLine, currentLine,-1,-1,-1,-1,this.getType())); 52 | isActivityTag = false; 53 | } 54 | 55 | currentLine++; 56 | } 57 | reader.close(); 58 | 59 | return locations; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/xml/InvalidActivityNameDetector.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.xml; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import javax.xml.parsers.ParserConfigurationException; 11 | 12 | import org.xml.sax.SAXException; 13 | 14 | import edu.uniandes.tsdl.mutapk.detectors.TextBasedDetector; 15 | import edu.uniandes.tsdl.mutapk.helper.Helper; 16 | import edu.uniandes.tsdl.mutapk.model.MutationType; 17 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 18 | 19 | public class InvalidActivityNameDetector extends TextBasedDetector { 20 | 21 | public InvalidActivityNameDetector() { 22 | this.type = MutationType.INVALID_ACTIVITY_PATH; 23 | } 24 | 25 | @Override 26 | public List analyzeApp(String rootPath) throws ParserConfigurationException, SAXException, IOException { 27 | List locations = new ArrayList(); 28 | String path = rootPath + File.separator + Helper.MANIFEST; 29 | List activityNames = Helper.getInstance().getActivities(); 30 | 31 | // Read Source Code 32 | BufferedReader reader = new BufferedReader(new FileReader( 33 | new File(path))); 34 | String line = null; 35 | int startLine = 0; 36 | int startCol = 0; 37 | int endCol = 0; 38 | int lineNum = 0; 39 | boolean isActivityTag = false; 40 | int currentLine = 0; 41 | boolean found = false; 42 | while ((line = reader.readLine()) != null) { 43 | 44 | if (line.contains("")) { 58 | if(found){ 59 | locations.add(MutationLocation.buildLocation(path, startLine, currentLine, startCol, endCol, lineNum, -1, this.getType())); 60 | found = false; 61 | } 62 | isActivityTag = false; 63 | } 64 | } 65 | 66 | currentLine++; 67 | } 68 | reader.close(); 69 | 70 | return locations; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/xml/InvalidColorDetector.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.xml; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Map.Entry; 10 | import java.util.AbstractMap.SimpleEntry; 11 | 12 | import javax.xml.parsers.DocumentBuilder; 13 | import javax.xml.parsers.DocumentBuilderFactory; 14 | import javax.xml.parsers.ParserConfigurationException; 15 | 16 | import org.w3c.dom.Document; 17 | import org.w3c.dom.Node; 18 | import org.w3c.dom.NodeList; 19 | import org.xml.sax.SAXException; 20 | 21 | import edu.uniandes.tsdl.mutapk.detectors.TextBasedDetector; 22 | import edu.uniandes.tsdl.mutapk.helper.Helper; 23 | import edu.uniandes.tsdl.mutapk.model.MutationType; 24 | import edu.uniandes.tsdl.mutapk.model.location.InvalidColorMutationLocation; 25 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 26 | 27 | public class InvalidColorDetector extends TextBasedDetector { 28 | 29 | public InvalidColorDetector(){ 30 | this.type = MutationType.INVALID_COLOR; 31 | } 32 | 33 | @Override 34 | public List analyzeApp(String rootPath) throws ParserConfigurationException, SAXException, IOException { 35 | List locations = new ArrayList(); 36 | List> colorHex = new ArrayList>(); 37 | 38 | 39 | String path = rootPath + File.separator+"res"+File.separator+"values"+File.separator + Helper.COLORS; 40 | 41 | File fXmlFile = new File(path); 42 | if(fXmlFile.exists()) { 43 | DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); 44 | DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); 45 | Document doc = dBuilder.parse(fXmlFile); 46 | doc.getDocumentElement().normalize(); 47 | 48 | // Get all activities 49 | NodeList nodeList = doc.getElementsByTagName("color"); 50 | for (int i = 0; i < nodeList.getLength(); i++) { 51 | Node node = nodeList.item(i); 52 | String colorName = node.getAttributes().getNamedItem("name").getNodeValue(); 53 | colorHex.add(new SimpleEntry(colorName,node.getTextContent())); 54 | } 55 | for(Entry color : colorHex){ 56 | System.out.println(color.getKey()); 57 | System.out.println(color.getValue()); 58 | } 59 | 60 | // Read Source Code 61 | BufferedReader reader = new BufferedReader(new FileReader( 62 | new File(path))); 63 | String line = null; 64 | int startLine = 0; 65 | int startCol = 0; 66 | int endCol = 0; 67 | int lineNum = 0; 68 | String originalColor = ""; 69 | String colorName = ""; 70 | boolean isColorTag = false; 71 | int currentLine = 0; 72 | while ((line = reader.readLine()) != null) { 73 | 74 | if (line.contains(" color : colorHex){ 80 | if(line.contains("\""+color.getKey()+"\"")){ 81 | startCol = line.indexOf(color.getValue())+1; 82 | endCol = startCol+color.getValue().length()-1; 83 | lineNum = currentLine; 84 | originalColor = color.getValue(); 85 | colorName = color.getKey(); 86 | } 87 | } 88 | if (line.contains(">")) { 89 | locations.add(InvalidColorMutationLocation.buildLocation(path, startLine, currentLine, startCol, endCol, lineNum, -1, this.getType(), colorName, originalColor)); 90 | isColorTag = false; 91 | } 92 | } 93 | 94 | currentLine++; 95 | } 96 | reader.close(); 97 | } 98 | return locations; 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/xml/InvalidLabelDetector.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.xml; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import javax.xml.parsers.DocumentBuilder; 11 | import javax.xml.parsers.DocumentBuilderFactory; 12 | import javax.xml.parsers.ParserConfigurationException; 13 | 14 | import org.w3c.dom.Document; 15 | import org.w3c.dom.NamedNodeMap; 16 | import org.w3c.dom.Node; 17 | import org.w3c.dom.NodeList; 18 | import org.xml.sax.SAXException; 19 | 20 | import edu.uniandes.tsdl.mutapk.detectors.TextBasedDetector; 21 | import edu.uniandes.tsdl.mutapk.helper.Helper; 22 | import edu.uniandes.tsdl.mutapk.model.MutationType; 23 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 24 | 25 | public class InvalidLabelDetector extends TextBasedDetector { 26 | 27 | public InvalidLabelDetector() { 28 | this.type = MutationType.INVALID_LABEL; 29 | } 30 | 31 | @Override 32 | public List analyzeApp(String rootPath) throws ParserConfigurationException, SAXException, IOException { 33 | List locations = new ArrayList(); 34 | List activityLabels = new ArrayList(); 35 | 36 | 37 | String path = rootPath + File.separator + Helper.MANIFEST; 38 | 39 | File fXmlFile = new File(path); 40 | DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); 41 | DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); 42 | Document doc = dBuilder.parse(fXmlFile); 43 | doc.getDocumentElement().normalize(); 44 | 45 | // Get all activities 46 | NodeList nodeList = doc.getElementsByTagName("activity"); 47 | for (int i = 0; i < nodeList.getLength(); i++) { 48 | Node node = nodeList.item(i); 49 | NamedNodeMap attrMap = node.getAttributes(); 50 | // Loop through attributes 51 | for (int j = 0; j < attrMap.getLength(); j++) { 52 | if (attrMap.item(j).getNodeName().equals("android:label")) { 53 | // Get all activity names 54 | activityLabels.add(attrMap.item(j).getNodeValue()); 55 | } 56 | } 57 | } 58 | 59 | // Read Source Code 60 | BufferedReader reader = new BufferedReader(new FileReader( 61 | new File(path))); 62 | String line = null; 63 | int startLine = 0; 64 | int startCol = 0; 65 | int endCol = 0; 66 | int lineNum = 0; 67 | boolean isActivityTag = false; 68 | int currentLine = 0; 69 | boolean labelFound = false; 70 | while ((line = reader.readLine()) != null) { 71 | 72 | if (line.contains("")) { 86 | if(labelFound){ 87 | locations.add(MutationLocation.buildLocation(path, startLine, currentLine, startCol, endCol, lineNum, -1, this.getType())); 88 | labelFound = false; 89 | } 90 | isActivityTag = false; 91 | } 92 | } 93 | currentLine++; 94 | } 95 | reader.close(); 96 | return locations; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/xml/MissingPermissionDetector.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.xml; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Stack; 10 | 11 | import edu.uniandes.tsdl.mutapk.detectors.TextBasedDetector; 12 | import edu.uniandes.tsdl.mutapk.helper.Helper; 13 | import edu.uniandes.tsdl.mutapk.model.MutationType; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | 16 | public class MissingPermissionDetector extends TextBasedDetector { 17 | 18 | 19 | public MissingPermissionDetector(){ 20 | this.type = MutationType.MISSING_PERMISSION_MANIFEST; 21 | } 22 | 23 | @Override 24 | public List analyzeApp(String rootPath) throws IOException { 25 | Stack stack = new Stack<>(); 26 | List locations = new ArrayList(); 27 | 28 | String path = rootPath+File.separator+Helper.MANIFEST; 29 | BufferedReader reader = new BufferedReader(new FileReader(new File(path))); 30 | String line = null; 31 | int startLine = 0; 32 | 33 | 34 | boolean isPermissionTag = false; 35 | int currentLine = 0; 36 | while( (line = reader.readLine() ) != null){ 37 | 38 | if( line.contains("") || line.contains("-->"))){ 48 | stack.pop(); 49 | } 50 | 51 | if(isPermissionTag && stack.isEmpty()){ 52 | locations.add(MutationLocation.buildLocation(path, startLine, currentLine, -1, -1, -1, -1, this.getType())); 53 | isPermissionTag = false; 54 | } 55 | 56 | currentLine++; 57 | } 58 | reader.close(); 59 | 60 | return locations; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/xml/SDKVersionDetector.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.xml; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import javax.xml.parsers.DocumentBuilder; 11 | import javax.xml.parsers.DocumentBuilderFactory; 12 | import javax.xml.parsers.ParserConfigurationException; 13 | 14 | import org.w3c.dom.Document; 15 | import org.w3c.dom.NamedNodeMap; 16 | import org.w3c.dom.Node; 17 | import org.w3c.dom.NodeList; 18 | import org.xml.sax.SAXException; 19 | 20 | import edu.uniandes.tsdl.mutapk.detectors.TextBasedDetector; 21 | import edu.uniandes.tsdl.mutapk.helper.Helper; 22 | import edu.uniandes.tsdl.mutapk.model.MutationType; 23 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 24 | 25 | public class SDKVersionDetector extends TextBasedDetector { 26 | 27 | public SDKVersionDetector() { 28 | this.type = MutationType.SDK_VERSION; 29 | } 30 | 31 | @Override 32 | public List analyzeApp(String rootPath) throws ParserConfigurationException, SAXException, IOException { 33 | List locations = new ArrayList(); 34 | List sdkVersion = new ArrayList(); 35 | 36 | 37 | String path = rootPath + File.separator + Helper.MANIFEST; 38 | 39 | File fXmlFile = new File(path); 40 | DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); 41 | DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); 42 | Document doc = dBuilder.parse(fXmlFile); 43 | doc.getDocumentElement().normalize(); 44 | 45 | // Get all activities 46 | NodeList nodeList = doc.getElementsByTagName("uses-sdk"); 47 | for (int i = 0; i < nodeList.getLength(); i++) { 48 | Node node = nodeList.item(i); 49 | NamedNodeMap attrMap = node.getAttributes(); 50 | // Loop through attributes 51 | for (int j = 0; j < attrMap.getLength(); j++) { 52 | String nodeName = attrMap.item(j).getNodeName(); 53 | // Get all sdk version 54 | if(nodeName.equals(Helper.MIN_SDK_VERSION) || 55 | nodeName.equals(Helper.TARGET_SDK_VERSION) || 56 | nodeName.equals(Helper.MAX_SDK_VERSION)){ 57 | 58 | sdkVersion.add(nodeName); 59 | } 60 | } 61 | } 62 | 63 | // Read Source Code 64 | BufferedReader reader = new BufferedReader(new FileReader(new File(path))); 65 | String line = null; 66 | int startCol = 0; 67 | int endCol = 0; 68 | int lineNum = 0; 69 | 70 | boolean isActivityTag = false; 71 | int currentLine = 0; 72 | while ((line = reader.readLine()) != null) { 73 | 74 | if (line.contains("")) { 88 | isActivityTag = false; 89 | } 90 | } 91 | 92 | currentLine++; 93 | } 94 | reader.close(); 95 | 96 | return locations; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/xml/WrongMainActivityDetector.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.xml; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import javax.xml.parsers.ParserConfigurationException; 11 | 12 | import org.xml.sax.SAXException; 13 | 14 | import edu.uniandes.tsdl.mutapk.detectors.TextBasedDetector; 15 | import edu.uniandes.tsdl.mutapk.helper.Helper; 16 | import edu.uniandes.tsdl.mutapk.model.MutationType; 17 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 18 | 19 | public class WrongMainActivityDetector extends TextBasedDetector { 20 | 21 | public WrongMainActivityDetector() { 22 | this.type = MutationType.WRONG_MAIN_ACTIVITY; 23 | } 24 | 25 | @Override 26 | public List analyzeApp(String rootPath) throws ParserConfigurationException, SAXException, IOException { 27 | List locations = new ArrayList(); 28 | String mainActivity = Helper.getInstance().getMainActivity(); 29 | 30 | String path = rootPath + File.separator + Helper.MANIFEST; 31 | 32 | //Main activity not found! 33 | if(mainActivity.equals("")){ 34 | return locations; 35 | } 36 | 37 | // Read Source Code 38 | BufferedReader reader = new BufferedReader(new FileReader(new File(path))); 39 | String line = null; 40 | int startLine = 0; 41 | int startCol = 0; 42 | int endCol = 0; 43 | int lineNum = 0; 44 | 45 | boolean isActivityTag = false; 46 | boolean isMainActivity = false; 47 | int currentLine = 1; 48 | while ((line = reader.readLine()) != null) { 49 | 50 | if (line.contains("")) { 62 | if(isMainActivity){ 63 | locations.add(MutationLocation.buildLocation(path, startLine, currentLine, startCol, endCol, lineNum, -1, this.getType())); 64 | isMainActivity=false; 65 | } 66 | isActivityTag = false; 67 | } 68 | } 69 | 70 | currentLine++; 71 | } 72 | reader.close(); 73 | 74 | return locations; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/detectors/xml/WrongStringResourceDetector.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.detectors.xml; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import edu.uniandes.tsdl.mutapk.detectors.TextBasedDetector; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.MutationType; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | 15 | public class WrongStringResourceDetector extends TextBasedDetector { 16 | 17 | 18 | public WrongStringResourceDetector(){ 19 | this.type = MutationType.WRONG_STRING_RESOURCE; 20 | } 21 | 22 | @Override 23 | public List analyzeApp(String rootPath) throws IOException { 24 | List locations = new ArrayList(); 25 | 26 | String path = rootPath+File.separator+"res"+File.separator+"values"+File.separator+Helper.STRINGS; 27 | BufferedReader reader = new BufferedReader(new FileReader(new File(path))); 28 | String line = null; 29 | int startLine = 0; 30 | boolean isStringTag = false; 31 | int currentLine = 0; 32 | while( (line = reader.readLine() ) != null){ 33 | 34 | if( line.contains(" apkHashesSeparator = new HashMap(); 22 | 23 | /** 24 | * Enforce private constructor 25 | */ 26 | private ApkHashOrder() { } 27 | 28 | public static ApkHashOrder getInstance() { 29 | if (instance == null) { 30 | synchronized (ApkHashOrder.class) { 31 | if (instance == null) { 32 | instance = new ApkHashOrder(); 33 | } 34 | } 35 | } 36 | return instance; 37 | } 38 | 39 | public synchronized ApkHashSeparator setApkHashSeparator(ApkHashSeparator nuevoApkHashSeparator) { 40 | boolean isDuplicate = apkHashesSeparator.containsKey(nuevoApkHashSeparator); 41 | if(isDuplicate) { 42 | ApkHashSeparator duplicate = apkHashesSeparator.get(nuevoApkHashSeparator); 43 | System.out.println(nuevoApkHashSeparator.getMutantId() + " HashCode: " + nuevoApkHashSeparator.hashCode() + " duplicate: " + duplicate.hashCode()); 44 | if(duplicate != null && nuevoApkHashSeparator.equals(duplicate)) { 45 | // System.out.println("ES IGUAL: " + nuevoApkHashSeparator.equals(duplicate)); 46 | // System.out.println("ES IGUAL Nuevo: " + nuevoApkHashSeparator.getMutanteId()); 47 | // System.out.println("ES IGUAL Nuevo Manifest: " + nuevoApkHashSeparator.getMutanteId() + " " + nuevoApkHashSeparator.getHashManifest()); 48 | // System.out.println("ES IGUAL Nuevo Smali: " + nuevoApkHashSeparator.getMutanteId() + " " + nuevoApkHashSeparator.getHashSmali()); 49 | // System.out.println("ES IGUAL Nuevo Resource: " + nuevoApkHashSeparator.getMutanteId() + " " + nuevoApkHashSeparator.getHashResource()); 50 | // System.out.println("ES IGUAL Nuevo: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId()); 51 | // System.out.println("ES IGUAL Nuevo Manifest: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId() + " " + nuevoApkHashSeparator.getHashManifest()); 52 | // System.out.println("ES IGUAL Nuevo Smali: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId() + " " + nuevoApkHashSeparator.getHashSmali()); 53 | // System.out.println("ES IGUAL Nuevo Resource: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId() + " " + nuevoApkHashSeparator.getHashResource()); 54 | return duplicate; 55 | } 56 | } 57 | System.out.println(nuevoApkHashSeparator.getMutantId() + " HashCode: " + nuevoApkHashSeparator.hashCode()); 58 | nuevoApkHashSeparator.setId(id); 59 | apkHashesSeparator.put(nuevoApkHashSeparator, nuevoApkHashSeparator); 60 | id++; 61 | return null; 62 | } 63 | 64 | public synchronized int getId() { 65 | return id; 66 | } 67 | 68 | public synchronized int getLength() { 69 | return apkHashesSeparator.size(); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/hashfunction/sha3/ApkHashSeparator.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.hashfunction.sha3; 2 | 3 | public class ApkHashSeparator { 4 | 5 | private int id = -1; 6 | private final String hashManifest; 7 | private final String hashSmali; 8 | private final String hashResource; 9 | private final int mutantId; 10 | 11 | public static class Builder { 12 | private final String hashManifest; 13 | private final String hashSmali; 14 | private final String hashResource; 15 | private final int mutantId; 16 | 17 | public Builder(String hashManifest, String hashSmali, String hashResource, int mutantId) { 18 | this.hashManifest = hashManifest; 19 | this.hashSmali = hashSmali; 20 | this.hashResource = hashResource; 21 | this.mutantId = mutantId; 22 | } 23 | 24 | public ApkHashSeparator build() { 25 | return new ApkHashSeparator(this); 26 | } 27 | } 28 | 29 | private ApkHashSeparator(Builder builder) { 30 | this.hashManifest = builder.hashManifest; 31 | this.hashSmali = builder.hashSmali; 32 | this.hashResource = builder.hashResource; 33 | this.mutantId = builder.mutantId; 34 | } 35 | 36 | public int getId() { 37 | return id; 38 | } 39 | 40 | public void setId(int id) { 41 | this.id = id; 42 | } 43 | 44 | public String getHashManifest() { 45 | return hashManifest; 46 | } 47 | 48 | public String getHashSmali() { 49 | return hashSmali; 50 | } 51 | 52 | public String getHashResource() { 53 | return hashResource; 54 | } 55 | 56 | public int getMutantId() { 57 | return mutantId; 58 | } 59 | 60 | @Override 61 | public boolean equals(Object o) { 62 | if (o == this) { 63 | return true; 64 | } 65 | if(o == null){ 66 | return false; 67 | } 68 | if (!(o instanceof ApkHashSeparator)) { 69 | return false; 70 | } 71 | ApkHashSeparator apkHashseparator = (ApkHashSeparator) o; 72 | return (hashManifest.equals(apkHashseparator.getHashManifest()) 73 | && hashSmali.equals(apkHashseparator.getHashSmali()) 74 | && hashResource.equals(apkHashseparator.getHashResource())); 75 | 76 | } 77 | 78 | @Override 79 | public int hashCode() { 80 | int hash = 7; 81 | hash = 31 * hash + hashManifest.hashCode(); 82 | hash = 31 * hash + hashSmali.hashCode(); 83 | hash = 31 * hash + hashResource.hashCode(); 84 | return hash; 85 | } 86 | 87 | @Override 88 | public String toString() { 89 | return hashManifest + "||" + hashResource + "||" + hashSmali; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/hashfunction/sha3/Sha3.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.hashfunction.sha3; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.File; 5 | import java.io.FileInputStream; 6 | import java.io.FileNotFoundException; 7 | import java.io.IOException; 8 | import java.util.Collection; 9 | import java.util.StringJoiner; 10 | 11 | import org.apache.commons.io.FileUtils; 12 | import org.apache.commons.io.filefilter.TrueFileFilter; 13 | import org.bouncycastle.jcajce.provider.digest.SHA3.DigestSHA3; 14 | 15 | 16 | public class Sha3 { 17 | 18 | /** 19 | * Static Factory Method 20 | */ 21 | private Sha3() { 22 | } 23 | 24 | public static String sha512File(final File file) 25 | throws FileNotFoundException, IOException { 26 | final DigestSHA3 sha3 = new DigestSHA3(512); 27 | if (file.isFile()) { 28 | sha3.update(fileHash(file)); 29 | } else { 30 | Collection files = FileUtils.listFiles(new File(file.getAbsolutePath()), TrueFileFilter.INSTANCE, 31 | TrueFileFilter.INSTANCE); 32 | for (File fileHash : files) { 33 | sha3.update(fileHash(fileHash)); 34 | } 35 | } 36 | return hashToString(sha3.digest()); 37 | } 38 | 39 | public static String sha512FileSeparte(final File file) 40 | throws FileNotFoundException, IOException { 41 | if (file.isFile()) { 42 | return hashToString(fileHash(file)); 43 | } else { 44 | StringJoiner hashes = new StringJoiner("|"); 45 | Collection files = FileUtils.listFiles(new File(file.getAbsolutePath()), TrueFileFilter.INSTANCE, 46 | TrueFileFilter.INSTANCE); 47 | for (File fileHash : files) { 48 | String string = hashToString(fileHash(fileHash)); 49 | hashes.add(string); 50 | } 51 | return hashes.toString(); 52 | } 53 | } 54 | 55 | private static byte[] fileHash(final File file) throws FileNotFoundException, IOException { 56 | final DigestSHA3 sha3 = new DigestSHA3(512); 57 | BufferedInputStream bis =new BufferedInputStream(new FileInputStream(file)); 58 | int n = 0; 59 | byte[] buffer = new byte[8192]; 60 | while ((n = bis.read(buffer)) > 0) { 61 | sha3.update(buffer, 0, n); 62 | } 63 | bis.close(); 64 | byte[] hash = sha3.digest(); 65 | bis.close(); 66 | return hash; 67 | } 68 | 69 | private static String hashToString(byte[] hash) { 70 | StringBuffer buff = new StringBuffer(); 71 | for (byte b : hash) { 72 | buff.append(String.format("%02x", b & 0xFF)); 73 | } 74 | return buff.toString(); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/helper/APKToolWrapper.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.helper; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.nio.file.Files; 6 | import java.nio.file.Paths; 7 | 8 | import edu.uniandes.tsdl.mutapk.helper.Helper; 9 | 10 | public class APKToolWrapper { 11 | 12 | public static String openAPK(String path, String extraPath) throws IOException, InterruptedException{ 13 | String decodedPath = Helper.getInstance().getCurrentDirectory(); 14 | // Creates folder for decoded app 15 | // System.out.println(decodedPath); 16 | File tempFolder = new File(decodedPath+File.separator+"temp"); 17 | if(tempFolder.exists()) { 18 | tempFolder.delete(); 19 | } 20 | tempFolder.mkdirs(); 21 | System.out.println("> Processing your APK... "); 22 | Process ps = Runtime.getRuntime().exec(new String[]{"java","-jar",Paths.get(decodedPath,extraPath,"apktool.jar").toAbsolutePath().toString(),"d",Paths.get(decodedPath,path).toAbsolutePath().toString(),"-o",Paths.get(decodedPath,"temp").toAbsolutePath().toString(),"-f"}); 23 | ps.waitFor(); 24 | System.out.println("> Wow... that was an amazing APK to proccess!!! :D"); 25 | System.out.println(""); 26 | return tempFolder.getAbsolutePath(); 27 | // InputStream es = ps.getErrorStream(); 28 | // byte e[] = new byte[es.available()]; 29 | // es.read(e,0,e.length); 30 | // System.out.println("ERROR: "+ new String(e)); 31 | // InputStream is = ps.getInputStream(); 32 | // byte b[] = new byte[is.available()]; 33 | // is.read(b,0,b.length); 34 | // System.out.println("INFO: "+new String(b)); 35 | // System.out.println(decodedPath); 36 | } 37 | 38 | public static boolean buildAPK(String path, String extraPath, String appName, int mutantIndex) throws IOException, InterruptedException{ 39 | String decodedPath = Helper.getInstance().getCurrentDirectory(); 40 | Process ps = Runtime.getRuntime().exec(new String[]{"java","-jar",Paths.get(decodedPath,extraPath,"apktool.jar").toAbsolutePath().toString(),"b",Paths.get(decodedPath,path,"src").toAbsolutePath().toString(),"-o",Paths.get(decodedPath,path,appName).toAbsolutePath().toString(),"-f"}); 41 | System.out.println("Building mutant "+mutantIndex+"..."); 42 | ps.waitFor(); 43 | Process pss = Runtime.getRuntime().exec(new String[]{"java","-jar",Paths.get(decodedPath,extraPath,"uber-apk-signer.jar").toAbsolutePath().toString(),"-a",Paths.get(decodedPath,path).toAbsolutePath().toString(),"-o",Paths.get(decodedPath,path).toAbsolutePath().toString()}); 44 | System.out.println("Signing mutant "+mutantIndex+"..."); 45 | pss.waitFor(); 46 | if(Files.exists(Paths.get(decodedPath,path,appName).toAbsolutePath())) { 47 | System.out.println("SUCCESS: The "+mutantIndex+" mutant APK has been generated."); 48 | return true; 49 | } else { 50 | System.out.println("ERROR: The "+mutantIndex+" mutant APK has not been generated."); 51 | return false; 52 | } 53 | // InputStream es = ps.getErrorStream(); 54 | // byte e[] = new byte[es.available()]; 55 | // es.read(e,0,e.length); 56 | // System.out.println("ERROR: "+ new String(e)); 57 | // InputStream is = ps.getInputStream(); 58 | // byte b[] = new byte[is.available()]; 59 | // is.read(b,0,b.length); 60 | // System.out.println("INFO: "+new String(b)); 61 | } 62 | } -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/helper/FileHelper.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.helper; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.BufferedWriter; 5 | import java.io.FileNotFoundException; 6 | import java.io.FileReader; 7 | import java.io.FileWriter; 8 | import java.io.IOException; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public class FileHelper { 13 | 14 | public static List readLines(String filePath) { 15 | List lines = new ArrayList(); 16 | try { 17 | BufferedReader br = new BufferedReader(new FileReader(filePath)); 18 | 19 | String line; 20 | while ((line = br.readLine()) != null) { 21 | lines.add(line); 22 | } 23 | 24 | br.close(); 25 | } catch (FileNotFoundException e) { 26 | e.printStackTrace(); 27 | } catch (IOException e) { 28 | e.printStackTrace(); 29 | } 30 | 31 | return lines; 32 | } 33 | 34 | public static void writeLines(String filePath, List lines) throws IOException { 35 | 36 | BufferedWriter bw = new BufferedWriter(new FileWriter(filePath)); 37 | 38 | for (String newLine : lines) { 39 | bw.write(newLine); 40 | bw.newLine(); 41 | bw.flush(); 42 | } 43 | 44 | bw.close(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/helper/HexadecimalGenerator.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.helper; 2 | 3 | import java.util.Random; 4 | 5 | public class HexadecimalGenerator { 6 | 7 | 8 | public static String generateRandomHexa() { 9 | Random r = new Random(); 10 | final char [] hex = { '0', '1', '2', '3', '4', '5', '6', '7', 11 | '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; 12 | char [] s = new char[8]; 13 | int n = r.nextInt(0x1000000); 14 | 15 | // s[0] = '#'; 16 | for (int i=0;i<8;i++) { 17 | s[i] = hex[n & 0xf]; 18 | n >>= 4; 19 | } 20 | return new String(s); 21 | } 22 | 23 | public static String generateRandomHexaLong() { 24 | String hexa = generateRandomHexa(); 25 | return hexa.substring(0, hexa.length()-1)+"L"; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/helper/IntegerGenerator.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.helper; 2 | 3 | public class IntegerGenerator { 4 | 5 | private static final int MINIMUM = 0; 6 | private static final int MAXIMUM = 9999; 7 | 8 | public static int generateRandomInt(int minimum, int maximum){ 9 | 10 | return minimum + (int)(Math.random() * maximum); 11 | } 12 | 13 | 14 | public static int generateRandomInt(){ 15 | //Generate random integers between -9999 and 9999 16 | return (generateRandomInt(MINIMUM, MAXIMUM*2)-MAXIMUM); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/helper/StringGenerator.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.helper; 2 | 3 | import java.util.UUID; 4 | 5 | public class StringGenerator { 6 | 7 | 8 | public static String generateRandomString(){ 9 | 10 | return UUID.randomUUID().toString().replaceAll("-", ""); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/helper/StringMutator.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.helper; 2 | 3 | import java.util.Random; 4 | 5 | public class StringMutator { 6 | 7 | private static final int STRING_MUTATORS = 1; 8 | 9 | public static String performMutation(String str){ 10 | 11 | 12 | if(str.trim().isEmpty()){ 13 | return randomString(); 14 | } 15 | 16 | //Randomly select a String Mutator Operator 17 | int randomMutator = (int) Math.round((Math.random() * STRING_MUTATORS)); 18 | switch (randomMutator) { 19 | case 0: return swapCharacters(str); 20 | default: return deleteCharacter(str); 21 | } 22 | 23 | 24 | } 25 | 26 | 27 | private static String swapCharacters(String str){ 28 | //System.out.println("*Swapping Chars*"); 29 | char[] characters = str.toCharArray(); 30 | int minimum = 0; 31 | int maximum = characters.length-1; 32 | 33 | int i = minimum + (int)(Math.random() * maximum); 34 | int j = minimum + (int)(Math.random() * maximum); 35 | 36 | //Swaping characters 37 | char temp = characters[i]; 38 | characters[i] = characters[j]; 39 | characters[j] = temp; 40 | 41 | String newStr = new String(characters); 42 | return newStr; 43 | } 44 | 45 | 46 | 47 | private static String randomString(){ 48 | return StringGenerator.generateRandomString(); 49 | } 50 | 51 | private static String deleteCharacter(String str){ 52 | //System.out.println("*Deleting Chars*"); 53 | int minimum = 0; 54 | int maximum = str.length()-1; 55 | 56 | if(maximum > 1){ 57 | Random rnd = new Random(); 58 | int rndInt = rnd.nextInt( maximum-1); 59 | if(rndInt == 0){ 60 | rndInt = 1; 61 | } 62 | int i = minimum + rndInt; 63 | 64 | String sub1 = str.substring(0, i); 65 | String sub2 = ""; 66 | if(i+1 < maximum-1 ){ 67 | sub2 = str.substring(i+1); 68 | } 69 | 70 | String newStr = sub1 + sub2; 71 | 72 | return newStr; 73 | }else{ 74 | return ""; 75 | } 76 | 77 | } 78 | 79 | 80 | 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/helper/VisitableCommonTree.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.helper; 2 | 3 | public class VisitableCommonTree { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/model/CallGraphNode.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.model; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import org.antlr.runtime.tree.CommonTree; 7 | 8 | public class CallGraphNode { 9 | 10 | public String id; 11 | public String unitName; 12 | public CommonTree methodASTNode; 13 | public Set callers; 14 | public Set callees; 15 | 16 | 17 | public CallGraphNode(String id, String unitName, CommonTree methodASTNode) { 18 | super(); 19 | this.id = id; 20 | this.unitName = unitName; 21 | this.methodASTNode = methodASTNode; 22 | callers = new HashSet(); 23 | callees = new HashSet(); 24 | } 25 | 26 | @Override 27 | public boolean equals(Object obj) { 28 | CallGraphNode temp = (CallGraphNode) obj; 29 | return ((temp.getId().equals(this.getId())) && (temp.getUnitName().equals(this.getUnitName()))); 30 | } 31 | 32 | /** 33 | * @return the id 34 | */ 35 | public String getId() { 36 | return id; 37 | } 38 | 39 | /** 40 | * @param id the id to set 41 | */ 42 | public void setId(String id) { 43 | this.id = id; 44 | } 45 | 46 | /** 47 | * @return the unitName 48 | */ 49 | public String getUnitName() { 50 | return unitName; 51 | } 52 | 53 | /** 54 | * @param unitName the unitName to set 55 | */ 56 | public void setUnitName(String unitName) { 57 | this.unitName = unitName; 58 | } 59 | 60 | /** 61 | * @return the methodASTNode 62 | */ 63 | public CommonTree getMethodASTNode() { 64 | return methodASTNode; 65 | } 66 | 67 | /** 68 | * @param methodASTNode the methodASTNode to set 69 | */ 70 | public void setMethodASTNode(CommonTree methodASTNode) { 71 | this.methodASTNode = methodASTNode; 72 | } 73 | 74 | /** 75 | * @return the called 76 | */ 77 | public Set getCallers() { 78 | return callers; 79 | } 80 | 81 | /** 82 | * @param called the called to set 83 | */ 84 | public void setCallers(Set called) { 85 | this.callers = called; 86 | } 87 | 88 | /** 89 | * @return the callee 90 | */ 91 | public Set getCallees() { 92 | return callees; 93 | } 94 | 95 | /** 96 | * @param callee the callee to set 97 | */ 98 | public void setCallees(Set callee) { 99 | this.callees = callee; 100 | } 101 | 102 | public void addCallee(CallGraphNode cGN) { 103 | callees.add(cGN); 104 | } 105 | 106 | public void addCaller(CallGraphNode cGN) { 107 | 108 | callers.add(cGN); 109 | 110 | } 111 | 112 | 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/model/MutationType.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.model; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public enum MutationType { 7 | ACTIVITY_NOT_DEFINED(1,"ActivityNotDefined"), 8 | DIFFERENT_ACTIVITY_INTENT_DEFINITION(2,"DifferentActivityIntentDefinition"), 9 | INVALID_ACTIVITY_PATH(3,"InvalidActivityPATH"), 10 | INVALID_KEY_INTENT_PUT_EXTRA(4,"InvalidKeyIntentPutExtra"), 11 | INVALID_LABEL(5,"InvalidLabel"), 12 | NULL_INTENT(6,"NullIntent"), 13 | NULL_VALUE_INTENT_PUT_EXTRA(7,"NullValueIntentPutExtra"), 14 | WRONG_MAIN_ACTIVITY(8,"WrongMainActivity"), 15 | MISSING_PERMISSION_MANIFEST(9,"MissingPermissionManifest"), 16 | WRONG_STRING_RESOURCE(10,"WrongStringResource"), 17 | NOT_PARCELABLE(11,"NotParcelable"), 18 | SDK_VERSION(12,"SDKVersion"), 19 | LENGTHY_BACKEND_SERVICE(13,"LengthyBackEndService"), 20 | LONG_CONNECTION_TIME_OUT(14,"LongConnectionTimeOut"), 21 | BLUETOOTH_ADAPTER_ALWAYS_AVAILABLE(15,"BluetoothAdapterAlwaysEnabled"), 22 | NULL_BLUETOOTH_ADAPTER(16,"NullBluetoothAdapter"), 23 | INVALID_URI(17,"InvalidURI"), 24 | NULL_GPS_LOCATION(18,"NullGPSLocation"), 25 | INVALID_DATE(19,"InvalidDate"), 26 | NULL_BACKEND_SERVICE_RETURN(20,"NullBackEndServiceReturn"), 27 | INVALID_METHOD_CALL_ARGUMENT(21,"InvalidMethodCallArgument"), 28 | NULL_METHOD_CALL_ARGUMENT(22,"NullMethodCallArgument"), 29 | CLOSING_NULL_CURSOR(23,"ClosingNullCursor"), 30 | INVALID_INDEX_QUERY_PARAMETER(24,"InvalidIndexQueryParameter"), 31 | INVALID_SQL_QUERY(25,"InvalidSQLQuery"), 32 | VIEW_COMPONENT_NOT_VISIBLE(26,"ViewComponentNotVisible"), 33 | FINDVIEWBYID_RETURNS_NULL(27,"FindViewByIdReturnsNull"), 34 | INVALID_COLOR(28,"InvalidColor"), 35 | INVALID_VIEW_FOCUS(29,"InvalidViewFocus"), 36 | BUGGY_GUI_LISTENER(30,"BuggyGUIListener"), 37 | INVALID_ID_FINDVIEW(31,"InvalidIDFindView"), 38 | INVALID_FILE_PATH(32,"InvalidFilePath"), 39 | NULL_INPUT_STREAM(33,"NullInputStream"), 40 | NOT_SERIALIZABLE(34,"NotSerializable"), 41 | OOM_LARGE_IMAGE(35,"OOMLargeImage"), 42 | LENGTHY_GUI_LISTENER(36,"LengthyGUIListener"), 43 | NULL_OUTPUT_STREAM(37,"NullOutputStream"), 44 | LENGTHY_GUI_CREATION(38,"LengthyGUICreation"); 45 | 46 | private final int id; 47 | private final String name; 48 | 49 | 50 | private static Map map = new HashMap<>(); 51 | 52 | 53 | static { 54 | for (MutationType type : MutationType.values()) { 55 | map.put(type.getId(), type); 56 | } 57 | } 58 | 59 | MutationType(int id, String name){ 60 | this.id = id; 61 | this.name = name; 62 | } 63 | 64 | public int getId() { 65 | return id; 66 | } 67 | 68 | public String getName() { 69 | return name; 70 | } 71 | 72 | public static MutationType valueOf(int typeId) { 73 | return map.get(typeId); 74 | } 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/model/SmaliAST.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.model; 2 | 3 | import org.antlr.runtime.tree.CommonTree; 4 | 5 | public class SmaliAST { 6 | 7 | public String unitName; 8 | public String filePath; 9 | public CommonTree ast; 10 | 11 | 12 | public SmaliAST(String unitName, String filePath, CommonTree ast) { 13 | super(); 14 | this.unitName = unitName; 15 | this.filePath = filePath; 16 | this.ast = ast; 17 | } 18 | 19 | 20 | /** 21 | * @return the unitName 22 | */ 23 | public String getUnitName() { 24 | return unitName; 25 | } 26 | 27 | 28 | /** 29 | * @param unitName the unitName to set 30 | */ 31 | public void setUnitName(String unitName) { 32 | this.unitName = unitName; 33 | } 34 | 35 | 36 | /** 37 | * @return the filePath 38 | */ 39 | public String getFilePath() { 40 | return filePath; 41 | } 42 | 43 | 44 | /** 45 | * @param filePath the filePath to set 46 | */ 47 | public void setFilePath(String filePath) { 48 | this.filePath = filePath; 49 | } 50 | 51 | 52 | /** 53 | * @return the ast 54 | */ 55 | public CommonTree getAst() { 56 | return ast; 57 | } 58 | 59 | 60 | /** 61 | * @param ast the ast to set 62 | */ 63 | public void setAst(CommonTree ast) { 64 | this.ast = ast; 65 | } 66 | 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/model/location/ASTMutationLocation.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.model.location; 2 | 3 | import org.antlr.runtime.tree.CommonTree; 4 | 5 | import edu.uniandes.tsdl.mutapk.model.MutationType; 6 | 7 | public class ASTMutationLocation extends MutationLocation { 8 | private CommonTree tree; 9 | 10 | 11 | public CommonTree getTree() { 12 | return tree; 13 | } 14 | 15 | 16 | public void setTree(CommonTree tree) { 17 | this.tree = tree; 18 | } 19 | 20 | 21 | public static MutationLocation buildLocation( String path, int startLine, int endLine, int startCol, int endCol, int lineNum, int length, MutationType mType, CommonTree tree) { 22 | ASTMutationLocation location = new ASTMutationLocation(); 23 | location.setFilePath(path); 24 | location.setStartLine(startLine); 25 | location.setEndLine(endLine); 26 | location.setStartColumn(startCol); 27 | location.setEndColumn(endCol); 28 | location.setType(mType); 29 | location.setLine(lineNum); 30 | location.setLength(length); 31 | location.setTree(tree); 32 | return location; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/model/location/InvalidColorMutationLocation.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.model.location; 2 | 3 | import edu.uniandes.tsdl.mutapk.model.MutationType; 4 | 5 | public class InvalidColorMutationLocation extends MutationLocation{ 6 | 7 | private String colorName; 8 | private String originalColor; 9 | 10 | 11 | public String getColorName() { 12 | return colorName; 13 | } 14 | public void setColorName(String colorName) { 15 | this.colorName = colorName; 16 | } 17 | public String getOriginalColor() { 18 | return originalColor; 19 | } 20 | public void setOriginalColor(String originalColor) { 21 | this.originalColor = originalColor; 22 | } 23 | 24 | public static MutationLocation buildLocation( String path, int startLine, int endLine, int startCol, int endCol, int lineNum, int length, MutationType mType, String colorName, String originalColor) { 25 | InvalidColorMutationLocation location = new InvalidColorMutationLocation(); 26 | location.setFilePath(path); 27 | location.setStartLine(startLine); 28 | location.setEndLine(endLine); 29 | location.setStartColumn(startCol); 30 | location.setEndColumn(endCol); 31 | location.setType(mType); 32 | location.setLine(lineNum); 33 | location.setLength(length); 34 | location.setColorName(colorName); 35 | location.setOriginalColor(originalColor); 36 | return location; 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/model/location/MutationLocation.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.model.location; 2 | 3 | import edu.uniandes.tsdl.mutapk.model.MutationType; 4 | 5 | public class MutationLocation { 6 | 7 | private String filePath; 8 | private int line; 9 | private int startLine; 10 | private int endLine; 11 | private int startColumn; 12 | private int endColumn; 13 | private int length; 14 | 15 | private MutationType type; 16 | 17 | public String getFilePath() { 18 | return filePath; 19 | } 20 | 21 | public void setFilePath(String filePath) { 22 | this.filePath = filePath; 23 | } 24 | 25 | public int getLine() { 26 | return line; 27 | } 28 | 29 | public void setLine(int line) { 30 | this.line = line; 31 | } 32 | 33 | public int getStartColumn() { 34 | return startColumn; 35 | } 36 | 37 | public void setStartColumn(int startCoumn) { 38 | this.startColumn = startCoumn; 39 | } 40 | 41 | public int getEndColumn() { 42 | return endColumn; 43 | } 44 | 45 | public void setEndColumn(int endColumn) { 46 | this.endColumn = endColumn; 47 | } 48 | 49 | public int getStartLine() { 50 | return startLine; 51 | } 52 | 53 | public void setStartLine(int startLine) { 54 | this.startLine = startLine; 55 | } 56 | 57 | public int getEndLine() { 58 | return endLine; 59 | } 60 | 61 | public void setEndLine(int endLine) { 62 | this.endLine = endLine; 63 | } 64 | 65 | 66 | 67 | public MutationType getType() { 68 | return type; 69 | } 70 | 71 | public void setType(MutationType type) { 72 | this.type = type; 73 | } 74 | 75 | public int getLength() { 76 | return length; 77 | } 78 | 79 | public void setLength(int length) { 80 | this.length = length; 81 | } 82 | 83 | public static MutationLocation buildLocation( String path, int startLine, int endLine, int startCol, int endCol, int lineNum, int length, MutationType mType) { 84 | MutationLocation location = new MutationLocation(); 85 | location.setFilePath(path); 86 | location.setStartLine(startLine); 87 | location.setEndLine(endLine); 88 | location.setStartColumn(startCol); 89 | location.setEndColumn(endCol); 90 | location.setType(mType); 91 | location.setLine(lineNum); 92 | location.setLength(length); 93 | return location; 94 | } 95 | 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/MutationOperator.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | 6 | import javax.xml.parsers.ParserConfigurationException; 7 | 8 | import org.xml.sax.SAXException; 9 | 10 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 11 | 12 | public interface MutationOperator { 13 | 14 | boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException, ParserConfigurationException, SAXException; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/MutationOperatorFactory.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators; 2 | 3 | import java.util.ResourceBundle; 4 | 5 | public class MutationOperatorFactory { 6 | 7 | private static MutationOperatorFactory instance = null; 8 | private static ResourceBundle types = null; 9 | 10 | protected MutationOperatorFactory(){ 11 | types = ResourceBundle.getBundle("operator-types"); 12 | } 13 | 14 | public static MutationOperatorFactory getInstance() { 15 | if(instance == null) { 16 | instance = new MutationOperatorFactory(); 17 | } 18 | return instance; 19 | } 20 | 21 | 22 | public MutationOperator getOperator(int code){ 23 | 24 | try{ 25 | return (MutationOperator)Class.forName(types.getString(code+"")).newInstance(); 26 | }catch(Exception ex){ 27 | ex.printStackTrace(); 28 | return null; 29 | } 30 | 31 | 32 | } 33 | 34 | 35 | /*public static void main(String[] args){ 36 | MutationOperator operator = null; 37 | for(int i = 1; i <= 36; i++){ 38 | operator = MutationOperatorFactory.getInstance().getOperator(i); 39 | System.out.println(operator.getClass().getName()); 40 | } 41 | } 42 | */ 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/activity/ActivityNotDefined.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.activity; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 9 | import edu.uniandes.tsdl.mutapk.helper.Helper; 10 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 11 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 12 | 13 | public class ActivityNotDefined implements MutationOperator{ 14 | 15 | @Override 16 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 17 | 18 | List newLines = new ArrayList(); 19 | List lines = FileHelper.readLines(location.getFilePath()); 20 | 21 | for(int i=0; i < lines.size(); i++){ 22 | 23 | String currLine = lines.get(i); 24 | 25 | //Discard lines to remove in the new source code file 26 | if(i < location.getStartLine() || i > location.getEndLine()){ 27 | newLines.add(currLine); 28 | } 29 | 30 | } 31 | 32 | FileHelper.writeLines(location.getFilePath(), newLines); 33 | Helper.mutationSuccess(mutantIndex); 34 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {location.getStartLine()}, writer); 35 | writer.write(" For mutant "+mutantIndex+" the lines between "+(location.getStartLine()+1)+" and "+ (location.getEndLine()+1)+" have been deleted."); 36 | writer.newLine(); 37 | writer.flush(); 38 | 39 | return true; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/activity/InvalidActivityName.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.activity; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 9 | import edu.uniandes.tsdl.mutapk.helper.Helper; 10 | import edu.uniandes.tsdl.mutapk.helper.StringMutator; 11 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 12 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 13 | 14 | public class InvalidActivityName implements MutationOperator{ 15 | 16 | @Override 17 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 18 | 19 | List newLines = new ArrayList(); 20 | List lines = FileHelper.readLines(location.getFilePath()); 21 | String toMutate = ""; 22 | String mutatedString = ""; 23 | 24 | for(int i=0; i < lines.size(); i++){ 25 | 26 | String currLine = lines.get(i); 27 | 28 | if(i == location.getLine()){ 29 | //Apply mutation 30 | String sub1 = currLine.substring(0, location.getStartColumn()); 31 | toMutate = currLine.substring(location.getStartColumn(), location.getEndColumn()); 32 | String sub2 = currLine.substring(location.getEndColumn()); 33 | 34 | mutatedString = StringMutator.performMutation(toMutate); 35 | currLine = sub1 + mutatedString + sub2; 36 | } 37 | 38 | newLines.add(currLine); 39 | } 40 | 41 | FileHelper.writeLines(location.getFilePath(), newLines); 42 | Helper.mutationSuccess(mutantIndex); 43 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {location.getStartLine()}, writer); 44 | writer.write(" For mutant "+mutantIndex+" activity name at line "+location.getLine()+" has been change from \""+toMutate+"\" to \""+mutatedString+"\""); 45 | writer.newLine(); 46 | writer.flush(); 47 | return true; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/activity/InvalidKeyIntentPutExtra.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.activity; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.helper.StringGenerator; 13 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 16 | import edu.uniandes.tsdl.antlr.smaliParser; 17 | 18 | public class InvalidKeyIntentPutExtra implements MutationOperator{ 19 | 20 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 21 | 22 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 23 | CommonTree parent = (CommonTree) mLocation.getTree().getParent(); 24 | @SuppressWarnings("unchecked") 25 | List hijos = (List)parent.getChildren(); 26 | String extraKeyVar = hijos.get(1).getChild(1).toString(); 27 | CommonTree method = (CommonTree) parent.getParent(); 28 | int putExtraPos = parent.getChildIndex(); 29 | int extraKeyValPos = -1; 30 | boolean finished = false; 31 | for (int i = putExtraPos; i >-1 && !finished; i--) { 32 | CommonTree temp = (CommonTree) method.getChild(i); 33 | if(temp.getType()==smaliParser.I_STATEMENT_FORMAT22x && temp.getChild(1).toString().equals(extraKeyVar)) { 34 | extraKeyVar=temp.getChild(2).toString(); 35 | } 36 | if(temp.getType()==smaliParser.I_STATEMENT_FORMAT21c_STRING && temp.getChild(1).toString().equals(extraKeyVar)) { 37 | extraKeyValPos = temp.getLine(); 38 | finished = true; 39 | } 40 | } 41 | 42 | if (extraKeyValPos==-1) { 43 | extraKeyValPos=mLocation.getLine()-1; 44 | } 45 | 46 | 47 | String newKey = StringGenerator.generateRandomString(); 48 | 49 | List newLines = new ArrayList(); 50 | List lines = FileHelper.readLines(location.getFilePath()); 51 | 52 | //Add lines before the MutationLocation 53 | for(int i=0; i < extraKeyValPos-1; i++){ 54 | newLines.add(lines.get(i)); 55 | } 56 | 57 | //Apply mutation 58 | 59 | newLines.add(" const-string "+extraKeyVar+", \""+newKey+"\""); 60 | newLines.add(""); 61 | 62 | for(int i=extraKeyValPos; i < lines.size() ; i++){ 63 | newLines.add(lines.get(i)); 64 | } 65 | 66 | // // 67 | // int[] mutatedlines = new int[]{intentInstanceLine, contextInstanceLine, classComponentLine, mLocation.getLine()}; 68 | // String mutatedLines = "{ "; 69 | // for (int i = 0; i < mutatedlines.length; i++) { 70 | // mutatedLines += mutatedlines[i]+", "; 71 | // } 72 | // mutatedLines = mutatedLines.substring(0,mutatedLines.length()-2)+" }"; 73 | FileHelper.writeLines(location.getFilePath(), newLines); 74 | Helper.mutationSuccess(mutantIndex); 75 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {extraKeyValPos}, writer); 76 | writer.write(" For mutant "+mutantIndex+" extra key value at line "+extraKeyValPos+" has been set to "+newKey); 77 | writer.newLine(); 78 | writer.flush(); 79 | return true; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/activity/InvalidLabel.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.activity; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 9 | import edu.uniandes.tsdl.mutapk.helper.Helper; 10 | import edu.uniandes.tsdl.mutapk.helper.StringGenerator; 11 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 12 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 13 | 14 | public class InvalidLabel implements MutationOperator{ 15 | 16 | @Override 17 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 18 | 19 | List newLines = new ArrayList(); 20 | List lines = FileHelper.readLines(location.getFilePath()); 21 | String toMutate = ""; 22 | String mutatedString = ""; 23 | 24 | 25 | for(int i=0; i < lines.size(); i++){ 26 | 27 | String currLine = lines.get(i); 28 | 29 | if(i == location.getLine()){ 30 | //Apply mutation 31 | String sub1 = currLine.substring(0, location.getStartColumn()); 32 | toMutate = currLine.substring(location.getStartColumn(), location.getEndColumn()); 33 | String sub2 = currLine.substring(location.getEndColumn()); 34 | 35 | //String mutatedString = StringMutator.performMutation(toMutate); 36 | mutatedString = StringGenerator.generateRandomString(); 37 | currLine = sub1 + mutatedString + sub2; 38 | } 39 | 40 | newLines.add(currLine); 41 | } 42 | 43 | FileHelper.writeLines(location.getFilePath(), newLines); 44 | Helper.mutationSuccess(mutantIndex); 45 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {location.getStartLine()}, writer); 46 | writer.write(" For mutant "+mutantIndex+" activity label at line "+location.getLine()+" has been change from \""+toMutate+"\" to \""+mutatedString+"\""); 47 | writer.newLine(); 48 | writer.flush(); 49 | return true; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/activity/NullIntent.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.activity; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 9 | import edu.uniandes.tsdl.mutapk.helper.Helper; 10 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 11 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 12 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 13 | 14 | public class NullIntent implements MutationOperator{ 15 | 16 | @Override 17 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 18 | 19 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 20 | String intentInstanceLineVar = mLocation.getTree().getChild(1).getChild(0).toString(); 21 | 22 | List newLines = new ArrayList(); 23 | List lines = FileHelper.readLines(location.getFilePath()); 24 | 25 | 26 | //Add lines before the MutationLocation 27 | for(int i=0; i < mLocation.getLine()-1; i++){ 28 | newLines.add(lines.get(i)); 29 | } 30 | 31 | 32 | //Apply mutation 33 | newLines.add(" const/4 "+intentInstanceLineVar+", 0x0"); 34 | 35 | 36 | //Add lines after the MutationLocation 37 | for(int i=mLocation.getLine(); i < lines.size() ; i++){ 38 | newLines.add(lines.get(i)); 39 | } 40 | 41 | int[] mutatedlines = new int[]{mLocation.getLine()}; 42 | String mutatedLines = ""+mLocation.getLine(); 43 | FileHelper.writeLines(location.getFilePath(), newLines); 44 | Helper.mutationSuccess(mutantIndex); 45 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), mutatedlines, writer); 46 | writer.write(" For mutant "+mutantIndex+" intent defined at lines "+mutatedLines+" has been defined as null"); 47 | writer.newLine(); 48 | writer.flush(); 49 | return true; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/activity/NullValueIntentPutExtra.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.activity; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 15 | 16 | public class NullValueIntentPutExtra implements MutationOperator{ 17 | 18 | @SuppressWarnings("unchecked") 19 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 20 | 21 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 22 | CommonTree parent = (CommonTree) mLocation.getTree().getParent(); 23 | List hijos = (List)parent.getChildren(); 24 | String extraNamePos = hijos.get(1).getChild(2).getText(); 25 | String extraTypeText = hijos.get(4).getChild(2).getText(); 26 | for (int i = 3; i < hijos.get(4).getChildCount(); i++) { 27 | extraTypeText += hijos.get(4).getChild(i).getText(); 28 | } 29 | int extraTypePos = hijos.get(4).getChild(2).getCharPositionInLine(); 30 | // 31 | List newLines = new ArrayList(); 32 | List lines = FileHelper.readLines(location.getFilePath()); 33 | // 34 | //Add lines before the MutationLocation 35 | for(int i=0; i < mLocation.getLine()-1; i++){ 36 | newLines.add(lines.get(i)); 37 | } 38 | // 39 | // 40 | //Apply mutation 41 | newLines.add(" new-array "+extraNamePos+", "+extraNamePos+", [Landroid/os/Parcelable;"); 42 | newLines.add(""); 43 | String invoke = lines.get(location.getLine()-1);//.replace(extraNamePos, "v9"); 44 | String newInvoke = invoke.substring(0, extraTypePos)+"[Landroid/os/Parcelable;"+invoke.substring(extraTypePos+extraTypeText.length()); 45 | newLines.add(newInvoke); 46 | for(int i=location.getLine(); i < lines.size() ; i++){ 47 | newLines.add(lines.get(i)); 48 | } 49 | 50 | FileHelper.writeLines(location.getFilePath(), newLines); 51 | Helper.mutationSuccess(mutantIndex); 52 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {location.getStartLine()}, writer); 53 | writer.write(" For mutant "+mutantIndex+" extra intent value at line "+location.getStartLine()+" has been set to 'new Parcelable[0]'"); 54 | writer.newLine(); 55 | writer.flush(); 56 | return true; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/activity/WrongMainActivity.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.activity; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import javax.xml.parsers.ParserConfigurationException; 9 | 10 | import org.xml.sax.SAXException; 11 | 12 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 13 | import edu.uniandes.tsdl.mutapk.helper.Helper; 14 | import edu.uniandes.tsdl.mutapk.helper.IntegerGenerator; 15 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 16 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 17 | 18 | public class WrongMainActivity implements MutationOperator{ 19 | 20 | @Override 21 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws ParserConfigurationException, SAXException, IOException { 22 | 23 | List newLines = new ArrayList(); 24 | List lines = FileHelper.readLines(location.getFilePath()); 25 | String mainActivity = Helper.getInstance().getMainActivity(); 26 | String otherActivity = Helper.getInstance().getMainActivity(); 27 | List activities = Helper.getInstance().getActivities(); 28 | int otherActivityIndex = 0; 29 | while(otherActivity.equals(mainActivity)){ 30 | otherActivity = activities.get(IntegerGenerator.generateRandomInt(0, activities.size())); 31 | } 32 | for(int i=0; i < lines.size(); i++){ 33 | String currLine = lines.get(i); 34 | if(currLine.contains(otherActivity)){ 35 | otherActivityIndex = i; 36 | currLine = currLine.replaceAll(otherActivity, mainActivity); 37 | } else if (currLine.contains(mainActivity)){ 38 | currLine = currLine.replaceAll(mainActivity, otherActivity); 39 | } 40 | newLines.add(currLine); 41 | } 42 | 43 | FileHelper.writeLines(location.getFilePath(), newLines); 44 | Helper.mutationSuccess(mutantIndex); 45 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {location.getStartLine()}, writer); 46 | writer.write(" For mutant "+mutantIndex+" activity \""+mainActivity+"\" at line "+location.getStartLine()+" has been replaced as main activity by \""+otherActivity+"\" at line "+(otherActivityIndex+1)); 47 | writer.newLine(); 48 | writer.flush(); 49 | 50 | return true; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/backend/LengthyBackEndService.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.backend; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 15 | import edu.uniandes.tsdl.antlr.smaliParser; 16 | 17 | public class LengthyBackEndService implements MutationOperator { 18 | 19 | @Override 20 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 21 | 22 | 23 | List newLines = new ArrayList(); 24 | List lines = FileHelper.readLines(location.getFilePath()); 25 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 26 | CommonTree method = (CommonTree) mLocation.getTree().getAncestor(smaliParser.I_METHOD); 27 | for(int i=0; i < method.getLine()-1; i++){ 28 | newLines.add(lines.get(i)); 29 | } 30 | 31 | newLines.add(".method private delay()V"); 32 | newLines.add(" .locals 2"); 33 | newLines.add(""); 34 | newLines.add(" .line 332"); 35 | newLines.add(" const-wide/16 v0, 0x2710"); 36 | newLines.add(""); 37 | newLines.add(" :try_start_0"); 38 | newLines.add(" invoke-static {v0, v1}, Ljava/lang/Thread;->sleep(J)V"); 39 | newLines.add(" :try_end_0"); 40 | newLines.add(" .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0"); 41 | newLines.add(""); 42 | newLines.add(" .line 335"); 43 | newLines.add(" goto :goto_0"); 44 | newLines.add(""); 45 | newLines.add(" .line 333"); 46 | newLines.add(" :catch_0"); 47 | newLines.add(" move-exception v0"); 48 | newLines.add(""); 49 | newLines.add(" .line 334"); 50 | newLines.add(" .local v0, \"e\":Ljava/lang/InterruptedException;"); 51 | newLines.add(" invoke-virtual {v0}, Ljava/lang/InterruptedException;->printStackTrace()V"); 52 | newLines.add(""); 53 | newLines.add(" .line 336"); 54 | newLines.add(" .end local v0 # \"e\":Ljava/lang/InterruptedException;"); 55 | newLines.add(" :goto_0"); 56 | newLines.add(" return-void"); 57 | newLines.add(".end method"); 58 | 59 | for (int i = method.getLine()-1; i < mLocation.getLine(); i++) { 60 | newLines.add(lines.get(i)); 61 | } 62 | newLines.add(" invoke-direct/range {p0 .. p0}, Lcom/fsck/k9/mail/store/webdav/WebDavFolder;->delay()V"); 63 | 64 | for(int i=location.getLine(); i < lines.size() ; i++){ 65 | newLines.add(lines.get(i)); 66 | } 67 | 68 | FileHelper.writeLines(location.getFilePath(), newLines); 69 | Helper.mutationSuccess(mutantIndex); 70 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {location.getLine()}, writer); 71 | writer.write(" For mutant "+mutantIndex+" a large delay has been injected after backend response at line "+location.getLine()); 72 | writer.newLine(); 73 | writer.flush(); 74 | return true; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/backend/LongConnectionTimeOut.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.backend; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 15 | 16 | public class LongConnectionTimeOut implements MutationOperator { 17 | 18 | @Override 19 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 20 | 21 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 22 | CommonTree tree = mLocation.getTree(); 23 | String varName = tree.getChild(1).getChild(1).toStringTree(); 24 | 25 | List newLines = new ArrayList(); 26 | List lines = FileHelper.readLines(location.getFilePath()); 27 | 28 | //Add lines before the MutationLocation 29 | for(int i=0; i < mLocation.getLine()-1; i++){ 30 | newLines.add(lines.get(i)); 31 | } 32 | // //Apply mutation 33 | newLines.add(" const "+varName+", 0x186a0"); 34 | newLines.add(""); 35 | for(int i=mLocation.getLine()-1; i < lines.size() ; i++){ 36 | newLines.add(lines.get(i)); 37 | } 38 | // 39 | FileHelper.writeLines(location.getFilePath(), newLines); 40 | Helper.mutationSuccess(mutantIndex); 41 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 42 | writer.write(" For mutant "+mutantIndex+" time assigned to setConnectionTimeout method at line "+mLocation.getLine()+" has been updated to 100000 milliseconds"); 43 | writer.newLine(); 44 | writer.flush(); 45 | 46 | return true; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/connectivity/BluetoothAdapterAlwaysEnabled.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.connectivity; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.ASTHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 12 | import edu.uniandes.tsdl.mutapk.helper.Helper; 13 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 16 | import edu.uniandes.tsdl.antlr.smaliParser; 17 | 18 | public class BluetoothAdapterAlwaysEnabled implements MutationOperator { 19 | 20 | @Override 21 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 22 | 23 | 24 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 25 | CommonTree tree = mLocation.getTree(); 26 | CommonTree treee = ASTHelper.getFirstBrotherNamedOfType(smaliParser.I_STATEMENT_FORMAT21t, "if-eqz", tree); 27 | 28 | List newLines = new ArrayList(); 29 | List lines = FileHelper.readLines(location.getFilePath()); 30 | 31 | //Add lines before the MutationLocation 32 | for(int i=0; i < mLocation.getLine()-1; i++){ 33 | newLines.add(lines.get(i)); 34 | } 35 | 36 | newLines.add(""); 37 | 38 | for(int i=treee.getLine(); i < lines.size() ; i++){ 39 | newLines.add(lines.get(i)); 40 | } 41 | // 42 | FileHelper.writeLines(location.getFilePath(), newLines); 43 | Helper.mutationSuccess(mutantIndex); 44 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine(),treee.getLine()}, writer); 45 | writer.write(" For mutant "+mutantIndex+" Bluetooth Adapter state validation has been set to true"); 46 | writer.newLine(); 47 | writer.flush(); 48 | 49 | return true; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/connectivity/NullBluetoothAdapter.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.connectivity; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.ASTHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 12 | import edu.uniandes.tsdl.mutapk.helper.Helper; 13 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 16 | import edu.uniandes.tsdl.antlr.smaliParser; 17 | 18 | public class NullBluetoothAdapter implements MutationOperator { 19 | 20 | @Override 21 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 22 | 23 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 24 | CommonTree tree = mLocation.getTree(); 25 | CommonTree treee = ASTHelper.getFirstBrotherNamedOfType(smaliParser.I_STATEMENT_FORMAT11x, "move-result-object", tree); 26 | String varName = treee.getChild(1).toString(); 27 | 28 | List newLines = new ArrayList(); 29 | List lines = FileHelper.readLines(location.getFilePath()); 30 | 31 | //Add lines before the MutationLocation 32 | for(int i=0; i < mLocation.getLine()-1; i++){ 33 | newLines.add(lines.get(i)); 34 | } 35 | 36 | newLines.add(" const/16 "+varName+", 0x0"); 37 | 38 | for(int i=treee.getLine(); i < lines.size() ; i++){ 39 | newLines.add(lines.get(i)); 40 | } 41 | // 42 | FileHelper.writeLines(location.getFilePath(), newLines); 43 | Helper.mutationSuccess(mutantIndex); 44 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine(),treee.getLine()}, writer); 45 | writer.write(" For mutant "+mutantIndex+" Bluetooth Adapter has been set to null"); 46 | writer.newLine(); 47 | writer.flush(); 48 | 49 | return true; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/data/android/InvalidURI.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.data.android; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.helper.StringGenerator; 13 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 16 | 17 | public class InvalidURI implements MutationOperator { 18 | 19 | @Override 20 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 21 | 22 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 23 | CommonTree tree = mLocation.getTree(); 24 | String varName = tree.getChild(1).getChild(1).toStringTree(); 25 | 26 | List newLines = new ArrayList(); 27 | List lines = FileHelper.readLines(location.getFilePath()); 28 | 29 | //Add lines before the MutationLocation 30 | for(int i=0; i < mLocation.getLine()-1; i++){ 31 | newLines.add(lines.get(i)); 32 | } 33 | //String newVarName = varName.substring(0, 1)+(Integer.parseInt(varName.substring(1))+2); 34 | String newVarValue = StringGenerator.generateRandomString(); 35 | // //Apply mutation 36 | newLines.add(""); 37 | newLines.add(" const-string "+varName+", \""+newVarValue+"\""); 38 | newLines.add(""); 39 | newLines.add(lines.get(mLocation.getLine()-1)); 40 | newLines.add(""); 41 | 42 | for(int i=mLocation.getLine(); i < lines.size() ; i++){ 43 | newLines.add(lines.get(i)); 44 | } 45 | // 46 | FileHelper.writeLines(location.getFilePath(), newLines); 47 | Helper.mutationSuccess(mutantIndex); 48 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 49 | writer.write(" For mutant "+mutantIndex+" URI location has been set to "+newVarValue+" at line "+mLocation.getLine()); 50 | writer.newLine(); 51 | writer.flush(); 52 | 53 | return true; 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/data/android/NullGPSLocation.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.data.android; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 15 | 16 | public class NullGPSLocation implements MutationOperator { 17 | 18 | @Override 19 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 20 | 21 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 22 | CommonTree tree = mLocation.getTree(); 23 | String varName = tree.getChild(0).toString(); 24 | 25 | List newLines = new ArrayList(); 26 | List lines = FileHelper.readLines(location.getFilePath()); 27 | 28 | for(int i=0; i < tree.getParent().getChild(tree.getChildIndex()-1).getLine(); i++){ 29 | newLines.add(lines.get(i)); 30 | } 31 | 32 | // //Apply mutation 33 | newLines.add(" const/4 "+varName+", 0x0"); 34 | newLines.add(""); 35 | 36 | for(int i=tree.getLine()-1; i < lines.size() ; i++){ 37 | newLines.add(lines.get(i)); 38 | } 39 | 40 | FileHelper.writeLines(location.getFilePath(), newLines); 41 | Helper.mutationSuccess(mutantIndex); 42 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 43 | writer.write(" For mutant "+mutantIndex+" GPS Location object has been set to null"); 44 | writer.newLine(); 45 | writer.flush(); 46 | return true; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/data/general/InvalidDate.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.data.general; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.helper.HexadecimalGenerator; 13 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 16 | 17 | public class InvalidDate implements MutationOperator { 18 | 19 | @Override 20 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 21 | 22 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 23 | CommonTree tree = mLocation.getTree(); 24 | String varName = tree.getChild(1).getChild(1).toStringTree(); 25 | 26 | List newLines = new ArrayList(); 27 | List lines = FileHelper.readLines(location.getFilePath()); 28 | 29 | //Add lines before the MutationLocation 30 | for(int i=0; i < mLocation.getLine()-1; i++){ 31 | newLines.add(lines.get(i)); 32 | } 33 | String newVarValue = "0x"+HexadecimalGenerator.generateRandomHexaLong(); 34 | // //Apply mutation 35 | newLines.add(" const-wide "+varName+", "+newVarValue); 36 | newLines.add(""); 37 | newLines.add(lines.get(mLocation.getLine()-1)); 38 | newLines.add(""); 39 | 40 | for(int i=mLocation.getLine(); i < lines.size() ; i++){ 41 | newLines.add(lines.get(i)); 42 | } 43 | // 44 | FileHelper.writeLines(location.getFilePath(), newLines); 45 | Helper.mutationSuccess(mutantIndex); 46 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 47 | writer.write(" For mutant "+mutantIndex+" Date at line "+mLocation.getLine()+" has been updated to "+newVarValue); 48 | writer.newLine(); 49 | writer.flush(); 50 | 51 | return true; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/data/general/NullBackEndServiceReturn.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.data.general; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.ASTHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 12 | import edu.uniandes.tsdl.mutapk.helper.Helper; 13 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 16 | import edu.uniandes.tsdl.antlr.smaliParser; 17 | 18 | public class NullBackEndServiceReturn implements MutationOperator { 19 | 20 | @Override 21 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 22 | 23 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 24 | CommonTree tree = mLocation.getTree(); 25 | List newLines = new ArrayList(); 26 | List lines = FileHelper.readLines(location.getFilePath()); 27 | 28 | if(tree.getType()==smaliParser.I_STATEMENT_FORMAT35c_METHOD) { 29 | performMutationParam(tree, location, newLines, lines); 30 | } else { 31 | performMutationVariable(tree, location, newLines, lines); 32 | } 33 | 34 | Helper.mutationSuccess(mutantIndex); 35 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 36 | writer.write(" For mutant "+mutantIndex+" HttpResponse object has been set to null"); 37 | writer.newLine(); 38 | writer.flush(); 39 | return true; 40 | } 41 | 42 | private void performMutationVariable(CommonTree tree, MutationLocation location, List newLines, List lines) throws IOException { 43 | 44 | String varName = tree.getChild(0).toString(); 45 | 46 | for(int i=0; i < tree.getParent().getChild(tree.getChildIndex()-1).getLine(); i++){ 47 | newLines.add(lines.get(i)); 48 | } 49 | 50 | // //Apply mutation 51 | newLines.add(" const/4 "+varName+", 0x0"); 52 | newLines.add(""); 53 | 54 | for(int i=tree.getLine()-1; i < lines.size() ; i++){ 55 | newLines.add(lines.get(i)); 56 | } 57 | FileHelper.writeLines(location.getFilePath(), newLines); 58 | } 59 | 60 | private void performMutationParam(CommonTree tree, MutationLocation location, List newLines, List lines) throws IOException { 61 | 62 | CommonTree brother = ASTHelper.getFirstBrotherNamedOfType(smaliParser.I_STATEMENT_FORMAT11x, "move-result-object", tree); 63 | String varName = brother.getChild(1).toString(); 64 | 65 | 66 | for(int i=0; i < brother.getLine(); i++){ 67 | newLines.add(lines.get(i)); 68 | } 69 | 70 | // //Apply mutation 71 | newLines.add(""); 72 | newLines.add(" const/4 "+varName+", 0x0"); 73 | 74 | for(int i=brother.getLine(); i < lines.size() ; i++){ 75 | newLines.add(lines.get(i)); 76 | } 77 | FileHelper.writeLines(location.getFilePath(), newLines); 78 | 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/data/general/NullMethodCallArgument.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.data.general; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 15 | 16 | public class NullMethodCallArgument implements MutationOperator { 17 | 18 | @Override 19 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 20 | 21 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 22 | CommonTree tree = mLocation.getTree(); 23 | String varName = tree.getChild(1).getChild(mLocation.getStartColumn()).toString(); 24 | String methodd = tree.getChild(3).toStringTree(); 25 | 26 | List newLines = new ArrayList(); 27 | List lines = FileHelper.readLines(location.getFilePath()); 28 | 29 | //Add lines before the MutationLocation 30 | for(int i=0; i < mLocation.getLine()-1; i++){ 31 | newLines.add(lines.get(i)); 32 | } 33 | // //Apply mutation 34 | newLines.add(" const/4 "+varName+", 0x0"); 35 | newLines.add(""); 36 | 37 | for(int i=mLocation.getLine()-1; i < lines.size() ; i++){ 38 | newLines.add(lines.get(i)); 39 | } 40 | // 41 | FileHelper.writeLines(location.getFilePath(), newLines); 42 | Helper.mutationSuccess(mutantIndex); 43 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 44 | writer.write(" For mutant "+mutantIndex+", "+(mLocation.getStartColumn()+1)+" parameter of method "+methodd+" have been replaced with null"); 45 | writer.newLine(); 46 | writer.flush(); 47 | 48 | return true; 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/db/android/ClosingNullCursor.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.db.android; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 15 | 16 | public class ClosingNullCursor implements MutationOperator { 17 | 18 | @Override 19 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 20 | 21 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 22 | CommonTree tree = mLocation.getTree(); 23 | String varName = tree.getChild(1).getChild(0).toString(); 24 | 25 | List newLines = new ArrayList(); 26 | List lines = FileHelper.readLines(location.getFilePath()); 27 | 28 | //Add lines before the MutationLocation 29 | for(int i=0; i < mLocation.getLine()-1; i++){ 30 | newLines.add(lines.get(i)); 31 | } 32 | // //Apply mutation 33 | newLines.add(" const/4 "+varName+", 0x0"); 34 | newLines.add(""); 35 | 36 | for(int i=mLocation.getLine()-1; i < lines.size() ; i++){ 37 | newLines.add(lines.get(i)); 38 | } 39 | 40 | FileHelper.writeLines(location.getFilePath(), newLines); 41 | Helper.mutationSuccess(mutantIndex); 42 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 43 | writer.write(" For mutant "+mutantIndex+" Database cursor at line "+mLocation.getLine()+" has been set to null before close() call"); 44 | writer.newLine(); 45 | writer.flush(); 46 | return true; 47 | 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/db/general/InvalidIndexQueryParameter.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.db.general; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 15 | 16 | public class InvalidIndexQueryParameter implements MutationOperator { 17 | 18 | @Override 19 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 20 | 21 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 22 | CommonTree tree = mLocation.getTree(); 23 | String varName = tree.getChild(1).getChild(2).toString(); 24 | 25 | List newLines = new ArrayList(); 26 | List lines = FileHelper.readLines(location.getFilePath()); 27 | 28 | //Add lines before the MutationLocation 29 | for(int i=0; i < mLocation.getLine()-1; i++){ 30 | newLines.add(lines.get(i)); 31 | } 32 | // //Apply mutation 33 | newLines.add(" const/4 v1, 0x0"); 34 | newLines.add(""); 35 | newLines.add(" new-array "+varName+", v1, [Ljava/lang/String;"); 36 | newLines.add(""); 37 | 38 | for(int i=mLocation.getLine()-1; i < lines.size() ; i++){ 39 | newLines.add(lines.get(i)); 40 | } 41 | 42 | FileHelper.writeLines(location.getFilePath(), newLines); 43 | Helper.mutationSuccess(mutantIndex); 44 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 45 | writer.write(" For mutant "+mutantIndex+" params list send with SQL command have been replace with an empty String list"); 46 | writer.newLine(); 47 | writer.flush(); 48 | 49 | return true; 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/db/general/InvalidSQLQuery.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.db.general; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.helper.StringGenerator; 13 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 16 | 17 | public class InvalidSQLQuery implements MutationOperator { 18 | 19 | @Override 20 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 21 | 22 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 23 | CommonTree tree = mLocation.getTree(); 24 | String varName = tree.getChild(1).getChild(1).toString(); 25 | 26 | List newLines = new ArrayList(); 27 | List lines = FileHelper.readLines(location.getFilePath()); 28 | 29 | //Add lines before the MutationLocation 30 | for(int i=0; i < mLocation.getLine()-1; i++){ 31 | newLines.add(lines.get(i)); 32 | } 33 | // //Apply mutation 34 | String newCommand = StringGenerator.generateRandomString(); 35 | newLines.add(" const-string "+varName+", \""+newCommand+"\""); 36 | newLines.add(""); 37 | 38 | for(int i=mLocation.getLine()-1; i < lines.size() ; i++){ 39 | newLines.add(lines.get(i)); 40 | } 41 | 42 | FileHelper.writeLines(location.getFilePath(), newLines); 43 | Helper.mutationSuccess(mutantIndex); 44 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 45 | writer.write(" For mutant "+mutantIndex+" SQL command have been replace with "+newCommand); 46 | writer.newLine(); 47 | writer.flush(); 48 | 49 | return true; 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/gui/android/FindViewByIdReturnsNull.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.gui.android; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.ASTHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 12 | import edu.uniandes.tsdl.mutapk.helper.Helper; 13 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 16 | import edu.uniandes.tsdl.antlr.smaliParser; 17 | 18 | public class FindViewByIdReturnsNull implements MutationOperator { 19 | 20 | @Override 21 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 22 | 23 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 24 | CommonTree parent = (CommonTree) mLocation.getTree().getParent(); 25 | CommonTree cast = ASTHelper.getFirstBrotherNamedOfType(smaliParser.I_STATEMENT_FORMAT21c_TYPE, "check-cast", parent); 26 | String varName = ""; 27 | int position = -1; 28 | if(cast!=null && (cast.getLine()-parent.getLine()<5)) { 29 | varName = cast.getChild(1).toString(); 30 | position = cast.getLine(); 31 | } else { 32 | CommonTree moveResultObject = ASTHelper.getFirstBrotherNamedOfType(smaliParser.I_STATEMENT_FORMAT11x, "move-result-object", parent); 33 | varName = moveResultObject.getChild(1).toString(); 34 | position = moveResultObject.getLine(); 35 | } 36 | 37 | 38 | List newLines = new ArrayList(); 39 | List lines = FileHelper.readLines(location.getFilePath()); 40 | 41 | //Add lines before the MutationLocation 42 | for(int i=0; i < parent.getLine()-1; i++){ 43 | newLines.add(lines.get(i)); 44 | } 45 | 46 | //Apply mutation 47 | newLines.add(""); 48 | newLines.add(" const/4 "+varName+", 0x0"); 49 | newLines.add(""); 50 | 51 | for(int i=position; i < lines.size() ; i++){ 52 | newLines.add(lines.get(i)); 53 | } 54 | 55 | FileHelper.writeLines(location.getFilePath(), newLines); 56 | Helper.mutationSuccess(mutantIndex); 57 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine(), position}, writer); 58 | writer.write(" For mutant "+mutantIndex+" the element retrieved at line "+location.getStartLine()+" has been set to null"); 59 | writer.newLine(); 60 | writer.flush(); 61 | return true; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/gui/android/InvalidColor.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.gui.android; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 9 | import edu.uniandes.tsdl.mutapk.helper.Helper; 10 | import edu.uniandes.tsdl.mutapk.helper.HexadecimalGenerator; 11 | import edu.uniandes.tsdl.mutapk.model.location.InvalidColorMutationLocation; 12 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 13 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 14 | 15 | public class InvalidColor implements MutationOperator{ 16 | 17 | @Override 18 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 19 | 20 | InvalidColorMutationLocation mLocation = (InvalidColorMutationLocation) location; 21 | List newLines = new ArrayList(); 22 | List lines = FileHelper.readLines(mLocation.getFilePath()); 23 | String newColor = ""; 24 | 25 | for(int i=0; i < lines.size(); i++){ 26 | 27 | String currLine = lines.get(i); 28 | 29 | if(i == mLocation.getLine()){ 30 | //Apply mutation 31 | String sub1 = currLine.substring(0, mLocation.getStartColumn()); 32 | String sub2 = currLine.substring(mLocation.getEndColumn()); 33 | 34 | newColor = HexadecimalGenerator.generateRandomHexa(); 35 | currLine = sub1 + newColor + sub2; 36 | } 37 | 38 | newLines.add(currLine); 39 | } 40 | 41 | FileHelper.writeLines(mLocation.getFilePath(), newLines); 42 | Helper.mutationSuccess(mutantIndex); 43 | Helper.writeBasicLogInfo(mutantIndex, mLocation.getFilePath(), mLocation.getType().getName(), new int[] {mLocation.getStartLine()}, writer); 44 | 45 | writer.write(" For mutant "+mutantIndex+" the value of the color named \""+mLocation.getColorName()+"\" at line "+(location.getStartLine()+1)+" has been changed from \""+mLocation.getOriginalColor()+"\" to \"#"+newColor+"\""); 46 | writer.newLine(); 47 | writer.flush(); 48 | 49 | return true; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/gui/android/InvalidIDFindView.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.gui.android; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.ASTHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 12 | import edu.uniandes.tsdl.mutapk.helper.Helper; 13 | import edu.uniandes.tsdl.mutapk.helper.HexadecimalGenerator; 14 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 15 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 16 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 17 | import edu.uniandes.tsdl.antlr.smaliParser; 18 | 19 | public class InvalidIDFindView implements MutationOperator { 20 | 21 | @Override 22 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 23 | 24 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 25 | CommonTree parent = (CommonTree) mLocation.getTree().getParent(); 26 | boolean isParam = false; 27 | String constVarName = ""; 28 | int linee = -1; 29 | CommonTree uncle = ASTHelper.getFirstBackUncleNamedOfType(smaliParser.I_STATEMENT_FORMAT31i, "const", mLocation.getTree()); 30 | if (uncle == null) { 31 | uncle = ASTHelper.getFirstBackUncleNamedOfType(smaliParser.I_STATEMENT_FORMAT21ih, "const/high16", mLocation.getTree()); 32 | if (uncle == null && parent.getChild(1).getChild(1).getText().startsWith("p")) { 33 | isParam=true; 34 | constVarName = parent.getChild(1).getChild(1).getText(); 35 | linee = parent.getLine(); 36 | } 37 | } 38 | 39 | if (uncle != null && !isParam) { 40 | constVarName = uncle.getChild(1).getText(); 41 | linee = uncle.getLine(); 42 | } else if (uncle == null) { 43 | constVarName = parent.getChild(1).getChild(1).getText(); 44 | linee = parent.getLine(); 45 | } 46 | 47 | 48 | List newLines = new ArrayList(); 49 | List lines = FileHelper.readLines(location.getFilePath()); 50 | 51 | //Add lines before the MutationLocation 52 | for(int i=0; i < linee-1; i++){ 53 | newLines.add(lines.get(i)); 54 | } 55 | 56 | //Apply mutation 57 | newLines.add(""); 58 | newLines.add(" const "+constVarName+", 0x"+HexadecimalGenerator.generateRandomHexa()); 59 | newLines.add(""); 60 | if(isParam) { 61 | newLines.add(lines.get(linee-1)); 62 | } 63 | 64 | for(int i=linee; i < lines.size() ; i++){ 65 | newLines.add(lines.get(i)); 66 | } 67 | 68 | FileHelper.writeLines(location.getFilePath(), newLines); 69 | Helper.mutationSuccess(mutantIndex); 70 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {linee}, writer); 71 | writer.write(" For mutant "+mutantIndex+" the id of the element retrieved at line "+location.getStartLine()+" has been set to a random value"); 72 | writer.newLine(); 73 | writer.flush(); 74 | return true; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/gui/android/InvalidViewFocus.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.gui.android; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.ASTHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 12 | import edu.uniandes.tsdl.mutapk.helper.Helper; 13 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 16 | import edu.uniandes.tsdl.antlr.smaliParser; 17 | 18 | public class InvalidViewFocus implements MutationOperator { 19 | 20 | @Override 21 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 22 | 23 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 24 | CommonTree parent = (CommonTree) mLocation.getTree().getParent(); 25 | CommonTree iput = ASTHelper.getFirstBrotherNamedOfType(smaliParser.I_STATEMENT_FORMAT22c_FIELD, "iput-object", parent); 26 | String objectClass = iput.getChild(5).getText(); 27 | String varName = iput.getChild(1).getText(); 28 | 29 | List newLines = new ArrayList(); 30 | List lines = FileHelper.readLines(location.getFilePath()); 31 | 32 | //Add lines before the MutationLocation 33 | for(int i=0; i < iput.getLine(); i++){ 34 | newLines.add(lines.get(i)); 35 | } 36 | 37 | // //Apply mutation 38 | newLines.add(""); 39 | newLines.add(lines.get(iput.getLine()-1).replaceAll("iput-object", "iget-object")); 40 | newLines.add(""); 41 | newLines.add(" invoke-virtual {"+varName+"}, "+objectClass+"->requestFocus()Z"); 42 | newLines.add(""); 43 | 44 | for(int i=iput.getLine(); i < lines.size() ; i++){ 45 | newLines.add(lines.get(i)); 46 | } 47 | 48 | FileHelper.writeLines(location.getFilePath(), newLines); 49 | Helper.mutationSuccess(mutantIndex); 50 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {iput.getLine()}, writer); 51 | writer.write(" For mutant "+mutantIndex+" focus has been requested for the element found at line "+mLocation.getLine()); 52 | writer.newLine(); 53 | writer.flush(); 54 | return true; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/gui/android/ViewComponentNotVisible.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.gui.android; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.ASTHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 12 | import edu.uniandes.tsdl.mutapk.helper.Helper; 13 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 14 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 15 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 16 | 17 | public class ViewComponentNotVisible implements MutationOperator { 18 | 19 | @Override 20 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 21 | 22 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 23 | CommonTree parent = (CommonTree) mLocation.getTree().getParent(); 24 | @SuppressWarnings("unchecked") 25 | List hijos = (List)parent.getChildren(); 26 | String constVarName = hijos.get(1).getChild(1).getText(); 27 | CommonTree selTree = ASTHelper.hasIPutAndIGet(mLocation.getTree()); 28 | int selLine = selTree.getLine(); 29 | String className = selTree.getChild(3).toString(); 30 | 31 | List newLines = new ArrayList(); 32 | List lines = FileHelper.readLines(location.getFilePath()); 33 | 34 | //Add lines before the MutationLocation 35 | for(int i=0; i < selLine; i++){ 36 | newLines.add(lines.get(i)); 37 | } 38 | 39 | //Apply mutation 40 | newLines.add(""); 41 | newLines.add(" const/4 v9, 0x4"); 42 | newLines.add(""); 43 | newLines.add(" invoke-virtual {"+constVarName+", v9}, "+className+"->setVisibility(I)V"); 44 | newLines.add(""); 45 | 46 | for(int i=selLine; i < lines.size() ; i++){ 47 | newLines.add(lines.get(i)); 48 | } 49 | 50 | FileHelper.writeLines(location.getFilePath(), newLines); 51 | Helper.mutationSuccess(mutantIndex); 52 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {selLine}, writer); 53 | writer.write(" For mutant "+mutantIndex+" the visibility of element retrieved at line "+location.getStartLine()+" has been set to INVISIBLE at lines: "+(selLine+2)+" and "+(selLine+4)); 54 | writer.newLine(); 55 | writer.flush(); 56 | return true; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/image/OOMLargeImage.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.image; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 15 | 16 | public class OOMLargeImage implements MutationOperator { 17 | 18 | @Override 19 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 20 | 21 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 22 | CommonTree tree = mLocation.getTree(); 23 | String varWidth = tree.getChild(1).getChild(1).toString(); 24 | String varHeight = tree.getChild(1).getChild(2).toString(); 25 | 26 | List newLines = new ArrayList(); 27 | List lines = FileHelper.readLines(location.getFilePath()); 28 | 29 | //Add lines before the MutationLocation 30 | for(int i=0; i < mLocation.getLine()-1; i++){ 31 | newLines.add(lines.get(i)); 32 | } 33 | // //Apply mutation 34 | newLines.add(" const "+varHeight+", 0x186a0"); 35 | newLines.add(""); 36 | newLines.add(lines.get(mLocation.getLine()-1).replaceAll(varWidth, varHeight)); 37 | 38 | for(int i=mLocation.getLine(); i < lines.size() ; i++){ 39 | newLines.add(lines.get(i)); 40 | } 41 | 42 | FileHelper.writeLines(location.getFilePath(), newLines); 43 | Helper.mutationSuccess(mutantIndex); 44 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 45 | writer.write(" For mutant "+mutantIndex+" Bitmap created at line "+mLocation.getLine()+" has been scaled to 100000x100000 pixels"); 46 | writer.newLine(); 47 | writer.flush(); 48 | 49 | return true; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/io/InvalidFilePath.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.io; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 9 | import edu.uniandes.tsdl.mutapk.helper.Helper; 10 | import edu.uniandes.tsdl.mutapk.helper.StringGenerator; 11 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 12 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 13 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 14 | 15 | public class InvalidFilePath implements MutationOperator{ 16 | 17 | @Override 18 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 19 | 20 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 21 | String paramName = mLocation.getTree().getChild(1).getChild(1).toStringTree(); 22 | String mutationPath = StringGenerator.generateRandomString(); 23 | 24 | List newLines = new ArrayList(); 25 | List lines = FileHelper.readLines(location.getFilePath()); 26 | 27 | //Add lines before the MutationLocation 28 | for(int i=0; i < mLocation.getLine()-1; i++){ 29 | newLines.add(lines.get(i)); 30 | } 31 | 32 | //Apply mutation 33 | newLines.add(""); 34 | newLines.add(" const-string v9, \""+mutationPath+"\""); 35 | newLines.add(""); 36 | newLines.add(lines.get(mLocation.getLine()-1).replace(paramName+"}", "v9}")); 37 | newLines.add(""); 38 | 39 | for(int i=mLocation.getLine(); i < lines.size() ; i++){ 40 | newLines.add(lines.get(i)); 41 | } 42 | 43 | FileHelper.writeLines(location.getFilePath(), newLines); 44 | Helper.mutationSuccess(mutantIndex); 45 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 46 | writer.write(" For mutant "+mutantIndex+" the path of File at line "+mLocation.getLine()+" has been replaced by "+mutationPath); 47 | writer.newLine(); 48 | writer.flush(); 49 | return true; 50 | 51 | 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/io/NullStream.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.io; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 15 | 16 | public class NullStream implements MutationOperator { 17 | 18 | @Override 19 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 20 | 21 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 22 | CommonTree tree = mLocation.getTree(); 23 | String varName = tree.getChild(1).getChild(0).toString(); 24 | 25 | List newLines = new ArrayList(); 26 | List lines = FileHelper.readLines(location.getFilePath()); 27 | 28 | //Add lines before the MutationLocation 29 | for(int i=0; i < mLocation.getLine()-1; i++){ 30 | newLines.add(lines.get(i)); 31 | } 32 | // //Apply mutation 33 | newLines.add(" const/4 "+varName+", 0x0"); 34 | newLines.add(""); 35 | 36 | for(int i=mLocation.getLine()-1; i < lines.size() ; i++){ 37 | newLines.add(lines.get(i)); 38 | } 39 | 40 | FileHelper.writeLines(location.getFilePath(), newLines); 41 | Helper.mutationSuccess(mutantIndex); 42 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine()}, writer); 43 | writer.write(" For mutant "+mutantIndex+" "+((mLocation.getType().getId()==33)?"Input":"Output")+" Stream at line "+mLocation.getLine()+" has been set to null before calling close() method"); 44 | writer.newLine(); 45 | writer.flush(); 46 | return true; 47 | 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/programming/android/MissingPermissionManifest.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.programming.android; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 9 | import edu.uniandes.tsdl.mutapk.helper.Helper; 10 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 11 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 12 | 13 | public class MissingPermissionManifest implements MutationOperator{ 14 | 15 | @Override 16 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 17 | 18 | List newLines = new ArrayList(); 19 | List lines = FileHelper.readLines(location.getFilePath()); 20 | 21 | for(int i=0; i < lines.size(); i++){ 22 | 23 | String currLine = lines.get(i); 24 | 25 | //Discard lines to remove in the new source code file 26 | if(i < location.getStartLine() || i > location.getEndLine()){ 27 | newLines.add(currLine); 28 | } 29 | 30 | } 31 | 32 | FileHelper.writeLines(location.getFilePath(), newLines); 33 | Helper.mutationSuccess(mutantIndex); 34 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {location.getStartLine()}, writer); 35 | writer.write(" For mutant "+mutantIndex+" the lines between "+(location.getStartLine()+1)+" and "+ (location.getEndLine()+1)+" have been deleted."); 36 | writer.newLine(); 37 | writer.flush(); 38 | 39 | return true; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/programming/android/SDKVersion.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.programming.android; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 9 | import edu.uniandes.tsdl.mutapk.helper.Helper; 10 | import edu.uniandes.tsdl.mutapk.helper.IntegerGenerator; 11 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 12 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 13 | 14 | public class SDKVersion implements MutationOperator { 15 | 16 | @Override 17 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 18 | 19 | List newLines = new ArrayList(); 20 | List lines = FileHelper.readLines(location.getFilePath()); 21 | boolean isMinSDK = false; 22 | boolean isMaxSDK = false; 23 | String toMutate = ""; 24 | int newVersion = 0; 25 | 26 | for (int i = 0; i < lines.size(); i++) { 27 | 28 | String currLine = lines.get(i); 29 | 30 | if (i == location.getLine()) { 31 | // Apply mutation 32 | 33 | if (currLine.contains(Helper.MIN_SDK_VERSION) 34 | && (location.getStartColumn() - currLine.indexOf(Helper.MIN_SDK_VERSION) > 0) 35 | && (location.getStartColumn() - currLine.indexOf(Helper.MIN_SDK_VERSION) < 24)) { 36 | isMinSDK = true; 37 | } else if (currLine.contains(Helper.MAX_SDK_VERSION) 38 | && (location.getStartColumn() - currLine.indexOf(Helper.MAX_SDK_VERSION) > 0) 39 | && (location.getStartColumn() - currLine.indexOf(Helper.MAX_SDK_VERSION) < 24)) { 40 | isMaxSDK = true; 41 | } 42 | String sub1 = currLine.substring(0, location.getStartColumn()); 43 | toMutate = currLine.substring(location.getStartColumn(), location.getEndColumn()); 44 | String sub2 = currLine.substring(location.getEndColumn()); 45 | 46 | int currVersion = Integer.parseInt(toMutate); 47 | newVersion = IntegerGenerator.generateRandomInt(Helper.MIN_VERSION, Helper.MAX_VERSION); 48 | 49 | while (newVersion == currVersion) { 50 | newVersion = IntegerGenerator.generateRandomInt(Helper.MIN_VERSION, Helper.MAX_VERSION); 51 | } 52 | 53 | currLine = sub1 + newVersion + sub2; 54 | } 55 | 56 | newLines.add(currLine); 57 | } 58 | 59 | FileHelper.writeLines(location.getFilePath(), newLines); 60 | Helper.mutationSuccess(mutantIndex); 61 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {location.getStartLine()}, writer); 62 | writer.write(" For mutant "+mutantIndex+" the "+((isMinSDK)?"minSDKVersion":(isMaxSDK)?"maxSDKVersion":"targetSDKVersion")+" has been update from "+toMutate+" to "+newVersion); 63 | writer.newLine(); 64 | writer.flush(); 65 | 66 | return true; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/programming/android/WrongStringResource.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.programming.android; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 9 | import edu.uniandes.tsdl.mutapk.helper.Helper; 10 | import edu.uniandes.tsdl.mutapk.helper.StringGenerator; 11 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 12 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 13 | 14 | public class WrongStringResource implements MutationOperator{ 15 | 16 | @Override 17 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 18 | 19 | List newLines = new ArrayList(); 20 | List lines = FileHelper.readLines(location.getFilePath()); 21 | 22 | //Add lines before the MutationLocation 23 | for(int i=0; i < location.getStartLine(); i++){ 24 | newLines.add(lines.get(i)); 25 | } 26 | 27 | //Apply mutation 28 | String linesToConsider = ""; 29 | boolean newLineFlag = false; 30 | for(int i = location.getStartLine(); i <= location.getEndLine(); i++){ 31 | if(newLineFlag){ 32 | linesToConsider += " "+lines.get(i); 33 | } else { 34 | linesToConsider += lines.get(i); 35 | newLineFlag = true; 36 | } 37 | } 38 | 39 | int startS = linesToConsider.indexOf("", startS)+1; 46 | 47 | int end = linesToConsider.indexOf(""); 48 | 49 | String sub1 = linesToConsider.substring(0, start); 50 | String toMutate = linesToConsider.substring(start,end); 51 | String sub2 = linesToConsider.substring(end); 52 | int strNameStart = linesToConsider.indexOf("name=\"")+6; 53 | int strNameEnd = linesToConsider.indexOf("\"",strNameStart); 54 | String stringName = linesToConsider.substring(strNameStart,strNameEnd); 55 | 56 | String randomString = StringGenerator.generateRandomString(); 57 | 58 | String mutatedLine = sub1 + randomString + sub2; 59 | newLines.add(mutatedLine); 60 | 61 | 62 | //Add lines after the MutationLocation 63 | for(int i=location.getEndLine()+1; i < lines.size() ; i++){ 64 | newLines.add(lines.get(i)); 65 | } 66 | 67 | 68 | FileHelper.writeLines(location.getFilePath(), newLines); 69 | Helper.mutationSuccess(mutantIndex); 70 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {location.getStartLine()}, writer); 71 | 72 | writer.write(" For mutant "+mutantIndex+" the value of the string named \""+stringName+"\" at line "+(location.getStartLine()+1)+" has been changed from \""+toMutate+"\" to \""+randomString+"\""); 73 | writer.newLine(); 74 | writer.flush(); 75 | 76 | return true; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/threading/LengthyGUICreation.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.threading; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 15 | import edu.uniandes.tsdl.antlr.smaliParser; 16 | 17 | public class LengthyGUICreation implements MutationOperator { 18 | 19 | @Override 20 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 21 | 22 | List newLines = new ArrayList(); 23 | List lines = FileHelper.readLines(location.getFilePath()); 24 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 25 | CommonTree method = mLocation.getTree(); 26 | CommonTree classs = (CommonTree) ((CommonTree) method.getAncestors().get(0)).getFirstChildWithType(smaliParser.CLASS_DESCRIPTOR); 27 | CommonTree methodContent = (CommonTree) method.getFirstChildWithType(smaliParser.I_ORDERED_METHOD_ITEMS); 28 | CommonTree superCall = (CommonTree) methodContent.getFirstChildWithType(smaliParser.I_STATEMENT_FORMAT35c_METHOD); 29 | int lineToInsert = 0; 30 | if(superCall != null && superCall.getChildIndex()<3) { 31 | lineToInsert = superCall.getLine(); 32 | } else { 33 | lineToInsert = methodContent.getChild(0).getLine(); 34 | } 35 | 36 | for(int i=0; i < method.getLine()-1; i++){ 37 | newLines.add(lines.get(i)); 38 | } 39 | 40 | newLines.add(".method private delay()V"); 41 | newLines.add(" .locals 2"); 42 | newLines.add(""); 43 | newLines.add(" .line 332"); 44 | newLines.add(" const-wide/16 v0, 0x2710"); 45 | newLines.add(""); 46 | newLines.add(" :try_start_0"); 47 | newLines.add(" invoke-static {v0, v1}, Ljava/lang/Thread;->sleep(J)V"); 48 | newLines.add(" :try_end_0"); 49 | newLines.add(" .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0"); 50 | newLines.add(""); 51 | newLines.add(" .line 335"); 52 | newLines.add(" goto :goto_0"); 53 | newLines.add(""); 54 | newLines.add(" .line 333"); 55 | newLines.add(" :catch_0"); 56 | newLines.add(" move-exception v0"); 57 | newLines.add(""); 58 | newLines.add(" .line 334"); 59 | newLines.add(" .local v0, \"e\":Ljava/lang/InterruptedException;"); 60 | newLines.add(" invoke-virtual {v0}, Ljava/lang/InterruptedException;->printStackTrace()V"); 61 | newLines.add(""); 62 | newLines.add(" .line 336"); 63 | newLines.add(" .end local v0 # \"e\":Ljava/lang/InterruptedException;"); 64 | newLines.add(" :goto_0"); 65 | newLines.add(" return-void"); 66 | newLines.add(".end method"); 67 | 68 | for (int i = method.getLine()-1; i < lineToInsert; i++) { 69 | newLines.add(lines.get(i)); 70 | } 71 | newLines.add(" invoke-direct/range {p0 .. p0}, "+classs+"->delay()V"); 72 | 73 | for(int i=lineToInsert; i < lines.size() ; i++){ 74 | newLines.add(lines.get(i)); 75 | } 76 | 77 | FileHelper.writeLines(location.getFilePath(), newLines); 78 | Helper.mutationSuccess(mutantIndex); 79 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {location.getLine()}, writer); 80 | writer.write(" For mutant "+mutantIndex+" a large delay has been injected after GUI Creation at line "+location.getLine()); 81 | writer.newLine(); 82 | writer.flush(); 83 | return true; 84 | 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/operators/threading/LengthyGUIListener.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.operators.threading; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.antlr.runtime.tree.CommonTree; 9 | 10 | import edu.uniandes.tsdl.mutapk.helper.FileHelper; 11 | import edu.uniandes.tsdl.mutapk.helper.Helper; 12 | import edu.uniandes.tsdl.mutapk.model.location.ASTMutationLocation; 13 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 14 | import edu.uniandes.tsdl.mutapk.operators.MutationOperator; 15 | import edu.uniandes.tsdl.antlr.smaliParser; 16 | 17 | public class LengthyGUIListener implements MutationOperator { 18 | 19 | @Override 20 | public boolean performMutation(MutationLocation location, BufferedWriter writer, int mutantIndex) throws IOException { 21 | 22 | List newLines = new ArrayList(); 23 | List lines = FileHelper.readLines(location.getFilePath()); 24 | ASTMutationLocation mLocation = (ASTMutationLocation) location; 25 | CommonTree method = mLocation.getTree(); 26 | CommonTree classs = (CommonTree) ((CommonTree) method.getAncestors().get(0)).getFirstChildWithType(smaliParser.CLASS_DESCRIPTOR); 27 | CommonTree methodContent = (CommonTree) method.getFirstChildWithType(smaliParser.I_ORDERED_METHOD_ITEMS); 28 | int lineToInsert = methodContent.getChild(0).getLine(); 29 | 30 | for(int i=0; i < method.getLine()-1; i++){ 31 | newLines.add(lines.get(i)); 32 | } 33 | 34 | newLines.add(".method private delay()V"); 35 | newLines.add(" .locals 2"); 36 | newLines.add(""); 37 | newLines.add(" .line 332"); 38 | newLines.add(" const-wide/16 v0, 0x2710"); 39 | newLines.add(""); 40 | newLines.add(" :try_start_0"); 41 | newLines.add(" invoke-static {v0, v1}, Ljava/lang/Thread;->sleep(J)V"); 42 | newLines.add(" :try_end_0"); 43 | newLines.add(" .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0"); 44 | newLines.add(""); 45 | newLines.add(" .line 335"); 46 | newLines.add(" goto :goto_0"); 47 | newLines.add(""); 48 | newLines.add(" .line 333"); 49 | newLines.add(" :catch_0"); 50 | newLines.add(" move-exception v0"); 51 | newLines.add(""); 52 | newLines.add(" .line 334"); 53 | newLines.add(" .local v0, \"e\":Ljava/lang/InterruptedException;"); 54 | newLines.add(" invoke-virtual {v0}, Ljava/lang/InterruptedException;->printStackTrace()V"); 55 | newLines.add(""); 56 | newLines.add(" .line 336"); 57 | newLines.add(" .end local v0 # \"e\":Ljava/lang/InterruptedException;"); 58 | newLines.add(" :goto_0"); 59 | newLines.add(" return-void"); 60 | newLines.add(".end method"); 61 | newLines.add(""); 62 | 63 | for (int i = method.getLine()-1; i < lineToInsert; i++) { 64 | newLines.add(lines.get(i)); 65 | } 66 | newLines.add(" invoke-direct/range {p0 .. p0}, "+classs+"->delay()V"); 67 | 68 | for(int i=lineToInsert; i < lines.size() ; i++){ 69 | newLines.add(lines.get(i)); 70 | } 71 | 72 | FileHelper.writeLines(location.getFilePath(), newLines); 73 | Helper.mutationSuccess(mutantIndex); 74 | Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {location.getLine()}, writer); 75 | writer.write(" For mutant "+mutantIndex+" a large delay has been injected after GUI Listener Creation at line "+location.getLine()); 76 | writer.newLine(); 77 | writer.flush(); 78 | return true; 79 | 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/processors/SourceCodeProcessor.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.processors; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.nio.file.Paths; 6 | import java.util.Collection; 7 | import java.util.HashMap; 8 | import org.antlr.runtime.RecognitionException; 9 | import org.antlr.runtime.tree.CommonTree; 10 | import org.apache.commons.io.FileUtils; 11 | import org.apache.commons.io.filefilter.TrueFileFilter; 12 | 13 | import edu.uniandes.tsdl.antlr.smaliParser; 14 | import edu.uniandes.tsdl.mutapk.helper.ASTHelper; 15 | import edu.uniandes.tsdl.mutapk.helper.Helper; 16 | import edu.uniandes.tsdl.mutapk.model.SmaliAST; 17 | 18 | public class SourceCodeProcessor { 19 | 20 | public void generateASTsMap(String extrasFolder, String packageName, HashMap smaliASTs) throws IOException, RecognitionException { 21 | String decodedPath = Helper.getInstance().getCurrentDirectory(); 22 | // TODO check for multiple "smali*" folders 23 | String folderPath = Paths.get(decodedPath, "temp", "smali").toAbsolutePath().toString(); 24 | Collection files = FileUtils.listFiles(new File(folderPath), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); 25 | for (File file : files) { 26 | if(file.getName().endsWith(".smali") && file.getCanonicalPath().contains(packageName.replace(".", Helper.isWindows()?"\\":"/")) && !file.getName().contains("EmmaInstrumentation.java") && !file.getName().contains("FinishListener.java") && !file.getName().contains("InstrumentedActivity.java") && !file.getName().contains("SMSInstrumentedReceiver.java")){ 27 | String filePath = file.getAbsolutePath(); 28 | CommonTree baseAST = ASTHelper.getAST(file.getAbsolutePath()); 29 | String unitName = baseAST.getFirstChildWithType(smaliParser.CLASS_DESCRIPTOR).getText(); 30 | 31 | SmaliAST temp = new SmaliAST(unitName, filePath, baseAST); 32 | smaliASTs.put(unitName, temp); 33 | } 34 | } 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/processors/TextBasedDetectionsProcessor.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.processors; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.logging.Level; 6 | import java.util.logging.Logger; 7 | 8 | import edu.uniandes.tsdl.mutapk.detectors.MutationLocationDetector; 9 | import edu.uniandes.tsdl.mutapk.model.MutationType; 10 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 11 | 12 | 13 | public class TextBasedDetectionsProcessor { 14 | 15 | public static HashMap> process(String rootPath, List detectors){ 16 | HashMap> locations = new HashMap<>(); 17 | for(MutationLocationDetector mutationLocationDetector : detectors) { 18 | try { 19 | locations.put(mutationLocationDetector.getType(), mutationLocationDetector.analyzeApp(rootPath)); 20 | } catch (Exception e) { 21 | Logger.getAnonymousLogger().log(Level.SEVERE, "Error running detector: "+mutationLocationDetector.getType()); 22 | e.printStackTrace(); 23 | } 24 | } 25 | return locations; 26 | } 27 | 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/selector/InterfaceSelector.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.selector; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | 6 | import edu.uniandes.tsdl.mutapk.exception.MutAPKException; 7 | import edu.uniandes.tsdl.mutapk.model.MutationType; 8 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 9 | 10 | public interface InterfaceSelector { 11 | 12 | public List mutantSelector(HashMap> locations, 13 | SelectorType selectorType) throws MutAPKException; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/selector/SelectorAmountMutants.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.selector; 2 | 3 | public class SelectorAmountMutants extends SelectorType{ 4 | 5 | 6 | private final int amountMutants; 7 | 8 | public SelectorAmountMutants(boolean isConfidenceInterval, boolean isAPK, int totalMutants, int amountMutants) { 9 | super(isConfidenceInterval, isAPK, totalMutants); 10 | this.amountMutants = amountMutants; 11 | } 12 | 13 | public int getAmountMutants() { 14 | return amountMutants; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/selector/SelectorAmountMutantsMethod.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.selector; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | 7 | import edu.uniandes.tsdl.mutapk.detectors.MutationLocationListBuilder; 8 | import edu.uniandes.tsdl.mutapk.exception.MutAPKException; 9 | import edu.uniandes.tsdl.mutapk.model.MutationType; 10 | import edu.uniandes.tsdl.mutapk.model.location.MutationLocation; 11 | 12 | public class SelectorAmountMutantsMethod implements InterfaceSelector{ 13 | 14 | public SelectorAmountMutantsMethod() {} 15 | 16 | public List mutantSelector(HashMap> locations, SelectorType selectorType) throws MutAPKException { 17 | 18 | HashMap> newLocations = new HashMap>(); 19 | HashMap> tempLocations = locations; 20 | SelectorAmountMutants selectorAmountMutants = (SelectorAmountMutants) selectorType; 21 | int newAmountMutants = selectorAmountMutants.getAmountMutants(); 22 | List mutationLocationList = MutationLocationListBuilder.buildList(tempLocations); 23 | 24 | // Check if the amount of PFLocations is lower than the requested by the user 25 | if(mutationLocationList.size() < newAmountMutants) { 26 | throw new MutAPKException("The total of mutants need to be greater than the amount of mutants asked"); 27 | } 28 | System.out.println(""); 29 | 30 | for (MutationType key : tempLocations.keySet()) { 31 | if (tempLocations.get(key).size() > 0) { 32 | int selectedMutantNumber = (int) Math.random() * tempLocations.get(key).size(); 33 | MutationLocation selectedMutant = tempLocations.get(key).get(selectedMutantNumber); 34 | ArrayList temp = new ArrayList(); 35 | temp.add(selectedMutant); 36 | newLocations.put(key, temp); 37 | tempLocations.get(key).remove(selectedMutantNumber); 38 | newAmountMutants--; 39 | } 40 | } 41 | List newMutationLocationList = MutationLocationListBuilder.buildList(newLocations); 42 | 43 | for (int i = 0; i < newAmountMutants; i++) { 44 | int selectedMutantNumber = (int) Math.random() * mutationLocationList.size(); 45 | MutationLocation selectedMutant = mutationLocationList.get(selectedMutantNumber); 46 | newMutationLocationList.add(selectedMutant); 47 | mutationLocationList.remove(selectedMutantNumber); 48 | } 49 | return newMutationLocationList; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/selector/SelectorApkOldVSNewMethod.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.selector; 2 | 3 | public class SelectorApkOldVSNewMethod extends SelectorType{ 4 | 5 | public SelectorApkOldVSNewMethod(boolean isConfidenceInterval, boolean isAPK, int totalMutants) { 6 | super(isConfidenceInterval, isAPK, totalMutants); 7 | // TODO Auto-generated constructor stub 8 | } 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/selector/SelectorConfidenceInterval.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.selector; 2 | 3 | 4 | public class SelectorConfidenceInterval extends SelectorType { 5 | 6 | private final boolean isCIIndividual; 7 | private final int confidenceLevel; 8 | private final int marginError; 9 | 10 | /** 11 | * CI is Confidence Interval 12 | * 13 | * @param isConfidenceInterval 14 | * @param isAPK 15 | * @param isCIIndividual 16 | * @param isCIAll 17 | * @param confidenceLevel 18 | * @param marginError 19 | */ 20 | public SelectorConfidenceInterval(boolean isConfidenceInterval, boolean isAPK, int totalMutants, boolean isCIIndividual, int confidenceLevel, int marginError) { 21 | super(isConfidenceInterval, isAPK, totalMutants); 22 | this.isCIIndividual = isCIIndividual; 23 | this.confidenceLevel = confidenceLevel; 24 | this.marginError = marginError; 25 | } 26 | 27 | 28 | public boolean isCIIndividual() { 29 | return isCIIndividual; 30 | } 31 | 32 | public int confidenceLevel() { 33 | return confidenceLevel; 34 | } 35 | 36 | public int marginError() { 37 | return marginError; 38 | } 39 | 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/selector/SelectorType.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.selector; 2 | 3 | public class SelectorType { 4 | 5 | private final boolean isConfidenceInterval; 6 | private final boolean isAPK; 7 | private final int totalMutants; 8 | 9 | public SelectorType(boolean isConfidenceInterval, boolean isAPK, int totalMutants) { 10 | this.isConfidenceInterval = isConfidenceInterval; 11 | this.isAPK = isAPK; 12 | this.totalMutants = totalMutants; 13 | } 14 | 15 | public boolean isConfidenceInterval() { 16 | return isConfidenceInterval; 17 | } 18 | 19 | public boolean isAPK() { 20 | return isAPK; 21 | } 22 | 23 | public int getTotalMutants() { 24 | return totalMutants; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/mutapk/selector/TargetPopulation.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.selector; 2 | 3 | import org.apache.commons.math3.distribution.NormalDistribution; 4 | 5 | public class TargetPopulation { 6 | 7 | private static final NormalDistribution normalDistribution = new NormalDistribution(); 8 | 9 | /** 10 | * Static Factory Method 11 | */ 12 | private TargetPopulation() { 13 | } 14 | 15 | public static int calculateSampleSize(int populationSize, int confidenceLevel, int marginError) { 16 | if (populationSize < 0) { 17 | throw new IllegalArgumentException("The population size need to be a value bigger than 0"); 18 | } 19 | 20 | if (confidenceLevel > 100 || confidenceLevel < 0) { 21 | throw new IllegalArgumentException("The condifence level need to be a value between 0 to 100"); 22 | } 23 | 24 | if (marginError < 0) { 25 | throw new IllegalArgumentException("The margin error need to be a value equal or bigger than 0"); 26 | } 27 | 28 | double punctuationZ = getPuntuationZ(confidenceLevel); 29 | double expectedProportion = 0.5; 30 | double marginErrorP = (double) marginError / 100; 31 | 32 | double numeratorOne = punctuationZ * punctuationZ * expectedProportion * (1 - expectedProportion); 33 | double denominatorOne = marginErrorP * marginErrorP; 34 | double firstValue = numeratorOne / denominatorOne; 35 | 36 | double secondValue = firstValue / populationSize; 37 | 38 | return (int) Math.ceil(firstValue / (1 + secondValue)); 39 | } 40 | 41 | private static double getPuntuationZ(int confidenceLevel) { 42 | double centralArea = (double) confidenceLevel / 100; 43 | double tailArea = (1 - centralArea) / 2; 44 | double punctuationZ = normalDistribution.inverseCumulativeProbability(centralArea + tailArea); 45 | return punctuationZ; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/smali/InvalidToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [The "BSD licence"] 3 | * Copyright (c) 2010 Ben Gruver 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | package edu.uniandes.tsdl.smali; 30 | 31 | import org.antlr.runtime.CommonToken; 32 | import edu.uniandes.tsdl.antlr.*; 33 | 34 | public class InvalidToken extends CommonToken { 35 | private final String message; 36 | 37 | public InvalidToken(String message) { 38 | super(smaliParser.INVALID_TOKEN); 39 | this.message = message; 40 | this.channel = smaliParser.ERROR_CHANNEL; 41 | } 42 | 43 | public InvalidToken(String message, String text) { 44 | super(smaliParser.INVALID_TOKEN, text); 45 | this.message = message; 46 | this.channel = smaliParser.ERROR_CHANNEL; 47 | } 48 | 49 | public String getMessage() { 50 | return message; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/smali/LexerErrorInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [The "BSD licence"] 3 | * Copyright (c) 2010 Ben Gruver 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | package edu.uniandes.tsdl.smali; 30 | 31 | import org.antlr.runtime.CharStream; 32 | import org.antlr.runtime.Lexer; 33 | import org.antlr.runtime.RecognizerSharedState; 34 | 35 | public interface LexerErrorInterface { 36 | public int getNumberOfSyntaxErrors(); 37 | 38 | //ANTLR doesn't provide any way to add interfaces to the lexer class directly, so this is an intermediate 39 | //class that implements LexerErrorInterface that we can have the ANTLR parser extend 40 | public abstract static class ANTLRLexerWithErrorInterface extends Lexer implements LexerErrorInterface { 41 | public ANTLRLexerWithErrorInterface() { 42 | } 43 | 44 | public ANTLRLexerWithErrorInterface(CharStream input, RecognizerSharedState state) { 45 | super(input, state); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/smali/OdexedInstructionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [The "BSD licence"] 3 | * Copyright (c) 2010 Ben Gruver (JesusFreke) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | package edu.uniandes.tsdl.smali; 30 | 31 | import org.antlr.runtime.IntStream; 32 | import org.antlr.runtime.RecognitionException; 33 | 34 | @SuppressWarnings("serial") 35 | public class OdexedInstructionException extends RecognitionException { 36 | private String odexedInstruction; 37 | 38 | public OdexedInstructionException(IntStream input, String odexedInstruction) { 39 | super(input); 40 | this.odexedInstruction = odexedInstruction; 41 | } 42 | 43 | public String getMessage() { 44 | return odexedInstruction + " is an odexed instruction. You cannot reassemble a disassembled odex file " + 45 | "unless it has been deodexed."; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/edu/uniandes/tsdl/smali/SemanticException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [The "BSD licence"] 3 | * Copyright (c) 2010 Ben Gruver (JesusFreke) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | package edu.uniandes.tsdl.smali; 30 | 31 | import org.antlr.runtime.CommonToken; 32 | import org.antlr.runtime.IntStream; 33 | import org.antlr.runtime.RecognitionException; 34 | import org.antlr.runtime.Token; 35 | import org.antlr.runtime.tree.CommonTree; 36 | 37 | public class SemanticException extends RecognitionException { 38 | private String errorMessage; 39 | 40 | 41 | public SemanticException(IntStream input, String errorMessage, Object... messageArguments) { 42 | super(input); 43 | this.errorMessage = String.format(errorMessage, messageArguments); 44 | } 45 | 46 | SemanticException(IntStream input, Exception ex) { 47 | super(input); 48 | this.errorMessage = ex.getMessage(); 49 | } 50 | 51 | SemanticException(IntStream input, CommonTree tree, String errorMessage, Object... messageArguments) { 52 | super(); 53 | this.input = input; 54 | this.token = tree.getToken(); 55 | this.index = tree.getTokenStartIndex(); 56 | this.line = token.getLine(); 57 | this.charPositionInLine = token.getCharPositionInLine(); 58 | this.errorMessage = String.format(errorMessage, messageArguments); 59 | } 60 | 61 | public SemanticException(IntStream input, Token token, String errorMessage, Object... messageArguments) { 62 | super(); 63 | this.input = input; 64 | this.token = token; 65 | this.index = ((CommonToken)token).getStartIndex(); 66 | this.line = token.getLine(); 67 | this.charPositionInLine = token.getCharPositionInLine(); 68 | this.errorMessage = String.format(errorMessage, messageArguments); 69 | } 70 | 71 | public String getMessage() { 72 | return errorMessage; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/resources/operator-types.properties: -------------------------------------------------------------------------------- 1 | 1 = edu.uniandes.tsdl.mutapk.operators.activity.ActivityNotDefined 2 | 2 = edu.uniandes.tsdl.mutapk.operators.activity.DifferentActivityIntentDefinition 3 | 3 = edu.uniandes.tsdl.mutapk.operators.activity.InvalidActivityName 4 | 4 = edu.uniandes.tsdl.mutapk.operators.activity.InvalidKeyIntentPutExtra 5 | 5 = edu.uniandes.tsdl.mutapk.operators.activity.InvalidLabel 6 | 6 = edu.uniandes.tsdl.mutapk.operators.activity.NullIntent 7 | 7 = edu.uniandes.tsdl.mutapk.operators.activity.NullValueIntentPutExtra 8 | 8 = edu.uniandes.tsdl.mutapk.operators.activity.WrongMainActivity 9 | 9 = edu.uniandes.tsdl.mutapk.operators.programming.android.MissingPermissionManifest 10 | 10 = edu.uniandes.tsdl.mutapk.operators.programming.android.WrongStringResource 11 | 11 = edu.uniandes.tsdl.mutapk.operators.programming.android.NotParcelable 12 | 12 = edu.uniandes.tsdl.mutapk.operators.programming.android.SDKVersion 13 | 13 = edu.uniandes.tsdl.mutapk.operators.backend.LengthyBackEndService 14 | 14 = edu.uniandes.tsdl.mutapk.operators.backend.LongConnectionTimeOut 15 | 15 = edu.uniandes.tsdl.mutapk.operators.connectivity.BluetoothAdapterAlwaysEnabled 16 | 16 = edu.uniandes.tsdl.mutapk.operators.connectivity.NullBluetoothAdapter 17 | 17 = edu.uniandes.tsdl.mutapk.operators.data.android.InvalidURI 18 | 18 = edu.uniandes.tsdl.mutapk.operators.data.android.NullGPSLocation 19 | 19 = edu.uniandes.tsdl.mutapk.operators.data.general.InvalidDate 20 | 20 = edu.uniandes.tsdl.mutapk.operators.data.general.NullBackEndServiceReturn 21 | 21 = edu.uniandes.tsdl.mutapk.operators.programming.oo.InvalidMethodCallArgument 22 | 22 = edu.uniandes.tsdl.mutapk.operators.data.general.NullMethodCallArgument 23 | 23 = edu.uniandes.tsdl.mutapk.operators.db.android.ClosingNullCursor 24 | 24 = edu.uniandes.tsdl.mutapk.operators.db.general.InvalidIndexQueryParameter 25 | 25 = edu.uniandes.tsdl.mutapk.operators.db.general.InvalidSQLQuery 26 | 26 = edu.uniandes.tsdl.mutapk.operators.gui.android.ViewComponentNotVisible 27 | 27 = edu.uniandes.tsdl.mutapk.operators.gui.android.FindViewByIdReturnsNull 28 | 28 = edu.uniandes.tsdl.mutapk.operators.gui.android.InvalidColor 29 | 29 = edu.uniandes.tsdl.mutapk.operators.gui.android.InvalidViewFocus 30 | 30 = edu.uniandes.tsdl.mutapk.operators.gui.general.BuggyGUIListener 31 | 31 = edu.uniandes.tsdl.mutapk.operators.gui.android.InvalidIDFindView 32 | 32 = edu.uniandes.tsdl.mutapk.operators.io.InvalidFilePath 33 | 33 = edu.uniandes.tsdl.mutapk.operators.io.NullStream 34 | 34 = edu.uniandes.tsdl.mutapk.operators.programming.oo.NotSerializable 35 | 35 = edu.uniandes.tsdl.mutapk.operators.image.OOMLargeImage 36 | 36 = edu.uniandes.tsdl.mutapk.operators.threading.LengthyGUIListener 37 | 37 = edu.uniandes.tsdl.mutapk.operators.io.NullStream 38 | 38 = edu.uniandes.tsdl.mutapk.operators.threading.LengthyGUICreation -------------------------------------------------------------------------------- /src/main/resources/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "apkPath": "./apk/com.evancharlton.mileage_3110.apk", 3 | "appName": "com.evancharlton.mileage", 4 | "mutantsFolder": "./mutants", 5 | "operatorsDir": "./", 6 | "multithreadExec": "true", 7 | "extraPath": "./extra", 8 | "selectionStrategy": "all", 9 | "selectionParameters":{ 10 | "amountMutants":"34", 11 | "perOperator":"false", 12 | "confidenceLevel":"85", 13 | "marginError":"10", 14 | "baseAPKPath":"./" 15 | } 16 | } -------------------------------------------------------------------------------- /src/test/java/edu/uniandes/tsdl/mutapk/hashfunction/sha3/Sha3Test.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.hashfunction.sha3; 2 | 3 | public class Sha3Test { 4 | 5 | 6 | // String apkAbsolutePath = "C:\\Users\\PERSONAL\\git\\MutAPK\\test\\temp"; 7 | // File manifest = new File(apkAbsolutePath + File.separator + "AndroidManifest.xml"); 8 | // File smali = new File(apkAbsolutePath + File.separator + "smali"); 9 | // File resource = new File(apkAbsolutePath + File.separator + "res"); 10 | // 11 | // @Test 12 | // public void equalHashTest() throws FileNotFoundException, IOException { 13 | // String hashManifest = Sha3.sha512FileSeparte(manifest); 14 | // String hashSmali = Sha3.sha512FileSeparte(smali); 15 | // String hashResource = Sha3.sha512FileSeparte(resource); 16 | // 17 | // String hashManifestCompare = ""; 18 | // String hashSmaliCompare = ""; 19 | // String hashResourceCompare = ""; 20 | // 21 | // for (int i = 0; i < 10; i++) { 22 | // hashManifestCompare = Sha3.sha512FileSeparte(manifest); 23 | // hashSmaliCompare = Sha3.sha512FileSeparte(smali); 24 | // hashResourceCompare = Sha3.sha512FileSeparte(resource); 25 | // 26 | // if(!hashManifest.equals(hashManifestCompare)) { 27 | // fail("They should be always equals"); 28 | // } 29 | // if(!hashSmali.equals(hashSmaliCompare)) { 30 | // fail("They should be always equals"); 31 | // } 32 | // if(!hashResource.equals(hashResourceCompare)) { 33 | // fail("They should be always equals"); 34 | // } 35 | // } 36 | // } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/edu/uniandes/tsdl/mutapk/selector/TargetPopulationTest.java: -------------------------------------------------------------------------------- 1 | package edu.uniandes.tsdl.mutapk.selector; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | import edu.uniandes.tsdl.mutapk.selector.TargetPopulation; 8 | 9 | public class TargetPopulationTest { 10 | 11 | /** 12 | * PS = Population Size; 13 | * CLP = Confidence Level Percentage; 14 | * MEP = Margin Error Percentage; 15 | */ 16 | 17 | @Test 18 | public void test100PS99CLP1MEP() { 19 | int size = TargetPopulation.calculateSampleSize(100, 99, 1); 20 | assertEquals(100, size); 21 | } 22 | 23 | @Test 24 | public void test1000PS99CLP10MEP() { 25 | int size = TargetPopulation.calculateSampleSize(1000, 99, 10); 26 | assertEquals(143, size); 27 | } 28 | 29 | @Test 30 | public void test10000PS99CLP10MEP() { 31 | int size = TargetPopulation.calculateSampleSize(10000, 99, 10); 32 | assertEquals(164, size); 33 | } 34 | 35 | @Test 36 | public void test100PS95CLP1MEP() { 37 | int size = TargetPopulation.calculateSampleSize(100, 95, 1); 38 | assertEquals(99, size); 39 | } 40 | 41 | @Test 42 | public void test1000PS95CLP10MEP() { 43 | int size = TargetPopulation.calculateSampleSize(1000, 95, 10); 44 | assertEquals(88, size); 45 | } 46 | 47 | @Test 48 | public void test10000PS95CLP10MEP() { 49 | int size = TargetPopulation.calculateSampleSize(10000, 95, 10); 50 | assertEquals(96, size); 51 | } 52 | 53 | @Test 54 | public void test100PS90CLP1MEP() { 55 | int size = TargetPopulation.calculateSampleSize(100, 90, 1); 56 | assertEquals(99, size); 57 | } 58 | 59 | @Test 60 | public void test1000PS90CLP10MEP() { 61 | int size = TargetPopulation.calculateSampleSize(1000, 90, 10); 62 | assertEquals(64, size); 63 | } 64 | 65 | @Test 66 | public void test10000PS90CLP10MEP() { 67 | int size = TargetPopulation.calculateSampleSize(10000, 90, 10); 68 | assertEquals(68, size); 69 | } 70 | 71 | @Test 72 | public void test100PS85CLP1MEP() { 73 | int size = TargetPopulation.calculateSampleSize(100, 85, 1); 74 | assertEquals(99, size); 75 | } 76 | 77 | @Test 78 | public void test1000PS85CLP10MEP() { 79 | int size = TargetPopulation.calculateSampleSize(1000, 85, 10); 80 | assertEquals(50, size); 81 | } 82 | 83 | @Test 84 | public void test10000PS85CLP10MEP() { 85 | int size = TargetPopulation.calculateSampleSize(10000, 85, 10); 86 | assertEquals(52, size); 87 | } 88 | 89 | @Test(expected = IllegalArgumentException.class) 90 | public void test10000PSLess1CLP10MEP() { 91 | TargetPopulation.calculateSampleSize(10000, -1, 10); 92 | } 93 | 94 | @Test(expected = IllegalArgumentException.class) 95 | public void test10000PS101CLP10MEP() { 96 | TargetPopulation.calculateSampleSize(10000, 101, 10); 97 | } 98 | 99 | @Test(expected = IllegalArgumentException.class) 100 | public void test10000PS85CLPLess1MEP() { 101 | TargetPopulation.calculateSampleSize(10000, 85, -1); 102 | } 103 | } 104 | 105 | -------------------------------------------------------------------------------- /test/MutAPK-2.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/MutAPK-2.0.0.jar -------------------------------------------------------------------------------- /test/apk/a2dp.Vol.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/a2dp.Vol.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/a2dp.Vol.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/a2dp.Vol.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/aarddict.android.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/aarddict.android.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/be.ppareit.swiftp_free.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/be.ppareit.swiftp_free.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/caldwell.ben.bites.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/caldwell.ben.bites.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/ch.blinkenlights.battery.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/ch.blinkenlights.battery.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.android.keepass.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.android.keepass.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.android.lolcat.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.android.lolcat.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.android.spritemethodtest.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.android.spritemethodtest.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.angrydoughnuts.android.alarmclock.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.angrydoughnuts.android.alarmclock.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.beust.android.translate.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.beust.android.translate.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.bwx.bequick.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.bwx.bequick.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.chmod0.manpages.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.chmod0.manpages.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.eleybourn.bookcatalogue.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.eleybourn.bookcatalogue.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.evancharlton.mileage.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.evancharlton.mileage.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.everysoft.autoanswer.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.everysoft.autoanswer.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.example.amazed.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.example.amazed.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.example.android.musicplayer.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.example.android.musicplayer.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.example.anycut.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.example.anycut.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.gluegadget.hndroid.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.gluegadget.hndroid.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.google.android.opengles.spritetext.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.google.android.opengles.spritetext.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.google.android.opengles.triangle.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.google.android.opengles.triangle.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.google.android.photostream.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.google.android.photostream.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.hectorone.multismssender.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.hectorone.multismssender.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.irahul.worldclock.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.irahul.worldclock.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.nloko.android.syncmypix.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.nloko.android.syncmypix.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.teleca.jamendo.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.teleca.jamendo.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/com.tum.yahtzee.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/com.tum.yahtzee.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/cri.sanity.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/cri.sanity.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/de.homac.Mirrored.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/de.homac.Mirrored.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/edu.killerud.fileexplorer.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/edu.killerud.fileexplorer.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/es.senselesssolutions.gpl.weightchart.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/es.senselesssolutions.gpl.weightchart.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/hiof.enigma.android.soundboard.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/hiof.enigma.android.soundboard.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/hu.vsza.adsdroid.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/hu.vsza.adsdroid.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/i4nc4mp.myLock.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/i4nc4mp.myLock.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/in.shick.lockpatterngenerator.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/in.shick.lockpatterngenerator.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/info.bpace.munchlife.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/info.bpace.munchlife.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/jp.sblo.pandora.aGrep.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/jp.sblo.pandora.aGrep.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/net.everythingandroid.timer.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/net.everythingandroid.timer.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/net.fercanet.LNM.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/net.fercanet.LNM.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/net.jaqpot.netcounter.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/net.jaqpot.netcounter.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/net.mandaria.tippytipper.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/net.mandaria.tippytipper.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/net.sf.andbatdog.batterydog.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/net.sf.andbatdog.batterydog.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.beide.bomber.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.beide.bomber.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.dnaq.dialer2.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.dnaq.dialer2.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.jfedor.frozenbubble.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.jfedor.frozenbubble.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.jtb.alogcat.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.jtb.alogcat.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.liberty.android.fantastischmemo.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.liberty.android.fantastischmemo.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.passwordmaker.android.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.passwordmaker.android.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.scoutant.blokish.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.scoutant.blokish.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.smerty.zooborns.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.smerty.zooborns.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.tomdroid.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.tomdroid.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.totschnig.myexpenses.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.totschnig.myexpenses.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.waxworlds.edam.importcontacts.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.waxworlds.edam.importcontacts.apk -------------------------------------------------------------------------------- /test/apk/androtest-apks/apks/org.wikipedia.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/androtest-apks/apks/org.wikipedia.apk -------------------------------------------------------------------------------- /test/apk/com.adobe.spark.post.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/com.adobe.spark.post.apk -------------------------------------------------------------------------------- /test/apk/com.canva.editor.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/com.canva.editor.apk -------------------------------------------------------------------------------- /test/apk/com.evancharlton.mileage_3110.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/com.evancharlton.mileage_3110.apk -------------------------------------------------------------------------------- /test/apk/com.example.android.xyztouristattractions.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/com.example.android.xyztouristattractions.apk -------------------------------------------------------------------------------- /test/apk/com.google.android.photostream.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/com.google.android.photostream.apk -------------------------------------------------------------------------------- /test/apk/com.nloko.android.syncmypix.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/com.nloko.android.syncmypix.apk -------------------------------------------------------------------------------- /test/apk/io.github.hidroh.materialistic_75.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/io.github.hidroh.materialistic_75.apk -------------------------------------------------------------------------------- /test/apk/k9mail-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/k9mail-debug.apk -------------------------------------------------------------------------------- /test/apk/myExpenses-acra-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/myExpenses-acra-debug.apk -------------------------------------------------------------------------------- /test/apk/org.totschnig.myexpenses_332.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/apk/org.totschnig.myexpenses_332.apk -------------------------------------------------------------------------------- /test/extra/apktool.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/extra/apktool.jar -------------------------------------------------------------------------------- /test/extra/materialistic.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/extra/materialistic.jks -------------------------------------------------------------------------------- /test/extra/uber-apk-signer.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheSoftwareDesignLab/MutAPK/36fcaa6c183b58d8ccf68e683c79a476a1faf3a4/test/extra/uber-apk-signer.jar -------------------------------------------------------------------------------- /test/operators.properties: -------------------------------------------------------------------------------- 1 | 1 = ActivityNotDefined 2 | 2 = DifferentActivityIntentDefinition 3 | 3 = InvalidActivityPATH 4 | 4 = InvalidKeyIntentPutExtra 5 | 5 = InvalidLabel 6 | 6 = NullIntent 7 | 7 = NullValueIntentPutExtra 8 | 8 = WrongMainActivity 9 | 9 = MissingPermissionManifest 10 | 10 = WrongStringResource 11 | 12 = SDKVersion 12 | 13 = LengthyBackEndService 13 | 14 = LongConnectionTimeOut 14 | 15 = BluetoothAdapterAlwaysEnabled 15 | 16 = NullBluetoothAdapter 16 | 17 = InvalidURI 17 | 18 = NullGPSLocation 18 | 19 = InvalidDate 19 | 20 = NullBackEndServiceReturn 20 | 22 = NullMethodCallArgument 21 | 23 = ClosingNullCursor 22 | 24 = InvalidIndexQueryParameter 23 | 25 = InvalidSQLQuery 24 | 26 = ViewComponentNotVisible 25 | 27 = FindViewByIdReturnsNull 26 | 28 = InvalidColor 27 | 29 = InvalidViewFocus 28 | 31 = InvalidIDFindView 29 | 32 = InvalidFilePath 30 | 33 = NullInputStream 31 | 35 = OOMLargeImage 32 | 36 = LengthyGUIListener 33 | 37 = NullOutputStream 34 | 38 = LengthyGUICreation -------------------------------------------------------------------------------- /test/operators.propertiess: -------------------------------------------------------------------------------- 1 | # 30 = BuggyGUIListener 2 | # 15 = BluetoothAdapterAlwaysEnabled 3 | # 31 = InvalidIDFindView 4 | # 2 = DifferentActivityIntentDefinition 5 | #4 = InvalidKeyIntentPutExtra 6 | #17 = InvalidURI 7 | #28 = InvalidColor 8 | #20 = NullBackEndServiceReturn 9 | #27 = FindViewByIdReturnsNull 10 | 6 = NullIntent -------------------------------------------------------------------------------- /test/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "apkPath": "./apk/com.evancharlton.mileage_3110.apk", 3 | "appName": "com.evancharlton.mileage", 4 | "mutantsFolder": "./mutants", 5 | "operatorsDir": "./", 6 | "multithreadExec": "true", 7 | "ignoreDeadCode": "true", 8 | "extraPath": "./extra", 9 | "selectionStrategy": "amountMutants", 10 | "selectionParameters":{ 11 | "amountMutants":"34", 12 | "perOperator":"false", 13 | "confidenceLevel":"85", 14 | "marginError":"10", 15 | "baseAPKPath":"./" 16 | } 17 | } --------------------------------------------------------------------------------