blob: d309d605909527cde4a09ecb6154327c94bf6261 [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"""),
Rick Bartraed950052017-06-29 17:20:33 -040049 cfg.BoolOpt('test_custom_requirements',
50 default=False,
Felipe Monteirof6eb8622017-08-06 06:08:02 +010051 deprecated_group='rbac',
Rick Bartraed950052017-06-29 17:20:33 -040052 help="""
53This option determines whether Patrole should run against a
54`custom_requirements_file` which defines RBAC requirements. The
55purpose of setting this flag to True is to verify that RBAC policy
56is in accordance to requirements. The idea is that the
57`custom_requirements_file` perfectly defines what the RBAC requirements are.
58
59Here are the possible outcomes when running the Patrole tests against
60a `custom_requirements_file`:
61
62YAML definition: allowed
63test run: allowed
64test result: pass
65
66YAML definition: allowed
67test run: not allowed
68test result: fail (under-permission)
69
70YAML definition: not allowed
71test run: allowed
72test result: fail (over-permission)
73"""),
74 cfg.StrOpt('custom_requirements_file',
Felipe Monteirof6eb8622017-08-06 06:08:02 +010075 deprecated_group='rbac',
Rick Bartraed950052017-06-29 17:20:33 -040076 help="""
77File path of the yaml file that defines your RBAC requirements. This
78file must be located on the same host that Patrole runs on. The yaml
79file should be written as follows:
80
81```
82<service>:
83 <api_action>:
84 - <allowed_role>
85 - <allowed_role>
86 - <allowed_role>
87 <api_action>:
88 - <allowed_role>
89 - <allowed_role>
90<service>
91 <api_action>:
92 - <allowed_role>
93```
94Where:
95service = the service that is being tested (cinder, nova, etc)
96api_action = the policy action that is being tested. Examples:
97 - volume:create
98 - os_compute_api:servers:start
99 - add_image
100allowed_role = the Keystone role that is allowed to perform the API
101""")
DavidPurcell029d8c32017-01-06 15:27:41 -0500102]
Felipe Monteirof6eb8622017-08-06 06:08:02 +0100103
104
105rbac_group = cfg.OptGroup(name='rbac',
106 title='RBAC testing options',
107 help="This group is deprecated and will be removed "
108 "in the next release. Use the [patrole] group "
109 "instead.")
Sean Pryor7f8993f2017-08-14 12:53:17 -0400110
111patrole_log_group = cfg.OptGroup(
112 name='patrole_log', title='Patrole Logging Options')
113
114PatroleLogGroup = [
115 cfg.BoolOpt('enable_reporting',
116 default=False,
117 help="Enables reporting on RBAC expected and actual test "
118 "results for each Patrole test"),
119 cfg.StrOpt('report_log_name',
120 default='patrole.log',
121 help="Name of file where output from 'enable_reporting' is "
122 "logged. Note that this file is recreated on each "
123 "invocation of patrole"),
124 cfg.StrOpt('report_log_path',
125 default='.',
126 help="Path (relative or absolute) where the output from "
127 "'enable_reporting' is logged. This is combined with"
128 "report_log_name to generate the full path."),
129]
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100130
131
132def list_opts():
133 """Return a list of oslo.config options available.
134
135 The purpose of this is to allow tools like the Oslo sample config file
136 generator to discover the options exposed to users.
137 """
138 opt_list = [
139 (patrole_group, PatroleGroup),
140 (patrole_log_group, PatroleLogGroup),
141 (rbac_group, PatroleGroup)
142 ]
143
144 return opt_list