Inserts specified rule into firewall policy.
176340
def firewall_policy_insert_rule(self, firewall_policy, body=None):
        """"""
        return self.put(self.firewall_policy_insert_path % (firewall_policy),
                        body=body)
866094
protected function setDefaultRule()
    {
        if (RBACHelper::getAuthManager()->getRule(RouteRule::RULE_NAME) === null) {
            RBACHelper::getAuthManager()->add(new RouteRule());
        }
    }
310545
public synchronized void addRule(final RuleImpl rule) throws InvalidPatternException {
        final List<TerminalNode> terminals = this.ruleBuilder.addRule( rule,
                                                                       this.kBase );

        BaseNode[] nodes = terminals.toArray( new BaseNode[terminals.size()] );
        this.rules.put( rule.getFullyQualifiedName(), nodes );
        if (rule.isQuery()) {
            this.queries.put( rule.getName(), nodes );
        }
    }
990020
def addRule( self, rule ):
        
        self._rules[rule.term()] = rule
        self.updateRules()
716063
def add_url_rule(self, rule, endpoint=None, view_func=None, roles=None, **options):
        
        super().add_url_rule(rule, endpoint, view_func, **options)

        if roles:
            self.add_access_controller(
                endpoint, allow_access_for_roles(roles), endpoint=True
            )
446236
def create_policy(name, policy_name, policy_type, policy, region=None,
                  key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    if not exists(name, region, key, keyid, profile):
        return False
    try:
        success = conn.create_lb_policy(name, policy_name, policy_type, policy)
        if success:
            log.info('Created policy %s on ELB %s', policy_name, name)
            return True
        else:
            log.error('Failed to create policy %s on ELB %s', policy_name, name)
            return False
    except boto.exception.BotoServerError as e:
        log.error('Failed to create policy %s on ELB %s: %s',
                  policy_name, name, e.message,
                  exc_info_on_loglevel=logging.DEBUG)
        return False
963296
def _add_common_args(parser, is_create=True):
    
    parser.add_argument(
        '--name',
        help=_('Name for the firewall rule.'))
    parser.add_argument(
        '--description',
        help=_('Description for the firewall rule.'))
    parser.add_argument(
        '--source-ip-address',
        help=_('Source IP address or subnet.'))
    parser.add_argument(
        '--destination-ip-address',
        help=_('Destination IP address or subnet.'))
    parser.add_argument(
        '--source-port',
        help=_('Source port (integer in [1, 65535] or range in a:b).'))
    parser.add_argument(
        '--destination-port',
        help=_('Destination port (integer in [1, 65535] or range in '
               'a:b).'))
    utils.add_boolean_argument(
        parser, '--enabled', dest='enabled',
        help=_('Whether to enable or disable this rule.'))
    parser.add_argument(
        '--protocol', choices=['tcp', 'udp', 'icmp', 'any'],
        required=is_create,
        type=utils.convert_to_lowercase,
        help=_('Protocol for the firewall rule.'))
    parser.add_argument(
        '--action',
        required=is_create,
        type=utils.convert_to_lowercase,
        choices=['allow', 'deny', 'reject'],
        help=_('Action for the firewall rule.'))
677642
def block(self):
        '''
        
        '''
        st,output = _runcmd("/sbin/pfctl -aswitchyard -f -", self._rules)
        log_debug("Installing rules: {}".format(output))
1089924
def delete_firewall_rule(self, server_uuid, firewall_rule_position):
        
        url = '/server/{0}/firewall_rule/{1}'.format(server_uuid, firewall_rule_position)
        return self.request('DELETE', url)
359028
def rule(self, key):
        """"""
        def register(f):
            self.rules[key] = f
            return f
        return register
484983
def cli(env, identifier):
    """"""

    mgr = SoftLayer.FirewallManager(env.client)

    firewall_type, firewall_id = firewall.parse_id(identifier)
    if firewall_type == 'vlan':
        orig_rules = mgr.get_dedicated_fwl_rules(firewall_id)
    else:
        orig_rules = mgr.get_standard_fwl_rules(firewall_id)
    # open an editor for the user to enter their rules
    edited_rules = open_editor(rules=orig_rules)
    env.out(edited_rules)
    if formatting.confirm("Would you like to submit the rules. "
                          "Continue?"):
        while True:
            try:
                rules = parse_rules(edited_rules)
                if firewall_type == 'vlan':
                    rules = mgr.edit_dedicated_fwl_rules(firewall_id,
                                                         rules)
                else:
                    rules = mgr.edit_standard_fwl_rules(firewall_id,
                                                        rules)
                break
            except (SoftLayer.SoftLayerError, ValueError) as error:
                env.out("Unexpected error({%s})" % (error))
                if formatting.confirm("Would you like to continue editing "
                                      "the rules. Continue?"):
                    edited_rules = open_editor(content=edited_rules)
                    env.out(edited_rules)
                    if formatting.confirm("Would you like to submit the "
                                          "rules. Continue?"):
                        continue
                    else:
                        raise exceptions.CLIAbort('Aborted.')
                else:
                    raise exceptions.CLIAbort('Aborted.')
                env.fout('Firewall updated!')
    else:
        raise exceptions.CLIAbort('Aborted.')
41539
def put_user_policy(user_name, policy_name, policy_json, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    user = get_user(user_name, region, key, keyid, profile)
    if not user:
        log.error('IAM user %s does not exist', user_name)
        return False
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    try:
        if not isinstance(policy_json, six.string_types):
            policy_json = salt.utils.json.dumps(policy_json)
        created = conn.put_user_policy(user_name, policy_name,
                                       policy_json)
        if created:
            log.info('Created policy %s for IAM user %s.', policy_name, user_name)
            return True
        log.error('Could not create policy %s for IAM user %s.', policy_name, user_name)
    except boto.exception.BotoServerError as e:
        log.debug(e)
        log.error('Failed to create policy %s for IAM user %s.', policy_name, user_name)
    return False
675320
def create_firewall_rule(self, protocol, action, **kwargs):
        '''
        
        '''
        body = {'protocol': protocol, 'action': action}
        if 'tenant_id' in kwargs:
            body['tenant_id'] = kwargs['tenant_id']
        if 'name' in kwargs:
            body['name'] = kwargs['name']
        if 'description' in kwargs:
            body['description'] = kwargs['description']
        if 'ip_version' in kwargs:
            body['ip_version'] = kwargs['ip_version']
        if 'source_ip_address' in kwargs:
            body['source_ip_address'] = kwargs['source_ip_address']
        if 'destination_port' in kwargs:
            body['destination_port'] = kwargs['destination_port']
        if 'shared' in kwargs:
            body['shared'] = kwargs['shared']
        if 'enabled' in kwargs:
            body['enabled'] = kwargs['enabled']
        return self.network_conn.create_firewall_rule(body={'firewall_rule': body})
807786
public static void setPolicy(Policy policy) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Setting Hadoop security policy");
    }
    Policy.setPolicy(policy);
  }
