blob: 8ac2a2096a23ff4ca71c43f8182f193636c0ff7b [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."),
30 cfg.BoolOpt('strict_policy_check',
Felipe Monteirof71def82017-11-07 03:27:13 +000031 default=True,
Felipe Monteirof71def82017-11-07 03:27:13 +000032 deprecated_for_removal=True,
33 deprecated_reason="""This option allows for the possibility
34of false positives. As a testing framework, Patrole should fail any test that
35passes in an invalid policy.""",
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010036 help="""If true, throws RbacParsingException for policies which
37don't exist or are not included in the service's policy file. If false, throws
38skipException."""),
Rick Bartraed950052017-06-29 17:20:33 -040039 # TODO(rb560u): There needs to be support for reading these JSON files from
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010040 # other hosts. It may be possible to leverage the v3 identity policy API.
41 cfg.ListOpt('custom_policy_files',
42 default=['/etc/%s/policy.json'],
43 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,
51 help="""
52This option determines whether Patrole should run against a
53`custom_requirements_file` which defines RBAC requirements. The
54purpose of setting this flag to True is to verify that RBAC policy
55is in accordance to requirements. The idea is that the
56`custom_requirements_file` perfectly defines what the RBAC requirements are.
57
58Here are the possible outcomes when running the Patrole tests against
59a `custom_requirements_file`:
60
61YAML definition: allowed
62test run: allowed
63test result: pass
64
65YAML definition: allowed
66test run: not allowed
67test result: fail (under-permission)
68
69YAML definition: not allowed
70test run: allowed
71test result: fail (over-permission)
72"""),
73 cfg.StrOpt('custom_requirements_file',
74 help="""
75File path of the yaml file that defines your RBAC requirements. This
76file must be located on the same host that Patrole runs on. The yaml
77file should be written as follows:
78
79```
80<service>:
81 <api_action>:
82 - <allowed_role>
83 - <allowed_role>
84 - <allowed_role>
85 <api_action>:
86 - <allowed_role>
87 - <allowed_role>
88<service>
89 <api_action>:
90 - <allowed_role>
91```
92Where:
93service = the service that is being tested (cinder, nova, etc)
94api_action = the policy action that is being tested. Examples:
95 - volume:create
96 - os_compute_api:servers:start
97 - add_image
98allowed_role = the Keystone role that is allowed to perform the API
99""")
DavidPurcell029d8c32017-01-06 15:27:41 -0500100]
Felipe Monteirof6eb8622017-08-06 06:08:02 +0100101
102
Sean Pryor7f8993f2017-08-14 12:53:17 -0400103patrole_log_group = cfg.OptGroup(
104 name='patrole_log', title='Patrole Logging Options')
105
106PatroleLogGroup = [
107 cfg.BoolOpt('enable_reporting',
108 default=False,
109 help="Enables reporting on RBAC expected and actual test "
110 "results for each Patrole test"),
111 cfg.StrOpt('report_log_name',
112 default='patrole.log',
113 help="Name of file where output from 'enable_reporting' is "
114 "logged. Note that this file is recreated on each "
115 "invocation of patrole"),
116 cfg.StrOpt('report_log_path',
117 default='.',
118 help="Path (relative or absolute) where the output from "
119 "'enable_reporting' is logged. This is combined with"
120 "report_log_name to generate the full path."),
121]
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100122
123
124def list_opts():
125 """Return a list of oslo.config options available.
126
127 The purpose of this is to allow tools like the Oslo sample config file
128 generator to discover the options exposed to users.
129 """
130 opt_list = [
131 (patrole_group, PatroleGroup),
Felipe Monteirob58c1192017-11-20 01:50:24 +0000132 (patrole_log_group, PatroleLogGroup)
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100133 ]
134
135 return opt_list