mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
fix(stores): handle Android storage aliases
This commit is contained in:
1 parent
9222a1fe4d
commit
1e23bb6d8d
2 files changed
+17
-1
No files matched your search
@@ -8,7 +8,8 @@ internal object AmazonEngine {
|
||||
fun verify(directory: File): Boolean = runCatching {
|
||||
val manifest = File(directory, "engine.json")
|
||||
val library = File(directory, "libdroiddeckamazon.so")
|
||||
check(manifest.canonicalFile == manifest.absoluteFile && library.canonicalFile == library.absoluteFile)
|
||||
val root = directory.canonicalFile
|
||||
check(manifest.canonicalFile == File(root, manifest.name) && library.canonicalFile == File(root, library.name))
|
||||
check(manifest.length() in 1..131_072 && library.isFile)
|
||||
val data = JSONObject(manifest.readText())
|
||||
check(data.getInt("schema") == 1 && data.getInt("abi") == 1)
|
||||
|
||||
@@ -2,10 +2,12 @@ package com.droiddeck.launcher.stores.amazon
|
||||
|
||||
import java.io.File
|
||||
import java.security.MessageDigest
|
||||
import java.nio.file.Files
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Assume.assumeFalse
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.junit.runner.RunWith
|
||||
@@ -51,4 +53,17 @@ class AmazonEngineTest {
|
||||
File(malformed, "engine.json").writeText("not json")
|
||||
assertFalse(AmazonEngine.verify(malformed))
|
||||
}
|
||||
|
||||
@Test fun parentStorageAliasIsAllowedButLibrarySymlinkIsRejected() {
|
||||
assumeFalse(System.getProperty("os.name").startsWith("Windows"))
|
||||
val directory = prepared()
|
||||
val alias = File(temp.root, "alias")
|
||||
Files.createSymbolicLink(alias.toPath(), directory.toPath())
|
||||
assertTrue(AmazonEngine.verify(alias))
|
||||
val library = File(directory, "libdroiddeckamazon.so")
|
||||
val outside = temp.newFile("outside.so").apply { writeBytes(library.readBytes()) }
|
||||
library.delete()
|
||||
Files.createSymbolicLink(library.toPath(), outside.toPath())
|
||||
assertFalse(AmazonEngine.verify(directory))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user