blob: fcf29afe57c1bcc43ff0e771b39942ab4ec994e6 [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 Monteirof6eb8622017-08-06 06:08:02 +010025 deprecated_group='rbac',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010026 help="""The current RBAC role against which to run Patrole
27tests."""),
Samantha Blanco0d880082017-03-23 18:14:37 -040028 cfg.BoolOpt('enable_rbac',
Felipe Monteiro2c0c55a2017-03-06 17:22:10 -050029 default=True,
Felipe Monteirof6eb8622017-08-06 06:08:02 +010030 deprecated_group='rbac',
Samantha Blanco0d880082017-03-23 18:14:37 -040031 help="Enables RBAC tests."),
32 cfg.BoolOpt('strict_policy_check',
33 default=False,
Felipe Monteirof6eb8622017-08-06 06:08:02 +010034 deprecated_group='rbac',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010035 help="""If true, throws RbacParsingException for policies which
36don't exist or are not included in the service's policy file. If false, throws
37skipException."""),
Rick Bartraed950052017-06-29 17:20:33 -040038 # TODO(rb560u): There needs to be support for reading these JSON files from
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010039 # other hosts. It may be possible to leverage the v3 identity policy API.
40 cfg.ListOpt('custom_policy_files',
41 default=['/etc/%s/policy.json'],
Felipe Monteirof6eb8622017-08-06 06:08:02 +010042 deprecated_group='rbac',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010043 help="""List of the paths to search for policy files. Each
44policy path assumes that the service name is included in the path once. Also
45assumes Patrole is on the same host as the policy files. The paths should be
46ordered by precedence, with high-priority paths before low-priority paths. The
47first path that is found to contain the service's policy file will be used.
48"""),
Samantha Blanco85f79d72017-04-21 11:09:14 -040049 cfg.StrOpt('cinder_policy_file',
50 default='/etc/cinder/policy.json',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010051 help="""Location of the Cinder policy file. Assumed to be on
52the same host as Patrole.""",
Felipe Monteirof6eb8622017-08-06 06:08:02 +010053 deprecated_group='rbac',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010054 deprecated_for_removal=True,
55 deprecated_reason="It is better to use `custom_policy_files` "
56 "which supports any OpenStack service."),
Samantha Blanco85f79d72017-04-21 11:09:14 -040057 cfg.StrOpt('glance_policy_file',
58 default='/etc/glance/policy.json',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010059 help="""Location of the Glance policy file. Assumed to be on
60the same host as Patrole.""",
Felipe Monteirof6eb8622017-08-06 06:08:02 +010061 deprecated_group='rbac',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010062 deprecated_for_removal=True,
63 deprecated_reason="It is better to use `custom_policy_files` "
64 "which supports any OpenStack service."),
Samantha Blanco85f79d72017-04-21 11:09:14 -040065 cfg.StrOpt('keystone_policy_file',
66 default='/etc/keystone/policy.json',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010067 help="""Location of the custom Keystone policy file. Assumed to
68be on the same host as Patrole.""",
Felipe Monteirof6eb8622017-08-06 06:08:02 +010069 deprecated_group='rbac',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010070 deprecated_for_removal=True,
71 deprecated_reason="It is better to use `custom_policy_files` "
72 "which supports any OpenStack service."),
Samantha Blanco85f79d72017-04-21 11:09:14 -040073 cfg.StrOpt('neutron_policy_file',
74 default='/etc/neutron/policy.json',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010075 help="""Location of the Neutron policy file. Assumed to be on
76the same host as Patrole.""",
Felipe Monteirof6eb8622017-08-06 06:08:02 +010077 deprecated_group='rbac',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010078 deprecated_for_removal=True,
79 deprecated_reason="It is better to use `custom_policy_files` "
80 "which supports any OpenStack service."),
Samantha Blanco85f79d72017-04-21 11:09:14 -040081 cfg.StrOpt('nova_policy_file',
82 default='/etc/nova/policy.json',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010083 help="""Location of the custom Nova policy file. Assumed to be
84on the same host as Patrole.""",
Felipe Monteirof6eb8622017-08-06 06:08:02 +010085 deprecated_group='rbac',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010086 deprecated_for_removal=True,
87 deprecated_reason="It is better to use `custom_policy_files` "
88 "which supports any OpenStack service."),
Rick Bartraed950052017-06-29 17:20:33 -040089 cfg.BoolOpt('test_custom_requirements',
90 default=False,
Felipe Monteirof6eb8622017-08-06 06:08:02 +010091 deprecated_group='rbac',
Rick Bartraed950052017-06-29 17:20:33 -040092 help="""
93This option determines whether Patrole should run against a
94`custom_requirements_file` which defines RBAC requirements. The
95purpose of setting this flag to True is to verify that RBAC policy
96is in accordance to requirements. The idea is that the
97`custom_requirements_file` perfectly defines what the RBAC requirements are.
98
99Here are the possible outcomes when running the Patrole tests against
100a `custom_requirements_file`:
101
102YAML definition: allowed
103test run: allowed
104test result: pass
105
106YAML definition: allowed
107test run: not allowed
108test result: fail (under-permission)
109
110YAML definition: not allowed
111test run: allowed
112test result: fail (over-permission)
113"""),
114 cfg.StrOpt('custom_requirements_file',
Felipe Monteirof6eb8622017-08-06 06:08:02 +0100115 deprecated_group='rbac',
Rick Bartraed950052017-06-29 17:20:33 -0400116 help="""
117File path of the yaml file that defines your RBAC requirements. This
118file must be located on the same host that Patrole runs on. The yaml
119file should be written as follows:
120
121```
122<service>:
123 <api_action>:
124 - <allowed_role>
125 - <allowed_role>
126 - <allowed_role>
127 <api_action>:
128 - <allowed_role>
129 - <allowed_role>
130<service>
131 <api_action>:
132 - <allowed_role>
133```
134Where:
135service = the service that is being tested (cinder, nova, etc)
136api_action = the policy action that is being tested. Examples:
137 - volume:create
138 - os_compute_api:servers:start
139 - add_image
140allowed_role = the Keystone role that is allowed to perform the API
141""")
DavidPurcell029d8c32017-01-06 15:27:41 -0500142]
Felipe Monteirof6eb8622017-08-06 06:08:02 +0100143
144
145rbac_group = cfg.OptGroup(name='rbac',
146 title='RBAC testing options',
147 help="This group is deprecated and will be removed "
148 "in the next release. Use the [patrole] group "
149 "instead.")
Sean Pryor7f8993f2017-08-14 12:53:17 -0400150
151patrole_log_group = cfg.OptGroup(
152 name='patrole_log', title='Patrole Logging Options')
153
154PatroleLogGroup = [
155 cfg.BoolOpt('enable_reporting',
156 default=False,
157 help="Enables reporting on RBAC expected and actual test "
158 "results for each Patrole test"),
159 cfg.StrOpt('report_log_name',
160 default='patrole.log',
161 help="Name of file where output from 'enable_reporting' is "
162 "logged. Note that this file is recreated on each "
163 "invocation of patrole"),
164 cfg.StrOpt('report_log_path',
165 default='.',
166 help="Path (relative or absolute) where the output from "
167 "'enable_reporting' is logged. This is combined with"
168 "report_log_name to generate the full path."),
169]