提交 8dd76420 编写于 作者: S Skylot

fix(deobf): complete disable rename if all rename options unchecked (#1076)

上级 dfe026ac
......@@ -313,7 +313,8 @@ public class Deobfuscator {
} else {
if (!clsMap.containsKey(classInfo)) {
String clsShortName = classInfo.getShortName();
boolean badName = shouldRename(clsShortName) || reservedClsNames.contains(clsShortName);
boolean badName = shouldRename(clsShortName)
|| (args.isRenameValid() && reservedClsNames.contains(clsShortName));
makeClsAlias(cls, badName);
}
}
......
......@@ -188,17 +188,20 @@ public class RenameVisitor extends AbstractVisitor {
mth.addAttr(new RenameReasonAttr(mth, notValid, notPrintable));
}
}
Set<String> names = new HashSet<>(methods.size());
for (MethodNode mth : methods) {
AccessInfo accessFlags = mth.getAccessFlags();
if (accessFlags.isBridge() || accessFlags.isSynthetic()
|| mth.contains(AFlag.DONT_GENERATE) /* this flag not set yet */) {
continue;
}
String signature = mth.getMethodInfo().makeSignature(true, false);
if (!names.add(signature)) {
deobfuscator.forceRenameMethod(mth);
mth.addAttr(new RenameReasonAttr("collision with other method in class"));
// Rename methods with same signature
if (args.isRenameValid()) {
Set<String> names = new HashSet<>(methods.size());
for (MethodNode mth : methods) {
AccessInfo accessFlags = mth.getAccessFlags();
if (accessFlags.isBridge() || accessFlags.isSynthetic()
|| mth.contains(AFlag.DONT_GENERATE) /* this flag not set yet */) {
continue;
}
String signature = mth.getMethodInfo().makeSignature(true, false);
if (!names.add(signature)) {
deobfuscator.forceRenameMethod(mth);
mth.addAttr(new RenameReasonAttr("collision with other method in class"));
}
}
}
}
......
package jadx.tests.integration.deobf.a;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestNegativeRenameCondition extends IntegrationTest {
public static class TestCls {
@SuppressWarnings("checkstyle:TypeName")
public interface a {
@SuppressWarnings("checkstyle:MethodName")
void a();
}
public void test(a a) {
a.a();
}
}
@Test
public void test() {
noDebugInfo();
enableDeobfuscation();
// disable rename by length
args.setDeobfuscationMinLength(0);
args.setDeobfuscationMaxLength(999);
// disable all renaming options
args.setRenameFlags(Collections.emptySet());
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("renamed from")
.containsOne("package jadx.tests.integration.deobf.a;")
.containsOne("public interface a {");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册