add items to existing csp policies
969230
def update_policy(self,cspDefaultHeaders):
		
		try:
			self.check_valid(cspDefaultHeaders)
			if self.inputs is not None:
				for p,l in self.inputs.items():
					cspDefaultHeaders[p] = cspDefaultHeaders[p]+ list(set(self.inputs[p]) - set(cspDefaultHeaders[p]))
				return cspDefaultHeaders
			else:
				return self.inputs
		except Exception, e:
			raise
946746
def add_backend_policy(self, json_data):
        
        env = boto3.session.Session(profile_name=self.env, region_name=self.region)
        elbclient = env.client('elb')

        # Attach backend server policies to created ELB
        for job in json.loads(json_data)['job']:
            for listener in job['listeners']:
                instance_port = listener['internalPort']
                backend_policy_list = listener['backendPolicies']
                if backend_policy_list:
                    LOG.info('Adding backend server policies: %s', backend_policy_list)
                    elbclient.set_load_balancer_policies_for_backend_server(
                        LoadBalancerName=self.app, InstancePort=instance_port, PolicyNames=backend_policy_list)
312650
def _create_scaling_policies(conn, as_name, scaling_policies):
    ''
    if scaling_policies:
        for policy in scaling_policies:
            policy = autoscale.policy.ScalingPolicy(
                name=policy["name"],
                as_name=as_name,
                adjustment_type=policy["adjustment_type"],
                scaling_adjustment=policy["scaling_adjustment"],
                min_adjustment_step=policy.get("min_adjustment_step", None),
                cooldown=policy["cooldown"])
            conn.create_scaling_policy(policy)
877839
def add_policy(self, scaling_group, name, policy_type, cooldown,
            change=None, is_percent=False, desired_capacity=None, args=None):
        
        uri = "/%s/%s/policies" % (self.uri_base, utils.get_id(scaling_group))
        body = self._create_policy_body(name, policy_type, cooldown,
                change=change, is_percent=is_percent,
                desired_capacity=desired_capacity, args=args)
        # "body" needs to be a list
        body = [body]
        resp, resp_body = self.api.method_post(uri, body=body)
        pol_info = resp_body.get("policies")[0]
        return AutoScalePolicy(self, pol_info, scaling_group)
1153686
def sync_policies(self, vault_client):
        """"""
        p_resources = [x for x in self.resources()
                       if isinstance(x, Policy)]
        for resource in p_resources:
            resource.sync(vault_client)

        return [x for x in self.resources()
                if not isinstance(x, Policy)]
362171
def add(self, items):
        """"""
        with _presub_lock:
            self.load_from_cloud()
            for entry in utils.ensure_listable(items):
                # add new entries, but only if they're unique
                if entry not in self.current:
                    self.current.append(entry)
            self.save_to_cloud()
173836
def addItem(self, item, message=None):
        """"""
        if message is None:
            message = 'Adding item %s' % item.path
        try:
            v = Version.new(repo=self)
            v.addItem(item)
            v.save(message)
        except VersionError, e:
            raise RepoError(e)
1206355
def attach(item, action, greedy=False, ignore_no_tokens=None, ignore_one_token=None):
    """"""
    if use_computation_graph:
        # use the action's annotations to generate the defaults
        if ignore_no_tokens is None:
            ignore_no_tokens = getattr(action, "ignore_no_tokens", False)
        if ignore_one_token is None:
            ignore_one_token = getattr(action, "ignore_one_token", False)
        # only include True keyword arguments in the partial, since False is the default
        kwargs = {}
        if greedy:
            kwargs["greedy"] = greedy
        if ignore_no_tokens:
            kwargs["ignore_no_tokens"] = ignore_no_tokens
        if ignore_one_token:
            kwargs["ignore_one_token"] = ignore_one_token
        action = partial(ComputationNode, action, **kwargs)
    return add_action(item, action)
694687
public void addPolicy(final ExpirationPolicy policy) {
        LOGGER.trace("Adding expiration policy [{}] with name [{}]", policy, policy.getName());
        this.policies.put(policy.getName(), policy);
    }
