OwlCyberSecurity - MANAGER
Edit File: validate.pyc
� {fc�����������@���sF��d��Z��d�g�Z�d�d�l�Z�d�d�l�Z�d�d�l�m�Z�m�Z�m�Z�m�Z�d�d�l �Z �e�j �d���Z�e�j �d���Z�d�e �f�d�������YZ�d ����Z�d ����Z�d�d�d�������YZ�d �d�d�������YZ�d�d�d�������YZ�d�d �d�������YZ�d�d!�d�������YZ�d����Z�d����Z�d����Z�d����Z�d����Z�d����Z�d����Z�d����Z�d�S("���s"�� Middleware to check for obedience to the WSGI specification. Some of the things this checks: * Signature of the application and start_response (including that keyword arguments are not used). * Environment checks: - Environment is a dictionary (and not a subclass). - That all the required keys are in the environment: REQUEST_METHOD, SERVER_NAME, SERVER_PORT, wsgi.version, wsgi.input, wsgi.errors, wsgi.multithread, wsgi.multiprocess, wsgi.run_once - That HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH are not in the environment (these headers should appear as CONTENT_LENGTH and CONTENT_TYPE). - Warns if QUERY_STRING is missing, as the cgi module acts unpredictably in that case. - That CGI-style variables (that don't contain a .) have (non-unicode) string values - That wsgi.version is a tuple - That wsgi.url_scheme is 'http' or 'https' (@@: is this too restrictive?) - Warns if the REQUEST_METHOD is not known (@@: probably too restrictive). - That SCRIPT_NAME and PATH_INFO are empty or start with / - That at least one of SCRIPT_NAME or PATH_INFO are set. - That CONTENT_LENGTH is a positive integer. - That SCRIPT_NAME is not '/' (it should be '', and PATH_INFO should be '/'). - That wsgi.input has the methods read, readline, readlines, and __iter__ - That wsgi.errors has the methods flush, write, writelines * The status is a string, contains a space, starts with an integer, and that integer is in range (> 100). * That the headers is a list (not a subclass, not another kind of sequence). * That the items of the headers are tuples of strings. * That there is no 'status' header (that is used in CGI, but not in WSGI). * That the headers don't contain newlines or colons, end in _ or -, or contain characters codes below 037. * That Content-Type is given if there is content (CGI often has a default content type, but WSGI does not). * That no Content-Type is given when there is no content (@@: is this too restrictive?) * That the exc_info argument to start_response is a tuple or None. * That all calls to the writer are with strings, and no other methods on the writer are accessed. * That wsgi.input is used properly: - .read() is called with zero or one argument - That it returns a string - That readline, readlines, and __iter__ return strings - That .close() is not called - No other methods are provided * That wsgi.errors is used properly: - .write() and .writelines() is called with a string - That .close() is not called, and no other methods are provided. * The response iterator: - That it is not a string (it should be a list of a single string; a string will work, but perform horribly). - That .next() returns a string - That the iterator is not iterated over until start_response has been called (that can signal either a server or application error). - That .close() is called (doesn't raise exception, only prints to sys.stderr, because we only know it isn't called when the object is garbage collected). t ���validatori����N(���t���DictTypet ���StringTypet ���TupleTypet���ListTypes���^[a-zA-Z][a-zA-Z0-9\-_]*$s���[\000-\037]t���WSGIWarningc�����������B���s���e��Z�d��Z�RS(���s:��� Raised in response to WSGI-spec-related warnings (���t���__name__t ���__module__t���__doc__(����(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR���z���s���c���������G���s���|��s�t��|������n��d��S(���N(���t���AssertionError(���t���condt���args(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyt���assert_���s����c������������s������f�d����}�|�S(���s��� When applied between a WSGI server and a WSGI application, this middleware will check for WSGI compliancy on a number of levels. This middleware does not modify the request or response in any way, but will raise an AssertionError if anything seems off (except for a failure to close the application iterator, which will be printed to stderr -- there's no way to raise an exception at that point). c�������������s����t��t�|����d�k�d���t��|�d���|��\�}����t�|���g���������f�d����}�t�|�d���|�d�<t�|�d���|�d�<��|�|���}�t��|�d��k �o��|�t�k�d���t�|���t�|�����S(���Ni���s���Two arguments requireds���No keyword arguments allowedc�������������s����t��t�|����d�k�p$�t�|����d�k�d�|��f���t��|�d���|��d�}�|��d�}�t�|����d�k�rs�|��d�}�n�d��}�t�|���t�|���t�|�|���t�|�����j�d����t����|�������S(���Ni���i���s���Invalid number of arguments: %ss���No keyword arguments allowedi����i���( ���R���t���lent���Nonet���check_statust ���check_headerst���check_content_typet���check_exc_infot���appendt���WriteWrapper(���R���t���kwt���statust���headerst���exc_info(���t���start_responset���start_response_started(����s(���/usr/lib64/python2.7/wsgiref/validate.pyt���start_response_wrapper����s����$ s ���wsgi.inputs���wsgi.errorss>���The application must return an iterator, if only an empty list( ���R���R ���t ���check_environt���InputWrappert���ErrorWrapperR���t���Falset���check_iteratort���IteratorWrapper(���R���R���t���environR���t���iterator(���t���application(���R���R���s(���/usr/lib64/python2.7/wsgiref/validate.pyt���lint_app����s���� (����(���R$���R%���(����(���R$���s(���/usr/lib64/python2.7/wsgiref/validate.pyR��������s����)R���c�����������B���s>���e��Z�d�����Z�d����Z�d����Z�d����Z�d����Z�d����Z�RS(���c���������C���s ���|�|��_��d��S(���N(���t���input(���t���selft ���wsgi_input(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyt���__init__����s����c���������G���sH���t��t�|���d�k���|��j�j�|����}�t��t�|���t�d���k���|�S(���Ni���t����(���R���R ���R&���t���readt���type(���R'���R���t���v(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR+�������s����c���������C���s/���|��j��j����}�t�t�|���t�d���k���|�S(���NR*���(���R&���t���readlineR���R,���(���R'���R-���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR.�������s����c���������G���su���t��t�|���d�k���|��j�j�|����}�t��t�|���t�g����k���x*�|�D]"�}�t��t�|���t�d���k���qK�W|�S(���Ni���R*���(���R���R ���R&���t ���readlinesR,���(���R'���R���t���linest���line(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR/�������s���� c���������c���s&���x�|��j�����}�|�s�d��S|�Vq�Wd��S(���N(���R.���(���R'���R1���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyt���__iter__����s ����c���������C���s���t��d�d���d��S(���Ni����s ���input.close() must not be called(���R���(���R'���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyt���close����s����(���R���R���R)���R+���R.���R/���R2���R3���(����(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR�������s��� R���c�����������B���s5���e��Z�d�����Z�d����Z�d����Z�d����Z�d����Z�RS(���c���������C���s ���|�|��_��d��S(���N(���t���errors(���R'���t���wsgi_errors(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR)�������s����c���������C���s0���t��t�|���t�d���k���|��j�j�|���d��S(���NR*���(���R���R,���R4���t���write(���R'���t���s(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR6�������s����c���������C���s���|��j��j����d��S(���N(���R4���t���flush(���R'���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR8�������s����c���������C���s"���x�|�D]�}�|��j��|���q�Wd��S(���N(���R6���(���R'���t���seqR1���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyt ���writelines����s���� c���������C���s���t��d�d���d��S(���Ni����s!���errors.close() must not be called(���R���(���R'���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR3�������s����(���R���R���R)���R6���R8���R:���R3���(����(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR�������s ��� R���c�����������B���s���e��Z�d�����Z�d����Z�RS(���c���������C���s ���|�|��_��d��S(���N(���t���writer(���R'���t���wsgi_writer(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR)�������s����c���������C���s-���t��t�|���t�d���k���|��j�|���d��S(���NR*���(���R���R,���R;���(���R'���R7���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyt���__call__����s����(���R���R���R)���R=���(����(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR�������s��� t���PartialIteratorWrapperc�����������B���s���e��Z�d�����Z�d����Z�RS(���c���������C���s ���|�|��_��d��S(���N(���R#���(���R'���t ���wsgi_iterator(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR)�������s����c���������C���s���t��|��j�d����S(���N(���R!���R#���R���(���R'���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR2�������s����(���R���R���R)���R2���(����(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR>�������s��� R!���c�����������B���s5���e��Z�d�����Z�d����Z�d����Z�d����Z�d����Z�RS(���c���������C���s.���|�|��_��t�|���|��_�t�|��_�|�|��_�d��S(���N(���t���original_iteratort���iterR#���R���t���closedt���check_start_response(���R'���R?���RC���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR)�����s���� c���������C���s���|��S(���N(����(���R'���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR2��� ��s����c���������C���sO���t��|��j�d���|��j�j����}�|��j�d��k �rK�t��|��j�d���d��|��_�n��|�S(���Ns���Iterator read after closedsj���The application returns and we started iterating over its body, but start_response has not yet been called(���R���RB���R#���t���nextRC���R���(���R'���R-���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyRD�����s���� c���������C���s/���t��|��_�t�|��j�d���r+�|��j�j����n��d��S(���NR3���(���t���TrueRB���t���hasattrR@���R3���(���R'���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR3�����s���� c���������C���s0���|��j��s�t�j�j�d���n��t�|��j��d���d��S(���Ns/���Iterator garbage collected without being closed(���RB���t���syst���stderrR6���R���(���R'���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyt���__del__��s ���� (���R���R���R)���R2���RD���R3���RI���(����(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR!�����s ��� c������ ���C���s���t��t�|����t�k�d�t�|����|��f���xC�d�d�d�d�d�d�d�d �d �g �D] �}�t��|�|��k�d�|�f���qK�Wx5�d�d �g�D]'�}�t��|�|��k�d�|�|�d�f���q|�Wd�|��k�r��t�j�d�t���n��x^�|��j����D]P�}�d�|�k�r��q��n��t��t�|��|���t�k�d�|�t�|��|���|��|�f���q��Wt��t�|��d���t�k�d�|��d�f���t��|��d�d,�k�d�|��d���t �|��d���t �|��d���|��d�d-�k�r�t�j�d!�|��d�t���n��t��|��j�d"���p�|��d"�j�d#���d$�|��d"���t��|��j�d%���p |��d%�j�d#���d&�|��d%���|��j�d'���rPt��t �|��d'���d(�k�d)�|��d'���n��|��j�d"���sut��d%�|��k�d*���n��t��|��j�d"���d#�k�d+���d��S(.���Ns:���Environment is not of the right type: %r (environment: %r)t���REQUEST_METHODt���SERVER_NAMEt���SERVER_PORTs���wsgi.versions ���wsgi.inputs���wsgi.errorss���wsgi.multithreads���wsgi.multiprocesss ���wsgi.run_onces$���Environment missing required key: %rt���HTTP_CONTENT_TYPEt���HTTP_CONTENT_LENGTHs8���Environment should not have the key: %s (use %s instead)i���t���QUERY_STRINGs����QUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likelyt���.s9���Environmental variable %s is not a string: %r (value: %r)s#���wsgi.version should be a tuple (%r)s���wsgi.url_schemet���httpt���httpss���wsgi.url_scheme unknown: %rt���GETt���HEADt���POSTt���OPTIONSt���PATCHt���PUTt���DELETEt���TRACEs���Unknown REQUEST_METHOD: %rt���SCRIPT_NAMEt���/s$���SCRIPT_NAME doesn't start with /: %rt ���PATH_INFOs"���PATH_INFO doesn't start with /: %rt���CONTENT_LENGTHi����s���Invalid CONTENT_LENGTH: %rsg���One of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)sO���SCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/'(���RQ���RR���(���RS���RT���RU���RV���RW���RX���RY���RZ���(���R���R,���R���t���warningst���warnR���t���keysR���R���t���check_inputt���check_errorst���gett ���startswitht���int(���R"���t���key(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR���"��s`���� # c���������C���sA���x:�d�d�d�d�g�D]&�}�t��t�|��|���d�|��|�f���q�Wd��S(���NR+���R.���R/���R2���s-���wsgi.input (%r) doesn't have the attribute %s(���R���RF���(���R(���t���attr(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyRb���c��s����c���������C���s>���x7�d�d�d�g�D]&�}�t��t�|��|���d�|��|�f���q�Wd��S(���NR8���R6���R:���s.���wsgi.errors (%r) doesn't have the attribute %s(���R���RF���(���R5���Rh���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyRc���i��s����c���������C���s����t��t�|����t�k�d�|����|��j�d��d���d�}�t��t�|���d�k�d�|���t�|���}�t��|�d�k�d�|���t�|����d�k��s��|��d�d �k�r��t�j�d �|��t ���n��d��S(���Ns ���Status must be a string (not %r)i���i����i���s)���Status codes must be three characters: %rid���s���Status code is invalid: %ri���t��� sj���The status string (%r) should be a three-digit integer followed by a single space and a status explanation( ���R���R,���R���t���splitR���R ���Rf���R_���R`���R���(���R���t���status_codet ���status_int(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR���o��s����"c���������C���s_��t��t�|����t�k�d�|��t�|����f���i��}�x)|��D]!}�t��t�|���t�k�d�|�t�|���f���t��t�|���d�k���|�\�}�}�t��|�j����d�k�d�|���d��|�|�j����<t��d�|�k�o��d�|�k�d�|���t��t�j�|���d �|���t��|�j �d ���o|�j �d���d�|���t �j�|���r6�t��d �d�|�t �j�|���j�d ���f���q6�q6�Wd��S(���Ns%���Headers (%r) must be of type list: %rs1���Individual headers (%r) must be of type tuple: %ri���R���sy���The Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r).s��� t���:s,���Header names may not contain ':' or '\n': %rs���Bad header name: %rt���-t���_s#���Names may not end in '-' or '_': %ri����s#���Bad header value: %r (bad char: %r)(���R���R,���R���R���R ���t���lowerR���t ���header_ret���searcht���endswitht���bad_header_value_ret���group(���R���t���header_namest���itemt���namet���value(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR���~��s,���� c���������C���s����t��|��j�d��d���d���}�d�}�xJ�|�D]B�\�}�}�|�j����d�k�r)�|�|�k�rW�d��St�d�d�|���q)�q)�W|�|�k�r��t�d�d�|���n��d��S( ���Ni���i����i����i0��s���content-typesJ���Content-Type header found in a %s response, which must not return content.s,���No Content-Type header found in headers (%s)(���i����i0��(���Rf���Rj���R���Rp���R���(���R���R���t���codet���NO_MESSAGE_BODYRx���Ry���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR������s���� c���������C���s?���t��|��d��k�p$�t�|����t�d���k�d�|��t�|����f���d��S(���Ns ���exc_info (%r) is not a tuple: %r(����(���R���R���R,���(���R���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR������s����$c���������C���s���t��t�|��t���d���d��S(���Nsv���You should not return a string as your application iterator, instead return a single-item list containing that string.(���R���t ���isinstancet���str(���R#���(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyR ������s����(����(����(����(����(����(���R���t���__all__t���reRG���t���typesR���R���R���R���R_���t���compileRq���Rt���t���WarningR���R���R����R���R���R���R>���R!���R���Rb���Rc���R���R���R���R���R ���(����(����(����s(���/usr/lib64/python2.7/wsgiref/validate.pyt���<module>n���s.��� " 7" ! A