ComputeSecurityPolicy
Property | Value |
---|---|
Google Cloud Service Name | Compute Engine |
Google Cloud Service Documentation | /compute/docs/ |
Google Cloud REST Resource Name | v1.securityPolicies |
Google Cloud REST Resource Documentation | /compute/docs/reference/rest/v1/securityPolicies |
Config Connector Resource Short Names | gcpcomputesecuritypolicy gcpcomputesecuritypolicies computesecuritypolicy |
Config Connector Service Name | compute.googleapis.com |
Config Connector Resource Fully Qualified Name | computesecuritypolicies.compute.cnrm.cloud.google.com |
Can Be Referenced by IAMPolicy/IAMPolicyMember | No |
Config Connector Default Average Reconcile Interval In Seconds | 600 |
Custom Resource Definition Properties
Annotations
Fields | |
---|---|
cnrm.cloud.google.com/project-id |
Spec
Schema
adaptiveProtectionConfig:
autoDeployConfig:
confidenceThreshold: float
expirationSec: integer
impactedBaselineThreshold: float
loadThreshold: float
layer7DdosDefenseConfig:
enable: boolean
ruleVisibility: string
advancedOptionsConfig:
jsonCustomConfig:
contentTypes:
- string
jsonParsing: string
logLevel: string
userIpRequestHeaders:
- string
description: string
recaptchaOptionsConfig:
redirectSiteKeyRef:
external: string
name: string
namespace: string
resourceID: string
rule:
- action: string
description: string
headerAction:
requestHeadersToAdds:
- headerName: string
headerValue: string
match:
config:
srcIpRanges:
- string
expr:
expression: string
versionedExpr: string
preconfiguredWafConfig:
exclusion:
- requestCookie:
- operator: string
value: string
requestHeader:
- operator: string
value: string
requestQueryParam:
- operator: string
value: string
requestUri:
- operator: string
value: string
targetRuleIds:
- string
targetRuleSet: string
preview: boolean
priority: integer
rateLimitOptions:
banDurationSec: integer
banThreshold:
count: integer
intervalSec: integer
conformAction: string
enforceOnKey: string
enforceOnKeyConfigs:
- enforceOnKeyName: string
enforceOnKeyType: string
enforceOnKeyName: string
exceedAction: string
exceedRedirectOptions:
target: string
type: string
rateLimitThreshold:
count: integer
intervalSec: integer
redirectOptions:
target: string
type: string
type: string
Fields | |
---|---|
Optional |
Adaptive Protection Config of this security policy. |
Optional |
Auto Deploy Config of this security policy. |
Optional |
Rules are only automatically deployed for alerts on potential attacks with confidence scores greater than this threshold. |
Optional |
Google Cloud Armor stops applying the action in the automatically deployed rule to an identified attacker after this duration. The rule continues to operate against new requests. |
Optional |
Rules are only automatically deployed when the estimated impact to baseline traffic from the suggested mitigation is below this threshold. |
Optional |
Identifies new attackers only when the load to the backend service that is under attack exceeds this threshold. |
Optional |
Layer 7 DDoS Defense Config of this security policy. |
Optional |
If set to true, enables CAAP for L7 DDoS detection. |
Optional |
Rule visibility. Supported values include: "STANDARD", "PREMIUM". |
Optional |
Advanced Options Config of this security policy. |
Optional |
Custom configuration to apply the JSON parsing. Only applicable when JSON parsing is set to STANDARD. |
Required* |
A list of custom Content-Type header values to apply the JSON parsing. |
Required* |
|
Optional |
JSON body parsing. Supported values include: "DISABLED", "STANDARD". |
Optional |
Logging level. Supported values include: "NORMAL", "VERBOSE". |
Optional |
An optional list of case-insensitive request header names to use for resolving the callers client IP address. |
Optional |
|
Optional |
An optional description of this security policy. Max size is 2048. |
Optional |
reCAPTCHA configuration options to be applied for the security policy. |
Required* |
A field to supply a reCAPTCHA site key to be used for all the rules using the redirect action with the type of GOOGLE_RECAPTCHA under the security policy. The specified site key needs to be created from the reCAPTCHA API. The user is responsible for the validity of the specified site key. If not specified, a Google-managed site key is used. |
Optional |
Allowed value: The `name` field of a `RecaptchaEnterpriseKey` resource. |
Optional |
Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names |
Optional |
Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ |
Optional |
Immutable. Optional. The name of the resource. Used for creation and acquisition. When unset, the value of `metadata.name` is used as the default. |
Optional |
The set of rules that belong to this policy. There must always be a default rule (rule with priority 2147483647 and match "*"). If no rules are provided when creating a security policy, a default rule with action "allow" will be added. |
Optional |
|
Required* |
Action to take when match matches the request. |
Optional |
An optional description of this rule. Max size is 64. |
Optional |
Additional actions that are performed on headers. |
Required* |
The list of request headers to add or overwrite if they're already present. |
Required* |
|
Required* |
The name of the header to set. |
Optional |
The value to set the named header to. |
Required* |
A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding action is enforced. |
Optional |
The configuration options available when specifying versioned_expr. This field must be specified if versioned_expr is specified and cannot be specified if versioned_expr is not specified. |
Required* |
Set of IP addresses or ranges (IPV4 or IPV6) in CIDR notation to match against inbound traffic. There is a limit of 10 IP ranges per rule. A value of '*' matches all IPs (can be used to override the default behavior). |
Required* |
|
Optional |
User defined CEVAL expression. A CEVAL expression is used to specify match criteria such as origin.ip, source.region_code and contents in the request header. |
Required* |
Textual representation of an expression in Common Expression Language syntax. The application context of the containing message determines which well-known feature set of CEL is supported. |
Optional |
Predefined rule expression. If this field is specified, config must also be specified. Available options: SRC_IPS_V1: Must specify the corresponding src_ip_ranges field in config. |
Optional |
Preconfigured WAF configuration to be applied for the rule. If the rule does not evaluate preconfigured WAF rules, i.e., if evaluatePreconfiguredWaf() is not used, this field will have no effect. |
Optional |
An exclusion to apply during preconfigured WAF evaluation. |
Optional |
|
Optional |
Request cookie whose value will be excluded from inspection during preconfigured WAF evaluation. |
Optional |
|
Required* |
You can specify an exact match or a partial match by using a field operator and a field value. Available options: EQUALS: The operator matches if the field value equals the specified value. STARTS_WITH: The operator matches if the field value starts with the specified value. ENDS_WITH: The operator matches if the field value ends with the specified value. CONTAINS: The operator matches if the field value contains the specified value. EQUALS_ANY: The operator matches if the field value is any value. |
Optional |
A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY. |
Optional |
Request header whose value will be excluded from inspection during preconfigured WAF evaluation. |
Optional |
|
Required* |
You can specify an exact match or a partial match by using a field operator and a field value. Available options: EQUALS: The operator matches if the field value equals the specified value. STARTS_WITH: The operator matches if the field value starts with the specified value. ENDS_WITH: The operator matches if the field value ends with the specified value. CONTAINS: The operator matches if the field value contains the specified value. EQUALS_ANY: The operator matches if the field value is any value. |
Optional |
A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY. |
Optional |
Request query parameter whose value will be excluded from inspection during preconfigured WAF evaluation. Note that the parameter can be in the query string or in the POST body. |
Optional |
|
Required* |
You can specify an exact match or a partial match by using a field operator and a field value. Available options: EQUALS: The operator matches if the field value equals the specified value. STARTS_WITH: The operator matches if the field value starts with the specified value. ENDS_WITH: The operator matches if the field value ends with the specified value. CONTAINS: The operator matches if the field value contains the specified value. EQUALS_ANY: The operator matches if the field value is any value. |
Optional |
A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY. |
Optional |
Request URI from the request line to be excluded from inspection during preconfigured WAF evaluation. When specifying this field, the query or fragment part should be excluded. |
Optional |
|
Required* |
You can specify an exact match or a partial match by using a field operator and a field value. Available options: EQUALS: The operator matches if the field value equals the specified value. STARTS_WITH: The operator matches if the field value starts with the specified value. ENDS_WITH: The operator matches if the field value ends with the specified value. CONTAINS: The operator matches if the field value contains the specified value. EQUALS_ANY: The operator matches if the field value is any value. |
Optional |
A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY. |
Optional |
A list of target rule IDs under the WAF rule set to apply the preconfigured WAF exclusion. If omitted, it refers to all the rule IDs under the WAF rule set. |
Optional |
|
Required* |
Target WAF rule set to apply the preconfigured WAF exclusion. |
Optional |
When set to true, the action specified above is not enforced. Stackdriver logs for requests that trigger a preview action are annotated as such. |
Required* |
An unique positive integer indicating the priority of evaluation for a rule. Rules are evaluated from highest priority (lowest numerically) to lowest priority (highest numerically) in order. |
Optional |
Rate limit threshold for this security policy. Must be specified if the action is "rate_based_ban" or "throttle". Cannot be specified for any other actions. |
Optional |
Can only be specified if the action for the rule is "rate_based_ban". If specified, determines the time (in seconds) the traffic will continue to be banned by the rate limit after the rate falls below the threshold. |
Optional |
Can only be specified if the action for the rule is "rate_based_ban". If specified, the key will be banned for the configured 'banDurationSec' when the number of requests that exceed the 'rateLimitThreshold' also exceed this 'banThreshold'. |
Required* |
Number of HTTP(S) requests for calculating the threshold. |
Required* |
Interval over which the threshold is computed. |
Required* |
Action to take for requests that are under the configured rate limit threshold. Valid option is "allow" only. |
Optional |
Determines the key to enforce the rateLimitThreshold on. |
Optional |
Enforce On Key Config of this security policy. |
Optional |
|
Optional |
Rate limit key name applicable only for the following key types: HTTP_HEADER -- Name of the HTTP header whose value is taken as the key value. HTTP_COOKIE -- Name of the HTTP cookie whose value is taken as the key value. |
Optional |
Determines the key to enforce the rate_limit_threshold on. |
Optional |
Rate limit key name applicable only for the following key types: HTTP_HEADER -- Name of the HTTP header whose value is taken as the key value. HTTP_COOKIE -- Name of the HTTP cookie whose value is taken as the key value. |
Required* |
Action to take for requests that are above the configured rate limit threshold, to either deny with a specified HTTP response code, or redirect to a different endpoint. Valid options are "deny()" where valid values for status are 403, 404, 429, and 502, and "redirect" where the redirect parameters come from exceedRedirectOptions below. |
Optional |
Parameters defining the redirect action that is used as the exceed action. Cannot be specified if the exceed action is not redirect. |
Optional |
Target for the redirect action. This is required if the type is EXTERNAL_302 and cannot be specified for GOOGLE_RECAPTCHA. |
Required* |
Type of the redirect action. |
Required* |
Threshold at which to begin ratelimiting. |
Required* |
Number of HTTP(S) requests for calculating the threshold. |
Required* |
Interval over which the threshold is computed. |
Optional |
Parameters defining the redirect action. Cannot be specified for any other actions. |
Optional |
Target for the redirect action. This is required if the type is EXTERNAL_302 and cannot be specified for GOOGLE_RECAPTCHA. |
Required* |
Type of the redirect action. Available options: EXTERNAL_302: Must specify the corresponding target field in config. GOOGLE_RECAPTCHA: Cannot specify target field in config. |
Optional |
The type indicates the intended use of the security policy. CLOUD_ARMOR - Cloud Armor backend security policies can be configured to filter incoming HTTP requests targeting backend services. They filter requests before they hit the origin servers. CLOUD_ARMOR_EDGE - Cloud Armor edge security policies can be configured to filter incoming HTTP requests targeting backend services (including Cloud CDN-enabled) as well as backend buckets (Cloud Storage). They filter requests before the request is served from Google's cache. |
* Field is required when parent field is specified
Status
Schema
conditions:
- lastTransitionTime: string
message: string
reason: string
status: string
type: string
fingerprint: string
observedGeneration: integer
selfLink: string
Fields | |
---|---|
conditions |
Conditions represent the latest available observation of the resource's current state. |
conditions[] |
|
conditions[].lastTransitionTime |
Last time the condition transitioned from one status to another. |
conditions[].message |
Human-readable message indicating details about last transition. |
conditions[].reason |
Unique, one-word, CamelCase reason for the condition's last transition. |
conditions[].status |
Status is the status of the condition. Can be True, False, Unknown. |
conditions[].type |
Type is the type of the condition. |
fingerprint |
Fingerprint of this resource. |
observedGeneration |
ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource. |
selfLink |
The URI of the created resource. |
Sample YAML(s)
Lockdown Security Policy With Test
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: compute.cnrm.cloud.google.com/v1beta1
kind: ComputeSecurityPolicy
metadata:
name: computesecuritypolicy-sample-lockdownwithtest
spec:
description: A policy designed to completely lock down network access while testing the effect of opening ports over a few select ranges.
rule:
- action: deny(403)
priority: 2147483647
match:
versionedExpr: SRC_IPS_V1
config:
srcIpRanges:
- "*"
description: Rule matching all IPs with priority 2147483647, set to deny.
- action: allow
preview: true
priority: 1000000000
match:
versionedExpr: SRC_IPS_V1
config:
srcIpRanges:
- 16.0.0.0/4
- 115.128.0.0/9
- 62.48.212.0/24
description: Tests opening listed IP ranges. Logs sent to Stackdriver.
Multirule Security Policy
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: compute.cnrm.cloud.google.com/v1beta1
kind: ComputeSecurityPolicy
metadata:
name: computesecuritypolicy-sample-multirule
spec:
description: A generally permissive policy that locks out a large block of untrusted IPs, except for some allowed trusted IP ranges within them, and never allows IPs from a denylist.
rule:
- action: allow
priority: 2147483647
match:
versionedExpr: SRC_IPS_V1
config:
srcIpRanges:
- "*"
description: This rule must be included in any rule array. Action can change.
- action: deny(502)
priority: 111111111
match:
versionedExpr: SRC_IPS_V1
config:
srcIpRanges:
- 60.0.0.0/6
description: Untrusted range. Block IPs and return 502.
- action: allow
priority: 555
match:
versionedExpr: SRC_IPS_V1
config:
srcIpRanges:
- 63.0.0.0/8
- 61.128.0.0/10
description: Even though they're in an untrusted block, these ranges are OK.
- action: deny(403)
priority: 0
match:
versionedExpr: SRC_IPS_V1
config:
srcIpRanges:
- 145.4.56.4/30
- 63.63.63.63/32
- 4.5.4.0/24
description: Never allow these denylisted IP ranges.