blob: 0077d1952798b24ed4a62de99bab79a7f54c2811 [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
97PatroleLogGroup = [
98 cfg.BoolOpt('enable_reporting',
99 default=False,
100 help="Enables reporting on RBAC expected and actual test "
101 "results for each Patrole test"),
102 cfg.StrOpt('report_log_name',
103 default='patrole.log',
104 help="Name of file where output from 'enable_reporting' is "
105 "logged. Note that this file is recreated on each "
106 "invocation of patrole"),
107 cfg.StrOpt('report_log_path',
108 default='.',
109 help="Path (relative or absolute) where the output from "
110 "'enable_reporting' is logged. This is combined with"
111 "report_log_name to generate the full path."),
112]
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100113
114
115def list_opts():
116 """Return a list of oslo.config options available.
117
118 The purpose of this is to allow tools like the Oslo sample config file
119 generator to discover the options exposed to users.
120 """
121 opt_list = [
122 (patrole_group, PatroleGroup),
Felipe Monteirob58c1192017-11-20 01:50:24 +0000123 (patrole_log_group, PatroleLogGroup)
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100124 ]
125
126 return opt_list