aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2016-09-29 15:27:00 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-09-29 15:27:00 +0000
commit3ef6a5aaa0e822a3862a252c4ee4b32153bd157b (patch)
tree7c3fe9b72e50255af0fa84e0a64575564408820d /tests
parentcb1fcd774a4e425e65bdf4fab532f221284b9b0f (diff)
parent79e61b15a11698197da4bb78cd1be469a38b9c35 (diff)
downloadContactsProvider-3ef6a5aaa0e822a3862a252c4ee4b32153bd157b.tar.gz
Merge "Report invalid SQL with non-crashing 'wtf' rather than crash"
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/providers/contacts/SqlInjectionDetectionTest.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/src/com/android/providers/contacts/SqlInjectionDetectionTest.java b/tests/src/com/android/providers/contacts/SqlInjectionDetectionTest.java
index c7eb64cc..32caa731 100644
--- a/tests/src/com/android/providers/contacts/SqlInjectionDetectionTest.java
+++ b/tests/src/com/android/providers/contacts/SqlInjectionDetectionTest.java
@@ -47,13 +47,15 @@ public class SqlInjectionDetectionTest extends BaseContactsProvider2Test {
@Override
protected void setUp() throws Exception {
super.setUp();
-
- getContactsProvider().getContactsDatabaseHelperForTest().setSqlCheckEnabled(true);
}
- public void testPhoneQueryValid() {
+ public void testQueryValid() {
assertQueryValid(Phone.CONTENT_URI, PHONE_ID_PROJECTION,
Phone.NUMBER + "='555-123-4567'", null);
+
+ // The following tables are whitelisted.
+ assertQueryValid(Data.CONTENT_URI, null,
+ "data._id in default_directory", null);
}
public void testPhoneQueryBadProjection() {
@@ -73,7 +75,7 @@ public class SqlInjectionDetectionTest extends BaseContactsProvider2Test {
"0=1) UNION SELECT _id FROM view_data--", null);
assertQueryThrows(Phone.CONTENT_URI, PHONE_ID_PROJECTION, ";delete from contacts", null);
assertQueryThrows(Phone.CONTENT_URI, PHONE_ID_PROJECTION,
- "_id in default_directory", null);
+ "_id in data_usage_stat", null);
assertQueryThrows(Phone.CONTENT_URI, PHONE_ID_PROJECTION,
"_id in (select _id from default_directory)", null);
}
@@ -83,7 +85,7 @@ public class SqlInjectionDetectionTest extends BaseContactsProvider2Test {
PHONE_ID_PROJECTION, null, "_id UNION SELECT _id FROM view_data--");
assertQueryThrows(Phone.CONTENT_URI, PHONE_ID_PROJECTION, null, ";delete from contacts");
assertQueryThrows(Phone.CONTENT_URI, PHONE_ID_PROJECTION, null,
- "_id in default_directory");
+ "_id in data_usage_stat");
assertQueryThrows(Phone.CONTENT_URI, PHONE_ID_PROJECTION,
null, "exists (select _id from default_directory)");
}
@@ -127,7 +129,7 @@ public class SqlInjectionDetectionTest extends BaseContactsProvider2Test {
mResolver.delete(Contacts.CONTENT_URI, ";delete from contacts;--", null);
});
assertThrows(IllegalArgumentException.class, () -> {
- mResolver.delete(Contacts.CONTENT_URI, "_id in default_directory", null);
+ mResolver.delete(Contacts.CONTENT_URI, "_id in data_usage_stat", null);
});
}
@@ -136,7 +138,7 @@ public class SqlInjectionDetectionTest extends BaseContactsProvider2Test {
mResolver.update(Data.CONTENT_URI, cv(), ";delete from contacts;--", null);
});
assertThrows(IllegalArgumentException.class, () -> {
- mResolver.update(Data.CONTENT_URI, cv(), "_id in default_directory", null);
+ mResolver.update(Data.CONTENT_URI, cv(), "_id in data_usage_stat", null);
});
assertThrows(IllegalArgumentException.class, () -> {
mResolver.update(Data.CONTENT_URI, cv("_id/**/", 1), null, null);