提交 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,6 +188,8 @@ public class RenameVisitor extends AbstractVisitor {
mth.addAttr(new RenameReasonAttr(mth, notValid, notPrintable));
}
}
// Rename methods with same signature
if (args.isRenameValid()) {
Set<String> names = new HashSet<>(methods.size());
for (MethodNode mth : methods) {
AccessInfo accessFlags = mth.getAccessFlags();
......@@ -202,6 +204,7 @@ public class RenameVisitor extends AbstractVisitor {
}
}
}
}
private static void processRootPackages(Deobfuscator deobfuscator, RootNode root, List<ClassNode> classes) {
Set<String> rootPkgs = collectRootPkgs(classes);
......
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.
先完成此消息的编辑!
想要评论请 注册