blob: 79662478b8f2c216a8b92da079b2edfe29269dfd [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',
Felipe Monteirof71def82017-11-07 03:27:13 +000033 default=True,
Felipe Monteirof6eb8622017-08-06 06:08:02 +010034 deprecated_group='rbac',
Felipe Monteirof71def82017-11-07 03:27:13 +000035 deprecated_for_removal=True,
36 deprecated_reason="""This option allows for the possibility
37of false positives. As a testing framework, Patrole should fail any test that
38passes in an invalid policy.""",
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010039 help="""If true, throws RbacParsingException for policies which
40don't exist or are not included in the service's policy file. If false, throws
41skipException."""),
Rick Bartraed950052017-06-29 17:20:33 -040042 # TODO(rb560u): There needs to be support for reading these JSON files from
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010043 # other hosts. It may be possible to leverage the v3 identity policy API.
44 cfg.ListOpt('custom_policy_files',
45 default=['/etc/%s/policy.json'],
Felipe Monteirof6eb8622017-08-06 06:08:02 +010046 deprecated_group='rbac',
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010047 help="""List of the paths to search for policy files. Each
48policy path assumes that the service name is included in the path once. Also
49assumes Patrole is on the same host as the policy files. The paths should be
50ordered by precedence, with high-priority paths before low-priority paths. The
51first path that is found to contain the service's policy file will be used.
52"""),
Rick Bartraed950052017-06-29 17:20:33 -040053 cfg.BoolOpt('test_custom_requirements',
54 default=False,
Felipe Monteirof6eb8622017-08-06 06:08:02 +010055 deprecated_group='rbac',
Rick Bartraed950052017-06-29 17:20:33 -040056 help="""
57This option determines whether Patrole should run against a
58`custom_requirements_file` which defines RBAC requirements. The
59purpose of setting this flag to True is to verify that RBAC policy
60is in accordance to requirements. The idea is that the
61`custom_requirements_file` perfectly defines what the RBAC requirements are.
62
63Here are the possible outcomes when running the Patrole tests against
64a `custom_requirements_file`:
65
66YAML definition: allowed
67test run: allowed
68test result: pass
69
70YAML definition: allowed
71test run: not allowed
72test result: fail (under-permission)
73
74YAML definition: not allowed
75test run: allowed
76test result: fail (over-permission)
77"""),
78 cfg.StrOpt('custom_requirements_file',
Felipe Monteirof6eb8622017-08-06 06:08:02 +010079 deprecated_group='rbac',
Rick Bartraed950052017-06-29 17:20:33 -040080 help="""
81File path of the yaml file that defines your RBAC requirements. This
82file must be located on the same host that Patrole runs on. The yaml
83file should be written as follows:
84
85```
86<service>:
87 <api_action>:
88 - <allowed_role>
89 - <allowed_role>
90 - <allowed_role>
91 <api_action>:
92 - <allowed_role>
93 - <allowed_role>
94<service>
95 <api_action>:
96 - <allowed_role>
97```
98Where:
99service = the service that is being tested (cinder, nova, etc)
100api_action = the policy action that is being tested. Examples:
101 - volume:create
102 - os_compute_api:servers:start
103 - add_image
104allowed_role = the Keystone role that is allowed to perform the API
105""")
DavidPurcell029d8c32017-01-06 15:27:41 -0500106]
Felipe Monteirof6eb8622017-08-06 06:08:02 +0100107
108
109rbac_group = cfg.OptGroup(name='rbac',
110 title='RBAC testing options',
111 help="This group is deprecated and will be removed "
112 "in the next release. Use the [patrole] group "
113 "instead.")
Sean Pryor7f8993f2017-08-14 12:53:17 -0400114
115patrole_log_group = cfg.OptGroup(
116 name='patrole_log', title='Patrole Logging Options')
117
118PatroleLogGroup = [
119 cfg.BoolOpt('enable_reporting',
120 default=False,
121 help="Enables reporting on RBAC expected and actual test "
122 "results for each Patrole test"),
123 cfg.StrOpt('report_log_name',
124 default='patrole.log',
125 help="Name of file where output from 'enable_reporting' is "
126 "logged. Note that this file is recreated on each "
127 "invocation of patrole"),
128 cfg.StrOpt('report_log_path',
129 default='.',
130 help="Path (relative or absolute) where the output from "
131 "'enable_reporting' is logged. This is combined with"
132 "report_log_name to generate the full path."),
133]
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100134
135
136def list_opts():
137 """Return a list of oslo.config options available.
138
139 The purpose of this is to allow tools like the Oslo sample config file
140 generator to discover the options exposed to users.
141 """
142 opt_list = [
143 (patrole_group, PatroleGroup),
144 (patrole_log_group, PatroleLogGroup),
145 (rbac_group, PatroleGroup)
146 ]
147
148 return opt_list