-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ignore incorrect dex files in apk (#700)
- Loading branch information
Showing
3 changed files
with
69 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
jadx-core/src/test/java/jadx/core/utils/files/InputFileTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package jadx.core.utils.files; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.core.utils.exceptions.DecodeException; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
class InputFileTest { | ||
private static final String TEST_SAMPLES_DIR = "test-samples/"; | ||
|
||
@Test | ||
public void testApkWithFakeDex() throws IOException, DecodeException { | ||
File sample = getFileFromSampleDir("app-with-fake-dex.apk"); | ||
|
||
List<InputFile> list = new ArrayList<>(); | ||
InputFile.addFilesFrom(sample, list, false); | ||
assertThat(list, hasSize(1)); | ||
InputFile inputFile = list.get(0); | ||
assertThat(inputFile.getDexFiles(), hasSize(1)); | ||
} | ||
|
||
private static File getFileFromSampleDir(String fileName) { | ||
URL resource = InputFileTest.class.getClassLoader().getResource(TEST_SAMPLES_DIR + fileName); | ||
assertThat(resource, notNullValue()); | ||
String pathStr = resource.getFile(); | ||
return new File(pathStr); | ||
} | ||
} |
Binary file not shown.