code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def _properties_changed(self,
object_path,
interface_name,
changed_properties,
invalidated_properties):
"""
Internal method.
Called when a DBusProperty of any managed object changes.
... |
Internal method.
Called when a DBusProperty of any managed object changes.
| _properties_changed | python | coldfix/udiskie | udiskie/udisks2.py | https://github.com/coldfix/udiskie/blob/master/udiskie/udisks2.py | MIT |
def _job_completed(self, job_name, success, message):
"""
Internal method.
Called when a job of a long running task completes.
"""
job = self._objects[job_name][Interface['Job']]
action = self._action_by_operation.get(job['Operation'])
if not action:
... |
Internal method.
Called when a job of a long running task completes.
| _job_completed | python | coldfix/udiskie | udiskie/udisks2.py | https://github.com/coldfix/udiskie/blob/master/udiskie/udisks2.py | MIT |
def send_messages(self, request, queryset, bulk=False):
"""
Provides error handling for DeviceAdmin send_message and send_bulk_message methods.
"""
ret = []
errors = []
r = ""
for device in queryset:
try:
if bulk:
r = queryset.send_message("Test bulk notification")
else:
r = device.s... |
Provides error handling for DeviceAdmin send_message and send_bulk_message methods.
| send_messages | python | jazzband/django-push-notifications | push_notifications/admin.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/admin.py | MIT |
def apns_send_message(registration_id, alert, application_id=None, creds=None, **kwargs):
"""
Sends an APNS notification to a single registration_id.
This will send the notification as form data.
If sending multiple notifications, it is more efficient to use
apns_send_bulk_message()
Note that if set alert should... |
Sends an APNS notification to a single registration_id.
This will send the notification as form data.
If sending multiple notifications, it is more efficient to use
apns_send_bulk_message()
Note that if set alert should always be a string. If it is not set,
it won"t be included in the notification. You will nee... | apns_send_message | python | jazzband/django-push-notifications | push_notifications/apns.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/apns.py | MIT |
def apns_send_bulk_message(
registration_ids, alert, application_id=None, creds=None, **kwargs
):
"""
Sends an APNS notification to one or more registration_ids.
The registration_ids argument needs to be a list.
Note that if set alert should always be a string. If it is not set,
it won"t be included in the notif... |
Sends an APNS notification to one or more registration_ids.
The registration_ids argument needs to be a list.
Note that if set alert should always be a string. If it is not set,
it won"t be included in the notification. You will need to pass None
to this for silent notifications.
| apns_send_bulk_message | python | jazzband/django-push-notifications | push_notifications/apns.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/apns.py | MIT |
def apns_send_message(
registration_id: str,
alert: Union[str, Alert],
application_id: str = None,
creds: Credentials = None,
topic: str = None,
badge: int = None,
sound: str = None,
content_available: bool = None,
extra: dict = {},
expiration: int = None,
thread_id: str = None,
loc_key: str = None,
priori... |
Sends an APNS notification to a single registration_id.
If sending multiple notifications, it is more efficient to use
apns_send_bulk_message()
Note that if set alert should always be a string. If it is not set,
it won"t be included in the notification. You will need to pass None
to this for silent notification... | apns_send_message | python | jazzband/django-push-notifications | push_notifications/apns_async.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/apns_async.py | MIT |
def apns_send_bulk_message(
registration_ids: list[str],
alert: Union[str, Alert],
application_id: str = None,
creds: Credentials = None,
topic: str = None,
badge: int = None,
sound: str = None,
content_available: bool = None,
extra: dict = {},
expiration: int = None,
thread_id: str = None,
loc_key: str = N... |
Sends an APNS notification to one or more registration_ids.
The registration_ids argument needs to be a list.
Note that if set alert should always be a string. If it is not set,
it won"t be included in the notification. You will need to pass None
to this for silent notifications.
:param registration_ids: A lis... | apns_send_bulk_message | python | jazzband/django-push-notifications | push_notifications/apns_async.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/apns_async.py | MIT |
def get_prep_value(self, value):
""" Return the integer value to be stored from the hex string """
if value is None or value == "":
return None
if isinstance(value, str):
value = _hex_string_to_unsigned_integer(value)
if _using_signed_storage():
value = _unsigned_to_signed_integer(value)
return value | Return the integer value to be stored from the hex string | get_prep_value | python | jazzband/django-push-notifications | push_notifications/fields.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/fields.py | MIT |
def from_db_value(self, value, *args):
""" Return an unsigned int representation from all db backends """
if value is None:
return value
if _using_signed_storage():
value = _signed_to_unsigned_integer(value)
return value | Return an unsigned int representation from all db backends | from_db_value | python | jazzband/django-push-notifications | push_notifications/fields.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/fields.py | MIT |
def to_python(self, value):
""" Return a str representation of the hexadecimal """
if isinstance(value, str):
return value
if value is None:
return value
return _unsigned_integer_to_hex_string(value) | Return a str representation of the hexadecimal | to_python | python | jazzband/django-push-notifications | push_notifications/fields.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/fields.py | MIT |
def dict_to_fcm_message(data: dict, dry_run=False, **kwargs) -> messaging.Message:
"""
Constructs a messaging.Message from the old dictionary.
FCM_NOTIFICATION_PAYLOAD_KEYS are being put into the AndroidNotification
FCM_OPTIONS_KEYS are being put into the AndroidConfig
FCM_TARGETS_KEYS is mapped to either topic, ... |
Constructs a messaging.Message from the old dictionary.
FCM_NOTIFICATION_PAYLOAD_KEYS are being put into the AndroidNotification
FCM_OPTIONS_KEYS are being put into the AndroidConfig
FCM_TARGETS_KEYS is mapped to either topic, token or condition
If dry_run is included and its value is True, no message will be r... | dict_to_fcm_message | python | jazzband/django-push-notifications | push_notifications/gcm.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/gcm.py | MIT |
def _chunks(l, n):
"""
Yield successive chunks from list \a l with a maximum size \a n
"""
for i in range(0, len(l), n):
yield l[i:i + n] |
Yield successive chunks from list l with a maximum size n
| _chunks | python | jazzband/django-push-notifications | push_notifications/gcm.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/gcm.py | MIT |
def send_message(
registration_ids,
message: messaging.Message,
application_id=None,
dry_run=False,
**kwargs
):
"""
Sends an FCM notification to one or more registration_ids. The registration_ids
can be a list or a single string.
:param registration_ids: A list of registration ids or a single string
:param m... |
Sends an FCM notification to one or more registration_ids. The registration_ids
can be a list or a single string.
:param registration_ids: A list of registration ids or a single string
:param message: The Message object, use `dict_to_fcm_message` to convert dict to Message
:param application_id: The application ... | send_message | python | jazzband/django-push-notifications | push_notifications/gcm.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/gcm.py | MIT |
def _wns_authenticate(scope="notify.windows.com", application_id=None):
"""
Requests an Access token for WNS communication.
:return: dict: {'access_token': <str>, 'expires_in': <int>, 'token_type': 'bearer'}
"""
client_id = get_manager().get_wns_package_security_id(application_id)
client_secret = get_manager().g... |
Requests an Access token for WNS communication.
:return: dict: {'access_token': <str>, 'expires_in': <int>, 'token_type': 'bearer'}
| _wns_authenticate | python | jazzband/django-push-notifications | push_notifications/wns.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/wns.py | MIT |
def _wns_send(uri, data, wns_type="wns/toast", application_id=None):
"""
Sends a notification data and authentication to WNS.
:param uri: str: The device's unique notification URI
:param data: dict: The notification data to be sent.
:return:
"""
access_token = _wns_authenticate(application_id=application_id)
... |
Sends a notification data and authentication to WNS.
:param uri: str: The device's unique notification URI
:param data: dict: The notification data to be sent.
:return:
| _wns_send | python | jazzband/django-push-notifications | push_notifications/wns.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/wns.py | MIT |
def _wns_prepare_toast(data, **kwargs):
"""
Creates the xml tree for a `toast` notification
:param data: dict: The notification data to be converted to an xml tree.
{
"text": ["Title text", "Message Text", "Another message!"],
"image": ["src1", "src2"],
}
:return: str
"""
root = ET.Element("toast")
visu... |
Creates the xml tree for a `toast` notification
:param data: dict: The notification data to be converted to an xml tree.
{
"text": ["Title text", "Message Text", "Another message!"],
"image": ["src1", "src2"],
}
:return: str
| _wns_prepare_toast | python | jazzband/django-push-notifications | push_notifications/wns.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/wns.py | MIT |
def wns_send_message(
uri, message=None, xml_data=None, raw_data=None, application_id=None, **kwargs
):
"""
Sends a notification request to WNS.
There are four notification types that WNS can send: toast, tile, badge and raw.
Toast, tile, and badge can all be customized to use different
templates/icons/sounds/lau... |
Sends a notification request to WNS.
There are four notification types that WNS can send: toast, tile, badge and raw.
Toast, tile, and badge can all be customized to use different
templates/icons/sounds/launch params/etc.
See docs for more information:
https://msdn.microsoft.com/en-us/library/windows/apps/br2128... | wns_send_message | python | jazzband/django-push-notifications | push_notifications/wns.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/wns.py | MIT |
def wns_send_bulk_message(
uri_list, message=None, xml_data=None, raw_data=None, application_id=None, **kwargs
):
"""
WNS doesn't support bulk notification, so we loop through each uri.
:param uri_list: list: A list of uris the notification will be sent to.
:param message: str: The notification data to be sent.
... |
WNS doesn't support bulk notification, so we loop through each uri.
:param uri_list: list: A list of uris the notification will be sent to.
:param message: str: The notification data to be sent.
:param xml_data: dict: A dictionary containing data to be converted to an xml tree.
:param raw_data: str: Data to be s... | wns_send_bulk_message | python | jazzband/django-push-notifications | push_notifications/wns.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/wns.py | MIT |
def dict_to_xml_schema(data):
"""
Input a dictionary to be converted to xml. There should be only one key at
the top level. The value must be a dict with (required) `children` key and
(optional) `attrs` key. This will be called the `sub-element dictionary`.
The `attrs` value must be a dictionary; each value will ... |
Input a dictionary to be converted to xml. There should be only one key at
the top level. The value must be a dict with (required) `children` key and
(optional) `attrs` key. This will be called the `sub-element dictionary`.
The `attrs` value must be a dictionary; each value will be added to the
element's xml tag... | dict_to_xml_schema | python | jazzband/django-push-notifications | push_notifications/wns.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/wns.py | MIT |
def _add_sub_elements_from_dict(parent, sub_dict):
"""
Add SubElements to the parent element.
:param parent: ElementTree.Element: The parent element for the newly created SubElement.
:param sub_dict: dict: Used to create a new SubElement. See `dict_to_xml_schema`
method docstring for more information. e.g.:
{"e... |
Add SubElements to the parent element.
:param parent: ElementTree.Element: The parent element for the newly created SubElement.
:param sub_dict: dict: Used to create a new SubElement. See `dict_to_xml_schema`
method docstring for more information. e.g.:
{"example": {
"attrs": {
"key1": "value1",
...
... | _add_sub_elements_from_dict | python | jazzband/django-push-notifications | push_notifications/wns.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/wns.py | MIT |
def _add_element_attrs(elem, attrs):
"""
Add attributes to the given element.
:param elem: ElementTree.Element: The element the attributes are being added to.
:param attrs: dict: A dictionary of attributes. e.g.:
{"attribute1": "value", "attribute2": "another"}
:return: ElementTree.Element
"""
for attr, value... |
Add attributes to the given element.
:param elem: ElementTree.Element: The element the attributes are being added to.
:param attrs: dict: A dictionary of attributes. e.g.:
{"attribute1": "value", "attribute2": "another"}
:return: ElementTree.Element
| _add_element_attrs | python | jazzband/django-push-notifications | push_notifications/wns.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/wns.py | MIT |
def _validate_apns_certificate(self, certfile):
"""Validate the APNS certificate at startup."""
try:
with open(certfile) as f:
content = f.read()
check_apns_certificate(content)
except Exception as e:
raise ImproperlyConfigured(
"The APNS certificate file at {!r} is not readable: {}".format(cer... | Validate the APNS certificate at startup. | _validate_apns_certificate | python | jazzband/django-push-notifications | push_notifications/conf/app.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/conf/app.py | MIT |
def _validate_allowed_settings(self, application_id, application_config, allowed_settings):
"""Confirm only allowed settings are present."""
for setting_key in application_config.keys():
if setting_key not in allowed_settings:
raise ImproperlyConfigured(
"Platform {}, app {} does not support the settin... | Confirm only allowed settings are present. | _validate_allowed_settings | python | jazzband/django-push-notifications | push_notifications/conf/app.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/conf/app.py | MIT |
def _validate_required_settings(
self, application_id, application_config, required_settings,
should_throw=True
):
"""All required keys must be present"""
for setting_key in required_settings:
if setting_key not in application_config.keys():
if should_throw:
raise ImproperlyConfigured(
MISSI... | All required keys must be present | _validate_required_settings | python | jazzband/django-push-notifications | push_notifications/conf/app.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/conf/app.py | MIT |
def _get_application_settings(self, application_id, platform, settings_key):
"""
Walks through PUSH_NOTIFICATIONS_SETTINGS to find the correct setting value
or raises ImproperlyConfigured.
"""
if not application_id:
conf_cls = "push_notifications.conf.AppConfig"
raise ImproperlyConfigured(
"{} requ... |
Walks through PUSH_NOTIFICATIONS_SETTINGS to find the correct setting value
or raises ImproperlyConfigured.
| _get_application_settings | python | jazzband/django-push-notifications | push_notifications/conf/app.py | https://github.com/jazzband/django-push-notifications/blob/master/push_notifications/conf/app.py | MIT |
def test_application_id_required(self):
"""Using AppConfig without an application_id raises ImproperlyConfigured."""
manager = AppConfig()
with self.assertRaises(ImproperlyConfigured):
manager._get_application_settings(None, None, None) | Using AppConfig without an application_id raises ImproperlyConfigured. | test_application_id_required | python | jazzband/django-push-notifications | tests/test_app_config.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_app_config.py | MIT |
def test_application_not_found(self):
"""
Using AppConfig with an application_id that does not exist raises
ImproperlyConfigured.
"""
application_id = "my_fcm_app"
manager = AppConfig()
with self.assertRaises(ImproperlyConfigured):
manager._get_application_settings(application_id, "FCM", "API_KEY") |
Using AppConfig with an application_id that does not exist raises
ImproperlyConfigured.
| test_application_not_found | python | jazzband/django-push-notifications | tests/test_app_config.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_app_config.py | MIT |
def test_platform_configured(self):
"""
Using AppConfig with an application config that does not define PLATFORM
raises ImproperlyConfigured.
"""
application_id = "my_fcm_app"
PUSH_SETTINGS = {
"APPLICATIONS": {
application_id: {}
}
}
with self.assertRaises(ImproperlyConfigured):
AppConfi... |
Using AppConfig with an application config that does not define PLATFORM
raises ImproperlyConfigured.
| test_platform_configured | python | jazzband/django-push-notifications | tests/test_app_config.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_app_config.py | MIT |
def test_platform_invalid(self):
"""
Using AppConfig with an invalid platform raises ImproperlyConfigured.
"""
application_id = "my_fcm_app"
PUSH_SETTINGS = {
"APPLICATIONS": {
application_id: {
"PLATFORM": "XXX"
}
}
}
with self.assertRaises(ImproperlyConfigured):
AppConfig(PUSH_SE... |
Using AppConfig with an invalid platform raises ImproperlyConfigured.
| test_platform_invalid | python | jazzband/django-push-notifications | tests/test_app_config.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_app_config.py | MIT |
def test_platform_invalid_setting(self):
"""
Fetching application settings for the wrong platform raises ImproperlyConfigured.
"""
application_id = "my_fcm_app"
PUSH_SETTINGS = {
"APPLICATIONS": {
application_id: {
"PLATFORM": "FCM",
}
}
}
manager = AppConfig(PUSH_SETTINGS)
with se... |
Fetching application settings for the wrong platform raises ImproperlyConfigured.
| test_platform_invalid_setting | python | jazzband/django-push-notifications | tests/test_app_config.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_app_config.py | MIT |
def test_validate_apns_config(self):
"""
Verify the settings for APNS platform.
"""
path = os.path.join(os.path.dirname(__file__), "test_data", "good_revoked.pem")
#
# all settings specified, required and optional, does not raise an error.
#
PUSH_SETTINGS = {
"APPLICATIONS": {
"my_apns_app": {
... |
Verify the settings for APNS platform.
| test_validate_apns_config | python | jazzband/django-push-notifications | tests/test_app_config.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_app_config.py | MIT |
def test_get_allowed_settings_fcm(self):
"""Verify the settings allowed for FCM platform."""
#
# all settings specified, required and optional, does not raise an error.
#
PUSH_SETTINGS = {
"APPLICATIONS": {
"my_fcm_app": {
"PLATFORM": "FCM",
"MAX_RECIPIENTS": "...",
"FIREBASE_APP": "...... | Verify the settings allowed for FCM platform. | test_get_allowed_settings_fcm | python | jazzband/django-push-notifications | tests/test_app_config.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_app_config.py | MIT |
def test_get_allowed_settings_wns(self):
"""
Verify the settings allowed for WNS platform.
"""
# all settings specified, required and optional, does not raise an error.
PUSH_SETTINGS = {
"APPLICATIONS": {
"my_wns_app": {
"PLATFORM": "WNS",
"PACKAGE_SECURITY_ID": "...",
"SECRET_KEY": "..... |
Verify the settings allowed for WNS platform.
| test_get_allowed_settings_wns | python | jazzband/django-push-notifications | tests/test_app_config.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_app_config.py | MIT |
def test_payload_keys(self):
"""
old FCM_NOTIFICATIONS_PAYLOAD_KEYS payload is mapped to message object correctly
"""
payload = {
"message": "Hello World",
"title": "Title",
"body": "Body",
"icon": "Icon",
"image": "Image",
"sound": "Sound",
"badge": "10",
"color": "Color",
"tag": "Ta... |
old FCM_NOTIFICATIONS_PAYLOAD_KEYS payload is mapped to message object correctly
| test_payload_keys | python | jazzband/django-push-notifications | tests/test_dict_to_message.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_dict_to_message.py | MIT |
def test_fcm_options(self):
"""
old FCM_OPTIONS_KEYS payload is mapped to message object correctly
"""
payload = {
"message": "Hello World",
"collapse_key": "Collapse Key",
"priority": "High",
"time_to_live": 3600,
"restricted_package_name": "restricted.package.name",
}
message = dict_to_fc... |
old FCM_OPTIONS_KEYS payload is mapped to message object correctly
| test_fcm_options | python | jazzband/django-push-notifications | tests/test_dict_to_message.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_dict_to_message.py | MIT |
def test_clean_valid_values(self):
"""Passing valid values returns the expected output."""
f = HexadecimalField()
for valid, expected in self._VALID_HEX_VALUES.items():
self.assertEqual(expected, f.clean(valid)) | Passing valid values returns the expected output. | test_clean_valid_values | python | jazzband/django-push-notifications | tests/test_fields.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_fields.py | MIT |
def test_registration_id_unique(self):
"""Validate that a duplicate registration id raises a validation error."""
# add a device
serializer = GCMDeviceSerializer(data={
"registration_id": "foobar",
"name": "Galaxy Note 3",
"device_id": "0x1031af3b",
"application_id": "XXXXXXXXXXXXXXXXXXXX",
})
se... | Validate that a duplicate registration id raises a validation error. | test_registration_id_unique | python | jazzband/django-push-notifications | tests/test_rest_framework.py | https://github.com/jazzband/django-push-notifications/blob/master/tests/test_rest_framework.py | MIT |
def get_default_session() -> Session:
"""
Return the default [Session][androguard.session.Session] from the configuration
or create a new one, if the session in the configuration is `None`.
:returns: `androguard.session.Session` object
"""
if androconf.CONF["SESSION"] is None:
androconf... |
Return the default [Session][androguard.session.Session] from the configuration
or create a new one, if the session in the configuration is `None`.
:returns: `androguard.session.Session` object
| get_default_session | python | androguard/androguard | androguard/misc.py | https://github.com/androguard/androguard/blob/master/androguard/misc.py | Apache-2.0 |
def AnalyzeAPK(
_file: Union[str, bytes],
session: Union[Session, None] = None,
raw: bool = False,
) -> tuple[apk.APK, list[dex.DEX], Analysis]:
"""
Analyze an android application and setup all stuff for a more quickly
analysis!
If session is `None`, no session is used at all. This is the de... |
Analyze an android application and setup all stuff for a more quickly
analysis!
If session is `None`, no session is used at all. This is the default
behaviour.
If you like to continue your work later, it might be a good idea to use a
session.
A default session can be created by using [get_d... | AnalyzeAPK | python | androguard/androguard | androguard/misc.py | https://github.com/androguard/androguard/blob/master/androguard/misc.py | Apache-2.0 |
def AnalyzeDex(
filename: str, session: Session = None, raw: bool = False
) -> tuple[str, dex.DEX, Analysis]:
"""
Analyze an android dex file and setup all stuff for a more quickly analysis !
:param filename: the filename of the android dex file or a buffer which represents the dex file
:param sess... |
Analyze an android dex file and setup all stuff for a more quickly analysis !
:param filename: the filename of the android dex file or a buffer which represents the dex file
:param session: A session (Default `None`)
:param raw: If set, `filenam`` will be used as the odex's data (bytes). Defaults to `... | AnalyzeDex | python | androguard/androguard | androguard/misc.py | https://github.com/androguard/androguard/blob/master/androguard/misc.py | Apache-2.0 |
def clean_file_name(
filename: str,
unique: bool = True,
replace: str = "_",
force_nt: bool = False,
) -> str:
"""
Return a filename version, which has no characters in it which are forbidden.
On Windows these are for example <, /, ?, ...
The intention of this function is to allow distr... |
Return a filename version, which has no characters in it which are forbidden.
On Windows these are for example <, /, ?, ...
The intention of this function is to allow distribution of files to different OSes.
:param filename: string to clean
:param unique: check if the filename is already taken an... | clean_file_name | python | androguard/androguard | androguard/misc.py | https://github.com/androguard/androguard/blob/master/androguard/misc.py | Apache-2.0 |
def __init__(
self,
export_ipython: bool = False,
db_url: str = 'sqlite:///androguard.db',
) -> None:
"""
Create a new Session object
:param export_ipython: set to True in order to create attributes for the
use in iPython
"""
self._setup_objec... |
Create a new Session object
:param export_ipython: set to True in order to create attributes for the
use in iPython
| __init__ | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def show(self) -> None:
"""
Print information to stdout about the current session.
Gets all APKs, all DEX files and all Analysis objects.
"""
print("APKs in Session: {}".format(len(self.analyzed_apk)))
for d, a in self.analyzed_apk.items():
print("\t{}: {}".fo... |
Print information to stdout about the current session.
Gets all APKs, all DEX files and all Analysis objects.
| show | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def addAPK(self, filename: str, data: bytes) -> tuple[str, apk.APK]:
"""
Add an APK file to the Session and run analysis on it.
:param filename: (file)name of APK file
:param data: binary data of the APK file
:return: a tuple of SHA256 Checksum and APK Object
"""
... |
Add an APK file to the Session and run analysis on it.
:param filename: (file)name of APK file
:param data: binary data of the APK file
:return: a tuple of SHA256 Checksum and APK Object
| addAPK | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def addDEX(
self,
filename: str,
data: bytes,
dx: Union[Analysis, None] = None,
postpone_xref: bool = False,
) -> tuple[str, dex.DEX, Analysis]:
"""
Add a DEX file to the Session and run analysis.
:param filename: the (file)name of the DEX file
... |
Add a DEX file to the Session and run analysis.
:param filename: the (file)name of the DEX file
:param data: binary data of the dex file
:param dx: an existing `Analysis` Object (optional)
:param postpone_xref: True if no xref shall be created, and will be called manually
... | addDEX | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def addODEX(
self, filename: str, data: bytes, dx: Union[Analysis, None] = None
) -> tuple[str, dex.ODEX, Analysis]:
"""
Add an ODEX file to the session and run the analysis
:param filename: the ODEX filename
:param data: the ODEX bytes
:param dx: the `Analysis` obje... |
Add an ODEX file to the session and run the analysis
:param filename: the ODEX filename
:param data: the ODEX bytes
:param dx: the `Analysis` object to add the ODEX to
:returns: a tuple containing the SHA256 digest, the new `dex.ODEX` object, and the `Analysis` it is contained ... | addODEX | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def add(
self,
filename: str,
raw_data: Union[bytes, None] = None,
dx: Union[Analysis, None] = None,
) -> Union[str, None]:
"""
Generic method to add a file to the session.
This is the main method to use when adding files to a Session!
If an APK file... |
Generic method to add a file to the session.
This is the main method to use when adding files to a Session!
If an APK file is supplied, all DEX files are analyzed too.
For DEX and ODEX files, only this file is analyzed (what else should be
analyzed).
Returns the SHA25... | add | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def get_classes(
self,
) -> Iterator[tuple[int, str, str, list[dex.ClassDefItem]]]:
"""
Returns all Java Classes from the DEX objects as an array of DEX files.
:returns: an iterator where each element is a tuple containing the index of the `Analysis` object, the filename containing ... |
Returns all Java Classes from the DEX objects as an array of DEX files.
:returns: an iterator where each element is a tuple containing the index of the `Analysis` object, the filename containing the class (ODEX, DEX), the SHA256 digest of the `Analysis` object, and a list of `CalssDefItem`
| get_classes | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def get_analysis(self, current_class: dex.ClassDefItem) -> Analysis:
"""
Returns the [Analysis][androguard.core.analysis.analysis.Analysis] object
which contains the `current_class`.
:param current_class: The class to search for
:returns: the `androguard.core.analysis.analysis.A... |
Returns the [Analysis][androguard.core.analysis.analysis.Analysis] object
which contains the `current_class`.
:param current_class: The class to search for
:returns: the `androguard.core.analysis.analysis.Analysis` object
| get_analysis | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def get_filename_by_class(
self, current_class: dex.ClassDefItem
) -> Union[str, None]:
"""
Returns the filename of the DEX file where the class is in.
Returns the first filename this class was present.
For example, if you analyzed an APK, this should return the filename of
... |
Returns the filename of the DEX file where the class is in.
Returns the first filename this class was present.
For example, if you analyzed an APK, this should return the filename of
the APK and not of the DEX file.
:param current_class: `ClassDefItem`
:returns: `None`... | get_filename_by_class | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def get_digest_by_class(
self, current_class: dex.ClassDefItem
) -> Union[str, None]:
"""
Return the SHA256 hash of the object containing the [ClassDefItem][androguard.core.dex.ClassDefItem]
Returns the first digest this class was present.
For example, if you analyzed an APK... |
Return the SHA256 hash of the object containing the [ClassDefItem][androguard.core.dex.ClassDefItem]
Returns the first digest this class was present.
For example, if you analyzed an APK, this should return the digest of
the APK and not of the DEX file.
| get_digest_by_class | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def get_strings(
self,
) -> Iterator[tuple[str, str, dict[str, StringAnalysis]]]:
"""
Yields all [StringAnalysis][androguard.core.analysis.analysis.StringAnalysis] for all unique [Analysis][androguard.core.analysis.analysis.Analysis] objects
:returns: an iterator of `StringAnalysis`... |
Yields all [StringAnalysis][androguard.core.analysis.analysis.StringAnalysis] for all unique [Analysis][androguard.core.analysis.analysis.Analysis] objects
:returns: an iterator of `StringAnalysis` objects
| get_strings | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def get_nb_strings(self) -> int:
"""
Return the total number of strings in all [Analysis][androguard.core.analysis.analysis.Analysis] objects
:returns: the number of strings
"""
nb = 0
seen = []
for digest, dx in self.analyzed_vms.items():
if dx in se... |
Return the total number of strings in all [Analysis][androguard.core.analysis.analysis.Analysis] objects
:returns: the number of strings
| get_nb_strings | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def get_all_apks(self) -> Iterator[tuple[str, apk.APK]]:
"""
Yields a list of tuples of SHA256 hash of the APK and [APK][androguard.core.apk.APK] objects
of all analyzed APKs in the Session.
:returns: an iterator where each element is a tuple of sha256 of the APK, and the `APK` object
... |
Yields a list of tuples of SHA256 hash of the APK and [APK][androguard.core.apk.APK] objects
of all analyzed APKs in the Session.
:returns: an iterator where each element is a tuple of sha256 of the APK, and the `APK` object
| get_all_apks | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def get_objects_apk(
self,
filename: Union[str, None] = None,
digest: Union[str, None] = None,
) -> Iterator[tuple[apk.APK, list[dex.DEX], Analysis]]:
"""
Returns [APK][androguard.core.apk.APK], list of [DEX][androguard.core.dex.DEX], and [Analysis][androguard.core.analysis.a... |
Returns [APK][androguard.core.apk.APK], list of [DEX][androguard.core.dex.DEX], and [Analysis][androguard.core.analysis.analysis.Analysis] of a specified APK.
You must specify either `filename` or `digest`.
It is possible to use both, but in this case only `digest` is used.
Example:
... | get_objects_apk | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def get_objects_dex(self) -> Iterator[tuple[str, dex.DEX, Analysis]]:
"""
Yields all [DEX][androguard.core.dex.DEX] objects including their [Analysis][androguard.core.analysis.analysis.Analysis] objects
:returns: tuple of (sha256, DEX, Analysis)
"""
# TODO: there is no variant l... |
Yields all [DEX][androguard.core.dex.DEX] objects including their [Analysis][androguard.core.analysis.analysis.Analysis] objects
:returns: tuple of (sha256, DEX, Analysis)
| get_objects_dex | python | androguard/androguard | androguard/session.py | https://github.com/androguard/androguard/blob/master/androguard/session.py | Apache-2.0 |
def set_log(level:str) -> None:
"""
Sets the log for loguru based on the level being passed.
The possible string values are:
* `TRACE`
* `DEBUG`
* `INFO`
* `SUCCESS`
* `WARNING`
* `ERROR`
* `CRITICAL`
:param level: the log level string
"""
logger.remove(0)
... |
Sets the log for loguru based on the level being passed.
The possible string values are:
* `TRACE`
* `DEBUG`
* `INFO`
* `SUCCESS`
* `WARNING`
* `ERROR`
* `CRITICAL`
:param level: the log level string
| set_log | python | androguard/androguard | androguard/util.py | https://github.com/androguard/androguard/blob/master/androguard/util.py | Apache-2.0 |
def calculate_fingerprint(key_object):
"""
Calculates a SHA-256 fingerprint of the public key based on its components.
:param key_object: A keys.PublicKeyInfo object containing the parsed public key
:return: The fingerprint of the public key as a byte string
"""
to_hash = None
# RSA Publi... |
Calculates a SHA-256 fingerprint of the public key based on its components.
:param key_object: A keys.PublicKeyInfo object containing the parsed public key
:return: The fingerprint of the public key as a byte string
| calculate_fingerprint | python | androguard/androguard | androguard/util.py | https://github.com/androguard/androguard/blob/master/androguard/util.py | Apache-2.0 |
def axml(input_, output, file_, resource):
"""
Parse the AndroidManifest.xml.
Parsing is either direct or from a given APK and prints in XML format or
saves to file.
This tool can also be used to process any AXML encoded file, for example
from the layout directory.
Example:
>>> a... |
Parse the AndroidManifest.xml.
Parsing is either direct or from a given APK and prints in XML format or
saves to file.
This tool can also be used to process any AXML encoded file, for example
from the layout directory.
Example:
>>> androguard axml AndroidManifest.xml
| axml | python | androguard/androguard | androguard/cli/cli.py | https://github.com/androguard/androguard/blob/master/androguard/cli/cli.py | Apache-2.0 |
def arsc(
input_,
file_,
output,
package,
locale,
type_,
id_,
list_packages,
list_locales,
list_types,
):
"""
Decode resources.arsc either directly from a given file or from an APK.
Example:
>>> androguard arsc app.apk
"""
from androguard.core impor... |
Decode resources.arsc either directly from a given file or from an APK.
Example:
>>> androguard arsc app.apk
| arsc | python | androguard/androguard | androguard/cli/cli.py | https://github.com/androguard/androguard/blob/master/androguard/cli/cli.py | Apache-2.0 |
def decompile(input_, file_, output, format_, jar, limit, decompiler):
"""
Decompile an APK and create Control Flow Graphs.
Example:
>>> androguard resources.arsc
"""
from androguard import session
if file_ and input_:
print(
"Can not give --input and positional ar... |
Decompile an APK and create Control Flow Graphs.
Example:
>>> androguard resources.arsc
| decompile | python | androguard/androguard | androguard/cli/cli.py | https://github.com/androguard/androguard/blob/master/androguard/cli/cli.py | Apache-2.0 |
def apkid(apks: list[str]):
"""Prints the packageName/versionCode/versionName per APK as JSON.
:param apks: list of apk filepaths
"""
from androguard.core.apk import get_apkid
logger.debug("APKID")
results = dict()
for apk in apks:
results[apk] = get_apkid(apk)
print(json.... | Prints the packageName/versionCode/versionName per APK as JSON.
:param apks: list of apk filepaths
| apkid | python | androguard/androguard | androguard/cli/cli.py | https://github.com/androguard/androguard/blob/master/androguard/cli/cli.py | Apache-2.0 |
def cg(
file_,
output,
output_type,
show,
classname,
methodname,
descriptor,
accessflag,
no_isolated,
):
"""
Create a call graph based on the data of Analysis and export it into a graph format.
"""
import matplotlib.pyplot as plt
from androguard.core.analysis.ana... |
Create a call graph based on the data of Analysis and export it into a graph format.
| cg | python | androguard/androguard | androguard/cli/cli.py | https://github.com/androguard/androguard/blob/master/androguard/cli/cli.py | Apache-2.0 |
def androlyze_main(session: Session, filename: str) -> None:
"""
Start an interactive shell
:param session: Session file to load
:param filename: File to analyze, can be APK or DEX (or ODEX)
"""
import atexit
import colorama
from colorama import Fore
from IPython.terminal.embed imp... |
Start an interactive shell
:param session: Session file to load
:param filename: File to analyze, can be APK or DEX (or ODEX)
| androlyze_main | python | androguard/androguard | androguard/cli/main.py | https://github.com/androguard/androguard/blob/master/androguard/cli/main.py | Apache-2.0 |
def shutdown_hook() -> None:
"""Save the session on exit, if wanted"""
if not s.isOpen():
return
try:
res = input("Do you want to save the session? (y/[n])?").lower()
except (EOFError, KeyboardInterrupt):
pass
else:
if res == "y":
... | Save the session on exit, if wanted | shutdown_hook | python | androguard/androguard | androguard/cli/main.py | https://github.com/androguard/androguard/blob/master/androguard/cli/main.py | Apache-2.0 |
def is_ascii_problem(s: str) -> bool:
"""
Test if a string contains other chars than ASCII
:param s: a string to test
:returns: `True` if string contains other chars than ASCII, `False` otherwise
"""
try:
# As MUTF8Strings are actually bytes, we can simply check if they are ASCII or not... |
Test if a string contains other chars than ASCII
:param s: a string to test
:returns: `True` if string contains other chars than ASCII, `False` otherwise
| is_ascii_problem | python | androguard/androguard | androguard/core/androconf.py | https://github.com/androguard/androguard/blob/master/androguard/core/androconf.py | Apache-2.0 |
def __init__(self) -> None:
"""
A Wrapper for the CONF object
This creates a singleton, which has the same attributes everywhere.
"""
if not Configuration.instance:
Configuration.instance = default_conf |
A Wrapper for the CONF object
This creates a singleton, which has the same attributes everywhere.
| __init__ | python | androguard/androguard | androguard/core/androconf.py | https://github.com/androguard/androguard/blob/master/androguard/core/androconf.py | Apache-2.0 |
def is_android(filename: str) -> str:
"""
Return the type of the file
:param filename: the filename
:returns: "APK", "DEX", None
"""
if not filename:
return None
with open(filename, "rb") as fd:
f_bytes = fd.read()
return is_android_raw(f_bytes) |
Return the type of the file
:param filename: the filename
:returns: "APK", "DEX", None
| is_android | python | androguard/androguard | androguard/core/androconf.py | https://github.com/androguard/androguard/blob/master/androguard/core/androconf.py | Apache-2.0 |
def is_android_raw(raw: bytes) -> str:
"""
Returns a string that describes the type of file, for common Android
specific formats
:param raw: the file bytes to check
:returns: the type of file
"""
val = None
# We do not check for META-INF/MANIFEST.MF,
# as you also want to analyze u... |
Returns a string that describes the type of file, for common Android
specific formats
:param raw: the file bytes to check
:returns: the type of file
| is_android_raw | python | androguard/androguard | androguard/core/androconf.py | https://github.com/androguard/androguard/blob/master/androguard/core/androconf.py | Apache-2.0 |
def rrmdir(directory: str) -> None:
"""
Recursively delete a directory
:param directory: directory to remove
"""
for root, dirs, files in os.walk(directory, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(os.p... |
Recursively delete a directory
:param directory: directory to remove
| rrmdir | python | androguard/androguard | androguard/core/androconf.py | https://github.com/androguard/androguard/blob/master/androguard/core/androconf.py | Apache-2.0 |
def make_color_tuple(color: str) -> tuple[int, int, int]:
"""
turn something like `#000000` into `0,0,0`
or `#FFFFFF` into `255,255,255`
"""
R = color[1:3]
G = color[3:5]
B = color[5:7]
R = int(R, 16)
G = int(G, 16)
B = int(B, 16)
return R, G, B |
turn something like `#000000` into `0,0,0`
or `#FFFFFF` into `255,255,255`
| make_color_tuple | python | androguard/androguard | androguard/core/androconf.py | https://github.com/androguard/androguard/blob/master/androguard/core/androconf.py | Apache-2.0 |
def interpolate_tuple(
startcolor: tuple[int, int, int],
goalcolor: tuple[int, int, int],
steps: int,
) -> list[str]:
"""
Take two RGB color sets and mix them over a specified number of steps. Return the list
"""
# white
R = startcolor[0]
G = startcolor[1]
B = startcolor[2]
... |
Take two RGB color sets and mix them over a specified number of steps. Return the list
| interpolate_tuple | python | androguard/androguard | androguard/core/androconf.py | https://github.com/androguard/androguard/blob/master/androguard/core/androconf.py | Apache-2.0 |
def color_range(
startcolor: tuple[int, int, int],
goalcolor: tuple[int, int, int],
steps: int,
) -> list[str]:
"""
wrapper for interpolate_tuple that accepts colors as html (`#CCCCC` and such)
:param startcolor: the start RGB color tuple
:param goalcolor: the goal RGB color tuple
:para... |
wrapper for interpolate_tuple that accepts colors as html (`#CCCCC` and such)
:param startcolor: the start RGB color tuple
:param goalcolor: the goal RGB color tuple
:param steps: amount of steps
:returns: the interpolated RGB tuple
| color_range | python | androguard/androguard | androguard/core/androconf.py | https://github.com/androguard/androguard/blob/master/androguard/core/androconf.py | Apache-2.0 |
def load_api_specific_resource_module(
resource_name: str, api: Union[str, int, None] = None
) -> dict:
"""
Load the module from the JSON files and return a dict, which might be empty
if the resource could not be loaded.
If no api version is given, the default one from the CONF dict is used.
:... |
Load the module from the JSON files and return a dict, which might be empty
if the resource could not be loaded.
If no api version is given, the default one from the CONF dict is used.
:param resource_name: Name of the resource to load
:param api: API version
:raises InvalidResourceError: if ... | load_api_specific_resource_module | python | androguard/androguard | androguard/core/androconf.py | https://github.com/androguard/androguard/blob/master/androguard/core/androconf.py | Apache-2.0 |
def _colorize_operands(operands, colors):
"""
Return strings with color coded operands
"""
for operand in operands:
if operand[0] == Operand.REGISTER:
yield "{}v{}{}".format(
colors["registers"], operand[1], colors["normal"]
)
elif operand[0] == O... |
Return strings with color coded operands
| _colorize_operands | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def _get_operand_html(operand, registers_colors, colors):
"""
Return a HTML representation of the operand.
The HTML should be compatible with pydot/graphviz to be used
inside a node label.
This is solely used in [method2dot][androguard.core.bytecode.method2dot]
:param operand: tuple containing... |
Return a HTML representation of the operand.
The HTML should be compatible with pydot/graphviz to be used
inside a node label.
This is solely used in [method2dot][androguard.core.bytecode.method2dot]
:param operand: tuple containing the operand type and operands
:param register_colors: key: r... | _get_operand_html | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def method2dot(
mx: MethodAnalysis, colors: Union[dict[str, str], None] = None
) -> str:
"""
Export analysis method to dot format.
A control flow graph is created by using the concept of BasicBlocks.
Each BasicBlock is a sequence of opcode without any jumps or branch.
:param mx: `androguard.co... |
Export analysis method to dot format.
A control flow graph is created by using the concept of BasicBlocks.
Each BasicBlock is a sequence of opcode without any jumps or branch.
:param mx: `androguard.core.analysis.analysis.MethodAnalysis`
:param colors: dict of colors to use, if colors is `None` t... | method2dot | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def method2format(
output: str,
_format: str = "png",
mx: Union[MethodAnalysis, None] = None,
raw: Union[str, None] = None,
):
"""
Export method structure as a graph to a specific file format using dot from the graphviz package.
The result is written to the file specified via `output`.
... |
Export method structure as a graph to a specific file format using dot from the graphviz package.
The result is written to the file specified via `output`.
There are two possibilites to give input for this method:
1) use `raw` argument and pass a dictionary containing the keys
`name`, `nodes` and... | method2format | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def method2png(
output: str, mx: MethodAnalysis, raw: Union[str, None] = None
) -> None:
"""
Export method to a png file format
:param output: output filename
:param mx: specify the `MethodAnalysis` object
:param raw: use directly a dot raw buffer
"""
buff = raw
if not raw:
... |
Export method to a png file format
:param output: output filename
:param mx: specify the `MethodAnalysis` object
:param raw: use directly a dot raw buffer
| method2png | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def method2jpg(
output: str, mx: MethodAnalysis, raw: Union[str, None] = None
) -> None:
"""
Export method to a jpg file format
:param output: output filename
:param mx: specify the `MethodAnalysis` object
:param raw: use directly a dot raw buffer (optional)
"""
buff = raw
if not ra... |
Export method to a jpg file format
:param output: output filename
:param mx: specify the `MethodAnalysis` object
:param raw: use directly a dot raw buffer (optional)
| method2jpg | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def vm2json(vm: DEX) -> str:
"""
Get a JSON representation of a DEX file
:param vm: `androguard.core.dex.DEX` object
:returns: str
"""
d = {"name": "root", "children": []}
for _class in vm.get_classes():
c_class = {"name": _class.get_name(), "children": []}
for method in _... |
Get a JSON representation of a DEX file
:param vm: `androguard.core.dex.DEX` object
:returns: str
| vm2json | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def method2json(mx: MethodAnalysis, directed_graph: bool = False) -> str:
"""
Create directed or undirected graph in the json format.
:param mx: `androguard.core.analysis.analysis.MethodAnalysis`
:param directed_graph: `True` if a directed graph should be created (default: `False`)
:returns: json s... |
Create directed or undirected graph in the json format.
:param mx: `androguard.core.analysis.analysis.MethodAnalysis`
:param directed_graph: `True` if a directed graph should be created (default: `False`)
:returns: json str
| method2json | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def method2json_undirect(mx: MethodAnalysis) -> str:
"""
Create an undirected graph in the json format
:param mx: `androguard.core.analysis.analysis.MethodAnalysis`
:return: json str
"""
d = {}
reports = []
d["reports"] = reports
for DVMBasicMethodBlock in mx.basic_blocks.gets():
... |
Create an undirected graph in the json format
:param mx: `androguard.core.analysis.analysis.MethodAnalysis`
:return: json str
| method2json_undirect | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def method2json_direct(mx: MethodAnalysis) -> str:
"""
Create a directed graph in the json format
:param mx: `androguard.core.analysis.analysis.MethodAnalysis`
:returns: the method json string
"""
d = {}
reports = []
d["reports"] = reports
hooks = {}
l = []
for DVMBasicMet... |
Create a directed graph in the json format
:param mx: `androguard.core.analysis.analysis.MethodAnalysis`
:returns: the method json string
| method2json_direct | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def object_to_bytes(obj: Union[str, bool, int, bytearray]) -> bytearray:
"""
Convert a object to a bytearray or call `get_raw()` of the object
if no useful type was found.
:param obj: the object to convert
:returns: the bytes
"""
if isinstance(obj, str):
return bytearray(obj, "UTF-8... |
Convert a object to a bytearray or call `get_raw()` of the object
if no useful type was found.
:param obj: the object to convert
:returns: the bytes
| object_to_bytes | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def FormatClassToPython(i: str) -> str:
"""
Transform a typed class name into a form which can be used as a python
attribute
Example:
>>> FormatClassToPython('Lfoo/bar/foo/Barfoo$InnerClass;')
'Lfoo_bar_foo_Barfoo_InnerClass'
:param i: classname to transform
:returns: the form... |
Transform a typed class name into a form which can be used as a python
attribute
Example:
>>> FormatClassToPython('Lfoo/bar/foo/Barfoo$InnerClass;')
'Lfoo_bar_foo_Barfoo_InnerClass'
:param i: classname to transform
:returns: the formatted string
| FormatClassToPython | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def get_package_class_name(name: str) -> tuple[str, str]:
"""
Return package and class name in a java variant from a typed variant name.
If no package could be found, the package is an empty string.
If the name is an array type, the array is discarded.
Example:
>>> get_package_class_name... |
Return package and class name in a java variant from a typed variant name.
If no package could be found, the package is an empty string.
If the name is an array type, the array is discarded.
Example:
>>> get_package_class_name('Ljava/lang/Object;')
('java.lang', 'Object')
>>... | get_package_class_name | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def FormatNameToPython(i: str) -> str:
"""
Transform a (method) name into a form which can be used as a python
attribute
Example:
>>> FormatNameToPython('<clinit>')
'clinit'
:param i: name to transform
:returns: the transformed name
"""
i = i.replace("<", "")
i = ... |
Transform a (method) name into a form which can be used as a python
attribute
Example:
>>> FormatNameToPython('<clinit>')
'clinit'
:param i: name to transform
:returns: the transformed name
| FormatNameToPython | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def FormatDescriptorToPython(i: str) -> str:
"""
Format a descriptor into a form which can be used as a python attribute
Example:
>>> FormatDescriptorToPython('(Ljava/lang/Long; Ljava/lang/Long; Z Z)V')
'Ljava_lang_LongLjava_lang_LongZZV
:param i: name to transform
:returns: the f... |
Format a descriptor into a form which can be used as a python attribute
Example:
>>> FormatDescriptorToPython('(Ljava/lang/Long; Ljava/lang/Long; Z Z)V')
'Ljava_lang_LongLjava_lang_LongZZV
:param i: name to transform
:returns: the formatted descriptor string
| FormatDescriptorToPython | python | androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/master/androguard/core/bytecode.py | Apache-2.0 |
def get_basic_block(self, idx: int) -> Union[DEXBasicBlock,None]:
"""return the [DEXBasicBlock][androguard.core.analysis.analysis.DEXBasicBlock] at `idx`
:param idx: the index of the `DEXBasicBlock` to return
:return: the `DEXBasicBlock` or `None` if not found
"""
for i in self... | return the [DEXBasicBlock][androguard.core.analysis.analysis.DEXBasicBlock] at `idx`
:param idx: the index of the `DEXBasicBlock` to return
:return: the `DEXBasicBlock` or `None` if not found
| get_basic_block | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def __init__(
self,
start: int,
vm: dex.DEX,
method: dex.EncodedMethod,
context: BasicBlocks,
) -> None:
"""Initialize a new [DEXBasicBlock][androguard.core.analysis.analysis.DEXBasicBlock]
:param start: start address of the basic block
:param vm: `DE... | Initialize a new [DEXBasicBlock][androguard.core.analysis.analysis.DEXBasicBlock]
:param start: start address of the basic block
:param vm: `DEX` containing the basic block
:param method: `EncodedMethod` containing the basic block
:param context: `BasicBlocks` containing this basic bloc... | __init__ | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_instructions(self) -> Iterator[dex.Instruction]:
"""
Get all instructions from a basic block.
:returns: Return all instructions in the current basic block
"""
idx = 0
for i in self.method.get_instructions():
if self.start <= idx < self.end:
... |
Get all instructions from a basic block.
:returns: Return all instructions in the current basic block
| get_instructions | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_special_ins(self, idx: int) -> Union[dex.Instruction, None]:
"""
Return the associated instruction to a specific instruction (for example a packed/sparse switch)
:param idx: the index of the instruction
:returns: the associated `dex.Instruction`
"""
if idx in se... |
Return the associated instruction to a specific instruction (for example a packed/sparse switch)
:param idx: the index of the instruction
:returns: the associated `dex.Instruction`
| get_special_ins | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def __init__(self, vm: dex.DEX, method: dex.EncodedMethod) -> None:
"""Initialize new [MethodAnalysis][androguard.core.analysis.analysis.MethodAnalysis]
:param vm: the `dex.DEX` containing the method
:param method: the `dex.EncodedMethod` to wrap
"""
logger.debug(
"A... | Initialize new [MethodAnalysis][androguard.core.analysis.analysis.MethodAnalysis]
:param vm: the `dex.DEX` containing the method
:param method: the `dex.EncodedMethod` to wrap
| __init__ | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def _create_basic_block(self) -> None:
"""
Internal Method to create the basic block structure
Parses all instructions and exceptions.
"""
current_basic = DEXBasicBlock(
0, self.__vm, self.method, self.basic_blocks
)
self.basic_blocks.push(current_basi... |
Internal Method to create the basic block structure
Parses all instructions and exceptions.
| _create_basic_block | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_xref_read(
self, classobj: ClassAnalysis, fieldobj: FieldAnalysis, offset: int
) -> None:
"""
:param ClassAnalysis classobj:
:param FieldAnalysis fieldobj:
:param int offset: offset in the bytecode
"""
self.xrefread.add((classobj, fieldobj, offset)) |
:param ClassAnalysis classobj:
:param FieldAnalysis fieldobj:
:param int offset: offset in the bytecode
| add_xref_read | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_xref_to(
self, classobj: ClassAnalysis, methodobj: MethodAnalysis, offset: int
) -> None:
"""
Add a crossreference to another method
(this method calls another method)
"""
self.xrefto.add((classobj, methodobj, offset)) |
Add a crossreference to another method
(this method calls another method)
| add_xref_to | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_xref_from(
self, classobj: ClassAnalysis, methodobj: MethodAnalysis, offset: int
) -> None:
"""
Add a crossrefernece from another method
(this method is called by another method)
"""
self.xreffrom.add((classobj, methodobj, offset)) |
Add a crossrefernece from another method
(this method is called by another method)
| add_xref_from | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_xref_new_instance(
self, classobj: ClassAnalysis, offset: int
) -> None:
"""
Add a crossreference to another class that is
instanced within this method.
"""
self.xrefnewinstance.add((classobj, offset)) |
Add a crossreference to another class that is
instanced within this method.
| add_xref_new_instance | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def is_android_api(self) -> bool:
"""
Returns `True` if the method seems to be an Android API method.
This method might be not very precise unless an list of known API methods
is given.
:returns: `True` if the method seems to be an Android API method, else `False`
"""
... |
Returns `True` if the method seems to be an Android API method.
This method might be not very precise unless an list of known API methods
is given.
:returns: `True` if the method seems to be an Android API method, else `False`
| is_android_api | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.