diff --git a/README.md b/README.md index daed61f..dfc1cb6 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ buildscript { url "https://plugins.gradle.org/m2/" } } - dependencies { + dependencies { classpath 'com.android.tools.build:gradle:3.5.2' // Add the Enigma classpath classpath 'gradle.plugin.chrisney:enigma:1.0.0.8' @@ -50,6 +50,7 @@ apply plugin: 'com.chrisney.enigma' // Set Enigma options: enigma.enabled = true enigma.injectFakeKeys = true +enigma.checkSCM = true enigma.ignoredClasses = ["com.my.packagename.MainActivity.java"] android { @@ -112,6 +113,7 @@ Bellow the options of Enigma plugin: * **enigma.enabled** *(true | false)* : Enable or disable the string encryption process (default: true) * **enigma.injectFakeKeys** *(true | false)* : if activated, create fake string keys and injected it into your code (default: true) +* **enigma.checkSCM** *(true | false)* : if activated, check for Source Code Management (default: true) * **enigma.hash** (string) : let you define your own encryption key (32 characters recommended) * **enigma.classes** (array of strings) : let you defined the only classes to encrypt * **enigma.ignoredClasses** (array of strings): define the classes to not encrypt diff --git a/src/main/groovy/com/chrisney/enigma/EnigmaPlugin.groovy b/src/main/groovy/com/chrisney/enigma/EnigmaPlugin.groovy index cb77fd4..93340af 100644 --- a/src/main/groovy/com/chrisney/enigma/EnigmaPlugin.groovy +++ b/src/main/groovy/com/chrisney/enigma/EnigmaPlugin.groovy @@ -40,6 +40,7 @@ class EnigmaPlugin implements Plugin { project.task('cleanBackup', type: CleanBackupTask) { enabled = extension.enabled + checkSCM = extension.checkSCM rootProject = project.rootDir.absolutePath pathSrc = project.rootDir.absolutePath + extension.srcJava debug = extension.debug @@ -47,6 +48,7 @@ class EnigmaPlugin implements Plugin { project.task('backup', type: BackupTask) { enabled = extension.enabled + checkSCM = extension.checkSCM rootProject = project.rootDir.absolutePath pathSrc = project.rootDir.absolutePath + extension.srcJava debug = extension.debug @@ -54,6 +56,7 @@ class EnigmaPlugin implements Plugin { project.task('injectCode', type: InjectCodeTask) { enabled = extension.enabled + checkSCM = extension.checkSCM rootProject = project.rootDir.absolutePath pathSrc = project.rootDir.absolutePath + extension.srcJava hash = extension.hash @@ -63,6 +66,7 @@ class EnigmaPlugin implements Plugin { project.task('encrypt', type: EnigmaTask) { enabled = extension.enabled + checkSCM = extension.checkSCM rootProject = project.rootDir.absolutePath pathSrc = project.rootDir.absolutePath + extension.srcJava hash = extension.hash @@ -76,6 +80,7 @@ class EnigmaPlugin implements Plugin { project.task('restore', type: RestoreTask) { enabled = extension.enabled + checkSCM = extension.checkSCM rootProject = project.rootDir.absolutePath pathSrc = project.rootDir.absolutePath + extension.srcJava debug = extension.debug diff --git a/src/main/groovy/com/chrisney/enigma/EnigmaPluginExtension.groovy b/src/main/groovy/com/chrisney/enigma/EnigmaPluginExtension.groovy index 2a9fb7b..08789e2 100644 --- a/src/main/groovy/com/chrisney/enigma/EnigmaPluginExtension.groovy +++ b/src/main/groovy/com/chrisney/enigma/EnigmaPluginExtension.groovy @@ -30,6 +30,10 @@ class EnigmaPluginExtension { * Enable / disable the fake keys injection (honeypot principal) */ boolean injectFakeKeys = true; + /** + * Enable / disable the Source Code Management check + */ + boolean checkSCM = true; /** * Enable / disable the DEBUG (verbose) mode */ @@ -45,4 +49,4 @@ class EnigmaPluginExtension { * @TODO : implement this option */ String encryptionTaskName = null; -} \ No newline at end of file +} diff --git a/src/main/java/com/chrisney/enigma/tasks/AbstractTask.java b/src/main/java/com/chrisney/enigma/tasks/AbstractTask.java index cc311cd..6ff1010 100644 --- a/src/main/java/com/chrisney/enigma/tasks/AbstractTask.java +++ b/src/main/java/com/chrisney/enigma/tasks/AbstractTask.java @@ -26,6 +26,7 @@ public class AbstractTask extends DefaultTask { "!.gitignore"; public boolean enabled = true; + public boolean checkSCM = true; public boolean debug = false; public String rootProject; public String pathSrc; @@ -58,6 +59,7 @@ protected Collection getAllXmlFiles() { * @return True if an SCM tool is found */ protected boolean checkSCM() { + if (!checkSCM) return true; boolean result = hasGit() || hasSubversion() || hasMercurial(); if (!result) { System.out.println("⚠️ The project has no Source Code Management. Please setup one (Git, SVN, Mercurial) before use Enigma plugin!"); @@ -149,4 +151,4 @@ protected boolean isEnigmatized(File srcFile) throws IOException { String contents = FileUtils.readFileToString(srcFile, "UTF-8"); return contents.contains(InjectCodeTask.IMPORT_NAME) || contents.contains(InjectCodeTask.FUNCTION_NAME); } -} \ No newline at end of file +} diff --git a/src/test/java/com/chrisney/enigma/UnitTests.java b/src/test/java/com/chrisney/enigma/UnitTests.java index f7d482c..8317f71 100644 --- a/src/test/java/com/chrisney/enigma/UnitTests.java +++ b/src/test/java/com/chrisney/enigma/UnitTests.java @@ -96,7 +96,7 @@ public void testJavaParser() throws Exception { File src = new File(repoPath + File.separator + "src" + File.separator); if (!src.exists()) { Git git = Git.cloneRepository() - .setURI("https://android.googlesource.com/platform/packages/apps/Launcher3") + .setURI("https://android.googlesource.com/platform/packages/apps/Launcher3#android11-dev") .setDirectory(repo) .call(); }