Enums

Enum class definitions that can be used as choices within Django models or as enum values. Note that all classes of this module inherit the StringEnum class, which acts as a string if you use special methods like ==, !=, str(x) and hash(x).

class mastf.MASTF.utils.enum.StringEnum(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

A custom enumeration that allows for the use of string values as enum members.

It extends the built-in ‘Enum’ class in Python and overrides several methods to provide additional functionality. To use this class, simply inherit from the StringEnum class and define class members with string values.

For example:

enum.py
1class MyEnum(StringEnum):
2    FOO = "foo"
3    BAR = "bar"
4    BAZ = "baz"

You can then use the enum members like any other enum member, including comparing them with strings:

>>> MyEnum.FOO == "foo"
True
>>> MyEnum.BAR != "qux"
True
>>> str(MyEnum.BAZ)
'baz'

Note that you can still use the usual comparison operators (<, <=, >, >=) with StringEnum members, but they will be compared based on their order of definition in the class, not their string values.

Hint

You can use the class attribute choices within definitions of Django database models to restrict the amount of accepted values. Note also, that the static field won’t be added if you place your enum in other files than /mastf/MASTF/utils/enum.py.

>>> MyEnum.choices
[('foo', 'foo'), ('bar', 'bar'), ('baz', 'baz')]

Other Enum Classes

class mastf.MASTF.utils.enum.HostType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Intended to be used to categorize the type of connection an app has made.

INVALID = 'Invalid'

Represents an invalid or erroneous connection.

MALWARE = 'Malware'

Represents a connection made to a known malware domain.

NOT_SET = 'Not Set'

Represents a connection for which the type has not been set or cannot be determined.

OK = 'Ok'

Represents a connection made to a safe and trusted domain.

TRACKER = 'Tracker'

Represents a connection made to a tracking service.

class mastf.MASTF.utils.enum.DataProtectionLevel(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Represents the different levels of data protection that can be applied to transmitted data.

PRIVATE = 'Private'

Represents data that is intended to be kept private and confidential.

PUBLIC = 'Public'

Represents data that can be freely shared with others.

class mastf.MASTF.utils.enum.ProtectionLevel(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

The ProtectionLevel class represents different permission protection levels that are used in the Android permission system to protect user privacy and security. (Android Protection Levels)

APPOP = 'Appop'

Used for permissions that are granted to AppOps services.

APP_PREDICTOR = 'AppPredictor'

Used for permissions that are granted to app prediction services.

COMPANION = 'Companion'

Used for permissions that are granted to companion devices.

CONFIGURATOR = 'Configurator'

Used for permissions that are granted to app configurator services.

DANGEROUS = 'Dangerous'

Used for dangerous permissions that have to be approved by a user.

DEVELOPMENT = 'Development'

Used for permissions that are granted to development tools and features.

INCIDENTREPORTAPPROVER = 'IncidentReportApprover'

Used for permissions that are granted to incident report approver services.

INSTALLER = 'Installer'

Used for permissions that are granted to app installer services.

INSTANT = 'Instant'

Used for permissions that are granted to instant apps.

INTERNAL = 'Internal'

Used for permissions that are granted to internal system components and apps.

KNOWNSIGNER = 'KnownSigner'

Used for permissions that are granted to apps signed with a known signature.

MODULE = 'Module'

Used for permissions that are granted to dynamic feature modules.

NORMAL = 'Normal'

Used for normal permissions that don’t pose a significant risk to user privacy and security.

OEM = 'OEM'

Used for permissions that are granted to OEM-specific apps and features.

PRE23 = 'Pre23'

Used for permissions that were introduced in Android 6.0 (API level 23) or earlier.

PREINSTALLED = 'Preinstalled'

Used for permissions that are granted to preinstalled system apps.

PRIVILEGED = 'Privileged'

Used for permissions that are granted to privileged system apps.

RECENTS = 'Recents'

Used for permissions that are granted to the recents screen.

RETAILDEMO = 'RetailDemo'

Used for permissions that are granted to retail demo apps.

ROLE = 'Role'

Used for permissions that are granted to app roles.

RUNTIME = 'Runtime'

Used for permissions that are granted at runtime.

SETUP = 'Setup'

Used for permissions that are granted to setup services.

SIGNATURE = 'Signature'

A permission that the system is to grant only if the requesting application is signed with the same certificate as the application that declared the permission.

SIGNATUREORSYSTEM = 'SignatureOrSystem'

Old synonym for signature|privileged. Deprecated in API level 23.

SYSTEM = 'System'

Used for permissions that are granted to system components.

TEXTCLASSIFIER = 'TextClassifier'

Used for permissions that are granted to text classification services.

VENDORPRIVILEGED = 'VendorPrivileged'

Used for permissions that are granted to vendor-specific apps and features.

VERIFIER = 'Verifier'

Used for permissions that are granted to package verifier services.

static colors() dict[source]

Returns protection levels categorized into three groups.

Returns:

categorized protection level groups.

Return type:

dict