Debian Codegraph @

policy/testdata/restricted_destinations/policy.yaml

raw symbols SCIP
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: "restricted_destinations"
16 rule:
17 variables:
18 - name: matches_origin_ip
19 expression: >
20 locationCode(origin.ip) == spec.origin
21 - name: has_nationality
22 expression: >
23 has(request.auth.claims.nationality)
24 - name: matches_nationality
25 expression: >
26 variables.has_nationality && request.auth.claims.nationality == spec.origin
27 - name: matches_dest_ip
28 expression: >
29 locationCode(destination.ip) in spec.restricted_destinations
30 - name: matches_dest_label
31 expression: >
32 resource.labels.location in spec.restricted_destinations
33 - name: matches_dest
34 expression: >
35 variables.matches_dest_ip || variables.matches_dest_label
36 match:
37 - condition: variables.matches_nationality && variables.matches_dest
38 output: "true"
39 - condition: >
40 !variables.has_nationality && variables.matches_origin_ip && variables.matches_dest
41 output: "true"
42 - output: "false"