[
  {
    "path": ".gitignore",
    "content": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packaging\n.Python\nbuild/\ndevelop-eggs/\ndist/\ndownloads/\neggs/\n.eggs/\nlib/\nlib64/\nparts/\nsdist/\nvar/\nwheels/\n*.egg-info/\n.installed.cfg\n*.egg\nMANIFEST\n\n# PyInstaller\n#  Usually these files are written by a python script from a template\n#  before PyInstaller builds the exe, so as to inject date/other infos into it.\n*.manifest\n*.spec\n\n# Installer logs\npip-log.txt\npip-delete-this-directory.txt\n\n# Unit test / coverage reports\nhtmlcov/\n.tox/\n.coverage\n.coverage.*\n.cache\nnosetests.xml\ncoverage.xml\n*.cover\n.hypothesis/\n.pytest_cache/\n\n# Translations\n*.mo\n*.pot\n\n# Django stuff:\n*.log\nlocal_settings.py\ndb.sqlite3\n\n# Flask stuff:\ninstance/\n.webassets-cache\n\n# Scrapy stuff:\n.scrapy\n\n# Sphinx documentation\ndocs/_build/\n\n# PyBuilder\ntarget/\n\n# Jupyter Notebook\n.ipynb_checkpoints\n\n# pyenv\n.python-version\n\n# celery beat schedule file\ncelerybeat-schedule\n\n# SageMath parsed files\n*.sage.py\n\n# Environments\n.env\n.venv\nenv/\nvenv/\nENV/\nenv.bak/\nvenv.bak/\n\n# Spyder project settings\n.spyderproject\n.spyproject\n\n# Rope project settings\n.ropeproject\n\n# mkdocs documentation\n/site\n\n# mypy\n.mypy_cache/\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing to Kubernetes-rbac-audit\n\nThanks for your interest in this project!\n\nFor general contribution and community guidelines, please see the [community repo](https://github.com/cyberark/community).\nIn particular, before contributing please review our [contributor licensing guide](https://github.com/cyberark/community/blob/master/CONTRIBUTING.md#when-the-repo-does-not-include-the-cla)\nto ensure your contribution is compliant with our contributor license agreements.\n\n## Pull Request Workflow\n\n1. Search the [open issues][issues] in GitHub to find out what has been planned\n2. Open an issue in this repository to propose changes or fixes\n3. Add the `implementing` label to the issue as you begin to work on it\n4. Run RSpec and Cucumber tests as described [here][tests], ensuring they pass\n5. Submit a pull request, and include a link to the issue in your PR description (e.g. `Connected to #123`)\n6. Add the `implemented` label to the issue, and ask another contributor to review and merge your code\n7. Close the issue\n\n\n"
  },
  {
    "path": "ExtensiveRoleCheck.py",
    "content": "import json\r\nimport argparse\r\nimport logging\r\nfrom colorama import init, Fore, Back, Style\r\n\r\ndef get_argument_parser():\r\n    parser = argparse.ArgumentParser()\r\n    parser.add_argument('--clusterRole', type=str, required=False, help='ClusterRoles JSON file',)\r\n    parser.add_argument('--role', type=str, required=False, help='roles JSON file')\r\n    parser.add_argument('--rolebindings', type=str, required=False, help='RoleBindings JSON file')\r\n    parser.add_argument('--cluseterolebindings', type=str, required=False, help='ClusterRoleBindings JSON file')\r\n    return parser.parse_args()\r\n\r\n# Read data from files\r\ndef open_file(file_path):\r\n    with open(file_path) as f:\r\n        return json.load(f)\r\n\r\nclass ExtensiveRolesChecker(object):\r\n    def __init__(self, json_file, role_kind):\r\n        init()\r\n        self._role = logging.getLogger(role_kind)\r\n        self._role_handler = logging.StreamHandler()\r\n        self._role_format = logging.Formatter(f'{Fore.YELLOW}[!][%(name)s]{Fore.WHITE}\\u2192 %(message)s')\r\n        self._role_handler.setFormatter(self._role_format)\r\n        self._role.addHandler(self._role_handler)\r\n        self._json_file = json_file\r\n        self._results = {}\r\n        self._generate()\r\n\r\n    @property\r\n    def results(self):\r\n        return self._results\r\n\r\n    def add_result(self, name, value):\r\n        if not name:\r\n            return\r\n        if not (name in self._results.keys()):\r\n            self._results[name] = [value]\r\n        else:\r\n            self._results[name].append(value)\r\n\r\n    def _generate(self):\r\n        for entity in self._json_file['items']:\r\n            role_name = entity['metadata']['name']\r\n            for rule in entity['rules']:\r\n                if not rule.get('resources', None):\r\n                    continue\r\n                self.get_read_secrets(rule, role_name)\r\n                self.clusteradmin_role(rule, role_name)\r\n                self.any_resources(rule, role_name)\r\n                self.any_verb(rule, role_name)\r\n                self.high_risk_roles(rule, role_name)\r\n                self.role_and_roleBindings(rule, role_name)\r\n                self.create_pods(rule, role_name)\r\n                self.pods_exec(rule, role_name)\r\n                self.pods_attach(rule, role_name)\r\n\r\n    #Read cluster secrets:\r\n    def get_read_secrets(self, rule, role_name):\r\n        verbs = ['*','get','list']\r\n        if ('secrets' in rule['resources'] and any([sign for sign in verbs if sign in rule['verbs']])):\r\n            filtered_name = self.get_non_default_name(role_name)\r\n            if filtered_name:\r\n                self._role.warning(f'{Fore.GREEN}{filtered_name}' + f'{Fore.RED} Has permission to list secrets!')\r\n                self.add_result(filtered_name, 'Has permission to list secrets!')\r\n\r\n    #Any Any roles\r\n    def clusteradmin_role(self, rule, role_name):\r\n        if ('*' in rule['resources'] and '*' in rule['verbs']):\r\n            filtered_name = self.get_non_default_name(role_name)\r\n            if filtered_name:\r\n                self._role.warning(f'{Fore.GREEN}{filtered_name}'+ f'{Fore.RED} Has Admin-Cluster permission!')\r\n                self.add_result(filtered_name, 'Has Admin-Cluster permission!')\r\n\r\n    #get ANY verbs:\r\n    def any_verb(self, rule, role_name):\r\n        resources = ['secrets',\r\n                    'pods',\r\n                    'deployments',\r\n                    'daemonsets',\r\n                    'statefulsets',\r\n                    'replicationcontrollers',\r\n                    'replicasets',\r\n                    'cronjobs',\r\n                    'jobs',\r\n                    'roles',\r\n                    'clusterroles',\r\n                    'rolebindings',\r\n                    'clusterrolebindings',\r\n                    'users',\r\n                    'groups']\r\n        found_sign = [sign for sign in resources if sign in rule['resources']]\r\n        if not found_sign:\r\n            return\r\n        if '*' in rule['verbs']:\r\n            filtered_name = self.get_non_default_name(role_name)\r\n            if filtered_name:\r\n                self._role.warning(f'{Fore.GREEN}{filtered_name}'+ f'{Fore.RED} Has permission to access {found_sign[0]} with any verb!')\r\n                self.add_result(filtered_name, f'Has permission to access {found_sign[0]} with any verb!')\r\n\r\n    def any_resources(self, rule, role_name):\r\n        verbs = ['delete','deletecollection', 'create','list' , 'get' , 'impersonate']\r\n        found_sign = [sign for sign in verbs if sign in rule['verbs']]\r\n        if not found_sign:\r\n            return\r\n        if ('*' in rule['resources']):\r\n            filtered_name = self.get_non_default_name(role_name)\r\n            if filtered_name:\r\n                self._role.warning(f'{Fore.GREEN}{filtered_name}'+ f'{Fore.RED} Has permission to use {found_sign[0]} on any resource!')\r\n                self.add_result(filtered_name, f'Has permission to use {found_sign[0]} on any resource')\r\n\r\n    def high_risk_roles(self, rule, role_name):\r\n        verb_actions = ['create','update']\r\n        resources_attributes = ['deployments','daemonsets','statefulsets','replicationcontrollers','replicasets','jobs','cronjobs']\r\n        found_attribute = [attribute for attribute in resources_attributes if attribute in rule['resources']]\r\n        if not (found_attribute):\r\n            return\r\n        found_actions = [action for action in verb_actions if action in rule['verbs']]\r\n        if not (found_actions):\r\n            return\r\n        filtered_name = self.get_non_default_name(role_name)\r\n        if filtered_name:\r\n            self._role.warning(f'{Fore.GREEN}{filtered_name}'+ f'{Fore.RED} Has permission to {found_actions[0]} {found_attribute[0]}!')\r\n            self.add_result(filtered_name, f'Has permission to {found_actions[0]} {found_attribute[0]}!')\r\n\r\n    def role_and_roleBindings(self, rule, role_name):\r\n        resources_attributes = ['rolebindings','roles','clusterrolebindings']\r\n        found_attribute = [attribute for attribute in resources_attributes if attribute in rule['resources']]\r\n        if not found_attribute:\r\n            return\r\n        if ('create' in rule['verbs']):\r\n            filtered_name = self.get_non_default_name(role_name)\r\n            if filtered_name:\r\n                self._role.warning(f'{Fore.GREEN}{filtered_name}' + f'{Fore.RED} Has permission to create {found_attribute[0]}!')\r\n                self.add_result(filtered_name, f'Has permission to create {found_attribute[0]}!')\r\n\r\n\r\n    def create_pods(self, rule, role_name):\r\n        if 'pods' in rule['resources'] and 'create' in rule['verbs']:\r\n            filtered_name = self.get_non_default_name(role_name)\r\n            if filtered_name:\r\n                self._role.warning(f'{Fore.GREEN}{filtered_name}'+ f'{Fore.RED} Has permission to create pods!')\r\n                self.add_result(filtered_name, 'Has permission to create pods!')\r\n\r\n    def pods_exec(self, rule, role_name):\r\n        if 'pods/exec' in rule['resources'] and 'create' in rule['verbs']:\r\n            filtered_name = self.get_non_default_name(role_name)\r\n            if filtered_name:\r\n                self._role.warning(f'{Fore.GREEN}{filtered_name}' + f'{Fore.RED} Has permission to use pod exec!')\r\n                self.add_result(filtered_name, 'Has permission to use pod exec!')\r\n\r\n    def pods_attach(self, rule, role_name):\r\n        if 'pods/attach' in rule['resources'] and 'create' in rule['verbs']:\r\n            filtered_name = self.get_non_default_name(role_name)\r\n            if filtered_name:\r\n                self._role.warning(f'{Fore.GREEN}{filtered_name}' + f'{Fore.RED} Has permission to attach pods!')\r\n                self.add_result(filtered_name, 'Has permission to attach pods!')\r\n\r\n    @staticmethod\r\n    def get_non_default_name(name):\r\n        if not ((name[:7] == 'system:') or (name == 'edit') or (name == 'admin') or (name == 'cluster-admin') or (name == 'aws-node') or (name[:11] == 'kubernetes-')):\r\n            return name\r\n\r\n\r\nclass roleBingingChecker(object):\r\n    def __init__(self, json_file, extensive_roles, bind_kind):\r\n        self._json_file = json_file\r\n        self._extensive_roles = extensive_roles\r\n        self._bind_kind = bind_kind\r\n        self._results = []\r\n        self.bindsCheck()\r\n\r\n    def bindsCheck(self):\r\n        _rolebiding_found = []\r\n        for entity in self._json_file['items']:\r\n            _role_name = entity['metadata']['name']\r\n            _rol_ref = entity['roleRef']['name']\r\n            if not entity.get('subjects', None):\r\n                continue\r\n            if _rol_ref in self._extensive_roles:\r\n                _rolebiding_found.append(_rol_ref)\r\n                for sub in entity['subjects']:\r\n                    if not sub.get('name', None):\r\n                        continue\r\n                    self.print_rolebinding_results(sub, _role_name, self._bind_kind)\r\n        return _rolebiding_found\r\n\r\n    def print_rolebinding_results(self, sub, role_name, bind_kind):\r\n        if sub['kind'] == 'ServiceAccount':\r\n            print(f'{Fore.YELLOW}[!][{bind_kind}]{Fore.WHITE}\\u2192 ' + f'{Fore.GREEN}{role_name}{Fore.RED} is binded to {sub[\"name\"]} ServiceAccount.')\r\n        else:\r\n            print(f'{Fore.YELLOW}[!][{bind_kind}]{Fore.WHITE}\\u2192 ' + f'{Fore.GREEN}{role_name}{Fore.RED} is binded to the {sub[\"kind\"]}: {sub[\"name\"]}!')\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n    args = get_argument_parser()\r\n    if args.clusterRole:\r\n        print('\\n[*] Started enumerating risky ClusterRoles:')\r\n        role_kind = 'ClusterRole'\r\n        clusterRole_json_file = open_file(args.clusterRole)\r\n        extensiveClusterRolesChecker = ExtensiveRolesChecker(clusterRole_json_file, role_kind)\r\n        extensive_ClusterRoles = [result for result in extensiveClusterRolesChecker.results]\r\n\r\n    if args.role:\r\n        print(f'{Fore.WHITE}[*] Started enumerating risky Roles:')\r\n        role_kind = 'Role'\r\n        Role_json_file = open_file(args.role)\r\n        extensiveRolesChecker = ExtensiveRolesChecker(Role_json_file, role_kind)\r\n        extensive_roles = [result for result in extensiveRolesChecker.results if result not in extensive_ClusterRoles]\r\n        extensive_roles = extensive_roles + extensive_ClusterRoles\r\n\r\n    if args.cluseterolebindings:\r\n        print(f'{Fore.WHITE}[*] Started enumerating risky ClusterRoleBinding:')\r\n        bind_kind = 'ClusterRoleBinding'\r\n        clusterRoleBinding_json_file = open_file(args.cluseterolebindings)\r\n        extensive_clusteRoleBindings = roleBingingChecker(clusterRoleBinding_json_file, extensive_roles, bind_kind)\r\n\r\n    if args.rolebindings:\r\n        print(f'{Fore.WHITE}[*] Started enumerating risky RoleRoleBindings:')\r\n        bind_kind = 'RoleBinding'\r\n        RoleBinding_json_file = open_file(args.rolebindings)\r\n        extensive_RoleBindings = roleBingingChecker(RoleBinding_json_file, extensive_roles, bind_kind)\r\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# ExtensiveRoleCheck\n\n`ExtensiveRoleCheck` is a Python tool that scans the Kubernetes RBAC for risky roles. The tool is a part of the \"Kubernetes Pentest Methdology\" blog post series.\n```\nusage: ExtensiveRoleCheck.py [-h] [--clusterRole CLUSTERROLE] [--role ROLE]  \n                           [--rolebindings ROLEBINDINGS]  \n                           [--cluseterolebindings CLUSETEROLEBINDINGS]\n```\n\n\n## Overview\n\n**Status**: Alpha\n\nThe RBAC API is a set of roles that administrators can configure to limit access to the Kubernetes resources. The *ExtensiveRoleCheck* automates the searching process and outputs the risky roles and rolebindings found in the RBAC API. \n\n## Requirements:\n*ExtensiveRoleCheck* requires python3\n\n*ExtensiveRoleCheck* works in offline mode. This means that you should first export the following `JSON` from your Kubernetes cluster configuration:\n\n - Roles \n - ClusterRoles \n - RoleBindings \n - ClusterRoleBindings\n\nTo export those files you will need access permissions in the Kubernetes cluster. To export them, you might use the following commands:\n**Export RBAC Roles:**\n```\nkubectl get roles --all-namespaces -o json > Roles.json\n```\n**Export RBAC ClusterRoles:**\n```\nkubectl get clusterroles -o json > clusterroles.json\n```\n**Export RBAC RolesBindings:**\n```\nkubectl get rolebindings --all-namespaces -o json > rolebindings.json\n```\n**Export RBAC Cluster RolesBindings:**\n```\nkubectl get clusterrolebindings -o json > clusterrolebindings.json\n```\n##  example & output:\n**Usage**\n```\npython ExtensiveRoleCheck.py --clusterRole clusterroles.json  --role Roles.json --rolebindings rolebindings.json --cluseterolebindings clusterrolebindings.json\n```\n![Output example](https://github.com/cyberark/kubernetes-rbac-audit/blob/master/output-example.png)\n\n##  Maintainers:\nOr Ida: or.ida@cyberark.com\n\n\n"
  }
]