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

Critical obfuscation issue. #417

Open
Monabr opened this issue Jul 25, 2024 · 9 comments
Open

Critical obfuscation issue. #417

Monabr opened this issue Jul 25, 2024 · 9 comments
Labels
enhancement New feature or request
Milestone

Comments

@Monabr
Copy link

Monabr commented Jul 25, 2024

Hello. You have a great library, but there is a problem that prevents me from using it.

The generated code uses the full class name including the package as a key. This should not happen after obfuscation! Please change this behavior.

As a solution, I am ready to see a functionality where I would manually assign a key to each class. This could be made by an optional parameter in the annotation or by some additional annotation.

I believe this is a critical issue and should be fixed as soon as possible!

@Monabr Monabr changed the title Obfuscation issue! Big obfuscation issue. Jul 25, 2024
@Monabr Monabr changed the title Big obfuscation issue. Critical obfuscation issue. Jul 26, 2024
@evant evant added the enhancement New feature or request label Jul 26, 2024
@evant
Copy link
Owner

evant commented Jul 26, 2024

They really just need to be unique per type access, so some type of hashing my work here. Alternatively it looks like hilt solved a similar issue google/dagger#3197 though will have to dig to figure out what code changes they actually did.

@Monabr
Copy link
Author

Monabr commented Jul 26, 2024

@evant Could you tell me how fixable this problem is, should I wait for the nearest time? I am pressed for time and at the moment I am choosing between your library and service locators, which I would really like to avoid using.

@Monabr
Copy link
Author

Monabr commented Jul 26, 2024

@asapha
Copy link

asapha commented Jul 26, 2024

For Proguard/R8, there's the -adaptclassstrings option. The strings containing class names are modified to their obfuscated version. (source)

For example, in a generated mapping file, I have:

[...]
me.tatarka.inject.internal.LazyMap -> dR0:
# {"id":"sourceFile","fileName":"LazyMap.kt"}
[...]

And in an obfuscated component class, I see:

public final class bt0 implements c22, ut1 {
   // --> LazyMap
   public final dR0 b;

   public final lAi C() {
      // --> LazyMap usage
      return (lAi)this.b.a("lAi", bt0::a);
   }
[...]

It doesn't work if the key has backticks or if it points to a generic type, though.

@evant
Copy link
Owner

evant commented Jul 26, 2024

It doesn't work if the key has backticks or if it points to a generic type, though.

Hm, I wonder if doing something like

"com.example.MyClass" + "<" + "com.example.MyArg" + ">"

would help it pick up generic types properly

@evant
Copy link
Owner

evant commented Jul 26, 2024

@Monabr

Could you tell me how fixable this problem is, should I wait for the nearest time?

I can make no promises on timelines, but this does seem fixable, pr's welcome.

@Monabr
Copy link
Author

Monabr commented Jul 27, 2024

For Proguard/R8, there's the -adaptclassstrings option.

Are you talking about this as a temporary solution until the library is changed or do you mean that the dagger library team used this? If you mean the second option - it seems like they used something else.

@Monabr
Copy link
Author

Monabr commented Sep 6, 2024

@evant Want to highlight that Dagger uses Map<Class<?>, Boolean> instead of strings keys. So I believe this could be implemented in this library.

@evant
Copy link
Owner

evant commented Sep 7, 2024

You'd need to make sure generics are handled correctly, but yes that's a possible solution

@evant evant mentioned this issue Sep 9, 2024
@evant evant added this to the 1.0 milestone Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants