-
Notifications
You must be signed in to change notification settings - Fork 3
SourcesSinksManager
SourcesSinksManager is a singleton manager class for managing source and sink methods in an Android application. It extends the FileLoader class and loads, stores, and provides access to source and sink methods, represented as sets of AndroidMethod objects.
SourcesSinksManager deals with source and sink methods within an Android application. It loads the sources and sinks from a file, processes their signatures, and categorizes them into corresponding sets.
This class follows the Singleton pattern, ensuring only one instance during the execution of the application. The instance can be accessed via the v() method.
Returns the singleton instance of SourcesSinksManager.
Loads source and sink methods from a given file.
-
Parameters:
file- The file containing the source and sink methods' signatures.
Returns the set of source methods.
-
Return Value: The set of
AndroidMethodobjects representing source methods.
Returns the set of sink methods.
-
Return Value: The set of
AndroidMethodobjects representing sink methods.
Override of the abstract method from FileLoader. Returns the file path for sources and sinks.
SourcesSinksManager manager = SourcesSinksManager.v();Given a file with the following content:
SOURCE|<android.telephony.TelephonyManager: java.lang.String getLine1Number()>
SINK|<android.util.Log: int d(java.lang.String,java.lang.String)>
You can load the sources and sinks as follows:
File file = new File("path/to/sources_and_sinks.txt");
manager.loadSourcesSinksFromFile(file);Set<AndroidMethod> sources = manager.getSources();
Set<AndroidMethod> sinks = manager.getSinks();Based on the loaded file, the sources set will include a method related to getting the line number from TelephonyManager, and the sinks set will include a method related to logging from the Log class:
for (AndroidMethod source : sources) {
System.out.println("Source: " + source.getSignature());
}
for (AndroidMethod sink : sinks) {
System.out.println("Sink: " + sink.getSignature());
}Output:
Source: <android.telephony.TelephonyManager: java.lang.String getLine1Number()>
Sink: <android.util.Log: int d(java.lang.String,java.lang.String)>
These examples demonstrate how to use the SourcesSinksManager class to manage and utilize source and sink methods in an Android application.