Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkSCM option - fixes #12 #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions src/main/groovy/com/chrisney/enigma/EnigmaPlugin.groovy
Original file line number Diff line number Diff line change
@@ -40,20 +40,23 @@ class EnigmaPlugin implements Plugin<Project> {

project.task('cleanBackup', type: CleanBackupTask) {
enabled = extension.enabled
checkSCM = extension.checkSCM
rootProject = project.rootDir.absolutePath
pathSrc = project.rootDir.absolutePath + extension.srcJava
debug = extension.debug
}

project.task('backup', type: BackupTask) {
enabled = extension.enabled
checkSCM = extension.checkSCM
rootProject = project.rootDir.absolutePath
pathSrc = project.rootDir.absolutePath + extension.srcJava
debug = extension.debug
}

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> {

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> {

project.task('restore', type: RestoreTask) {
enabled = extension.enabled
checkSCM = extension.checkSCM
rootProject = project.rootDir.absolutePath
pathSrc = project.rootDir.absolutePath + extension.srcJava
debug = extension.debug
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 3 additions & 1 deletion src/main/java/com/chrisney/enigma/tasks/AbstractTask.java
Original file line number Diff line number Diff line change
@@ -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<File> 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);
}
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/chrisney/enigma/UnitTests.java
Original file line number Diff line number Diff line change
@@ -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();
}