use of edu.columbia.cs.psl.phosphor.runtime.Taint in project phosphor by gmu-swe.
the class ArrayLengthObjTagITCase method testTaintedIndexLoad.
@Test
public void testTaintedIndexLoad() throws Exception {
int i = MultiTainter.taintedInt(5, "foo");
Taint t = MultiTainter.getTaint(i);
int[] ar = new int[10];
int j = ar[i];
Taint r = MultiTainter.getTaint(ar[i]);
if (Configuration.ARRAY_LENGTH_TRACKING)
assertEquals(t.lbl, r.lbl);
else
assertNull(r);
String[] s = new String[10];
for (j = 0; j < s.length; j++) s[j] = "b";
r = (Taint) MultiTainter.getTaint(s[i]);
if (Configuration.ARRAY_LENGTH_TRACKING)
assertEquals(t.lbl, r.lbl);
else
assertNull(r);
}
use of edu.columbia.cs.psl.phosphor.runtime.Taint in project phosphor by gmu-swe.
the class BaseMultiTaintClass method assertNoTaint.
public static void assertNoTaint(String obj) {
Taint taint = MultiTainter.getTaint(obj.toCharArray()[0]);
if (taint == null) {
return;
}
if (taint.lbl == null && taint.hasNoDependencies())
return;
fail("Expected null taint. Got: " + taint);
}
use of edu.columbia.cs.psl.phosphor.runtime.Taint in project phosphor by gmu-swe.
the class DroidBenchImplicitITCase method taintedString.
public static String taintedString(String string) {
Object r = new String(MultiTainter.taintedCharArray(string.toCharArray(), new Taint("Some stuff")));
((TaintedWithObjTag) r).setPHOSPHOR_TAG(new Taint("Some tainted data " + (++i)));
return (String) r;
}
use of edu.columbia.cs.psl.phosphor.runtime.Taint in project phosphor by gmu-swe.
the class DroidBenchImplicitITCase method testImplicitFlow2.
@Test
public void testImplicitFlow2() {
String userInputPassword = taintedString("superSecure");
resetState();
assertNullOrEmpty(MultiTainter.getControlFlow().getTag());
// if (userInputPassword.equals("superSecure"))
if (equals(userInputPassword, "superSecure"))
passwordCorrect = true;
assertNullOrEmpty(MultiTainter.getControlFlow().getTag());
Taint taint = MultiTainter.getTaint(passwordCorrect);
assertTrue(MultiTainter.getTaint(passwordCorrect) != null && (MultiTainter.getTaint(passwordCorrect).lbl != null || !MultiTainter.getTaint(passwordCorrect).hasNoDependencies()));
}
use of edu.columbia.cs.psl.phosphor.runtime.Taint in project phosphor by gmu-swe.
the class ControlTaintTagStack method _pop.
private boolean _pop(EnqueuedTaint enq) {
if (enq == null || enq.taint == null) {
return false;
}
invalidated = true;
Taint tag = enq.taint;
boolean recalc = tag.lbl != null || !tag.hasNoDependencies();
LinkedList.Node<EnqueuedTaint> e = tag.enqueuedInControlFlow.getFirst();
LinkedList.Node<EnqueuedTaint> p = null;
while (e != null) {
if (e.entry.controlTag == this) {
// Remove from controltag's list
DoubleLinkedList.Node<EnqueuedTaint> pl = e.entry.place;
if (pl.prev != null)
pl.prev.next = pl.next;
if (pl.next != null)
pl.next.prev = pl.prev;
// Remove from tag's list
if (p != null)
p.next = e.next;
else
tag.enqueuedInControlFlow.clear();
}
p = e;
e = e.next;
}
return recalc;
}
Aggregations