Skip to content

Paprika model and metrics

Geoffrey Hecht edited this page Aug 20, 2014 · 20 revisions

This page describes the properties and metrics collected by Paprika and stored in the graph model.

Model entities

The model is composed of 6 main entities with attached properties. In the graph database each entity (excepting modifier) is represented by a node and the properties are attached to this node. In the java source code they are available in the package paprika.entities.

App (Java : PaprikaApp)

Represents an analyzed application. Most of the properties are metadatas which are passed are parameters to launch the analysis.

name (Java : name)

Application name on the store.

app_key (Java : key)

Unique identifier of an application, allowing multiple version of an application to be stored without conflict. This value is the sha256 sum of the apk. It is calculated by Paprika but it should be passed as a parameter when launching the analyze to ensure that the good package is analyzed. The app_key is added to every type of node of an application to facilitate queries.

rating (Java : rating)

Application rating on the market, represented by a double between 0 and 5.

date_download (Java : date)

Format : yyyy-mm-dd hh:mm:ss.S Download date of the package in prevision of the analysis.

date_analysis

Format : yyyy-mm-dd hh:mm:ss.S Date of the analysis. Not present in the analysis but added as a graph Properties at the end of the analysis/

package (Java : pack)

Name of the main application package, used as an identifier in the play store.

size (Java : size)

APK size in byte.

developer (Java : developer)

Name of the application developer.

category (Java : category)

Category of the application on the play store. Possible values are : APP_WALLPAPER, BOOKS_AND_REFERENCE, BUSINESS, COMICS, COMMUNICATION, EDUCATION, ENTERTAINMENT, FINANCE, GAME, HEALTH_AND_FITNESS, LIBRARIES_AND_DEMO, LIFESTYLE, MEDIA_AND_VIDEO, MEDICAL, MUSIC_AND_AUDIO, NEWS_AND_MAGAZINES, PERSONALIZATION, PHOTOGRAPHY, PRODUCTIVITY, SHOPPING, SOCIAL, SPORTS, TOOLS, TRANSPORTATION, TRAVEL_AND_LOCAL, WEATHER.

price (Java : price)

Price of the application the store, default value is "Free".

nb_download (Java : nbDownload)

Number of downloads of the application of the store. Formatted like 10000+,10+...

Class (Java : PaprikaClass)

Represents a class of the analyzed application. Java and Android library classes are excluded (but considered during the analysis).

name (Java : name)

Class name including package, e.g. com.example.MyClass . The name could be different from source code due to obfuscation.

app_key (Java : key)

Similar to app_key properties of PaprikaApp.

modifier (Java : modifier)

Java Access Level. See PaprikaModifiers

parent_name

Name of the parent class, default is java.lang.Object.

Variable (Java : PaprikaVariable)

Represents a class variable. The name could be different from source code due to obfuscation.

name (Java : name)

Application name on the store.

app_key (Java : key)

Similar to app_key properties of PaprikaApp.

modifier (Java : modifier)

Java Access Level. See PaprikaModifiers

type

Java type of the variable with package, default is java.lang.Object.

Method (Java : PaprikaMethod)

Represents a method of a class. The name could be different from source code due to obfuscation.

name (Java : name)

Method name. Constructors are identified by

app_key (Java : key)

Similar to app_key properties of PaprikaApp.

modifier (Java : modifier)

Java Access Level. See PaprikaModifiers

full_name

Name of a method and it's owning class, formatted as name#class_name.

return_type

Return type of the function, can be void, a java type or an object.

Argument (Java : PaprikaArgument)

Represents an argument of a method/

name (Java : name)

/!\ The name is not available in the bytecode, thus here it is the type of the argument.

app_key (Java : key)

Similar to app_key properties of PaprikaApp.

position

Position of the argument in the method signature, starting at 1.

PaprikaModifier ( Only present in Java, does not appears as a node)

Enum for Java Access Level, can be public, protected or private. Attached as a property to the relevant nodes in the graph (Class, Method and variable).

Relationships between entities

Nodes are connected to each other via oriented relationship to from a graph. Each application are representend by independant subgraph. The following list describes the different of relationship. In the java source code they are available in the package paprika.neo4J.

APP_OWNS_CLASS

Relationship from App to Class. Used to determined to which application a class belongs.

CLASS_OWNS_METHOD

Relationship from Class to Method. Used to determined to which class a method belongs.

CLASS_OWNS_VARIABLE

Relationship from Class to Variable. Used to determined to which class a variable belongs.

METHOD_OWNS_ARGUMENT

Relationship from Argument to Method. Used to determined to which method an argument belongs.

EXTENDS

Relationship from Class to Class. Java and Android library class are not considered. Determine inheritance between two classes.

IMPLEMENTS

Relationship from Class to Class. Used when a class implements an interface.

CALLS

Relationship from Method to Method. Used when a method call another method in at least one of its execution path. Multiple calls to the same method will result to only one relationship.

USES

Relationship from Method to Variable. Used when a method read or write into a class variable in at least one of its execution path. Multiple usage will be represented by an unique relationship.

Metrics

All the metrics are attached to a node as properties. They are extracted or computed from the apk, most of them are integers but some are boolean used to distinguish specific classes. In the java source code they are available in the package paprika.metrics.

App (Java : PaprikaApp)

