Search in sources :

Example 6 with TaintedWithObjTag

use of edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag 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;
}
Also used : TaintedWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag) Taint(edu.columbia.cs.psl.phosphor.runtime.Taint)

Example 7 with TaintedWithObjTag

use of edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag in project phosphor by gmu-swe.

the class DroidBenchObjTagITCase method taintedString.

public static String taintedString(String string) {
    Object r = new String(string.toCharArray());
    ((TaintedWithObjTag) r).setPHOSPHOR_TAG(new Taint("Some tainted data " + (++i)));
    return (String) r;
}
Also used : TaintedWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag) Taint(edu.columbia.cs.psl.phosphor.runtime.Taint)

Example 8 with TaintedWithObjTag

use of edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag in project phosphor by gmu-swe.

the class GetSetTaintObjTagITCase method testReferenceType.

@Test
public void testReferenceType() throws Exception {
    String s = "def";
    HashMap<Object, Object> m = new HashMap<Object, Object>();
    MultiTainter.taintedObject(s, new Taint(5));
    ;
    MultiTainter.taintedObject(m, new Taint(5));
    int[] x = new int[10];
    // In its default mode, Phosphor tracks ONLY for the array ELEMENTS - not for the reference
    // can do -withArrayLengthTags to track a tag for the length of the array
    x = MultiTainter.taintedIntArray(x, new Taint(3));
    assertTrue(((TaintedWithObjTag) m).getPHOSPHOR_TAG() != null);
    assertTrue(MultiTainter.getTaint(m) != null);
    assertTrue(MultiTainter.getTaint(s) != null);
    assertTrue(MultiTainter.getTaint(x[0]) != null);
}
Also used : HashMap(java.util.HashMap) TaintedWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag) Taint(edu.columbia.cs.psl.phosphor.runtime.Taint) Test(org.junit.Test)

Example 9 with TaintedWithObjTag

use of edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag in project phosphor by gmu-swe.

the class GetSetTaintObjTagITCase method testValueOf.

@Test
public void testValueOf() {
    String hundred = new String(new char[] { '1', '0', '0' });
    Object lbl = 5;
    String TRUE = new String(new char[] { 't', 'r', 'u', 'e' });
    ((TaintedWithObjTag) ((Object) hundred)).setPHOSPHOR_TAG(new Taint(lbl));
    ((TaintedWithObjTag) ((Object) TRUE)).setPHOSPHOR_TAG(new Taint(lbl));
    boolean z = Boolean.parseBoolean(TRUE);
    byte b = Byte.valueOf(hundred);
    byte b2 = Byte.parseByte(hundred);
    byte b3 = Byte.parseByte(hundred, 10);
    int i = Integer.valueOf(hundred);
    int i2 = Integer.valueOf(hundred, 10);
    int i3 = Integer.parseInt(hundred);
    int i4 = Integer.parseInt(hundred, 10);
    int i5 = Integer.parseUnsignedInt(hundred);
    int i6 = Integer.parseUnsignedInt(hundred, 10);
    short s = Short.parseShort(hundred);
    short s2 = Short.parseShort(hundred, 10);
    short s3 = Short.valueOf(hundred);
    short s4 = Short.valueOf(hundred, 10);
    long l = Long.valueOf(hundred);
    long l2 = Long.valueOf(hundred, 10);
    long l3 = Long.parseLong(hundred);
    long l4 = Long.parseLong(hundred, 10);
    long l5 = Long.parseUnsignedLong(hundred);
    long l6 = Long.parseUnsignedLong(hundred, 10);
    float f = Float.parseFloat(hundred);
    float f2 = Float.valueOf(hundred);
    double d = Double.parseDouble(hundred);
    double d2 = Double.valueOf(hundred);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(z), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(b), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(b2), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(b3), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(i), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(i2), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(i3), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(i4), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(i5), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(i6), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(s), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(s2), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(s3), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(s4), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(l), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(l2), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(l3), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(l4), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(l5), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(l6), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(f), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(f2), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(d), lbl);
    assertTaintHasOnlyLabel(MultiTainter.getTaint(d2), lbl);
}
Also used : TaintedWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag) Taint(edu.columbia.cs.psl.phosphor.runtime.Taint) Taint(edu.columbia.cs.psl.phosphor.runtime.Taint) Test(org.junit.Test)

Example 10 with TaintedWithObjTag

use of edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag in project phosphor by gmu-swe.

the class StringConcatObjTagITCase method testLDCStringConcat.

@Test
public void testLDCStringConcat() throws Exception {
    String str1 = "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);
}
Also used : TaintedWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag) Taint(edu.columbia.cs.psl.phosphor.runtime.Taint) Test(org.junit.Test)

Aggregations

TaintedWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag)13 Taint (edu.columbia.cs.psl.phosphor.runtime.Taint)8 TaintedWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedWithIntTag)5 LazyArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyArrayObjTags)4 Test (org.junit.Test)4 LazyArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyArrayIntTags)2 MethodInvoke (edu.columbia.cs.psl.phosphor.struct.MethodInvoke)2 ControlTaintTagStack (edu.columbia.cs.psl.phosphor.struct.ControlTaintTagStack)1 EnqueuedTaint (edu.columbia.cs.psl.phosphor.struct.EnqueuedTaint)1 TaintedPrimitiveWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedPrimitiveWithIntTag)1 TaintedPrimitiveWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedPrimitiveWithObjTag)1 HashMap (java.util.HashMap)1