androlyze.storage.importdb package¶
Submodules¶
androlyze.storage.importdb.ImportDatabaseStorage module¶
-
class
androlyze.storage.importdb.ImportDatabaseStorage.
ImportDatabaseStorage
(import_db_name)[source]¶ Bases:
object
,androlyze.storage.ImportStorageInterface.ImportStorageInterface
,androlyze.storage.importdb.ImportQueryInterface.ImportQueryInterface
Database for importing apks based on sqlite3 to have flat file databases which can be passed as arguments to AndroLyzeLab.
This class implements the ImportQueryInterface for providing the information about the imported apks.
The base error for the database is DatabaseException and for retrieving information it’s ImportQueryError.
See ImportQueryInterface.
Attributes
Methods
-
ADD_COLUMN_APP_CODE_SIZE
= 'ALTER TABLE apk_import ADD COLUMN size_app_code INTEGER DEFAULT 0'¶
-
ADD_COLUMN_BUILD_DATE
= 'ALTER TABLE apk_import ADD COLUMN build_date timestamp NOT NULL'¶
-
CREATE_STMT
= ' CREATE TABLE IF NOT EXISTS apk_import (\n hash TEXT PRIMARY KEY NOT NULL UNIQUE,\n package_name TEXT NOT NULL,\n version_name TEXT NOT NULL,\n path TEXT NOT NULL,\n import_date timestamp NOT NULL,\n tag TEXT,\n size_app_code INTEGER DEFAULT 0,\n build_date timestamp NOT NULL\n )'¶
-
DELETE_STMT
= ' DELETE FROM apk_import WHERE hash = ?'¶
-
INSERT_STMT
= ' INSERT INTO apk_import(hash, package_name, version_name, path, import_date, tag, size_app_code, build_date)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?)'¶
-
TIMEOUT
= 60¶
-
UPDATE_STMT
= ' UPDATE apk_import SET package_name = ?, version_name = ?, path = ?, import_date = ?, tag = ?, size_app_code = ?, build_date = ? WHERE hash = ?\n '¶
-
conn
¶ sqlite3.Connection : The established connection to the database
-
contains
(apk)[source]¶ Check if the apk has been imported yet.
Parameters: apk: Apk Returns: bool Raises: DatabaseStoreException
-
create_entry_for_apk
(apk, update=False, tag=None)[source]¶ Create entry for a single apk.
Parameters: apk : Apk
update : bool, optional (default is False)
Update an apk that has already been imported.
tag : str, optional (default is None)
Tag the apk with some text.
Raises: DatabaseStoreException
-
db_name
¶ str : Name of the database to use.
-
delete_entry_for_apk
(apk, delete_apk=False)[source]¶ Delete the apk from the database.
Parameters: apk: Apk
delete_apk : boolean, optional (default is False)
Not recognized.
Raises: DatabaseDeleteException
-
get_apk_paths
(hashes=None, package_names=None, tags=None)[source]¶ Get the paths of the imported apks.
Parameters: hashes : iterable<str>, optional (default is None)
package_names : iterable<str>, optional (default is None)
tags : iterable<str>, optional (default is None)
Returns: generator<str>
Raises: ImportQueryError
-
androlyze.storage.importdb.ImportQueryInterface module¶
-
class
androlyze.storage.importdb.ImportQueryInterface.
ImportQueryInterface
[source]¶ Interface for querying the import database. All methods may raise an ImportQueryError in the case of an error.
- Filtering can be done via some of these properties (in this order):
- hashes package names tags
Only one of the filter arguments will be used!
Methods
-
get_apk_hashes
(package_names=None, tags=None)[source]¶ Get the imported hashes (sorted by package name and version). If neither package_names nor tags are given, return all hashes.
Only one of the filter arguments will be used.
Preferred order is: package_names, tags.
Parameters: package_names : iterable<str>, optional (default is None)
The package names for which to get the hash(es). If not given, return all hashes.
tags : iterable<str>, optional (default is None)
Returns: generator<str>
Raises: ImportQueryError
-
get_apk_package_names
(hashes=None, tags=None)[source]¶ Get the package names.
Parameters: hashes : iterable<str>, optional (default is None)
tags : iterable<str>, optional (default is None)
Filter package names which have one of the specified tags. If not given, don’t filter at all.
Returns: generator<str>
Raises: ImportQueryError
-
get_apk_paths
(hashes=None, package_names=None, tags=None)[source]¶ Get the paths of the imported apks.
Parameters: hashes : iterable<str>, optional (default is None)
package_names : iterable<str>, optional (default is None)
tags : iterable<str>, optional (default is None)
Returns: generator<str>
Raises: ImportQueryError
-
get_imported_apks
(hashes=None, package_names=None, tags=None, **kwargs)[source]¶ Get the imported Apk`s (sorted by package name and version). If neither `hashes nor package_names nor tags are given, return all imported `Apk`s.
Only one of the filter arguments will be used.
Preferred order is: hashes, package_names, tags.
Parameters: hashes : iterable<str>, optional (default is None)
package_names : iterable<str>, optional (default is None)
tags : iterable<str>, optional (default is None)
Returns: generator<FastApk>
Other Parameters: order_by : str, optional (default is None)
Means order by package name. Has to be one of the keys in TABLE_APK_IMPORT_KEYS.
ascending : bool, optional (default is True)
Sort ascending.
Raises: ImportQueryError
-
get_versions
(hashes=None, package_names=None, tags=None)[source]¶ Get the imported versions.
Parameters: hashes : iterable<str>, optional (default is None)
package_names : iterable<str>, optional (default is None)
tags : iterable<str>, optional (default is None)
Returns: generator<str>
Raises: ImportQueryError