Exemplo n.º 1
0
 public function __call($name, $arguments)
 {
     if (empty($arguments)) {
         if ($this->taintedToUntainted) {
             $res = call_user_func(array($this->obj, $name));
             $res = attAspisRCO($res);
         } else {
             $res = call_user_func(array($this->obj, $name));
             $guard = AspisFindSourceGuard($name);
             if ($guard != "") {
                 $res = $guard($res);
             }
             $res = deAspisWarningRC($res);
         }
     } else {
         if ($this->taintedToUntainted) {
             foreach ($arguments as &$v) {
                 $v = deAspisWarningRC($v);
             }
             $res = call_user_func_array(array($this->obj, $name), $arguments);
             $res = attAspisRCO($res);
         } else {
             foreach ($arguments as &$v) {
                 $v = attAspisRCO($v);
             }
             $res = call_user_func_array(array($this->obj, $name), $arguments);
             $guard = AspisFindSourceGuard($name);
             if ($guard != "") {
                 $res = $guard($res);
             }
             $res = deAspisWarningRC($res);
         }
     }
     return $res;
 }
Exemplo n.º 2
0
function AspisNewUnknownProxy($classname, $params, $isTaintedContext = true)
{
    //the taint of the created object was unknown statically
    $class = new ReflectionClass($classname);
    global $aspis_taint_details;
    if (empty($aspis_taint_details)) {
        loadTaintDetails();
    }
    //attach a proxy object only when the object is created in an environment of different taint
    //attach an aspis to the resuly only when called from a taintex context
    if (isset($aspis_taint_details[1][$classname])) {
        if (!$isTaintedContext) {
            if (!empty($params)) {
                foreach ($params as &$v) {
                    $v = attAspisRCO($v);
                }
                $obj = $class->newInstanceArgs($params);
            } else {
                $obj = $class->newInstance();
            }
            return new AspisProxy($obj, false);
        }
    } else {
        if ($isTaintedContext) {
            if (!empty($params)) {
                foreach ($params as &$v) {
                    $v = deAspisWarningRC($v);
                }
                $obj = $class->newInstanceArgs($params);
            } else {
                $obj = $class->newInstance();
            }
            return array(new AspisProxy($obj, true), false);
        }
    }
    if (!empty($params)) {
        $obj = $class->newInstanceArgs($params);
    } else {
        $obj = $class->newInstance();
    }
    if ($isTaintedContext) {
        return array($obj, false);
    } else {
        return $obj;
    }
}