Felipe Monteiro | c458932 | 2017-06-09 19:42:50 +0100 | [diff] [blame] | 1 | ======================== |
| 2 | Team and repository tags |
| 3 | ======================== |
| 4 | |
shangxiaobj | 11b0232 | 2017-08-14 22:45:11 -0700 | [diff] [blame] | 5 | .. image:: https://governance.openstack.org/tc/badges/patrole.svg |
| 6 | :target: https://governance.openstack.org/tc/reference/tags/index.html |
Felipe Monteiro | c458932 | 2017-06-09 19:42:50 +0100 | [diff] [blame] | 7 | |
Felipe Monteiro | c458932 | 2017-06-09 19:42:50 +0100 | [diff] [blame] | 8 | Patrole - RBAC Integration Tempest Plugin |
| 9 | ========================================= |
DavidPurcell | 663aedf | 2017-01-03 10:01:14 -0500 | [diff] [blame] | 10 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 11 | Patrole is a security validation tool for verifying that Role-Based Access |
Felipe Monteiro | 443d39c | 2018-04-08 17:05:33 -0400 | [diff] [blame] | 12 | Control is correctly configured and enforced in a system. It runs |
| 13 | `Tempest`_-based API tests using specified RBAC roles, thus allowing |
| 14 | deployments to verify that only intended roles have access to those APIs. |
DavidPurcell | 663aedf | 2017-01-03 10:01:14 -0500 | [diff] [blame] | 15 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 16 | Patrole currently offers testing for the following OpenStack services: Nova, |
| 17 | Neutron, Glance, Cinder and Keystone. |
DavidPurcell | 663aedf | 2017-01-03 10:01:14 -0500 | [diff] [blame] | 18 | |
Felipe Monteiro | c287389 | 2017-11-15 06:09:02 +0000 | [diff] [blame] | 19 | Patrole is currently undergoing heavy development. As more projects move |
| 20 | toward policy in code, Patrole will align its testing with the appropriate |
| 21 | documentation. |
| 22 | |
Felipe Monteiro | 443d39c | 2018-04-08 17:05:33 -0400 | [diff] [blame] | 23 | .. _Tempest: https://docs.openstack.org/tempest/latest/ |
| 24 | |
Felipe Monteiro | c287389 | 2017-11-15 06:09:02 +0000 | [diff] [blame] | 25 | Design Principles |
| 26 | ----------------- |
| 27 | |
| 28 | Patrole borrows some design principles from Tempest, but not all, as its |
| 29 | testing scope is confined to policies. |
| 30 | |
| 31 | * *Stability*. Patrole uses OpenStack public interfaces. Tests in Patrole |
| 32 | should only touch public OpenStack APIs. |
| 33 | * *Atomicity*. Patrole tests should be atomic: they should test policies in |
| 34 | isolation. Unlike Tempest, a Patrole test strives to only call a single |
| 35 | endpoint at a time. |
Felipe Monteiro | 543f7b9 | 2018-06-10 13:38:31 -0400 | [diff] [blame^] | 36 | * *Complete coverage*. Patrole should validate all policy in code defaults. For |
| 37 | testing, Patrole uses the API-to-policy mapping contained in each project's |
| 38 | `policy in code`_ documentation where applicable. |
| 39 | |
| 40 | For example, Nova's policy in code documentation is located in the |
| 41 | `Nova repository`_ under ``nova/policies``. Likewise, Keystone's policy in |
| 42 | code documentation is located in the `Keystone repository`_ under |
| 43 | ``keystone/common/policies``. The other OpenStack services follow the same |
| 44 | directory layout pattern with respect to policy in code. |
| 45 | |
| 46 | .. note:: |
| 47 | |
| 48 | Realistically this is not always possible because some services have |
| 49 | not yet moved to policy in code. |
| 50 | |
| 51 | * *Self-cleaning*. Patrole should attempt to clean up after itself; whenever |
Felipe Monteiro | c287389 | 2017-11-15 06:09:02 +0000 | [diff] [blame] | 52 | possible we should tear down resources when done. |
| 53 | |
| 54 | .. note:: |
| 55 | |
| 56 | Patrole modifies roles dynamically in the background, which affects |
| 57 | pre-provisioned credentials. Work is currently underway to clean up |
| 58 | modifications made to pre-provisioned credentials. |
| 59 | |
Felipe Monteiro | 543f7b9 | 2018-06-10 13:38:31 -0400 | [diff] [blame^] | 60 | * *Self-testing*. Patrole should be self-testing. |
| 61 | |
| 62 | .. _policy in code: https://specs.openstack.org/openstack/oslo-specs/specs/newton/policy-in-code.html |
| 63 | .. _Nova repository: https://github.com/openstack/nova/tree/master/nova/policies |
| 64 | .. _Keystone repository: https://github.com/openstack/keystone/tree/master/keystone/common/policies |
Felipe Monteiro | c287389 | 2017-11-15 06:09:02 +0000 | [diff] [blame] | 65 | |
DavidPurcell | 663aedf | 2017-01-03 10:01:14 -0500 | [diff] [blame] | 66 | Features |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 67 | -------- |
| 68 | * Validation of default policy definitions located in policy.json files. |
| 69 | * Validation of in-code policy definitions. |
| 70 | * Validation of custom policy file definitions that override default policy |
| 71 | definitions. |
| 72 | * Built-in positive and negative testing. Positive and negative testing |
| 73 | are performed using the same tests and role-switching. |
| 74 | * Valdation of custom roles as well as default OpenStack roles. |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 75 | |
| 76 | .. note:: |
| 77 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 78 | Patrole does not yet support policy.yaml files, the new file format for |
| 79 | policy files in OpenStack. |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 80 | |
| 81 | How It Works |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 82 | ------------ |
| 83 | Patrole leverages ``oslo.policy`` (OpenStack's policy enforcement engine) to |
| 84 | determine whether a given role is allowed to perform a policy action, given a |
| 85 | specific role and OpenStack service. The output from ``oslo.policy`` (the |
| 86 | expected result) and the actual result from test execution are compared to |
| 87 | each other: if both results match, then the test passes; else it fails. |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 88 | |
gaozx | 268b71d | 2017-07-20 21:35:35 -0400 | [diff] [blame] | 89 | * Documentation: https://docs.openstack.org/patrole/latest/ |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 90 | * Bugs: https://bugs.launchpad.net/patrole |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 91 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 92 | Quickstart |
Felipe Monteiro | 7c7b570 | 2017-07-21 01:43:42 +0100 | [diff] [blame] | 93 | ---------- |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 94 | Tempest is a prerequisite for running Patrole. If you do not have Tempest |
| 95 | installed, please reference the official Tempest documentation for guidance. |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 96 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 97 | Assuming Tempest is installed, the simplest way to configure Patrole is: |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 98 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 99 | 1. Open up the ``tempest.conf`` configuration file and include the following |
| 100 | settings: |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 101 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 102 | .. code-block:: ini |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 103 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 104 | [rbac] |
| 105 | enable_rbac = True |
| 106 | rbac_test_role = admin |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 107 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 108 | These settings tell Patrole to run RBAC tests using the "admin" role (which |
| 109 | is the default admin role in OpenStack) to verify the default policy |
| 110 | definitions used by OpenStack services. Specifying a different role |
| 111 | for ``rbac_test_role`` will run Patrole tests against that role. For additional |
| 112 | information about Patrole's configuration settings, please refer to |
| 113 | :ref:`patrole-configuration` and :ref:`patrole-sampleconf` for a sample |
| 114 | configuration file. |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 115 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 116 | 2. You are now ready to run Patrole. To do so, you can use any testr-based test |
| 117 | runner:: |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 118 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 119 | $ testr run patrole_tempest_plugin.tests.api |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 120 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 121 | or:: |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 122 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 123 | $ ostestr --regex '(?!.*\[.*\bslow\b.*\])(^patrole_tempest_plugin\.tests\.api)' |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 124 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 125 | It is also possible to run Patrole using tox:: |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 126 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 127 | tox -eall-plugin -- patrole_tempest_plugin.tests.api |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 128 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 129 | Release Versioning |
Felipe Monteiro | 7c7b570 | 2017-07-21 01:43:42 +0100 | [diff] [blame] | 130 | ------------------ |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 131 | `Patrole Release Notes <https://docs.openstack.org/releasenotes/patrole/>`_ |
| 132 | shows which changes have been released for each version. |
Felipe Monteiro | 7bc35dc | 2017-04-19 21:11:46 +0100 | [diff] [blame] | 133 | |
Felipe Monteiro | 780210d | 2017-07-17 22:21:53 +0100 | [diff] [blame] | 134 | Patrole's release versioning follows Tempest's conventions. Like Tempest, |
| 135 | Patrole is branchless and uses versioning instead. |