|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdk.brics.string.StringAnalysis
public class StringAnalysis
A StringAnalysis
object encapsulates a string analysis performed
on a collection of classes.
The class also contains some convenience methods for loading and traversing
the classes to be analyzed.
Constructor Summary | |
---|---|
StringAnalysis()
Performs a string analysis on the current application classes. |
|
StringAnalysis(Collection<ValueBox> hotspots)
Performs a string analysis on the current application classes. |
|
StringAnalysis(Collection<ValueBox> hotspots,
ExternalVisibility ext)
|
|
StringAnalysis(Collection<ValueBox> hotspots,
ExternalVisibility ext,
TaintAnalysisStrategy taintAnalysisStrategy)
|
|
StringAnalysis(Collection<ValueBox> hotspots,
ExternalVisibility externallyVisible,
TaintAnalysisStrategy taintAnalysisStrategy,
DiagnosticsStrategy diagnostics)
Performs a string analysis on the current application classes. |
|
StringAnalysis(Collection<ValueBox> hotspots,
ExternalVisibility externallyVisible,
TaintAnalysisStrategy taintAnalysisStrategy,
StaticStringTypes staticStringTypes,
DiagnosticsStrategy diagnostics)
|
|
StringAnalysis(ExternalVisibility ext)
Performs a string analysis on the current application classes. |
Method Summary | |
---|---|
static void |
addDirectoryToClassPath(String dir)
Adds the specified directory or jar file to the internal classpath, so library classes can be loaded from there. |
static boolean |
addJarsToClassPath(String libDir)
Adds all jar files found in the specified directory to the internal classpath, so library classes can be loaded from those. |
static void |
addResolver(Resolver r)
Adds the given resolver to the list of active resolvers used during the string analysis. |
static void |
clearResolvers()
Removes all active resolvers. |
static List<ValueBox> |
getArgumentExpressions(String sig,
int argnum)
Returns a list containing all expressions occurring as argument to the specified method. |
Automaton |
getAutomaton(ValueBox box)
Computes the automaton describing the possible string values at the given expression. |
String |
getClassName(ValueBox box)
Returns the name of the class containing the given expression. |
int |
getLineNumber(ValueBox box)
Returns the source line number of the given expression. |
String |
getMethodName(ValueBox box)
Returns the name of the method containing the given expression. |
int |
getNumExps()
Returns the total number of analyzable expressions in the program. |
static List<ValueBox> |
getReturnExpressions(String sig)
Returns a list of all expressions that occur as the return value from the specified method or any method that overrides/implements it. |
String |
getSourceFile(ValueBox box)
Returns the name of the source file containing the given expression. |
Automaton |
getTypeAutomaton(Type t)
Computes the automaton describing the possible string values that can occur as a result of converting the given type into a string. |
static boolean |
hasValidType(ValueBox box)
Returns whether or not the given expression has a type that the string analysis is able to handle. |
boolean |
isTaint(ValueBox box)
Returns whether the strings that this valuebox contains can be taint. |
static SootClass |
loadClass(String name)
Loads the named class into the Soot scene, marks it as an application class, and generates bodies for all of its concrete methods. |
static int |
loadDirectory(String dir)
Loads all classes in the specified directory, where the directory refers to the root of the package tree. |
static void |
removeResolver(Resolver r)
Removes the given resolver from the list of active resolvers used during the string analysis. |
static void |
reset()
Resets Soot's globals and the list of resolvers. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringAnalysis()
public StringAnalysis(Collection<ValueBox> hotspots)
hotspots
- a set of ValueBox
objects indicating
the desired hot spotspublic StringAnalysis(Collection<ValueBox> hotspots, ExternalVisibility ext)
public StringAnalysis(Collection<ValueBox> hotspots, ExternalVisibility ext, TaintAnalysisStrategy taintAnalysisStrategy)
public StringAnalysis(Collection<ValueBox> hotspots, ExternalVisibility externallyVisible, TaintAnalysisStrategy taintAnalysisStrategy, DiagnosticsStrategy diagnostics)
hotspots
- a set of ValueBox
objects indicating
the desired hot spotsexternallyVisible
- defines which methods are externally visible.public StringAnalysis(Collection<ValueBox> hotspots, ExternalVisibility externallyVisible, TaintAnalysisStrategy taintAnalysisStrategy, StaticStringTypes staticStringTypes, DiagnosticsStrategy diagnostics)
public StringAnalysis(ExternalVisibility ext)
ext
- defines which methods are externally visible.Method Detail |
---|
public static void addDirectoryToClassPath(String dir)
dir
- classpath to append. May contain either one directoy or jar file, or several ones separated by File.pathSeparator
.public static boolean addJarsToClassPath(String libDir)
libDir
- path to a directory containing jar files.
public static void addResolver(Resolver r)
r
- the resolver to add.Resolver
public static void clearResolvers()
Resolver
public static List<ValueBox> getArgumentExpressions(String sig, int argnum)
sig
- the signature of the method to collect arguments to, e.g.
"<java.io.PrintStream: void println(java.lang.String)>"
.argnum
- the index of the argument to the call
public final Automaton getAutomaton(ValueBox box)
String
, StringBuffer
, StringBuilder
, or
array (of any dimension) of String
,
the inferred result is returned directly. If it is of a simple type
or a wrapper class, the corresponding type automaton is returned.
Otherwise, the inferred result for the return values of the
relevant toString
methods is returned.
If a specific set of hotspots has been supplied to the analysis,
and the expression is of one of the string types metioned above,
the expression given must be one of these hotspots.
box
- the Soot value box containing the expression.
IllegalArgumentException
- if the expression is not a marked hotspot.public final String getClassName(ValueBox box)
box
- the expression.
public final int getLineNumber(ValueBox box)
box
- the expression.
public final String getMethodName(ValueBox box)
box
- the expression.
public final int getNumExps()
public static List<ValueBox> getReturnExpressions(String sig)
sig
- the signature of the method to collect return expression from, e.g.
"<com.example.Action: String getSomeURL()>"
.
public final String getSourceFile(ValueBox box)
box
- the expression.
public final Automaton getTypeAutomaton(Type t)
toString
methods of
the type and all its subclasses.
t
- the Soot type.
public static boolean hasValidType(ValueBox box)
box
- the Soot value box containing the expression.
true
if the expression has type String
,
StringBuffer
, StringBuilder
,
or array (of any dimension) of String
;
false
otherwise;public boolean isTaint(ValueBox box)
TaintAnalysisStrategy
.
public static SootClass loadClass(String name)
name
- the fully qualified name of the class to be loaded.
public static int loadDirectory(String dir) throws IOException
addJarsToClassPath(String)
or addDirectoryToClassPath(String)
first.
If classes should be loaded from more than one directory, all directories should first
be added to the classpath and then loaded.
dir
- directory root of the package tree
IOException
public static void removeResolver(Resolver r)
r
- the resolver to remove.Resolver
public static void reset()
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |