use of edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag in project phosphor by gmu-swe.
the class TaintUtils method enumValueOf.
public static <T extends Enum<T>> T enumValueOf(Class<T> enumType, String name, ControlTaintTagStack ctrl) {
T ret = Enum.valueOf(enumType, name);
Taint tag = (Taint) ((TaintedWithObjTag) ((Object) name)).getPHOSPHOR_TAG();
tag = Taint.combineTags(tag, ctrl);
if (tag != null && !(tag.getLabel() == null && tag.hasNoDependencies())) {
ret = shallowClone(ret);
((TaintedWithObjTag) ret).setPHOSPHOR_TAG(tag);
}
return ret;
}
use of edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag in project phosphor by gmu-swe.
the class ReflectionMasker method fixAllArgs.
@SuppressWarnings("rawtypes")
public static Object[] fixAllArgs(Object[] in, Constructor c, boolean isObjTags) {
// System.out.println("Making constructo rcall to " + c);
if (c != null && in != null && c.getParameterTypes().length != in.length) {
Object[] ret = new Object[c.getParameterTypes().length];
int j = 0;
for (int i = 0; i < in.length; i++) {
if (c.getParameterTypes()[j].isPrimitive()) {
if (in[i] instanceof TaintedWithIntTag)
ret[j] = ((TaintedWithIntTag) in[i]).getPHOSPHOR_TAG();
else if (in[i] instanceof TaintedWithObjTag)
ret[j] = ((TaintedWithObjTag) in[i]).getPHOSPHOR_TAG();
else
ret[j] = 0;
j++;
} else if (c.getParameterTypes()[j] == Configuration.TAINT_TAG_OBJ_CLASS) {
if (in[i] instanceof TaintedWithObjTag)
ret[j] = ((TaintedWithObjTag) in[i]).getPHOSPHOR_TAG();
else
ret[j] = null;
j++;
} else if (LazyArrayIntTags.class.isAssignableFrom(c.getParameterTypes()[j])) {
LazyArrayIntTags arr = ((LazyArrayIntTags) in[i]);
if (arr == null) {
ret[j] = null;
j++;
ret[j] = null;
j++;
} else {
ret[j] = arr.taints;
j++;
ret[j] = arr.getVal();
j++;
}
continue;
} else if (LazyArrayObjTags.class.isAssignableFrom(c.getParameterTypes()[j])) {
LazyArrayObjTags arr = ((LazyArrayObjTags) in[i]);
if (arr == null) {
ret[j] = null;
j++;
ret[j] = null;
j++;
} else {
ret[j] = arr.taints;
j++;
ret[j] = arr.getVal();
j++;
}
continue;
}
ret[j] = in[i];
j++;
}
return ret;
} else if (in == null && c.getParameterTypes().length == 1) {
Object[] ret = new Object[1];
ret[0] = null;
return ret;
} else if (in == null && c.getParameterTypes().length == 2) {
Object[] ret = new Object[2];
ret[0] = new ControlTaintTagStack();
ret[1] = null;
return ret;
}
return in;
}
use of edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag in project phosphor by gmu-swe.
the class ReflectionMasker method fixAllArgs.
public static Object[] fixAllArgs(Object[] in, Constructor c, ControlTaintTagStack ctrl) {
// System.out.println("Making constructo rcall to " + c);
if (c != null && in != null && c.getParameterTypes().length != in.length) {
Object[] ret = new Object[c.getParameterTypes().length];
int j = 0;
for (int i = 0; i < in.length; i++) {
if (c.getParameterTypes()[j].isPrimitive()) {
if (in[i] instanceof TaintedWithIntTag)
ret[j] = ((TaintedWithIntTag) in[i]).getPHOSPHOR_TAG();
else if (in[i] instanceof TaintedWithObjTag)
ret[j] = ((TaintedWithObjTag) in[i]).getPHOSPHOR_TAG();
else
ret[j] = 0;
j++;
} else if (c.getParameterTypes()[j] == Configuration.TAINT_TAG_OBJ_CLASS) {
if (in[i] instanceof TaintedWithObjTag)
ret[j] = ((TaintedWithObjTag) in[i]).getPHOSPHOR_TAG();
else
ret[j] = null;
j++;
} else if (c.getParameterTypes()[j].isArray() && (c.getParameterTypes()[j].getComponentType().isPrimitive() || Configuration.TAINT_TAG_OBJ_CLASS.isAssignableFrom(c.getParameterTypes()[j].getComponentType()))) {
LazyArrayObjTags arr = ((LazyArrayObjTags) in[i]);
ret[j] = arr.taints;
j++;
ret[j] = arr.getVal();
j++;
continue;
}
ret[j] = in[i];
j++;
}
ret[ret.length - 2] = ctrl;
return ret;
} else if (in == null && c.getParameterTypes().length == 1) {
Object[] ret = new Object[1];
ret[0] = null;
return ret;
} else if (in == null && c.getParameterTypes().length == 2) {
Object[] ret = new Object[2];
ret[0] = ctrl;
ret[1] = null;
return ret;
}
return in;
}
use of edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag in project phosphor by gmu-swe.
the class Taint method combineTagsOnObject.
@SuppressWarnings("rawtypes")
public static void combineTagsOnObject(Object o, ControlTaintTagStack tags) {
if (tags.isEmpty() || IGNORE_TAINTING)
return;
if (Configuration.derivedTaintListener != null)
Configuration.derivedTaintListener.controlApplied(o, tags);
if (o instanceof TaintedWithObjTag) {
if (o instanceof String) {
Taint onObj = (Taint) ((TaintedWithObjTag) o).getPHOSPHOR_TAG();
((String) o).PHOSPHOR_TAG = Taint.combineTags(onObj, tags);
// for(int i = 0; i < ((String) o).length(); i++)
// {
// ((String)o).valuePHOSPHOR_TAG[i] = Taint.combineTags(((String)o).valuePHOSPHOR_TAG[i], tags);
// }
} else
((TaintedWithObjTag) o).setPHOSPHOR_TAG(Taint.combineTags((Taint) ((TaintedWithObjTag) o).getPHOSPHOR_TAG(), tags));
}
}
use of edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag in project phosphor by gmu-swe.
the class StringConcatObjTagITCase method testNewStringConcat.
@Test
public void testNewStringConcat() throws Exception {
String str1 = new String("abcdefg");
((TaintedWithObjTag) ((Object) str1)).setPHOSPHOR_TAG(new Taint("sensitive"));
String str2 = "a" + str1;
assertTrue(MultiTainter.getTaint(str2.charAt(0)) == null);
assertTrue(MultiTainter.getTaint(str2.charAt(1)) != null);
}
Aggregations