klaxit / hidden-secrets-gradle-plugin

🔒 Deeply hide secrets on Android
MIT License
395 stars 40 forks source link

Update underscore handling to match JNI spec #64

Closed pratclot closed 2 years ago

pratclot commented 2 years ago

Hey folks, nice plugin!

I declared my secrets in SUPER_SECRET_SECRET form, and Android Studio was suggesting to create getSUPER_1SECRET_1SECRET external methods in Secrets.kt. I then found an answer why this was happening.

There is no test for the contents of the generated files as of now it seems, and it was not easy to create one :smiley:

I threw together my limited understanding of kotest and bad knowledge of file operations in Gradle to at least check if function names match what JNI / AS would expect.

Detekt also did not like the absence of newlines, so I had to fix .editorconfig. If I did it the wrong way, please let me know!

Update: I edited the wrong file, the underscores should be converted in the .cpp, will fix that first then. Update: Fixed.

ben-j69 commented 2 years ago

Hello @pratclot ,

thanks for the PR and the work.

But you should not have encounter this problem on v0.1.5, this is the role of the getCppPackageName() function.

Did you try this version of the plugin ?

pratclot commented 2 years ago

Hey @ben-j69 ,

I tried 0.2.0 it seems. Looks like #53 fixed the package name handling, but not the secret names.

Do you think it will make sense to reuse the logic from the mentioned PR then?

Thanks!

ben-j69 commented 2 years ago

Hello @pratclot ,

based on your work I created another PR to only fix the problem you have found and don't touch anything else.

If it is ok for you I will close this PR and merge the one I created https://github.com/klaxit/hidden-secrets-gradle-plugin/pull/67 after internal review ?

pratclot commented 2 years ago

Hey @ben-j69 ,

Sure, sounds good to me, and thanks a lot for considering the changes!

ben-j69 commented 2 years ago

@pratclot thanks to you to find the issue and propose a solution.

I have also updated the test to also check that key in java file are corrects.

Replaced by https://github.com/klaxit/hidden-secrets-gradle-plugin/pull/67