mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 04:46:08 +00:00
Restrict library redaction exceptions to loader diagnostics
This commit is contained in:
1 parent
4ab4a86507
commit
3e90875be8
2 files changed
+79
-18
No files matched your search
@@ -42,35 +42,54 @@ class LogRedactorTest {
|
||||
assertEquals("login <redacted:email> ok", LogRedactor.redact("login someone@example.com ok"))
|
||||
}
|
||||
|
||||
@Test fun hidlSharedLibrariesStayVisibleWhileAdjacentSecretsAndEmailsAreRedacted() {
|
||||
@Test fun onlyLoaderDiagnosticsKeepHidlSharedLibraryNames() {
|
||||
val library = "android.hardware.graphics.mapper@4.0.so"
|
||||
val vendorLibrary = "vendor.qti.hardware.display.mapper@4.0.so"
|
||||
val line = "/vendor/lib64/hw/$library loaded $vendorLibrary contact=someone@company.so token=abcdef123456"
|
||||
val expected = "/vendor/lib64/hw/$library loaded $vendorLibrary contact=<redacted:email> token=<redacted:token>"
|
||||
val line = "dlopen failed: library \"$library\" not found"
|
||||
val pathLine = "dlopen failed: library \"/vendor/lib64/hw/$library\" not found"
|
||||
|
||||
assertEquals(expected, LogRedactor.redact(line))
|
||||
assertEquals(expected, LogRedactor.redactForShare(line))
|
||||
assertEquals(line, LogRedactor.redact(line))
|
||||
assertEquals(line, LogRedactor.redactForShare(line))
|
||||
assertEquals(pathLine, LogRedactor.redact(pathLine))
|
||||
assertEquals(pathLine, LogRedactor.redactForShare(pathLine))
|
||||
}
|
||||
|
||||
@Test fun privacyRulesOverrideTheHidlSharedLibraryException() {
|
||||
val library = "android.hardware.graphics.mapper@4.0.so"
|
||||
assertEquals("token=<redacted:token>", LogRedactor.redact("token=$library"))
|
||||
assertEquals("username=<redacted:account>", LogRedactor.redact("username=$library"))
|
||||
assertEquals("{\"password\":\"<redacted:token>\"}", LogRedactor.redact("{\"password\":\"$library\"}"))
|
||||
assertEquals("{\"password\":\"<redacted:token>\"}", LogRedactor.redactForShare("{\"password\":\"$library\"}"))
|
||||
assertEquals("{\"password\":\"<redacted:token>\"}", LogRedactor.redact("{\"password\":\"don't-use-$library\"}"))
|
||||
assertEquals("{\"password\":\"<redacted:token>\"}", LogRedactor.redactForShare("{\"password\":\"don't-use-$library\"}"))
|
||||
|
||||
val users = tmp.newFile("hidl-loginusers.vdf")
|
||||
val mixed = "dlopen failed: library \"$library\" not found; token=abcdef123456; contact=alice!$library; {\"password\":\"library \\\"$library\\\" not found\"}"
|
||||
val expected = "dlopen failed: library \"$library\" not found; token=<redacted:token>; contact=alice!<redacted:email>; {\"password\":\"<redacted:token>\"}"
|
||||
assertEquals(expected, LogRedactor.redact(mixed))
|
||||
assertEquals(expected, LogRedactor.redactForShare(mixed))
|
||||
|
||||
val root = java.nio.file.Files.createTempDirectory("hidl-redactor").toFile()
|
||||
val users = java.io.File(root, "loginusers.vdf")
|
||||
users.writeText("\"AccountName\" \"$library\"")
|
||||
try {
|
||||
LogRedactor.learnAccounts(users)
|
||||
assertEquals("<redacted:account>", LogRedactor.redact(library))
|
||||
} finally {
|
||||
LogRedactor.learnAccounts()
|
||||
root.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun onlyExactHidlSharedLibraryNamesBypassEmailRedaction() {
|
||||
@Test fun hidlSharedLibraryNamesAreRedactedOutsideLoaderDiagnostics() {
|
||||
val library = "android.hardware.graphics.mapper@4.0.so"
|
||||
|
||||
assertEquals(library, LogRedactor.redact(library))
|
||||
assertEquals("<redacted:email>", LogRedactor.redact(library))
|
||||
assertEquals("<redacted:email>", LogRedactor.redactForShare(library))
|
||||
assertEquals("/vendor/lib64/hw/<redacted:email>", LogRedactor.redact("/vendor/lib64/hw/$library"))
|
||||
for (punctuation in listOf("!", "#", "~", "/", "=")) {
|
||||
val expected = "contact=alice$punctuation<redacted:email>"
|
||||
assertEquals(expected, LogRedactor.redact("contact=alice$punctuation$library"))
|
||||
assertEquals(expected, LogRedactor.redactForShare("contact=alice$punctuation$library"))
|
||||
}
|
||||
assertEquals("<redacted:email>", LogRedactor.redact("$library.evil"))
|
||||
assertEquals("<redacted:email>", LogRedactor.redact("someone@company.so"))
|
||||
assertEquals("<redacted:email>", LogRedactor.redact("not$library"))
|
||||
@@ -81,6 +100,25 @@ class LogRedactorTest {
|
||||
assertEquals("<redacted:email>", LogRedactor.redact("android.hardware.graphics.mapper@4.0.so.evil"))
|
||||
}
|
||||
|
||||
@Test fun loaderContextRequiresExactWordsAndABoundedAndroidPath() {
|
||||
val library = "android.hardware.graphics.mapper@4.0.so"
|
||||
val valid = "library \"/system/lib64/$library\" not found: needed by app"
|
||||
assertEquals(valid, LogRedactor.redact(valid))
|
||||
assertEquals(valid, LogRedactor.redactForShare(valid))
|
||||
for (line in listOf(
|
||||
"not_library \"$library\" not found",
|
||||
"library \"$library\" not found_suffix",
|
||||
"library \"/home/user/$library\" not found",
|
||||
"library \"relative/$library\" not found",
|
||||
"library \"/vendor/invalid!/$library\" not found",
|
||||
"library \"/vendor/" + "a/".repeat(2050) + "$library\" not found",
|
||||
)) {
|
||||
val expected = line.replace(library, "<redacted:email>")
|
||||
assertEquals(expected, LogRedactor.redact(line))
|
||||
assertEquals(expected, LogRedactor.redactForShare(line))
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun clockTimeIsNotAnAddress() {
|
||||
val line = "[2026-09-27 10:03:05] Startup"
|
||||
assertEquals(line, LogRedactor.redact(line))
|
||||
|
||||
Reference in new issue
Block a user