Skip to content

Commit

Permalink
Update libs, remove jcenter depency, update gradle
Browse files Browse the repository at this point in the history
Add remarks

Signed-off-by: Ron Gebauer <[email protected]>
  • Loading branch information
Ben-J authored and Ben-J committed Apr 19, 2021
1 parent ea75073 commit 6e46d85
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 23 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
29 changes: 14 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}

pluginBundle {
Expand All @@ -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"
}
}
Expand All @@ -51,4 +50,4 @@ tasks.withType<Copy> {

tasks.withType<Test> {
useJUnitPlatform()
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
rootProject.name = "HiddenSecretsPlugin"

gradle.allprojects {
group = "com.klaxit.hiddensecrets"
version = "0.1.2"
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/klaxit/hiddensecrets/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}

/**
Expand Down
11 changes: 5 additions & 6 deletions src/main/resources/cpp/secrets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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];
Expand All @@ -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"
Expand Down

0 comments on commit 6e46d85

Please sign in to comment.