384989
def set_policy(vhost,
               name,
               pattern,
               definition,
               priority=None,
               runas=None,
               apply_to=None):
    '''
    
    '''
    if runas is None and not salt.utils.platform.is_windows():
        runas = salt.utils.user.get_user()
    if isinstance(definition, dict):
        definition = salt.utils.json.dumps(definition)
    if not isinstance(definition, six.string_types):
        raise SaltInvocationError(
            'The \'definition\' argument must be a dictionary or JSON string'
        )
    cmd = [RABBITMQCTL, 'set_policy', '-p', vhost]
    if priority:
        cmd.extend(['--priority', priority])
    if apply_to:
        cmd.extend(['--apply-to', apply_to])
    cmd.extend([name, pattern, definition])
    res = __salt__['cmd.run_all'](cmd, reset_system_locale=False, runas=runas, python_shell=False)
    log.debug('Set policy: %s', res['stdout'])
    return _format_response(res, 'Set')
281705
public static void addRule(TerminalNode tn, Collection<InternalWorkingMemory> wms, InternalKnowledgeBase kBase) {
        if (log.isTraceEnabled()) {
            log.trace("Adding Rule {}", tn.getRule().getName());
        }

        boolean hasProtos = kBase.hasSegmentPrototypes();
        boolean hasWms = !wms.isEmpty();

        if (!hasProtos && !hasWms) {
            return;
        }

        RuleImpl rule = tn.getRule();
        LeftTupleNode firstSplit = getNetworkSplitPoint(tn);
        PathEndNodes pathEndNodes = getPathEndNodes(kBase, firstSplit, tn, rule, hasProtos, hasWms);

        // Insert the facts for the new paths. This will iterate each new path from EndNode to the splitStart - but will not process the splitStart itself (as tha already exist).
        // It does not matter that the prior segments have not yet been processed for splitting, as this will only apply for branches of paths that did not exist before

        for (InternalWorkingMemory wm : wms) {
            wm.flushPropagations();

            if (NodeTypeEnums.LeftInputAdapterNode == firstSplit.getType() && firstSplit.getAssociationsSize() == 1) {
                // rule added with no sharing
                insertLiaFacts(firstSplit, wm);
            } else {
                PathEndNodeMemories tnms = getPathEndMemories(wm, pathEndNodes);

                if (tnms.subjectPmem == null) {
                    // If the existing PathMemories are not yet initialized there are no Segments or tuples to process
                    continue;
                }

                Map<PathMemory, SegmentMemory[]> prevSmemsLookup = reInitPathMemories(tnms.otherPmems, null);

                // must collect all visited SegmentMemories, for link notification
                Set<SegmentMemory> smemsToNotify = handleExistingPaths(tn, prevSmemsLookup, tnms.otherPmems, wm, ExistingPathStrategy.ADD_STRATEGY);

                addNewPaths(wm, smemsToNotify, tnms.subjectPmems);

                processLeftTuples(firstSplit, wm, true, rule);

                notifySegments(smemsToNotify, wm);
            }
        }

        if (hasWms) {
            insertFacts( pathEndNodes, wms );
        } else {
            for (PathEndNode node : pathEndNodes.otherEndNodes) {
                node.resetPathMemSpec( null );
            }
        }
    }
283199
function (rule, media) {
        if (media === undefined && Foundation.stylesheet) {
          Foundation.stylesheet.insertRule(rule, Foundation.stylesheet.cssRules.length);
        } else {
          var query = Foundation.media_queries[media];

          if (query !== undefined) {
            Foundation.stylesheet.insertRule('@media ' +
              Foundation.media_queries[media] + '{ ' + rule + ' }');
          }
        }
      }