예제 #1
0
}, 'args' => array('location' => array('type' => 'string', 'default' => '*nodefault*'), 'preORpost' => array('type' => 'string', 'default' => 'pre', 'choices' => array('pre', 'post'))));
$supportedActions['cloneforappoverride'] = array('name' => 'cloneForAppOverride', 'MainFunction' => function (CallContext $context) {
    $rule = $context->object;
    if ($rule->actionIsNegative()) {
        print $context->padding . " - IGNORED because Action is DENY\n";
        return;
    }
    if (!$rule->apps->isAny()) {
        print $context->padding . " - IGNORED because Application is NOT EQUAL ANY\n";
        return;
    }
    $ports = '';
    if (($rule->services->isAny() || $rule->services->isApplicationDefault()) && !$context->arguments['restrictToListOfServices'] == '*sameAsInRule*') {
        $ports = '1-65535';
        $portMapping = ServiceDstPortMapping::mappingFromText($ports, true);
        $udpPortMapping = ServiceDstPortMapping::mappingFromText($ports, false);
        $portMapping->mergeWithMapping($udpPortMapping);
    } else {
        $portMapping = new ServiceDstPortMapping();
        if ($context->arguments['restrictToListOfServices'] == '*sameAsInRule*') {
            $services = $rule->services->members();
        } else {
            $listOfServicesQueryName = $context->arguments['restrictToListOfServices'];
            if (!isset($context->nestedQueries[$listOfServicesQueryName])) {
                derr("cannot find query filter called '{$listOfServicesQueryName}'");
            }
            $rQuery = new RQuery('service');
            $errorMessage = '';
            if (!$rQuery->parseFromString($context->nestedQueries[$listOfServicesQueryName], $errorMessage)) {
                derr("error while parsing query: {$context->nestedQueries[$listOfServicesQueryName]}");
            }
예제 #2
0
 /**
  * @return ServiceDstPortMapping
  * @throws Exception
  */
 public function dstPortMapping()
 {
     if ($this->isTmpSrv()) {
         return new ServiceDstPortMapping();
     }
     if ($this->_protocol == 'tcp') {
         $tcp = true;
     } else {
         $tcp = false;
     }
     return ServiceDstPortMapping::mappingFromText($this->_dport, $tcp);
 }