summaryrefslogtreecommitdiff
path: root/tests/DynamicCodeLoggerIntegrationTests/src
diff options
context:
space:
mode:
author Alan Stokes <alanstokes@google.com> 2019-02-28 16:46:03 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-02-28 16:46:03 +0000
commit5e1c11cc444d6c83e5a09fd84e6646e3fcde14f9 (patch)
tree44aa72900e687dcbb14e7a823a3bc1754447145b /tests/DynamicCodeLoggerIntegrationTests/src
parent5ac2de02f67d18c0596653e3628b1063b1a89b2d (diff)
parentfc9a21de684f24f0005be43d0113b504bd5990fc (diff)
Merge "Detect native code loading by untrusted_app."
Diffstat (limited to 'tests/DynamicCodeLoggerIntegrationTests/src')
-rw-r--r--tests/DynamicCodeLoggerIntegrationTests/src/com/android/server/pm/dex/DynamicCodeLoggerIntegrationTests.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/DynamicCodeLoggerIntegrationTests/src/com/android/server/pm/dex/DynamicCodeLoggerIntegrationTests.java b/tests/DynamicCodeLoggerIntegrationTests/src/com/android/server/pm/dex/DynamicCodeLoggerIntegrationTests.java
index 8ef15d869a0b..4f9aeea5bdb4 100644
--- a/tests/DynamicCodeLoggerIntegrationTests/src/com/android/server/pm/dex/DynamicCodeLoggerIntegrationTests.java
+++ b/tests/DynamicCodeLoggerIntegrationTests/src/com/android/server/pm/dex/DynamicCodeLoggerIntegrationTests.java
@@ -235,6 +235,34 @@ public final class DynamicCodeLoggerIntegrationTests {
}
@Test
+ public void testGeneratesEvents_spoofed_validFile_untrustedApp() throws Exception {
+ File privateCopyFile = privateFile("spoofed2");
+
+ String expectedContentHash = copyAndHashResource(
+ "/DynamicCodeLoggerNativeExecutable", privateCopyFile);
+
+ EventLog.writeEvent(EventLog.getTagCode("auditd"),
+ "type=1400 avc: granted { execute_no_trans } "
+ + "path=\"" + privateCopyFile + "\" "
+ + "scontext=u:r:untrusted_app: "
+ + "tcontext=u:object_r:app_data_file: "
+ + "tclass=file ");
+
+ String expectedNameHash =
+ "3E57AA59249154C391316FDCF07C1D499C26A564E4D305833CCD9A98ED895AC9";
+
+ // Run the job to scan generated audit log entries
+ runDynamicCodeLoggingJob(AUDIT_WATCHING_JOB_ID);
+
+ // And then make sure we log events about it
+ long previousEventNanos = mostRecentEventTimeNanos();
+ runDynamicCodeLoggingJob(IDLE_LOGGING_JOB_ID);
+
+ assertDclLoggedSince(previousEventNanos, DCL_NATIVE_SUBTAG,
+ expectedNameHash, expectedContentHash);
+ }
+
+ @Test
public void testGeneratesEvents_spoofed_pathTraversal() throws Exception {
File privateDir = privateFile("x").getParentFile();