├── raven_sqs_proxy ├── __init__.py ├── tests │ ├── __init__.py │ ├── conftest.py │ └── test_sqsproxy.py ├── __about__.py └── sqsproxy.py ├── tox.ini ├── .gitignore ├── .travis.yml ├── setup.cfg ├── setup.py ├── README.md └── LICENSE.txt /raven_sqs_proxy/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /raven_sqs_proxy/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py27,py36 3 | 4 | [testenv] 5 | deps= 6 | pytest 7 | moto 8 | commands=pytest 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | venv/ 3 | venv 4 | 5 | *.pyc 6 | 7 | *.egg-info/ 8 | 9 | __pycache__/ 10 | .cache/ 11 | 12 | build/ 13 | dist/ 14 | 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.7" 4 | - "3.5" 5 | - "3.6" 6 | 7 | install: 8 | - pip install tox-travis 9 | 10 | script: 11 | - tox 12 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md 3 | 4 | [wheel] 5 | universal = 1 6 | 7 | [egg_info] 8 | tag_build = 9 | tag_date = 0 10 | tag_svn_revision = 0 11 | -------------------------------------------------------------------------------- /raven_sqs_proxy/__about__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | 3 | __all__ = [ 4 | "__title__", "__summary__", "__uri__", "__version__", "__author__", 5 | "__email__", "__license__", "__copyright__", 6 | ] 7 | 8 | __title__ = "raven-sqs-proxy" 9 | __summary__ = ("SQS proxy to Sentry.") 10 | __uri__ = "https://github.com/Netflix-Skunkworks/raven-sqs-proxy" 11 | 12 | __version__ = "0.1.0" 13 | 14 | __author__ = "The developers" 15 | __email__ = "oss@netflix.com" 16 | 17 | __license__ = "Apache License, Version 2.0" 18 | __copyright__ = "Copyright 2017 {0}".format(__author__) 19 | -------------------------------------------------------------------------------- /raven_sqs_proxy/tests/conftest.py: -------------------------------------------------------------------------------- 1 | """ 2 | .. module: sqsproxy 3 | :platform: Unix 4 | :copyright: (c) 2017 by Netflix Inc., see AUTHORS for more 5 | :license: Apache, see LICENSE for more details. 6 | .. moduleauthor:: Mike Grima @THISisPLACEHLDR 7 | """ 8 | import pytest 9 | from moto.sqs import mock_sqs 10 | import boto3 11 | 12 | 13 | @pytest.fixture(scope='function') 14 | def sqs(): 15 | with mock_sqs(): 16 | yield boto3.client('sqs', region_name="us-east-1") 17 | 18 | 19 | @pytest.fixture(scope='function') 20 | def sqs_queue(sqs): 21 | sqs.create_queue(QueueName="test-queue") 22 | 23 | return sqs 24 | 25 | 26 | @pytest.fixture(scope='function') 27 | def url(sqs_queue): 28 | return sqs_queue.get_queue_url(QueueName="test-queue", 29 | QueueOwnerAWSAccountId="123456789012")["QueueUrl"] 30 | 31 | 32 | @pytest.fixture(scope="function") 33 | def sqs_message(sqs_queue, url): 34 | sqs_queue.send_message(QueueUrl=url, MessageBody="hello") 35 | 36 | return sqs_queue.receive_message(QueueUrl=url) 37 | 38 | 39 | class MockSentry: 40 | def __init__(self, status_code): 41 | self.status_code = status_code 42 | 43 | def status_code(self): 44 | return self.status_code 45 | 46 | 47 | def mock_sentry(*args, **kwargs): 48 | if "fail" in args[0]: 49 | return MockSentry(404) 50 | 51 | return MockSentry(200) 52 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | """ 2 | Raven SQS Proxy 3 | =================== 4 | 5 | A simple SQS poller for proxying Sentry messages in SQS to Sentry 6 | """ 7 | import sys 8 | import os.path 9 | 10 | from setuptools import setup, find_packages 11 | 12 | ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__))) 13 | sys.path.insert(0, ROOT) 14 | 15 | about = {} 16 | with open(os.path.join(ROOT, "raven_sqs_proxy", "__about__.py")) as f: 17 | exec(f.read(), about) 18 | 19 | 20 | install_requires = [ 21 | 'boto3', 22 | 'requests', 23 | 'click', 24 | 'click_log', 25 | 'retrying' 26 | ] 27 | 28 | tests_require = [ 29 | 'pytest', 30 | 'moto' 31 | ] 32 | 33 | setup( 34 | name=about["__title__"], 35 | version=about["__version__"], 36 | author=about["__author__"], 37 | author_email=about["__email__"], 38 | url=about["__uri__"], 39 | description=about["__summary__"], 40 | long_description='See README.md', 41 | packages=find_packages(), 42 | include_package_data=True, 43 | zip_safe=False, 44 | install_requires=install_requires, 45 | extras_require={ 46 | 'tests': tests_require 47 | }, 48 | keywords=['aws', 'sentry', 'raven', 'sqs', 'proxy'], 49 | entry_points={ 50 | "console_scripts": [ 51 | "sqsproxy = raven_sqs_proxy.sqsproxy:cli" 52 | ] 53 | }, 54 | classifiers=[ 55 | "Programming Language :: Python", 56 | 'Programming Language :: Python :: 2', 57 | 'Programming Language :: Python :: 2.7', 58 | 'Programming Language :: Python :: 3', 59 | 'Programming Language :: Python :: 3.5', 60 | 'Programming Language :: Python :: 3.6', 61 | ], 62 | license="Apache 2.0", 63 | maintainer="Mike Grima " 64 | ) 65 | -------------------------------------------------------------------------------- /raven_sqs_proxy/tests/test_sqsproxy.py: -------------------------------------------------------------------------------- 1 | """ 2 | .. module: sqsproxy 3 | :platform: Unix 4 | :copyright: (c) 2017 by Netflix Inc., see AUTHORS for more 5 | :license: Apache, see LICENSE for more details. 6 | .. moduleauthor:: Mike Grima @THISisPLACEHLDR 7 | """ 8 | import pytest 9 | from botocore.exceptions import ClientError 10 | from retrying import RetryError 11 | import mock 12 | 13 | from raven_sqs_proxy.tests.conftest import mock_sentry 14 | 15 | 16 | def test_validate_region(): 17 | from raven_sqs_proxy.sqsproxy import validate_region 18 | import click 19 | 20 | assert validate_region(None, None, "us-east-1") == "us-east-1" 21 | 22 | with pytest.raises(click.BadParameter) as _: 23 | validate_region(None, None, "LOL") 24 | 25 | 26 | def test_retry_if_client_error(): 27 | from raven_sqs_proxy.sqsproxy import retry_if_client_error 28 | assert not retry_if_client_error(Exception()) 29 | assert retry_if_client_error(ClientError({"Error": {}}, "SendMessage")) 30 | 31 | 32 | def test_receive_messages(sqs_queue, url): 33 | import raven_sqs_proxy 34 | from raven_sqs_proxy.sqsproxy import receive_messages 35 | raven_sqs_proxy.sqsproxy.SQS_WAIT_TIME_SECONDS = 0 36 | 37 | result = receive_messages(sqs_queue, url) 38 | assert not result["Messages"] 39 | 40 | with pytest.raises(RetryError) as _: 41 | receive_messages(sqs_queue, "https://LOLNO") 42 | 43 | 44 | def test_delete_messages(sqs_queue, url, sqs_message): 45 | from raven_sqs_proxy.sqsproxy import delete_message 46 | 47 | delete_message(sqs_queue, url, sqs_message["Messages"][0]["ReceiptHandle"]) 48 | 49 | with pytest.raises(RetryError) as _: 50 | delete_message(sqs_queue, "https://LOLNO", sqs_message["Messages"][0]["ReceiptHandle"]) 51 | 52 | 53 | @mock.patch("requests.post", side_effect=mock_sentry) 54 | def test_send_to_sentry(mock_post): 55 | from raven_sqs_proxy.sqsproxy import send_to_sentry 56 | 57 | headers = {} 58 | data = {"LOL": "HAY"} 59 | 60 | send_to_sentry("pass", headers, data) 61 | 62 | with pytest.raises(RetryError) as _: 63 | send_to_sentry("fail", headers, data) 64 | 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sentry/Raven SQS Proxy 2 | 3 | [![Build Status](https://travis-ci.org/Netflix-Skunkworks/raven-sqs-proxy.svg?branch=master)](https://travis-ci.org/Netflix-Skunkworks/raven-sqs-proxy) 4 | [![PyPI version](https://badge.fury.io/py/raven-sqs-proxy.svg)](https://badge.fury.io/py/raven-sqs-proxy) 5 | 6 | ## About 7 | This is a very simple Python project that polls SQS for Sentry messages and then proxies them over to a Sentry instance. 8 | 9 | This is based on the implementation of the Sentry.IO `SQSTransport` as implemented in [this PR to raven-python](https://github.com/getsentry/raven-python/pull/1095). 10 | 11 | ## How to use: 12 | The first part in using this is to make use of the Sentry `SQSTransport` implemented in the [getsentry/raven-python](https://github.com/getsentry/raven-python) 13 | project. 14 | 15 | This will have an instance, lambda function, or anything with AWS credentials to an SQS queue to forward all Sentry messages to SQS. This project will then 16 | listen for those messages on the queue and simply proxy them over to Sentry for storage. 17 | 18 | ## Required Items: 19 | For sending to the SQS queue, you will need the following: 20 | 1. An SQS queue 21 | 1. An IAM role with the following permissions to the SQS queue in question: 22 | ``` 23 | sqs:GetQueueUrl 24 | sqs:SendMessage 25 | ``` 26 | 1. A Sentry DSN 27 | 1. Python code that creates a Sentry client that looks similar to this: 28 | ``` 29 | from raven.base import Client 30 | from raven.transport.sqs import SQSTransport 31 | 32 | # SQS details that are required are: 33 | # 1. `sqs_region` 34 | # 2. `sqs_account` This is the 12 digit AWS account number 35 | # 3. `sqs_name` 36 | 37 | sentry_client = Client(dsn="https://some-sentry-dsn?sqs_region=REGION&sqs_account=ACCOUNT_NUMsqs_name=QUEUE_NAME", 38 | transport=SQSTransport) 39 | 40 | ``` 41 | 42 | For retrieving messages: 43 | 1. Access to the SQS queue the source app above is sending to. This will need the following permissions against the queue: 44 | ``` 45 | sqs:GetQueueUrl 46 | sqs:SendMessage 47 | sqs:DeleteMessage 48 | ``` 49 | 1. Network-level access to the Sentry instance 50 | 51 | 52 | ## Installation: 53 | 1. Make and activate a Python virtual environment 54 | 1. Run `pip install raven_sqs_proxy` to install this 55 | 1. Hopefully you are running with on-instance AWS IAM role credentials. Otherwise, you will 56 | need to export them into your environment. 57 | 1. Run `sqsproxy --queue-name NAME-OF-QUEUE --queue-region QUEUE-REGION --queue-account AWS_ACCOUNT_ID_OF_QUEUE` 58 | 59 | 60 | That's it. 61 | -------------------------------------------------------------------------------- /raven_sqs_proxy/sqsproxy.py: -------------------------------------------------------------------------------- 1 | """ 2 | .. module: sqsproxy 3 | :platform: Unix 4 | :copyright: (c) 2017 by Netflix Inc., see AUTHORS for more 5 | :license: Apache, see LICENSE for more details. 6 | .. moduleauthor:: Mike Grima @THISisPLACEHLDR 7 | """ 8 | import boto3 9 | import click 10 | import requests 11 | import base64 12 | import click_log 13 | import json 14 | import logging 15 | import sys 16 | import signal 17 | 18 | from retrying import retry, RetryError 19 | from botocore.exceptions import ClientError 20 | 21 | logger = logging.getLogger(__name__) 22 | click_log.basic_config(logger) 23 | 24 | 25 | SQS_WAIT_TIME_SECONDS = 20 26 | 27 | 28 | # For graceful exits... 29 | def handle_exit(signal, frame): 30 | logger.info("[!] Received signal to exit... Exiting...") 31 | sys.exit(0) 32 | 33 | 34 | signal.signal(signal.SIGINT, handle_exit) 35 | 36 | 37 | def validate_region(ctx, param, value): 38 | """Validate that a proper AWS region was passed in""" 39 | all_regions = boto3.session.Session().get_available_regions("sqs") 40 | 41 | if value not in all_regions: 42 | raise click.BadParameter("Invalid region passed in. Must be one of: {}".format(", ".join(all_regions))) 43 | 44 | return value 45 | 46 | 47 | def retry_if_client_error(exception): 48 | """Retry function to detect if the exception is a boto client error""" 49 | return isinstance(exception, ClientError) 50 | 51 | 52 | @retry(retry_on_exception=retry_if_client_error, stop_max_attempt_number=5, wait_fixed=3000, wrap_exception=True) 53 | def receive_messages(client, url): 54 | """ 55 | Listens to the SQS queue and retrieves messages. 56 | :param client: 57 | :param url: 58 | :return: 59 | """ 60 | messages = client.receive_message(QueueUrl=url, WaitTimeSeconds=SQS_WAIT_TIME_SECONDS) 61 | 62 | if not messages.get("Messages"): 63 | logger.debug("[><] No messages received. Listening for another {} seconds...".format(SQS_WAIT_TIME_SECONDS)) 64 | messages["Messages"] = [] 65 | 66 | return messages 67 | 68 | 69 | @retry(retry_on_exception=retry_if_client_error, stop_max_attempt_number=5, wait_fixed=3000, wrap_exception=True) 70 | def delete_message(client, url, receipt_handle): 71 | """Deletes message from SQS because it was successfully processed""" 72 | client.delete_message(QueueUrl=url, ReceiptHandle=receipt_handle) 73 | 74 | 75 | @retry(stop_max_attempt_number=5, wait_fixed=3000, wrap_exception=True) 76 | def send_to_sentry(sentry_url, headers, data): 77 | """ 78 | Send the message over to Sentry. 79 | :param sentry_url: This is the URL of the Sentry server 80 | :param headers: This contains all the headers required to send over to Sentry 81 | :param data: The actual payload to send over to Sentry 82 | :return: 83 | """ 84 | result = requests.post(sentry_url, headers=headers, data=data) 85 | 86 | if result.status_code != 200: 87 | raise ValueError("Invalid response code from Sentry: {}".format(result.status_code)) 88 | 89 | 90 | def sqs_loop(client, url): 91 | """ 92 | This is the main logic proxy-loop. This will keep polling and proxying data to Sentry. 93 | :param client: 94 | :param url: 95 | :return: 96 | """ 97 | while True: 98 | logger.debug("[ ] Polling for messages...") 99 | 100 | # Get the messages: 101 | try: 102 | messages = receive_messages(client, url) 103 | except RetryError as re: 104 | logger.error("Encountered too many Boto ClientErrors while fetching messages... Exiting...") 105 | logger.exception(re.last_attempt.value) 106 | sys.exit(-1) 107 | 108 | # Place each message into Sentry: 109 | for message in messages["Messages"]: 110 | body = None 111 | try: 112 | body = json.loads(message["Body"]) 113 | 114 | except json.decoder.JSONDecodeError as _: 115 | logger.error("Error decoding message sent. Going to delete the message and skip...") 116 | 117 | if body: 118 | sentry_url = body["url"] 119 | headers = body["headers"] 120 | data = base64.b64decode(body["data"]) 121 | 122 | # Send it over! 123 | try: 124 | logger.debug("[ ] Sending message to Sentry at URL: {}".format(sentry_url)) 125 | send_to_sentry(sentry_url, headers, data) 126 | logger.debug("[+] Successfully sent message to Sentry at URL: {}".format(sentry_url)) 127 | except RetryError as re: 128 | logger.error("Encountered too many errors sending data to Sentry with URL: {}. " 129 | "Going to skip and delete message from SQS...".format(sentry_url)) 130 | logger.exception(re.last_attempt.value) 131 | 132 | # Delete the message from SQS: 133 | try: 134 | logger.debug("[ ] Deleting message from SQS with Receipt Handle: {}".format(message["ReceiptHandle"])) 135 | delete_message(client, url, message["ReceiptHandle"]) 136 | logger.debug("[-] Deleted message from SQS with Receipt Handle: {}".format(message["ReceiptHandle"])) 137 | except RetryError as re: 138 | logger.error("Encountered too many Boto ClientErrors while fetching messages... Exiting...") 139 | logger.exception(re.last_attempt.value) 140 | sys.exit(-1) 141 | 142 | 143 | @click.command() 144 | @click.option("--queue-name", type=click.STRING, required=True, help="The name of the SQS queue") 145 | @click.option("--queue-region", type=click.STRING, callback=validate_region, required=True, 146 | help="The region where the SQS queue lives") 147 | @click.option("--queue-account", type=click.STRING, required=True, help="The AWS account that contains the SQS queue") 148 | @click.option("--log-level", type=click.STRING, required=False, help="The log level for the application - DEFAULT INFO", 149 | default="INFO") 150 | def cli(queue_name, queue_region, queue_account, log_level): 151 | """ 152 | Runs the Raven SQS Proxy service -- this will just poll SQS and will proxy the messages to Sentry 153 | 154 | :param queue_name - The name of the SQS queue 155 | :return: 156 | """ 157 | # Set the log level: 158 | logger.setLevel(log_level) 159 | 160 | logger.info("[@] Raven SQS Poller is now running against queue Name/Account/Region: " 161 | "{name}/{account}/{region}".format(name=queue_name, account=queue_account, region=queue_region)) 162 | 163 | # Create the SQS client: 164 | client = boto3.client("sqs", region_name=queue_region) 165 | 166 | logger.debug("[ ] Fetching the URL of the SQS Queue...") 167 | try: 168 | url = client.get_queue_url(QueueName=queue_name, QueueOwnerAWSAccountId=queue_account)["QueueUrl"] 169 | 170 | except ClientError as ce: 171 | logger.error("[X] Unable to get queue URL. Cannot continue. Exception is below:") 172 | raise ce 173 | 174 | logger.debug("[+] Fetched the Queue URL: {}".format(url)) 175 | 176 | logger.info("[-->] Now monitoring SQS for messages to send over to Sentry...") 177 | sqs_loop(client, url) 178 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2014 Netflix, Inc. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------