From 6e46d85e4263f0727cffa7a66fcab16ae95fbd55 Mon Sep 17 00:00:00 2001 From: Ben-J Date: Fri, 16 Apr 2021 17:33:47 +0200 Subject: [PATCH] Update libs, remove jcenter depency, update gradle Add remarks Signed-off-by: Ron Gebauer --- CHANGELOG.md | 7 +++++ build.gradle.kts | 29 +++++++++---------- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 4 +++ .../kotlin/com/klaxit/hiddensecrets/Utils.kt | 2 +- src/main/resources/cpp/secrets.cpp | 11 ++++--- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5012bc..c4f66f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# v0.1.2 +### Fixes +* Fix call to `customDecode()` in C++ code +### Improvements +* jcenter dependency removed +* Moving up to gradle 6.8.3 +* Various libraries update # v0.1.1 ### Fixes * Fix sha256 generation : long keys are now decoded correctly. Reported in https://github.com/klaxit/hidden-secrets-gradle-plugin/issues/16 diff --git a/build.gradle.kts b/build.gradle.kts index 71ed5b1..96be158 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,30 +1,28 @@ plugins { - id("com.gradle.plugin-publish") version "0.12.0" - id("io.gitlab.arturbosch.detekt") version "1.14.2" - `java-gradle-plugin` + id("com.gradle.plugin-publish") version "0.14.0" + id("io.gitlab.arturbosch.detekt") version "1.16.0" `kotlin-dsl` `maven-publish` } -group = "com.klaxit.hiddensecrets" -version = "0.1.1" - repositories { mavenCentral() google() - jcenter() + maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") // Required by detekt } dependencies { - implementation("com.android.tools.build:gradle:4.0.2") + implementation("com.android.tools.build:gradle:4.1.3") - testImplementation("io.kotest:kotest-runner-junit5-jvm:4.3.1") - testImplementation("io.kotest:kotest-assertions-core-jvm:4.3.1") - testImplementation("junit:junit:4.13.1") + testImplementation("io.kotest:kotest-runner-junit5-jvm:4.4.3") + testImplementation("io.kotest:kotest-assertions-core-jvm:4.4.3") + testImplementation("junit:junit:4.13.2") } -configure { - sourceCompatibility = JavaVersion.VERSION_1_8 +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } } pluginBundle { @@ -38,7 +36,8 @@ gradlePlugin { create("HiddenSecretsPlugin") { id = "com.klaxit.hiddensecrets" displayName = "Hidden Secrets Plugin" - description = "This plugin allows any Android developer to deeply hide secrets in its project to prevent credentials harvesting." + description = "This plugin allows any Android developer" + + " to deeply hide secrets in its project to prevent credentials harvesting." implementationClass = "com.klaxit.hiddensecrets.HiddenSecretsPlugin" } } @@ -51,4 +50,4 @@ tasks.withType { tasks.withType { useJUnitPlatform() -} \ No newline at end of file +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1b16c34..442d913 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 42e2ac8..6d2acaa 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,2 +1,6 @@ rootProject.name = "HiddenSecretsPlugin" +gradle.allprojects { + group = "com.klaxit.hiddensecrets" + version = "0.1.2" +} diff --git a/src/main/kotlin/com/klaxit/hiddensecrets/Utils.kt b/src/main/kotlin/com/klaxit/hiddensecrets/Utils.kt index e4053be..31d3d47 100644 --- a/src/main/kotlin/com/klaxit/hiddensecrets/Utils.kt +++ b/src/main/kotlin/com/klaxit/hiddensecrets/Utils.kt @@ -33,7 +33,7 @@ object Utils { val bytes = toHash.toByteArray() val md = MessageDigest.getInstance("SHA-256") val digest = md.digest(bytes) - return digest.fold("", { str, it -> str + "%02x".format(it) }) + return digest.fold("") { str, it -> str + "%02x".format(it) } } /** diff --git a/src/main/resources/cpp/secrets.cpp b/src/main/resources/cpp/secrets.cpp index 55a04b7..32f3f1d 100644 --- a/src/main/resources/cpp/secrets.cpp +++ b/src/main/resources/cpp/secrets.cpp @@ -29,11 +29,12 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -void customDecode(char *str) { +char *customDecode(char *str) { /* Add your own logic here * To improve your key security you can encode it before to integrate it in the app. * And then decode it with your own logic in this function. */ + return str; } jstring getOriginalKey( @@ -44,10 +45,10 @@ jstring getOriginalKey( // Get the obfuscating string SHA256 as the obfuscator const char *obfuscatingStr = pEnv->GetStringUTFChars(obfuscatingJStr, NULL); - char buffer[2*SHA256::DIGEST_SIZE + 1]; + char buffer[2 * SHA256::DIGEST_SIZE + 1]; sha256(obfuscatingStr, buffer); - const char* obfuscator = buffer; + const char *obfuscator = buffer; // Apply a XOR between the obfuscated key and the obfuscating string to get original string char out[obfuscatedSecretSize + 1]; @@ -59,9 +60,7 @@ jstring getOriginalKey( out[obfuscatedSecretSize] = 0x0; //(Optional) To improve key security - customDecode(out); - - return pEnv->NewStringUTF(out); + return pEnv->NewStringUTF(customDecode(out)); } extern "C"