blob: 510388898d23cab21d85d5dce79c6b9b6917ebbf [file] [log] [blame]
DavidPurcellb25f93d2017-01-27 12:46:27 -05001# Copyright 2017 AT&T Corporation.
DavidPurcell663aedf2017-01-03 10:01:14 -05002# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from oslo_config import cfg
17
DavidPurcell029d8c32017-01-06 15:27:41 -050018
Felipe Monteirof6eb8622017-08-06 06:08:02 +010019patrole_group = cfg.OptGroup(name='patrole', title='Patrole Testing Options')
20
21
22PatroleGroup = [
DavidPurcell029d8c32017-01-06 15:27:41 -050023 cfg.StrOpt('rbac_test_role',
24 default='admin',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010025 help="""The current RBAC role against which to run Patrole
26tests."""),
Samantha Blanco0d880082017-03-23 18:14:37 -040027 cfg.BoolOpt('enable_rbac',
Felipe Monteiro2c0c55a2017-03-06 17:22:10 -050028 default=True,
Samantha Blanco0d880082017-03-23 18:14:37 -040029 help="Enables RBAC tests."),
Rick Bartraed950052017-06-29 17:20:33 -040030 # TODO(rb560u): There needs to be support for reading these JSON files from
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010031 # other hosts. It may be possible to leverage the v3 identity policy API.
32 cfg.ListOpt('custom_policy_files',
33 default=['/etc/%s/policy.json'],
34 help="""List of the paths to search for policy files. Each
35policy path assumes that the service name is included in the path once. Also
36assumes Patrole is on the same host as the policy files. The paths should be
37ordered by precedence, with high-priority paths before low-priority paths. The
38first path that is found to contain the service's policy file will be used.
39"""),
Rick Bartraed950052017-06-29 17:20:33 -040040 cfg.BoolOpt('test_custom_requirements',
41 default=False,
42 help="""
43This option determines whether Patrole should run against a
44`custom_requirements_file` which defines RBAC requirements. The
45purpose of setting this flag to True is to verify that RBAC policy
46is in accordance to requirements. The idea is that the
47`custom_requirements_file` perfectly defines what the RBAC requirements are.
48
49Here are the possible outcomes when running the Patrole tests against
50a `custom_requirements_file`:
51
52YAML definition: allowed
53test run: allowed
54test result: pass
55
56YAML definition: allowed
57test run: not allowed
58test result: fail (under-permission)
59
60YAML definition: not allowed
61test run: allowed
62test result: fail (over-permission)
63"""),
64 cfg.StrOpt('custom_requirements_file',
65 help="""
66File path of the yaml file that defines your RBAC requirements. This
67file must be located on the same host that Patrole runs on. The yaml
68file should be written as follows:
69
70```
71<service>:
72 <api_action>:
73 - <allowed_role>
74 - <allowed_role>
75 - <allowed_role>
76 <api_action>:
77 - <allowed_role>
78 - <allowed_role>
79<service>
80 <api_action>:
81 - <allowed_role>
82```
83Where:
84service = the service that is being tested (cinder, nova, etc)
85api_action = the policy action that is being tested. Examples:
86 - volume:create
87 - os_compute_api:servers:start
88 - add_image
89allowed_role = the Keystone role that is allowed to perform the API
90""")
DavidPurcell029d8c32017-01-06 15:27:41 -050091]
Felipe Monteirof6eb8622017-08-06 06:08:02 +010092
93
Sean Pryor7f8993f2017-08-14 12:53:17 -040094patrole_log_group = cfg.OptGroup(
95 name='patrole_log', title='Patrole Logging Options')
96
Felipe Monteiro739041f2018-03-25 00:24:03 -040097
Sean Pryor7f8993f2017-08-14 12:53:17 -040098PatroleLogGroup = [
99 cfg.BoolOpt('enable_reporting',
100 default=False,
101 help="Enables reporting on RBAC expected and actual test "
102 "results for each Patrole test"),
103 cfg.StrOpt('report_log_name',
104 default='patrole.log',
105 help="Name of file where output from 'enable_reporting' is "
106 "logged. Note that this file is recreated on each "
107 "invocation of patrole"),
108 cfg.StrOpt('report_log_path',
109 default='.',
110 help="Path (relative or absolute) where the output from "
111 "'enable_reporting' is logged. This is combined with"
112 "report_log_name to generate the full path."),
113]
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100114
115
Felipe Monteiro739041f2018-03-25 00:24:03 -0400116policy_feature_enabled = cfg.OptGroup(
117 name='policy-feature-enabled',
118 title='Feature Flags for New or Changed Policies')
119
120
121PolicyFeatureEnabledGroup = [
122 # TODO(felipemonteiro): The 6 feature flags below should be removed after
123 # Pike is EOL.
124 cfg.BoolOpt('create_port_fixed_ips_ip_address_policy',
125 default=True,
126 help="""Is the Neutron policy
127"create_port:fixed_ips:ip_address" available in the cloud? This policy was
128changed in a backwards-incompatible way."""),
129 cfg.BoolOpt('update_port_fixed_ips_ip_address_policy',
130 default=True,
131 help="""Is the Neutron policy
132"update_port:fixed_ips:ip_address" available in the cloud? This policy was
133changed in a backwards-incompatible way."""),
134 cfg.BoolOpt('limits_extension_used_limits_policy',
135 default=True,
136 help="""Is the Cinder policy
137"limits_extension:used_limits" available in the cloud? This policy was
138changed in a backwards-incompatible way."""),
139 cfg.BoolOpt('volume_extension_volume_actions_attach_policy',
140 default=True,
141 help="""Is the Cinder policy
142"volume_extension:volume_actions:attach" available in the cloud? This policy
143was changed in a backwards-incompatible way."""),
144 cfg.BoolOpt('volume_extension_volume_actions_reserve_policy',
145 default=True,
146 help="""Is the Cinder policy
147"volume_extension:volume_actions:reserve" available in the cloud? This policy
148was changed in a backwards-incompatible way."""),
149 cfg.BoolOpt('volume_extension_volume_actions_unreserve_policy',
150 default=True,
151 help="""Is the Cinder policy
152"volume_extension:volume_actions:unreserve" available in the cloud? This policy
153was changed in a backwards-incompatible way.""")
154]
155
156
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100157def list_opts():
158 """Return a list of oslo.config options available.
159
160 The purpose of this is to allow tools like the Oslo sample config file
161 generator to discover the options exposed to users.
162 """
163 opt_list = [
164 (patrole_group, PatroleGroup),
Felipe Monteiro739041f2018-03-25 00:24:03 -0400165 (patrole_log_group, PatroleLogGroup),
166 (policy_feature_enabled, PolicyFeatureEnabledGroup)
167
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100168 ]
169
170 return opt_list