Edit firewall rules.
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.')
789505
def get_firewall_rule(self, server_uuid, firewall_rule_position, server_instance=None):
        
        url = '/server/{0}/firewall_rule/{1}'.format(server_uuid, firewall_rule_position)
        res = self.get_request(url)
        return FirewallRule(**res['firewall_rule'])
936239
def configure_firewall(self, FirewallRules):
        
        firewall_rule_bodies = [
            FirewallRule.to_dict()
            for FirewallRule in FirewallRules
        ]
        return self.cloud_manager.configure_firewall(self, firewall_rule_bodies)
148808
def get_rich_rules(zone, permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --list-rich-rules'.format(zone)

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd).splitlines()
435358
def setblocking(fd, blocking):
    """"""
    if not fcntl:
        warnings.warn('setblocking() not supported on Windows')
    flags = fcntl.fcntl(fd, fcntl.F_GETFL)
    if blocking:
        flags |= os.O_NONBLOCK
    else:
        flags &= ~os.O_NONBLOCK
    fcntl.fcntl(fd, fcntl.F_SETFL, flags)
165741
public function list_firewallrules()
    {
        if (!$this->is_loggedin) {
            return false;
        }

        $response = $this->exec_curl('/api/s/' . $this->site . '/rest/firewallrule');

        return $this->process_response($response);
    }
37025
def edit_user_push_restrictions(self, *users):
        
        assert all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in users), users

        headers, data = self._requester.requestJsonAndCheck(
            "POST",
            self.protection_url + "/restrictions/users",
            input=users
        )
634815
def process_rule_info(self):
        """"""

        while True:
            try:
                event = self._iptq.get(block=False)
                LOG.debug('Dequeue event: %s.', event)
                self.update_rule_entry(event)
            except queue.Empty:
                self.update_iptables()
                time.sleep(1)
            except Exception:
                LOG.exception('ERROR: failed to process queue')
967392
def _get_firewall_policy(kwargs):
    '''
    
    '''
    fp_name = kwargs.get('name', None)
    fp_description = kwargs.get('description', None)
    firewallPolicy = FirewallPolicy(
        name=fp_name,
        description=fp_description
    )

    fpr_json = kwargs.get('rules', None)
    jdata = json.loads(fpr_json)
    rules = []
    for fwpr in jdata:
        firewallPolicyRule = FirewallPolicyRule()
        if 'protocol' in fwpr:
            firewallPolicyRule.rule_set['protocol'] = fwpr['protocol']
        if 'port_from' in fwpr:
            firewallPolicyRule.rule_set['port_from'] = fwpr['port_from']
        if 'port_to' in fwpr:
            firewallPolicyRule.rule_set['port_to'] = fwpr['port_to']
        if 'source' in fwpr:
            firewallPolicyRule.rule_set['source'] = fwpr['source']
        if 'action' in fwpr:
            firewallPolicyRule.rule_set['action'] = fwpr['action']
        if 'description' in fwpr:
            firewallPolicyRule.rule_set['description'] = fwpr['description']
        if 'port' in fwpr:
            firewallPolicyRule.rule_set['port'] = fwpr['port']
        rules.append(firewallPolicyRule)

    return {'firewall_policy': firewallPolicy, 'firewall_policy_rules': rules}
537458
def deny(ip,
        port=None,
        proto='tcp',
        direction='in',
        port_origin='d',
        ip_origin='d',
        ttl=None,
        comment=''):
    '''
    
    '''
    return _access_rule('deny', ip, port, proto, direction, port_origin, ip_origin, comment)
527314
def rule_list(env, securitygroup_id, sortby):
    """"""

    mgr = SoftLayer.NetworkManager(env.client)

    table = formatting.Table(COLUMNS)
    table.sortby = sortby

    rules = mgr.list_securitygroup_rules(securitygroup_id)
    for rule in rules:
        port_min = rule.get('portRangeMin')
        port_max = rule.get('portRangeMax')
        if port_min is None:
            port_min = formatting.blank()
        if port_max is None:
            port_max = formatting.blank()

        table.add_row([
            rule['id'],
            rule.get('remoteIp') or formatting.blank(),
            rule.get('remoteGroupId') or formatting.blank(),
            rule['direction'],
            rule.get('ethertype') or formatting.blank(),
            port_min,
            port_max,
            rule.get('protocol') or formatting.blank(),
            rule.get('createDate') or formatting.blank(),
            rule.get('modifyDate') or formatting.blank()
        ])

    env.fout(table)
810685
protected function updateRules()
    {
        foreach ($this->rules() as $Rule) {
            $this->authManager->add($Rule);

            echo sprintf('    > rule `%s` added.', $Rule->name) . PHP_EOL;
        }
    }
71650
def toggle_rules(self, *args):
        """"""
        if self.app.manager.current != 'rules' and not isinstance(self.app.selected_proxy, CharStatProxy):
            self.app.rules.entity = self.app.selected_proxy
            self.app.rules.rulebook = self.app.selected_proxy.rulebook
        if isinstance(self.app.selected_proxy, CharStatProxy):
            self.app.charrules.character = self.app.selected_proxy
            self.app.charrules.toggle()
        else:
            self.app.rules.toggle()
866495
def update_ip_rule(self, ip, mac):
        """"""

        rule_no = self._find_rule_no(mac)
        chain = self._find_chain_name(mac)
        if not rule_no or not chain:
            LOG.error('Failed to update ip rule for %(ip)s %(mac)s',
                      {'ip': ip, 'mac': mac})
            return

        update_cmd = ['iptables', '-R', '%s' % chain, '%s' % rule_no,
                      '-s', '%s/32' % ip, '-m', 'mac', '--mac-source',
                      '%s' % mac, '-j', 'RETURN']
        LOG.debug('Execute command: %s', update_cmd)
        dsl.execute(update_cmd, self._root_helper, log_output=False)
1314785
function replaceRules (rules) {
    // create new non global instance
    var accessControl = new ImmutableAccessControl({global: false})
    // set default rules from current instance
    accessControl.setRules(this.defaultRules)
    // set new rules
    accessControl.setRules(rules)
    // replace local rules
    this.rules = accessControl.rules
    // clear rule id
    this.id = undefined
}
57566
def edit
      security_transgression_unless @comment.can_be_edited_by?(@user)

      respond_to do |format|
        format.html { redirect_to @thread }
        format.js
      end
    end
459195
def show_firewall_policy(self, firewall_policy, **_params):
        """"""
        return self.get(self.firewall_policy_path % (firewall_policy),
                        params=_params)