number_of_classes (Java : NumberOfClasses)

Type : Integer Total number of classes in the application.

number_of_interfaces (Java : NumberOfInterfaces)

Type : Integer Total number of interfaces in the application.

number_of_abstract_classes (Java : NumberOfAbstractClasses)

Type : Integer Total number of abstract classes in the application.

number_of_activities (Java : NumberOfActivities)

Type : Integer - Specific to Android Total number of classes extending android.app.Activity.

number_of_broadcast_receivers (Java : NumberOfBroadcastReceivers)

Type : Integer - Specific to Android Total number of classes extending android.content.BroadcastReceiver.

number_of_content_providers (Java : NumberOfContentProviders)

Type : Integer - Specific to Android Total number of classes extending android.content.ContentProvider

number_of_services (Java : NumberOfServices)

Type : Integer - Specific to Android Total number of classes extending android.app.Service.

Class (Java : PaprikaClass)

number_of_methods (Java : NumberOfMethods)

Type : Integer Number of methods of the class.

depth_of_inheritance (Java : DepthOfInheritance)

Type : Integer Depth of Inheritance, starting at 1 since classes are at least java.lang.Object.

number_of_implemented_interfaces (Java : NumberOfImplementedInterfaces)

Type : Integer Number of interfaces implemented by the class.

number_of_attributes (Java : NumberOfAttributes)

Type : Integer Number of public, privated or protected attributes of the class.

number_of_children (Java : NumberOfChildren)

Type : Integer Number of class extending the current class.

class_complexity (Java : ClassComplexity)

Class complexity is the sum of all methods complexity of the class. Type : Integer

coupling_between_object_classes (Java : CouplingBetweenObjects)

Type : Integer Also know as CBO. Defined by Chidamber & Kemerer. CBO represents the number of other classes a class is coupled to. This metrics is calculated from the callgraph and it counts the reference to methods, variables or types once for each class.

lack_of_cohesion_in_methods (Java : LackofCohesionInMethods)

Type : Integer Also know as LCOM2. Defined by Chidamber & Kemerer. Determined how the methods of a class are related to each others.

is_abstract (Java : IsAbstract)

Type : Boolean True if the class is abstract.

is_activity (Java : IsActivity)

Type : Boolean - Specific to Android True if the class inherits from android.app.Activity.

is_application (Java : IsApplication)

Type : Boolean - Specific to Android True if the class inherits from android.app.Application.

is_broadcast_receiver (Java : IsBroadcastReceiver)

Type : Boolean - Specific to Android True if the class inherits from android.content.BroadcastReceiver.

is_content_provider (Java : IsContentProvider)

Type : Boolean - Specific to Android True if the class inherits from android.content.ContentProvider.

is_service (Java : IsService)

Type : Boolean - Specific to Android True if the class inherits from android.app.Service.

is_final (Java : IsFinal)

Type : Boolean True is the class is final.

is_static (Java : IsStatic)

Type : Boolean True is the class is static.

is_inner_class (Java : IsInnerClass)

Type : Boolean True is the class is an inner class. The class name will also contains a $.

is_interface (Java : IsInterface)

Type : Boolean True is the class is an interface.

Variable (Java : PaprikaVariable)

is_static (Java : IsStatic)

True if the variable is static. Type : Boolean

is_final (Java : IsFinal)

True if the variable is final. Type : Boolean

Method (Java : PaprikaMethod)

number_of_parameters (Java : NumberOfParameters)

Type : Integer Numbers of parameters required by the method.

number_of_declared_locals (Java : NumberOfDeclaredLocals)

Type : Integer Numbers of locals used by the method. Can be higher that the source code number since it's extracted from the bytecode.

number_of_instructions (Java : NumberOfInstructions)

Numbers of instructions used by the method. Can be higher that the source code number of line since it's extracted from the bytecode. Type : Integer

number_of_direct_calls (Java : NumberOfDirectCalls)

Numbers of calls to another methods, library methods included. Type : Integer

number_of_callers (Java : NumberOfCallers)

Numbers of calls made to this methods by other methods. Type : Integer

cyclomatic_complexity (Java : CyclomaticComplexity)

McCabe cyclomatic complexity. Represents the number of execution path inside a method. Minimum is one, the number is incremented for each branche detected in the body of a method. Type : Integer

is_abstract (Java : IsAbstract)

True if the method is abstract. Type : Boolean

is_final (Java : IsFinal)

True if the method is final. Type : Boolean

is_static (Java : IsStatic)

True if the method is static. Type : Boolean

is_getter (Java : IsGetter)

True if the method is a getter. The detection is not based on the method name since obfuscation and developer pratice could make false positive or true negative. Instead a getter is detected by looking at the number of instructions, the return type , the number of exceptions and the accessed variable. Only simple getter (no condition or computation) are considered. Type : Boolean

is_setter (Java : IsSetter)

Type : Boolean True if the method is a setter. The detection is not based on the method name since obfuscation and developer pratice could make false positive or true negative. Instead a setter is detected by looking at the number of instructions, the return type, the number of exceptions and the accessed variable. Only simple setter (no condition or computation) are considered.

is_synchronized (Java : IsSynchronized)

Type : Boolean True if the method is synchronized.

Argument (Java : PaprikaArgument)

Yet, there is no metrics attached to arguments.

Clone this wiki locally