├── cpgqls_client ├── __init__.py ├── queries.py └── client.py ├── setup.cfg ├── requirements.txt ├── requirements-tests.txt ├── tests ├── test_queries.py └── test_client.py ├── example_usage.py ├── setup.py ├── .github └── workflows │ └── build.yml ├── README.md └── LICENSE /cpgqls_client/__init__.py: -------------------------------------------------------------------------------- 1 | from .client import * # noqa 2 | from .queries import * # noqa 3 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | 4 | [metadata] 5 | license_file = LICENSE 6 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | certifi==2020.6.20 2 | chardet==3.0.4 3 | idna==2.10 4 | requests==2.25.1 5 | urllib3==1.26.5 6 | websockets==9.1 7 | -------------------------------------------------------------------------------- /requirements-tests.txt: -------------------------------------------------------------------------------- 1 | attrs==19.3.0 2 | more-itertools==8.4.0 3 | packaging==20.4 4 | pluggy==0.13.1 5 | py==1.10.0 6 | pyparsing==2.4.7 7 | pytest==5.4.3 8 | six==1.15.0 9 | wcwidth==0.2.5 10 | -------------------------------------------------------------------------------- /tests/test_queries.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cpgqls_client import import_code_query 4 | from cpgqls_client import workspace_query 5 | 6 | 7 | def test_workspace_query(): 8 | out = workspace_query() 9 | assert len(out) > 0 10 | 11 | 12 | def test_import_code_query(): 13 | with pytest.raises(Exception): 14 | import_code_query(None) 15 | 16 | out = import_code_query("/unix/path") 17 | assert len(out) > 0 18 | 19 | out = import_code_query("C:\\windows\\path") 20 | assert len(out) > 0 21 | 22 | out = import_code_query("/unix/path", "my-project") 23 | assert len(out) > 0 24 | 25 | out = import_code_query("/unix/path", "my-project", "c") 26 | assert len(out) > 0 27 | -------------------------------------------------------------------------------- /example_usage.py: -------------------------------------------------------------------------------- 1 | from cpgqls_client import CPGQLSClient, import_code_query, workspace_query 2 | 3 | server_endpoint = "localhost:8080" 4 | basic_auth_credentials = ("username", "password") 5 | client = CPGQLSClient(server_endpoint, auth_credentials=basic_auth_credentials) 6 | 7 | # execute a simple CPGQuery 8 | query = "val a = 1" 9 | result = client.execute(query) 10 | print(result) 11 | 12 | # execute a `workspace` CPGQuery 13 | query = workspace_query() 14 | result = client.execute(query) 15 | print(result['stdout']) 16 | 17 | # execute an `importCode` CPGQuery 18 | query = import_code_query("/home/user/code/x42/c", "my-c-project") 19 | result = client.execute(query) 20 | print(result['stdout']) 21 | 22 | query = import_code_query("/home/user/code/x42/java/X42.jar", "my-java-project") 23 | result = client.execute(query) 24 | print(result['stdout']) 25 | 26 | -------------------------------------------------------------------------------- /cpgqls_client/queries.py: -------------------------------------------------------------------------------- 1 | 2 | def import_code_query(path, project_name=None, language=None): 3 | if not path: 4 | raise Exception('An importCode query requires a project path') 5 | if project_name and language: 6 | fmt_str = u"""importCode(inputPath=\"%s\", projectName=\"%s\", 7 | language=\"%s\")""" 8 | return fmt_str % (path, project_name, language) 9 | if project_name and (language is None): 10 | fmt_str = u"""importCode(inputPath=\"%s\", projectName=\"%s\")""" 11 | return fmt_str % (path, project_name) 12 | return u"importCode(\"%s\")" % (path) 13 | 14 | 15 | def open_query(project_name): 16 | return f"open(\"{project_name}\")" 17 | 18 | 19 | def close_query(project_name): 20 | return f"close(\"{project_name}\")" 21 | 22 | 23 | def delete_query(project_name): 24 | return f"delete(\"{project_name}\")" 25 | 26 | 27 | def help_query(): 28 | return f"help" 29 | 30 | 31 | def workspace_query(): 32 | return "workspace" 33 | 34 | 35 | def project_query(): 36 | return "project" 37 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | from setuptools import setup, find_packages 3 | 4 | here = os.path.abspath(os.path.dirname(__file__)) 5 | os.chdir(here) 6 | 7 | 8 | with open("README.md", "r") as fh: 9 | long_description = fh.read() 10 | 11 | setup( 12 | name="cpgqls-client", 13 | version="0.0.10", 14 | author="ShiftLeft Inc.", 15 | author_email="claudiu@shiftleft.io", 16 | description="A client library for CPGQL servers", 17 | long_description=long_description, 18 | long_description_content_type="text/markdown", 19 | 20 | url="https://github.com/joernio/cpgqls-client-python", 21 | install_requires=[ 22 | "requests>=2.25.1", 23 | "websockets>=9.1", 24 | ], 25 | packages=find_packages(exclude=["tests", "tests.*"]), 26 | classifiers=[ 27 | "Programming Language :: Python :: 3.7", 28 | "Programming Language :: Python :: 3.8", 29 | "Programming Language :: Python :: 3.9", 30 | "License :: OSI Approved :: Apache Software License", 31 | "Operating System :: OS Independent", 32 | ], 33 | python_requires='>=3.7', 34 | ) 35 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Python package 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | strategy: 10 | matrix: 11 | python-version: [3.7, 3.8, 3.9] 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Set up Python ${{ matrix.python-version }} 16 | uses: actions/setup-python@v2 17 | with: 18 | python-version: ${{ matrix.python-version }} 19 | - name: Install dependencies 20 | run: | 21 | python -m pip install --upgrade pip 22 | pip install pytest 23 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 24 | if [ -f requirements-tests.txt ]; then pip install -r requirements-tests.txt; fi 25 | pip install setuptools wheel twine 26 | - name: Test with pytest 27 | run: | 28 | python -m pytest 29 | - name: Build and publish 30 | env: 31 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 32 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 33 | run: | 34 | python setup.py sdist bdist_wheel 35 | twine upload --skip-existing dist/* 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## cpgqls-client-python 2 | 3 | `cpgqls-client-python` is a simple Python library for communicating with an instance of 4 | a Code Property Graph Query Language server. 5 | 6 | ### Requirements 7 | 8 | Python 3.7 9 | 10 | ### Installation 11 | 12 | ``` 13 | pip install cpgqls-client 14 | ``` 15 | 16 | ### Example usage 17 | 18 | A prerequisite for the following example is access to a running instance of a 19 | Code Property Graph server. An easy way to set one up is by using the open 20 | source code analyzer [joern](https://joern.io): 21 | 22 | ```bash 23 | $ ./joern --server 24 | ``` 25 | 26 | ```python 27 | from cpgqls_client import CPGQLSClient, import_code_query, workspace_query 28 | 29 | server_endpoint = "localhost:8080" 30 | basic_auth_credentials = ("username", "password") 31 | client = CPGQLSClient(server_endpoint, auth_credentials=basic_auth_credentials) 32 | 33 | # execute a simple CPGQuery 34 | query = "val a = 1" 35 | result = client.execute(query) 36 | print(result) 37 | 38 | # execute a `workspace` CPGQuery 39 | query = workspace_query() 40 | result = client.execute(query) 41 | print(result['stdout']) 42 | 43 | # execute an `importCode` CPGQuery 44 | query = import_code_query("/home/user/code/x42/c", "my-c-project") 45 | result = client.execute(query) 46 | print(result['stdout']) 47 | 48 | query = import_code_query("/home/user/code/x42/java/X42.jar", "my-java-project") 49 | result = client.execute(query) 50 | print(result['stdout']) 51 | 52 | ``` 53 | 54 | ### Running the test suite 55 | 56 | ```bash 57 | # set up the virtual environment 58 | $ python -m venv .venv 59 | $ . .venv/bin/activate 60 | 61 | # install the dependencies 62 | $ pip install -r requirements.txt 63 | $ pip install -r requirements-tests.txt 64 | 65 | # run the tests 66 | $ python -m pytest 67 | ``` 68 | 69 | ### References 70 | 71 | * Code Property Graph specification and tools 72 | https://github.com/ShiftLeftSecurity/codepropertygraph/ 73 | * The open source code analyzer joern: https://joern.io 74 | 75 | -------------------------------------------------------------------------------- /cpgqls_client/client.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import requests 3 | import websockets 4 | 5 | 6 | class CPGQLSTransport: 7 | 8 | def __init__(self): 9 | self._ws_conn = None 10 | 11 | def connect(self, endpoint): 12 | self._ws_conn = websockets.connect(endpoint, ping_interval=None) 13 | return self._ws_conn 14 | 15 | async def recv(self): 16 | await self._ws_conn.recv() 17 | 18 | def post(self, uri, **kwargs): 19 | return requests.post(uri, **kwargs) 20 | 21 | def get(self, uri, **kwargs): 22 | return requests.get(uri, **kwargs) 23 | 24 | 25 | class CPGQLSClient: 26 | CPGQLS_MSG_CONNECTED = "connected" 27 | DEFAULT_TIMEOUT = 3600 28 | 29 | def __init__(self, server_endpoint, event_loop=None, transport=None, auth_credentials=None): 30 | if server_endpoint is None: 31 | raise ValueError("server_endpoint cannot be None") 32 | if not isinstance(server_endpoint, str): 33 | raise ValueError("server_endpoint parameter has to be a string") 34 | 35 | self._loop = asyncio.get_event_loop() if not event_loop else event_loop 36 | self._transport = CPGQLSTransport() if not transport else transport 37 | self._endpoint = server_endpoint.rstrip("/") 38 | self._auth_creds = auth_credentials 39 | 40 | def execute(self, query, timeout=DEFAULT_TIMEOUT): 41 | return self._loop.run_until_complete(self._send_query(query, timeout=timeout)) 42 | 43 | async def _send_query(self, query, timeout=DEFAULT_TIMEOUT): 44 | endpoint = self.connect_endpoint() 45 | async with self._transport.connect(endpoint) as ws_conn: 46 | connected_msg = await ws_conn.recv() 47 | if connected_msg != self.CPGQLS_MSG_CONNECTED: 48 | exception_msg = """Received unexpected first message 49 | on websocket endpoint""" 50 | raise Exception(exception_msg) 51 | endpoint = self.post_query_endpoint() 52 | post_res = self._transport.post(endpoint, json={"query": query}, auth=self._auth_creds) 53 | if post_res.status_code == 401: 54 | exception_msg = """Basic authentication failed""" 55 | raise Exception(exception_msg) 56 | elif post_res.status_code != 200: 57 | exception_msg = """Could not post query to the HTTP 58 | endpoint of the server""" 59 | raise Exception(exception_msg) 60 | await asyncio.wait_for(ws_conn.recv(), timeout=timeout) 61 | endpoint = self.get_result_endpoint(post_res.json()["uuid"]) 62 | get_res = self._transport.get(endpoint, auth=self._auth_creds) 63 | if post_res.status_code == 401: 64 | exception_msg = """Basic authentication failed""" 65 | raise Exception(exception_msg) 66 | elif get_res.status_code != 200: 67 | exception_msg = """Could not retrieve query result via the HTTP endpoint 68 | of the server""" 69 | raise Exception(exception_msg) 70 | return get_res.json() 71 | 72 | def connect_endpoint(self): 73 | return "ws://" + self._endpoint + "/connect" 74 | 75 | def post_query_endpoint(self): 76 | return "http://" + self._endpoint + "/query" 77 | 78 | def get_result_endpoint(self, uuid): 79 | return "http://" + self._endpoint + "/result/" + uuid 80 | -------------------------------------------------------------------------------- /tests/test_client.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | from unittest.mock import Mock 3 | 4 | import pytest 5 | 6 | from cpgqls_client import CPGQLSClient 7 | 8 | 9 | class MockCPGQLTransportConnection: 10 | def __init__(self, first_recv_msg, second_recv_msg): 11 | self._num_recv_msgs = 0 12 | self._first_recv_msg = first_recv_msg 13 | self._second_recv_msg = second_recv_msg 14 | 15 | def __await__(self): 16 | return self 17 | yield None # pylint: disable=unreachable 18 | 19 | async def recv(self): 20 | await asyncio.sleep(0) 21 | 22 | lock = asyncio.Lock() 23 | async with lock: 24 | msg = None 25 | if self._num_recv_msgs == 0: 26 | msg = self._first_recv_msg 27 | elif self._num_recv_msgs == 1: 28 | msg = self._second_recv_msg 29 | self._num_recv_msgs += 1 30 | return msg 31 | 32 | async def __aenter__(self): 33 | return await self 34 | 35 | async def __aexit__(self, exc_type, exc, transport): 36 | pass 37 | 38 | 39 | class MockCPGQLSTransport: 40 | def __init__(self, conn, get_response, post_response): 41 | self._conn = conn 42 | self._get_response = get_response 43 | self._post_response = post_response 44 | 45 | def connect(self, *args, **kwargs): 46 | return self._conn 47 | 48 | def post(self, *args, **kwargs): 49 | return self._post_response 50 | 51 | def get(self, *args, **kwargs): 52 | return self._get_response 53 | 54 | 55 | class ReturnParamsMockCPGQLSTransport: 56 | def __init__(self, conn): 57 | self._conn = conn 58 | self._last_post_response = None 59 | self._last_get_response = None 60 | 61 | def connect(self, *args, **kwargs): 62 | return self._conn 63 | 64 | def post(self, *args, **kwargs): 65 | other_params = {'json.return_value': {'uuid': 'one'}} 66 | self._last_post_response = Mock(status_code=200, kwargs=kwargs, **other_params) 67 | return self._last_post_response 68 | 69 | def get(self, *args, **kwargs): 70 | other_params = {'json.return_value': {'success': True}} 71 | self._last_get_response = Mock(status_code=200, kwargs=kwargs, **other_params) 72 | return self._last_get_response 73 | 74 | def last_get_response(self): 75 | return self._last_get_response 76 | 77 | def last_post_response(self): 78 | return self._last_post_response 79 | 80 | 81 | def test_basic_execution(): 82 | event_loop = asyncio.new_event_loop() 83 | conn = MockCPGQLTransportConnection("connected", "received") 84 | get_args = {'json.return_value': {'uuid': 'one'}} 85 | get_response_mock = Mock(status_code=200, **get_args) 86 | post_args = {'json.return_value': {'uuid': 'one'}} 87 | post_response_mock = Mock(status_code=200, **post_args) 88 | transport = MockCPGQLSTransport(conn, get_response_mock, post_response_mock) 89 | endpoint = "localhost:8080" 90 | client = CPGQLSClient(endpoint, event_loop=event_loop, transport=transport) 91 | result = client.execute("val a = 1") 92 | assert result == post_response_mock.json() 93 | 94 | 95 | def test_get_response_not_200(): 96 | event_loop = asyncio.new_event_loop() 97 | conn = MockCPGQLTransportConnection("connected", "received") 98 | get_args = {'json.return_value': {'uuid': 'one'}} 99 | get_response_mock = Mock(status_code=400, **get_args) 100 | post_args = {'json.return_value': {'uuid': 'one'}} 101 | post_response_mock = Mock(status_code=200, **post_args) 102 | transport = MockCPGQLSTransport(conn, get_response_mock, post_response_mock) 103 | endpoint = "localhost:8080" 104 | client = CPGQLSClient(endpoint, event_loop=event_loop, transport=transport) 105 | with pytest.raises(Exception): 106 | client.execute("val a = 1") 107 | 108 | 109 | def test_basic_auth(): 110 | event_loop = asyncio.new_event_loop() 111 | conn = MockCPGQLTransportConnection("connected", "received") 112 | transport = ReturnParamsMockCPGQLSTransport(conn) 113 | endpoint = "localhost:8080" 114 | auth_username = "username" 115 | auth_password = "password" 116 | client = CPGQLSClient(endpoint, 117 | event_loop=event_loop, 118 | transport=transport, 119 | auth_credentials=(auth_username, auth_password)) 120 | client.execute("val a = 1") 121 | 122 | # transport functions are called 123 | get_res = transport.last_get_response() 124 | post_res = transport.last_post_response() 125 | assert get_res is not None 126 | assert post_res is not None 127 | 128 | # correct auth args are set 129 | assert get_res.kwargs is not None 130 | assert post_res.kwargs is not None 131 | 132 | assert get_res.kwargs['auth'] is not None 133 | assert post_res.kwargs['auth'] is not None 134 | 135 | 136 | assert get_res.kwargs['auth'][0] is not None 137 | assert get_res.kwargs['auth'][1] is not None 138 | assert get_res.kwargs['auth'][0] is auth_username 139 | assert get_res.kwargs['auth'][1] is auth_password 140 | 141 | assert post_res.kwargs['auth'][0] is not None 142 | assert post_res.kwargs['auth'][1] is not None 143 | assert post_res.kwargs['auth'][0] is auth_username 144 | assert post_res.kwargs['auth'][1] is auth_password 145 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2020 ShiftLeft, Inc. 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------