Class TaintVec
This is the auxiliary type used by the Taint Analyzer's emulator.
Regarding serialization, we do not serialize the vector for storage, but only for display. For
storage, we instead serialize and store each taint set on an address-by-address basis. Thus, we
do not (yet) have a parse(String) method.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTaintVec(int length) Create a new uninitialized taint vector of the given length -
Method Summary
Modifier and TypeMethodDescriptionstatic TaintVecCreate a taint vector representing a new tainted byte array, where each element is given a distinct namestatic TaintVecBroadcast the given set into a new vector or the given lengthcopy()Create a copy of this vectorUnion each element with the given set, forming a new result vectorstatic TaintVecempties(int size) Create a vector of empty taint setsbooleanextended(int length, boolean isBigEndian, boolean isSigned) Extend this vector to create a new vector of the given lengthget(int i) Get an element from the vectorgetSets()Get the vector as a listinthashCode()static TaintVecvoidSet an element in the vectorSet several elements in the vectorFill this vector as inarray(String, long, int), modifying it in placesetBlur(boolean right) Modify the vector so each element becomes the union of itself and its neighborsetCascade(boolean isBigEndian) Modify the vector so each element becomes the union of itself and all elements of lesser significanceBroadcast the given set over this vector, modifying it in placeBroadcast the empty taint set over this vector, modifying it in placesetShifted(int right, TaintVec.ShiftMode mode) Shift this vector some number of elements, in placesub(int offset, int length) Extract a subpiece of this vectortagIndirectRead(TaintVec offset) Combine this and another taint vector to represent a tainted indirect readtagIndirectWrite(TaintVec offset) Combine this and another taint vector to represent a tainted indirect writeConvert the vector to a string suitable for display in the UItoString()truncated(int length, boolean isBigEndian) Drop all but length elements from this vector, creating a new vectorunion()Reduce this vector to a single taint set by unionUnion each element with its corresponding element from another vector, forming a new result vector
-
Field Details
-
length
public final int length
-
-
Constructor Details
-
TaintVec
public TaintVec(int length) Create a new uninitialized taint vector of the given length- Parameters:
length- the length
-
-
Method Details
-
of
-
empties
Create a vector of empty taint sets- Parameters:
size- the length of the vector- Returns:
- the new vector
-
copies
Broadcast the given set into a new vector or the given length- Parameters:
taint- the taint setsize- the length of the vector- Returns:
- the new vector
-
array
Create a taint vector representing a new tainted byte array, where each element is given a distinct nameFor example, the parameters
("arr", 0, 4)will produce the vector "[arr_0][arr_1][arr_2][arr_3]". Each element is a singleton set containing the mark for a byte in the tainted array.- Parameters:
name- the base for naming each elementstart- the starting index for naming each elementsize- the number of bytes, i.e., the length of the vector- Returns:
- the new vector
-
toString
-
toDisplay
Convert the vector to a string suitable for display in the UI- Returns:
- the string
-
equals
-
hashCode
public int hashCode() -
getSets
Get the vector as a list- Returns:
- the list
-
get
Get an element from the vector- Parameters:
i- the index- Returns:
- the taint set
-
set
Set an element in the vector- Parameters:
i- the indexs- the taint set
-
set
Set several elements in the vectorThis is essentially just an array copy. The entire source
vecis copied into this vector such that the first element of the source is placed at the start index of the destination.- Parameters:
start- the starting indexvec- the vector of sets- Returns:
- this vector
-
zipUnion
Union each element with its corresponding element from another vector, forming a new result vector- Parameters:
that- the other vector- Returns:
- the result
-
eachUnion
Union each element with the given set, forming a new result vector- Parameters:
set- the taint set- Returns:
- the result
-
union
Reduce this vector to a single taint set by union- Returns:
- the resulting taint set
-
tagIndirectRead
Combine this and another taint vector to represent a tainted indirect readBecause the all bytes of the address offset "affect" the value read, we first union all the taint sets of the that offset. We then tag each mark in that union with "
indR". Finally we union that result with each element of this vector (this vector representing the bytes read from memory).- Parameters:
offset- the vector representing the bytes that encode the offset- Returns:
- the vector representing the tainted bytes read from memory
-
tagIndirectWrite
Combine this and another taint vector to represent a tainted indirect writeThis works the same as
tagIndirectRead(TaintVec), except with the tag "indW" and it occurs before the actual write.- Parameters:
offset- the vector representing the bytes that encode the offset- Returns:
- the vector representing the tainted bytes to be written to memory
-
setCopies
Broadcast the given set over this vector, modifying it in place- Parameters:
taint- the taint set- Returns:
- this vector
-
setEmpties
Broadcast the empty taint set over this vector, modifying it in place- Returns:
- this vector
-
setArray
Fill this vector as inarray(String, long, int), modifying it in place- Parameters:
name- the base for naming each elementstart- the starting index for naming each element- Returns:
- this vector
-
setCascade
Modify the vector so each element becomes the union of itself and all elements of lesser significanceThis should be used after
zipUnion(TaintVec)to model operations with carries.- Parameters:
isBigEndian- true if smaller indices have greater significance- Returns:
- this vector
-
setBlur
Modify the vector so each element becomes the union of itself and its neighborThis should be used to model shift operations. Both the shift direction and the endianness must be considered.
- Parameters:
right- true to cause each greater index to be unioned in place with less-indexed neighbor- Returns:
- this vector
-
setShifted
Shift this vector some number of elements, in place- Parameters:
right- the number of elements to shift right, or negative for leftmode- the behavior of the shift- Returns:
- this vector
-
truncated
Drop all but length elements from this vector, creating a new vectorDrops the most significant elements of this vector, as specified by the endianness
- Parameters:
length- the length fo the new vectorisBigEndian- true to drop lower-indexed elements, false to drop higher-indexed elements- Returns:
- the truncated vector
-
copy
Create a copy of this vector- Returns:
- the copy
-
extended
Extend this vector to create a new vector of the given lengthElements are appended at the most significant end, as specified by the endianness. If signed, the appended elements are copies of the most significant element in this vector. Otherwise, they are empty taint sets.
- Parameters:
length- the length of the new vectorisBigEndian- true to append to the lower-indexed end, false to append to the higher-indexed endisSigned- true to append copies of the most significant element, false to append empty sets- Returns:
- the new vector
-
sub
Extract a subpiece of this vector- Parameters:
offset- the offset into this vectorlength- the number of sets to extract- Returns:
- the resulting vector
-