Search in sources :

Example 1 with TaintedByteWithObjTag

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

the class BoxedPrimitiveStoreWithObjTags method byteValue.

public static TaintedByteWithObjTag byteValue(Byte z) {
    TaintedByteWithObjTag ret = new TaintedByteWithObjTag();
    ret.val = z;
    if (z.valueOf && tags.containsKey(z))
        ret.taint = tags.get(z);
    return ret;
}
Also used : TaintedByteWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedByteWithObjTag)

Example 2 with TaintedByteWithObjTag

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

the class RuntimeReflectionPropogator method get.

public static Object get(Field f, Object obj, boolean isObjTags) throws IllegalArgumentException, IllegalAccessException {
    f.setAccessible(true);
    Object ret;
    if (f.getType().isPrimitive()) {
        if (f.getType() == Boolean.TYPE)
            if (isObjTags)
                ret = getBoolean$$PHOSPHORTAGGED(f, obj, new TaintedBooleanWithObjTag());
            else
                ret = getBoolean$$PHOSPHORTAGGED(f, obj, new TaintedBooleanWithIntTag());
        else if (f.getType() == Byte.TYPE)
            if (isObjTags)
                ret = getByte$$PHOSPHORTAGGED(f, obj, new TaintedByteWithObjTag());
            else
                ret = getByte$$PHOSPHORTAGGED(f, obj, new TaintedByteWithIntTag());
        else if (f.getType() == Character.TYPE)
            if (isObjTags)
                ret = getChar$$PHOSPHORTAGGED(f, obj, new TaintedCharWithObjTag());
            else
                ret = getChar$$PHOSPHORTAGGED(f, obj, new TaintedCharWithIntTag());
        else if (f.getType() == Double.TYPE)
            if (isObjTags)
                ret = getDouble$$PHOSPHORTAGGED(f, obj, new TaintedDoubleWithObjTag());
            else
                ret = getDouble$$PHOSPHORTAGGED(f, obj, new TaintedDoubleWithIntTag());
        else if (f.getType() == Float.TYPE)
            if (isObjTags)
                ret = getFloat$$PHOSPHORTAGGED(f, obj, new TaintedFloatWithObjTag());
            else
                ret = getFloat$$PHOSPHORTAGGED(f, obj, new TaintedFloatWithIntTag());
        else if (f.getType() == Long.TYPE)
            if (isObjTags)
                ret = getLong$$PHOSPHORTAGGED(f, obj, new TaintedLongWithObjTag());
            else
                ret = getLong$$PHOSPHORTAGGED(f, obj, new TaintedLongWithIntTag());
        else if (f.getType() == Integer.TYPE)
            if (isObjTags)
                ret = getInt$$PHOSPHORTAGGED(f, obj, new TaintedIntWithObjTag());
            else
                ret = getInt$$PHOSPHORTAGGED(f, obj, new TaintedIntWithIntTag());
        else if (f.getType() == Short.TYPE)
            if (isObjTags)
                ret = getShort$$PHOSPHORTAGGED(f, obj, new TaintedShortWithObjTag());
            else
                ret = getShort$$PHOSPHORTAGGED(f, obj, new TaintedShortWithIntTag());
        else
            throw new IllegalArgumentException();
    } else
        ret = f.get(obj);
    if (f.getType().isArray() && f.getType().getComponentType().isPrimitive()) {
        Object taint = null;
        try {
            try {
                if (ret instanceof LazyArrayIntTags && ((LazyArrayIntTags) ret).taints != null) {
                    return ret;
                } else if (ret instanceof LazyArrayObjTags && ((LazyArrayObjTags) ret).taints != null) {
                    return ret;
                } else {
                    Field taintField;
                    if (fieldToField.containsKey(f))
                        taintField = fieldToField.get(f);
                    else {
                        taintField = f.getDeclaringClass().getDeclaredField(f.getName() + TaintUtils.TAINT_FIELD);
                        taintField.setAccessible(true);
                        fieldToField.put(f, taintField);
                    }
                    taint = taintField.get(obj);
                    return taint;
                }
            } catch (NoSuchFieldException t) {
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (ret instanceof TaintedPrimitiveWithIntTag) {
        return ((TaintedPrimitiveWithIntTag) ret).toPrimitiveType();
    }
    if (ret instanceof TaintedPrimitiveWithObjTag) {
        return ((TaintedPrimitiveWithObjTag) ret).toPrimitiveType();
    }
    return ret;
}
Also used : TaintedShortWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedShortWithObjTag) TaintedPrimitiveWithIntTag(edu.columbia.cs.psl.phosphor.struct.TaintedPrimitiveWithIntTag) Field(java.lang.reflect.Field) TaintedByteWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedByteWithObjTag) TaintedLongWithIntTag(edu.columbia.cs.psl.phosphor.struct.TaintedLongWithIntTag) LazyArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyArrayObjTags) TaintedDoubleWithIntTag(edu.columbia.cs.psl.phosphor.struct.TaintedDoubleWithIntTag) TaintedBooleanWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag) TaintedDoubleWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedDoubleWithObjTag) TaintedCharWithIntTag(edu.columbia.cs.psl.phosphor.struct.TaintedCharWithIntTag) TaintedBooleanWithIntTag(edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithIntTag) TaintedPrimitiveWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedPrimitiveWithObjTag) TaintedFloatWithIntTag(edu.columbia.cs.psl.phosphor.struct.TaintedFloatWithIntTag) TaintedLongWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedLongWithObjTag) TaintedByteWithIntTag(edu.columbia.cs.psl.phosphor.struct.TaintedByteWithIntTag) TaintedIntWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedIntWithObjTag) TaintedFloatWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedFloatWithObjTag) TaintedShortWithIntTag(edu.columbia.cs.psl.phosphor.struct.TaintedShortWithIntTag) TaintedIntWithIntTag(edu.columbia.cs.psl.phosphor.struct.TaintedIntWithIntTag) TaintedCharWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedCharWithObjTag) LazyArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyArrayIntTags)

Aggregations

TaintedByteWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedByteWithObjTag)2 LazyArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyArrayIntTags)1 LazyArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyArrayObjTags)1 TaintedBooleanWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithIntTag)1 TaintedBooleanWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag)1 TaintedByteWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedByteWithIntTag)1 TaintedCharWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedCharWithIntTag)1 TaintedCharWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedCharWithObjTag)1 TaintedDoubleWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedDoubleWithIntTag)1 TaintedDoubleWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedDoubleWithObjTag)1 TaintedFloatWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedFloatWithIntTag)1 TaintedFloatWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedFloatWithObjTag)1 TaintedIntWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedIntWithIntTag)1 TaintedIntWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedIntWithObjTag)1 TaintedLongWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedLongWithIntTag)1 TaintedLongWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedLongWithObjTag)1 TaintedPrimitiveWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedPrimitiveWithIntTag)1 TaintedPrimitiveWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedPrimitiveWithObjTag)1 TaintedShortWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedShortWithIntTag)1 TaintedShortWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedShortWithObjTag)1