|
1 | 1 | import java |
| 2 | +import Android |
2 | 3 |
|
| 4 | +/** |
| 5 | + * The class `android.database.sqlite.SQLiteDatabase`. |
| 6 | + */ |
3 | 7 | class TypeSQLiteDatabase extends Class { |
4 | 8 | TypeSQLiteDatabase() { hasQualifiedName("android.database.sqlite", "SQLiteDatabase") } |
5 | 9 | } |
6 | 10 |
|
| 11 | +/** |
| 12 | + * The class `android.database.sqlite.SQLiteQueryBuilder`. |
| 13 | + */ |
| 14 | +class TypeSQLiteQueryBuilder extends Class { |
| 15 | + TypeSQLiteQueryBuilder() { hasQualifiedName("android.database.sqlite", "SQLiteQueryBuilder") } |
| 16 | +} |
| 17 | + |
| 18 | +/** |
| 19 | + * The class `android.database.DatabaseUtils`. |
| 20 | + */ |
| 21 | +class TypeDatabaseUtils extends Class { |
| 22 | + TypeDatabaseUtils() { hasQualifiedName("android.database", "DatabaseUtils") } |
| 23 | +} |
| 24 | + |
7 | 25 | abstract class SQLiteRunner extends Method { |
8 | 26 | abstract int sqlIndex(); |
9 | 27 | } |
10 | 28 |
|
11 | | -class ExecSqlMethod extends SQLiteRunner { |
| 29 | +private class ExecSqlMethod extends SQLiteRunner { |
12 | 30 | ExecSqlMethod() { |
13 | 31 | this.getDeclaringType() instanceof TypeSQLiteDatabase and |
14 | | - this.getName() = "execSql" |
| 32 | + // execPerConnectionSQL(String sql, Object[] bindArgs) |
| 33 | + // execSQL(String sql) |
| 34 | + // execSQL(String sql, Object[] bindArgs) |
| 35 | + this.hasName(["execPerConnectionSQL", "execSQL"]) |
15 | 36 | } |
16 | 37 |
|
17 | 38 | override int sqlIndex() { result = 0 } |
18 | 39 | } |
19 | 40 |
|
20 | | -class QueryMethod extends SQLiteRunner { |
| 41 | +private class QueryMethod extends SQLiteRunner { |
21 | 42 | QueryMethod() { |
22 | 43 | this.getDeclaringType() instanceof TypeSQLiteDatabase and |
23 | | - this.getName().matches("rawQuery%") |
| 44 | + this.hasName(["query", "queryWithFactory"]) |
24 | 45 | } |
25 | 46 |
|
26 | 47 | override int sqlIndex() { |
| 48 | + // query(boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) |
| 49 | + // query(boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit, CancellationSignal cancellationSignal) |
| 50 | + // query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) |
| 51 | + // query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy) |
27 | 52 | this.getName() = "query" and |
28 | | - (if this.getParameter(0).getType() instanceof TypeString then result = 2 else result = 3) |
| 53 | + ( |
| 54 | + if this.getParameter(0).getType() instanceof TypeString |
| 55 | + then result = [0, 1, 2, 4, 5, 6, 7] |
| 56 | + else result = [1, 2, 3, 5, 6, 7, 8] |
| 57 | + ) |
29 | 58 | or |
30 | | - this.getName() = "queryWithFactory" and result = 4 |
| 59 | + // queryWithFactory(SQLiteDatabase.CursorFactory cursorFactory, boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit, CancellationSignal cancellationSignal) |
| 60 | + // queryWithFactory(SQLiteDatabase.CursorFactory cursorFactory, boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) |
| 61 | + this.getName() = "queryWithFactory" and result = [2, 3, 4, 6, 7, 8, 9] |
31 | 62 | } |
32 | 63 | } |
33 | 64 |
|
34 | | -class RawQueryMethod extends SQLiteRunner { |
| 65 | +private class RawQueryMethod extends SQLiteRunner { |
35 | 66 | RawQueryMethod() { |
36 | 67 | this.getDeclaringType() instanceof TypeSQLiteDatabase and |
37 | | - this.getName().matches("rawQuery%") |
| 68 | + this.hasName(["rawQuery", "rawQueryWithFactory"]) |
38 | 69 | } |
39 | 70 |
|
40 | 71 | override int sqlIndex() { |
| 72 | + // rawQuery(String sql, String[] selectionArgs, CancellationSignal cancellationSignal) |
| 73 | + // rawQuery(String sql, String[] selectionArgs) |
41 | 74 | this.getName() = "rawQuery" and result = 0 |
42 | 75 | or |
| 76 | + // rawQueryWithFactory(SQLiteDatabase.CursorFactory cursorFactory, String sql, String[] selectionArgs, String editTable, CancellationSignal cancellationSignal) |
| 77 | + // rawQueryWithFactory(SQLiteDatabase.CursorFactory cursorFactory, String sql, String[] selectionArgs, String editTable) |
43 | 78 | this.getName() = "rawQueryWithFactory" and result = 1 |
44 | 79 | } |
45 | 80 | } |
| 81 | + |
| 82 | +private class CompileStatementMethod extends SQLiteRunner { |
| 83 | + CompileStatementMethod() { |
| 84 | + this.getDeclaringType() instanceof TypeSQLiteDatabase and |
| 85 | + // compileStatement(String sql) |
| 86 | + this.hasName("compileStatement") |
| 87 | + } |
| 88 | + |
| 89 | + override int sqlIndex() { result = 0 } |
| 90 | +} |
| 91 | + |
| 92 | +private class DeleteMethod extends SQLiteRunner { |
| 93 | + DeleteMethod() { |
| 94 | + this.getDeclaringType() instanceof TypeSQLiteDatabase and |
| 95 | + // delete(String table, String whereClause, String[] whereArgs) |
| 96 | + this.hasName("delete") |
| 97 | + } |
| 98 | + |
| 99 | + override int sqlIndex() { result = 1 } |
| 100 | +} |
| 101 | + |
| 102 | +private class UpdateMethod extends SQLiteRunner { |
| 103 | + UpdateMethod() { |
| 104 | + this.getDeclaringType() instanceof TypeSQLiteDatabase and |
| 105 | + // update(String table, ContentValues values, String whereClause, String[] whereArgs) |
| 106 | + // updateWithOnConflict(String table, ContentValues values, String whereClause, String[] whereArgs, int conflictAlgorithm) |
| 107 | + this.hasName(["update", "updateWithOnConflict"]) |
| 108 | + } |
| 109 | + |
| 110 | + override int sqlIndex() { result = 2 } |
| 111 | +} |
| 112 | + |
| 113 | +private class ForQueryMethod extends SQLiteRunner { |
| 114 | + ForQueryMethod() { |
| 115 | + // (blobFileDescriptor|long|string)ForQuery(SQLiteDatabase db, String query, String[] selectionArgs) |
| 116 | + this.getDeclaringType() instanceof TypeDatabaseUtils and |
| 117 | + this.hasName(["blobFileDescriptorForQuery", "longForQuery", "stringForQuery"]) and |
| 118 | + this.getNumberOfParameters() = 3 |
| 119 | + } |
| 120 | + |
| 121 | + override int sqlIndex() { result = 1 } |
| 122 | +} |
| 123 | + |
| 124 | +private class CreateDbFromSqlStatementsMethod extends SQLiteRunner { |
| 125 | + CreateDbFromSqlStatementsMethod() { |
| 126 | + // createDbFromSqlStatements(Context context, String dbName, int dbVersion, String sqlStatements) |
| 127 | + this.getDeclaringType() instanceof TypeDatabaseUtils and |
| 128 | + this.hasName("createDbFromSqlStatements") |
| 129 | + } |
| 130 | + |
| 131 | + override int sqlIndex() { result = 3 } |
| 132 | +} |
| 133 | + |
| 134 | +private class QueryNumEntriesMethod extends SQLiteRunner { |
| 135 | + QueryNumEntriesMethod() { |
| 136 | + // queryNumEntries(SQLiteDatabase db, String table, String selection) |
| 137 | + // queryNumEntries(SQLiteDatabase db, String table, String selection, String[] selectionArgs) |
| 138 | + this.getDeclaringType() instanceof TypeDatabaseUtils and |
| 139 | + this.hasName("queryNumEntries") |
| 140 | + } |
| 141 | + |
| 142 | + override int sqlIndex() { result = 2 } |
| 143 | +} |
| 144 | + |
| 145 | +private class QueryBuilderDeleteMethod extends SQLiteRunner { |
| 146 | + QueryBuilderDeleteMethod() { |
| 147 | + // delete(SQLiteDatabase db, String selection, String[] selectionArgs) |
| 148 | + this.getDeclaringType().getASourceSupertype*() instanceof TypeSQLiteQueryBuilder and |
| 149 | + this.hasName("delete") |
| 150 | + } |
| 151 | + |
| 152 | + override int sqlIndex() { result = [-1, 1] } |
| 153 | +} |
| 154 | + |
| 155 | +private class QueryBuilderInsertMethod extends SQLiteRunner { |
| 156 | + QueryBuilderInsertMethod() { |
| 157 | + // insert(SQLiteDatabase db, ContentValues values) |
| 158 | + this.getDeclaringType().getASourceSupertype*() instanceof TypeSQLiteQueryBuilder and |
| 159 | + this.hasName("insert") |
| 160 | + } |
| 161 | + |
| 162 | + override int sqlIndex() { result = -1 } |
| 163 | +} |
| 164 | + |
| 165 | +private class QueryBuilderQueryMethod extends SQLiteRunner { |
| 166 | + QueryBuilderQueryMethod() { |
| 167 | + // query(SQLiteDatabase db, String[] projectionIn, String selection, String[] selectionArgs, String groupBy, String having, String sortOrder) |
| 168 | + // query(SQLiteDatabase db, String[] projectionIn, String selection, String[] selectionArgs, String groupBy, String having, String sortOrder, String limit) |
| 169 | + // query(SQLiteDatabase db, String[] projectionIn, String selection, String[] selectionArgs, String groupBy, String having, String sortOrder, String limit, CancellationSignal cancellationSignal) |
| 170 | + this.getDeclaringType().getASourceSupertype*() instanceof TypeSQLiteQueryBuilder and |
| 171 | + this.hasName("query") |
| 172 | + } |
| 173 | + |
| 174 | + override int sqlIndex() { result = [-1, 2, 4, 5, 6, 7] } |
| 175 | +} |
| 176 | + |
| 177 | +private class QueryBuilderUpdateMethod extends SQLiteRunner { |
| 178 | + QueryBuilderUpdateMethod() { |
| 179 | + // update(SQLiteDatabase db, ContentValues values, String selection, String[] selectionArgs) |
| 180 | + this.getDeclaringType().getASourceSupertype*() instanceof TypeSQLiteQueryBuilder and |
| 181 | + this.hasName("update") |
| 182 | + } |
| 183 | + |
| 184 | + override int sqlIndex() { result = [-1, 2] } |
| 185 | +} |
| 186 | + |
| 187 | +private class ContentProviderDeleteMethod extends SQLiteRunner { |
| 188 | + ContentProviderDeleteMethod() { |
| 189 | + // delete(Uri uri, String selection, String[] selectionArgs) |
| 190 | + ( |
| 191 | + this.getDeclaringType() instanceof AndroidContentProvider or |
| 192 | + this.getDeclaringType() instanceof AndroidContentResolver |
| 193 | + ) and |
| 194 | + this.hasName("delete") and |
| 195 | + this.getNumberOfParameters() = 3 |
| 196 | + } |
| 197 | + |
| 198 | + override int sqlIndex() { result = 1 } |
| 199 | +} |
| 200 | + |
| 201 | +private class ContentProviderQueryMethod extends SQLiteRunner { |
| 202 | + ContentProviderQueryMethod() { |
| 203 | + // query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) |
| 204 | + // query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) |
| 205 | + ( |
| 206 | + this.getDeclaringType() instanceof AndroidContentProvider or |
| 207 | + this.getDeclaringType() instanceof AndroidContentResolver |
| 208 | + ) and |
| 209 | + this.hasName("query") and |
| 210 | + this.getNumberOfParameters() = [5, 6] |
| 211 | + } |
| 212 | + |
| 213 | + override int sqlIndex() { result = 2 } |
| 214 | +} |
| 215 | + |
| 216 | +private class ContentProviderUpdateMethod extends SQLiteRunner { |
| 217 | + ContentProviderUpdateMethod() { |
| 218 | + // update(Uri uri, ContentValues values, String selection, String[] selectionArgs) |
| 219 | + ( |
| 220 | + this.getDeclaringType() instanceof AndroidContentProvider or |
| 221 | + this.getDeclaringType() instanceof AndroidContentResolver |
| 222 | + ) and |
| 223 | + this.hasName("update") and |
| 224 | + this.getNumberOfParameters() = 4 |
| 225 | + } |
| 226 | + |
| 227 | + override int sqlIndex() { result = 2 } |
| 228 | +} |
0 commit comments