1108857
def policies(self):
        """"""
        policies = [self._pb.integer_policy, self._pb.float_policy,
                    self._pb.string_policy, self._pb.bool_policy]
        key_types = ["integer", "float", "string", "bool"]
        return zip(key_types, policies)
843299
def csp_header(csp={}):
    
    _csp = csp_default().read()
    _csp.update(csp)
    
    _header = ''
    if 'report-only' in _csp and _csp['report-only'] is True:
    	_header = 'Content-Security-Policy-Report-Only'
    else:
    	_header = 'Content-Security-Policy'
    if 'report-only' in _csp:
    	del _csp['report-only']
    _headers = {_header: create_csp_header(_csp)}
    
    def decorator(f):
        @wraps(f)
        def decorated_function(*args, **kwargs):
            resp = make_response(f(*args, **kwargs))
            h = resp.headers
            for header, value in _headers.items():
                h[header] = value
            return resp
        return decorated_function
    return decorator
129880
def set_policy(table='filter', chain=None, policy=None, family='ipv4'):
    '''
    
    '''
    if not chain:
        return 'Error: Chain needs to be specified'
    if not policy:
        return 'Error: Policy needs to be specified'

    wait = '--wait' if _has_option('--wait', family) else ''
    cmd = '{0} {1} -t {2} -P {3} {4}'.format(
            _iptables_cmd(family), wait, table, chain, policy)
    out = __salt__['cmd.run'](cmd)
    return out
592135
def replace_policy(self, scaling_group, policy, name,
            policy_type, cooldown, change=None, is_percent=False,
            desired_capacity=None, args=None):
        
        policy_id = utils.get_id(policy)
        group_id = utils.get_id(scaling_group)
        uri = "/%s/%s/policies/%s" % (self.uri_base, group_id, policy_id)
        body = self._create_policy_body(name=name, policy_type=policy_type,
                cooldown=cooldown, change=change, is_percent=is_percent,
                desired_capacity=desired_capacity, args=args)
        resp, resp_body = self.api.method_put(uri, body=body)
1245321
def put_bucket_policy(bucket_policy)
        if bucket_policy && bucket_policy.is_a?(String) && bucket_policy.strip != ''
             bucket_request(:put,:body => bucket_policy,:subresource=>"policy")
             true
        else  
            false
        end
    end
1220303
public function modify(HeaderBag &$headers)
    {
        $cspHeaders = [
            'Content-Security-Policy' => 'csp',
            'Content-Security-Policy-Report-Only' => 'cspro',
        ];

        foreach ($cspHeaders as $header => $type)
        {
            if ($this->combine)
            {
                $otherPolicyHeaders = $headers->getByName($header);

                $policies = [$this->{$type.'Config'}];

                foreach ($otherPolicyHeaders as $otherPolicy)
                {
                    $policies[]
                        = self::deconstructCSP($otherPolicy->getValue());
                }

                $this->{$type.'Config'} = self::mergeCSPList($policies);
            }

            $value = $this->{'compile'.strtoupper($type)}();

            if (empty($value))
            {
                continue;
            }

            $headers->{($this->combine ? 'replace' : 'add')}($header, $value);

            if ($this->sendLegacyHeaders)
            {
                $headers->{($this->combine ? 'replace' : 'add')}("X-$header", $value);
            }
        }
    }
503673
def add_to_inventory(self):
        """"""
        if not self.server_attrs:
            return
        for addy in self.server_attrs[A.server.PUBLIC_IPS]:
            self.stack.add_host(addy, self.groups, self.hostvars)
435493
def add_CSSsource(self, new_src):
        """"""
        if isinstance(new_src, list):
            for h in new_src:
                self.CSSsource.append(h)
        elif isinstance(new_src, basestring):
            self.CSSsource.append(new_src)
        else:
            raise OptionTypeError("Option: %s Not Allowed For Series Type: %s" % type(new_src))