Search in sources :

Example 6 with TaintedBooleanWithObjTag

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

the class NativeHelper method ensureIsBoxedImplicitTracking.

@SuppressWarnings("rawtypes")
public static final Collection ensureIsBoxedImplicitTracking(Collection in) {
    if (in != null) {
        Collection tmp = null;
        for (Object o : in) {
            if (o == null)
                break;
            Type t = Type.getType(o.getClass());
            if (t.getSort() == Type.ARRAY && t.getElementType().getSort() != Type.OBJECT) {
                if (tmp == null) {
                    try {
                        tmp = (Collection) in.getClass().getConstructor().newInstance(null);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
                tmp.add$$PHOSPHORTAGGED(MultiDTaintedArrayWithObjTag.boxIfNecessary(o), new ControlTaintTagStack(), new TaintedBooleanWithObjTag());
            } else
                break;
        }
        if (tmp != null) {
            in.clear();
            tmp.add$$PHOSPHORTAGGED(tmp, new ControlTaintTagStack(), new TaintedBooleanWithObjTag());
        }
    }
    return in;
}
Also used : ControlTaintTagStack(edu.columbia.cs.psl.phosphor.struct.ControlTaintTagStack) Type(org.objectweb.asm.Type) Collection(java.util.Collection) TaintedBooleanWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag)

Example 7 with TaintedBooleanWithObjTag

use of edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag 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

TaintedBooleanWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag)7 Collection (java.util.Collection)4 Type (org.objectweb.asm.Type)3 ControlTaintTagStack (edu.columbia.cs.psl.phosphor.struct.ControlTaintTagStack)2 Taint (edu.columbia.cs.psl.phosphor.runtime.Taint)1 LazyArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyArrayIntTags)1 LazyArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyArrayObjTags)1 LazyBooleanArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayObjTags)1 LazyByteArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyByteArrayObjTags)1 LazyCharArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags)1 LazyDoubleArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayObjTags)1 LazyFloatArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags)1 LazyIntArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyIntArrayObjTags)1 LazyLongArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyLongArrayObjTags)1 LazyShortArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyShortArrayObjTags)1 TaintedBooleanWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithIntTag)1 TaintedByteWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedByteWithIntTag)1 TaintedByteWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedByteWithObjTag)1 TaintedCharWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedCharWithIntTag)1 TaintedCharWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedCharWithObjTag)1