| 1 |
# Copyright 2024 Google LLC |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
|
| 15 |
name: nested_rule2 |
| 16 |
rule: |
| 17 |
variables: |
| 18 |
- name: "permitted_regions" |
| 19 |
expression: "['us', 'uk', 'es']" |
| 20 |
match: |
| 21 |
- condition: resource.?user.orValue("").startsWith("bad") |
| 22 |
rule: |
| 23 |
id: "banned regions" |
| 24 |
description: > |
| 25 |
determine whether the resource origin is in the banned |
| 26 |
list. If the region is also in the permitted list, the |
| 27 |
ban has no effect. |
| 28 |
variables: |
| 29 |
- name: "banned_regions" |
| 30 |
expression: "{'us': false, 'ru': false, 'ir': false}" |
| 31 |
match: |
| 32 |
- condition: | |
| 33 |
resource.origin in variables.banned_regions && |
| 34 |
!(resource.origin in variables.permitted_regions) |
| 35 |
output: "{'banned': 'restricted_region'}" |
| 36 |
explanation: "'resource is in the banned region ' + resource.origin" |
| 37 |
- output: "{'banned': 'bad_actor'}" |
| 38 |
- condition: "!(resource.origin in variables.permitted_regions)" |
| 39 |
output: "{'banned': 'unconfigured_region'}" |
| 40 |
- output: "{}" |