OwlCyberSecurity - MANAGER
Edit File: logging.cpython-311.pyc
� ������h]?����������������������Z����U�d�Z�ddlmZ�ddlZddlZddlmZ�ddlZddlmZm Z �ddl mZ�ddlm Z �ddlmZ�dd lmZ�dd lmZ�ej��������dk����rddlmZ�nddlmZ�erdd lmZ�dddddddd�Zded<���h�d�Z�eg�d�������������Z �d2d3d"�Z�G�d#��d$e j��������������������Z d4d'�Z!d5d+�Z"d6d-�Z#d7d1�Z$dS�)8z"Checker for use of Python logging.�����)�annotationsN)� TYPE_CHECKING)�bases�nodes)�InferenceResult)�checkers)�utils)� infer_all)�MessageDefinitionTuple)��������)�Literal)�PyLinter)�&Use %s formatting in logging functions�logging-not-lazya���Used when a logging statement has a call form of "logging.<logging method>(format_string % (format_args...))". Use another type of string formatting instead. You can use % formatting but leave interpolation to the logging function by passing the parameters as arguments. If logging-fstring-interpolation is disabled then you can use fstring formatting. If logging-format-interpolation is disabled then you can use str.format.)r����logging-format-interpolationa���Used when a logging statement has a call form of "logging.<logging method>(format_string.format(format_args...))". Use another type of string formatting instead. You can use % formatting but leave interpolation to the logging function by passing the parameters as arguments. If logging-fstring-interpolation is disabled then you can use fstring formatting. If logging-not-lazy is disabled then you can use % formatting as normal.)r����logging-fstring-interpolationa���Used when a logging statement has a call form of "logging.<logging method>(f"...")".Use another type of string formatting instead. You can use % formatting but leave interpolation to the logging function by passing the parameters as arguments. If logging-format-interpolation is disabled then you can use str.format. If logging-not-lazy is disabled then you can use % formatting as normal.)z;Unsupported logging format character %r (%#02x) at index %d�logging-unsupported-formatzWUsed when an unsupported format character is used in a logging statement format string.)z<Logging format string ends in middle of conversion specifier�logging-format-truncatedz`Used when a logging statement format string terminates before the end of a conversion specifier.)z,Too many arguments for logging format string�logging-too-many-argsz>Used when a logging format string is given too many arguments.)z.Not enough arguments for logging format string�logging-too-few-argsz=Used when a logging format string is given too few arguments.)�W1201�W1202�W1203�E1200�E1201�E1205�E1206z!dict[str, MessageDefinitionTuple]�MSGS>����info�warn�debug�error�fatal�warning�critical� exception)z%sz%dz%fz%r���func�bases.BoundMethod�types�tuple[str, ...]�methods�return�boolc����������������������t����������|�t����������j��������������������o=t����������|�j��������t����������j��������������������o|r|�j��������j��������|v�ndo|r |�j��������|v�ndS�)a~��Determines if a BoundMethod node represents a method call. Args: func: The BoundMethod AST node to check. types: Optional sequence of caller type names to restrict check. methods: Optional sequence of method names to restrict check. Returns: true if the node represents a method call for the given type and method names, False otherwise. T)� isinstance�astroid�BoundMethod�bound�Instance�name)r)���r+���r-���s��� �h/builddir/build/BUILD/cloudlinux-venv-1.0.8/venv/lib/python3.11/site-packages/pylint/checkers/logging.py�is_method_callr8���o���sf������� �4��,�-�-�� 8��t�z�7�#3�4�4� 8�).� 8�T�Z�_�� %� %�D� 8��&-� 6�T�Y�'� !� !�$� �����c������������������������e�Zd�ZdZdZeZdddddd�fd d ddd d gdd�ffZd+d�Zd,d�Z d-d�Z d.d�Zd/d�Zd0d�Z ed1d#���������������Zed2d%���������������Zd.d&�Zd3d)�Zd*S�)4�LoggingCheckerz!Checks use of the logging module.�loggingzlogging-modules)r<����csvz<comma separated list>zcLogging modules to check that the string format arguments are in logging function parameter format.)�default�type�metavar�helpzlogging-format-style�old�choicez<old (%) or new ({)>�newztThe type of string formatting that logging methods do. `old` means using % formatting, `new` is for `{}` formatting.)r>���r?���r@����choicesrA����_�nodes.Moduler.����Nonec�����������������8����t������������������������|�_��������|�j��������j��������j��������}|�j��������j��������j��������|�_��������t����������|������������|�_��������i�|�_��������|D�]A}|� ��������������������dd������������}t����������|������������dk����r|d���������|�j��������|d���������<����BdS�)z?Clears any state left in this checker from last module checked.�.����r���N)�set�_logging_names�linter�config�logging_modules�logging_format_style� _format_style�_logging_modules� _from_imports�rsplit�len)�selfrF����logging_mods�logging_mod�partss��� r7����visit_modulezLoggingChecker.visit_module����s������� �),������{�)�9��!�[�/�D��� #�L� 1� 1������'�� 8�� 8�K��&�&�s�A�.�.�E��5�z�z�A�~�~�/4�Q�x��"�5��8�,�� 8�� 8r9����node�nodes.ImportFromc���������������������� �|�j���������|j�����������������}|j��������D�]'\��}}||k����r|�j�����������������������������|p|��������������(dS�#�t ����������$�r�Y�dS�w�xY�w)z;Checks to see if a module uses a non-Python logging module.N)rT����modname�namesrM����add�KeyError)rW���r\����logging_name�module�as_names��� r7����visit_importfromzLoggingChecker.visit_importfrom����s������� ��-�d�l�;�L�#'�:�� ?�� ?�����\�)�)��'�+�+�G�,=�v�>�>�>�� ?�� ?����� �� �� ��D�D� ���s����AA�� A�A�nodes.Importc�����������������j�����|j���������D�]*\��}}||�j��������v�r|�j�����������������������������|p|��������������+dS�)z<Checks to see if this module uses Python's built-in logging.N)r`���rS���rM���ra���)rW���r\���rd���re���s��� r7����visit_importzLoggingChecker.visit_import����sL������#�z�� ;�� ;�O�F�G���.�.�.��#�'�'��(9�6�:�:�:�� ;�� ;r9���� nodes.Callc�������������������������d���fd�}d�fd�}�|��������������r �j���������j��������}n�|��������������\��}}|sdS�������������������������|�������������dS�) z Checks calls to logging methods.r.���r/���c������������������������t������������j��������t����������j��������������������o;t������������j��������j��������t����������j��������������������o��j��������j��������j���������j��������v�S��N)r1���r)���r���� Attribute�expr�Namer6���rM���)r\���rW���s�����r7����is_logging_namez2LoggingChecker.visit_call.<locals>.is_logging_name����sH��������4�9�e�o�6�6��?��t�y�~�u�z�:�:�?��I�N�'�4�+>�>� r9����tuple[bool, str | None]c������������������\�����t�����������j��������������������D�]�}�t����������|�t����������j��������������������ry|�j��������j��������}t����������|t����������j��������������������rS|� ����������������������������������dk����s+t����������d��|�����������������������������������D���������������������������rd|�j��������j��������fc�S���dS�)N�logging.Loggerc��������������3���F���K����|�]}|������������������������������������d�k����V����dS�)rt���N)�qname)�.0�ancestors��� r7���� <genexpr>zELoggingChecker.visit_call.<locals>.is_logger_class.<locals>.<genexpr>����sF�������������� (��%�N�N�,�,�0@�@�����������r9���T)FN) r ���r)���r1���r2���r3����_proxied�parentr����ClassDefrv����any� ancestorsr6���)�inferredr{���r\���s��� �r7����is_logger_classz2LoggingChecker.visit_call.<locals>.is_logger_class����s��������%�d�i�0�0�� <�� <���h��(;�<�<�� <�%�.�5�F�!�&�%�.�9�9��<������*:�:�:������,2�,<�,<�,>�,>�����������;�� $�X�%6�%;�;�;�;�;���;r9���N)r.���r/���)r.���rr���)r)����attrname�_check_log_method)rW���r\���rq���r����r6����results���`` r7���� visit_callzLoggingChecker.visit_call����s��������� �� �� �� �� �� �� � �� �� �� �� �� ���?���� ��9�%�D�D�*�?�,�,�L�F�D��� ������t�T�*�*�*�*�*r9���r6����strc�����������������������|dk����r+|j���������s|j��������st����������|j��������������������dk�����rdS�d}n%|t����������v�r|j���������s|j��������s|j��������sdS�d}ndS�|j��������|���������}t����������|t����������j��������������������r�|}|j��������dk����}|j��������dk����rB��� ��������������������|������������s-t������������fd�|j��������|j��������fD���������������������������}|dk����}|r.��� ��������������������d |�����������������������|������������f� �������������dS�dS�t����������|t����������j��������������������r�����������������������|�������������dS�t����������|t����������j��������������������r�����������������������||�������������dS�t����������|t����������j��������������������r?t)����������|������������rdS���� ��������������������d|�����������������������|������������f� �������������dS�dS�)z9Checks calls to logging.log(level, format, *format_args).�log����NrK���r����%�+c��������������3���j����K����|�]-}�����������������������t����������j��������|�������������������������)d�V����.dS��rK���N)�_is_operand_literal_strr ���� safe_infer)rw����operandrW���s��� �r7���ry���z3LoggingChecker._check_log_method.<locals>.<genexpr>����sV������������.��.���3�3�E�4D�W�4M�4M�N�N�.��.��.��.��.��.��.r9���r����r\����argsr���)�starargs�kwargsrV���r�����CHECKED_CONVENIENCE_FUNCTIONSr1���r����BinOp�op�#_is_node_explicit_str_concatenation�sum�left�right�add_message�_helper_string�Call�_check_call_func�Const�_check_format_string� JoinedStr�str_formatting_in_f_string)rW���r\���r6���� format_pos� format_arg�binop�emit�total_number_of_stringss���` r7���r����z LoggingChecker._check_log_method����s:�������5�=�=��}�� ���� �s�4�9�~�~��/A�/A����()�J�J� �2� 2� 2��}�� ���� �4�9�� �����J�J��F��Y�z�*� ��j�%�+�.�.�� ��E��8�s�?�D��x�3���t�'O�'O�PU�'V�'V��*-��.��.��.��.�$)�J���#<�.��.��.��+��+�'� �/��2���� �� � �&���-�-�d�3�3�5��!����������� �� ��� �E�J� /� /�� ��!�!�*�-�-�-�-�-� � �E�K� 0� 0�� ��%�%�d�J�7�7�7�7�7� � �E�O� 4� 4�� �)�*�5�5�� ������/���)�)�$�/�/�1�� �� �� �� �� �� � �� r9���c�����������������p����dg}|�j������������������������������d|j��������������������s|���������������������d�������������|�j������������������������������d|j��������������������s|���������������������d�������������|�j������������������������������d|j��������������������s|���������������������d�������������d���������������������|������������S�) zGCreate a string that lists the valid types of formatting for this node.zlazy %zlogging-fstring-formatting�fstringr���z .format()r���r����z or )rN����is_message_enabled� fromlineno�append�join)rW���r\����valid_typess��� r7���r����zLoggingChecker._helper_string��s��������j���{�-�-�(�$�/� �� �� *�� ���y�)�)�)��{�-�-�*�D�O� �� �� ,�� ���{�+�+�+��{�-�-�.@�$�/�R�R�� $����s�#�#�#��{�{�;�'�'�'r9���r�����InferenceResult | Noner/���c�����������������L�����t����������|�t����������j��������������������o |�j��������dk����S�)z;Return True if the operand in argument is a literal string.r����)r1���r���r����r6���)r����s��� r7���r����z&LoggingChecker._is_operand_literal_str$��s"��������'�5�;�/�/�I�G�L�E�4I�Ir9����nodes.NodeNGc�����������������2����t����������|�t����������j��������������������sdS�t�������������������������������|�j��������������������pt�������������������������������|�j��������������������o=t�������������������������������|�j��������������������pt�������������������������������|�j��������������������S�)zEReturn True if the node represents an explicitly concatenated string.F)r1���r���r����r;���r����r����r����r�����r\���s��� r7���r����z2LoggingChecker._is_node_explicit_str_concatenation)��s���������$���,�,�� ��5��2�2�4�9�=�=�� M��A�A�$�)�L�L� �� �2�2�4�:�>�>�� N��A�A�$�*�M�M� r9���c�����������������"����t����������j��������|j��������������������}d}d}t����������|t����������j��������������������rSt ����������|||������������rDt����������|j��������������������s2|�� ��������������������d||�� ��������������������|������������f��������������dS�dS�dS�dS�)z8Checks that function call is not format_string.format().)r�����unicode)�formatr���r����N)r ���r����r)���r1���r2���r3���r8����is_complex_format_strr4���r����r����)rW���r\���r)���r+���r-���s��� r7���r����zLoggingChecker._check_call_func6��s���������� �*�*��"�����t�W�0�1�1� ��t�U�G�4�4� ��*�$�*�5�5� � � ���.���)�)�$�/�/�1�� �� �� �� �� �� � �� �� �� �� �� r9���r����� Literal[0, 1]c����������� ������H����t����������|j��������|dz���d����������������������}|sdS�|j��������|���������j��������}d}t����������|t����������������������r|�����������������������������������}t����������|t����������������������r� �|�j��������dk����rt����������j ��������|������������\��}}}}|rdS�nD|�j��������dk����r9t����������j ��������|������������\��}} } t����������d��|D���������������������������}|| z���| z���}n#�t����������j��������$�rE}||j �����������������} |����������������������d|| t����������| ������������|j ��������f��������������Y�d}~dS�d}~wt����������j��������$�r�|����������������������d |� �������������Y�dS�w�xY�w||k����r|����������������������d|� �������������dS�||k�����r|����������������������d|� �������������dS�dS�) z�Checks that format string tokens match the supplied arguments. Args: node: AST node to be checked. format_arg: Index of the format string in the node arguments. rK���Nr���rB���rD���c�����������������B�����h�|�]\��}}t����������|t�����������������������|��S�r(���)r1����int)rw����krF���s��� r7���� <setcomp>z6LoggingChecker._check_format_string.<locals>.<setcomp>i��s+������S�S�S�t�q�!� �1�c�@R�@R�S��S�S�Sr9���r���r����r���r����r���r���)�_count_supplied_tokensr�����valuer1����bytes�decoder����rR���r ����parse_format_string�parse_format_method_stringrV����UnsupportedFormatCharacter�indexr�����ord�IncompleteFormatString)rW���r\���r�����num_args� format_string�required_num_args�keyword_argsrF����keyword_arguments�implicit_pos_args�explicit_pos_args�keyword_args_cnt�ex�chars��� r7���r����z#LoggingChecker._check_format_stringF��s8������*�$�)�J��N�4D�4D�*E�F�F���� �� �F�� �*�-�3� ����m�U�+�+�� 3�)�0�0�2�2�M��m�S�)�)��! � ��%��.�.�<A�<U�%�=��=�9�L�"3�Q���$���������'�5�0�0� ��8��G�G� �)�)�)��(+�S�S�'8�S�S�S�(��(�$��)�+<�<�?P�P��&�����3�� �� �� �$�R�X�.��� � �0����D� � �2�8�4��!������� ������������/�� �� �� �� � �!;�$� �G�G�G���� ������'�'�'����4�4��@�@�@�@�@� �)� )� )����3�$��?�?�?�?�?��*� )s%����7&C%��AC%��%E!�4:D4�4)E!� E!N)rF���rG���r.���rH���)r\���r]���r.���rH���)r\���rg���r.���rH���)r\���rj���r.���rH���)r\���rj���r6���r����r.���rH���)r\���rj���r.���r����)r����r����r.���r/����r\���r����r.���r/���)r\���rj���r����r����r.���rH���)�__name__� __module__�__qualname__�__doc__r6���r����msgs�optionsr[���rf���ri���r����r����r�����staticmethodr����r����r����r����r(���r9���r7���r;���r;�������sd�������������+�+��D��D�� �'��3�F� �� � �� #� � �1�!�5�>�P� �� � ��G�08��8��8��8�"�������;��;��;��;�+��+��+��+�@-��-��-��-�^(��(��(��(�"��J��J��J���\�J��� �� �� ���\� �������� 6@��6@��6@��6@��6@��6@r9���r;���r\���r����c�����������������b����t����������j��������|�������������}|�4t����������|t����������j��������������������rt����������|j��������t����������������������sdS� �t����������t����������j ����������������������� ��������������������|j��������������������������������}n#�t����������$�r�Y�dS�w�xY�wt����������d��|D���������������������������S�)zJReturn whether the node represents a string with complex formatting specs.NTFc��������������3���$���K����|�]\��}}}}|V����d�S�rm���r(���)rw���rF����format_specs��� r7���ry���z(is_complex_format_str.<locals>.<genexpr>���s+����������@�@�5��1�k�1�{�@�@�@�@�@�@r9���) r ���r����r1���r���r����r����r�����list�string� Formatter�parse� ValueErrorr}���)r\���r����parseds��� r7���r����r������s����������%�%�H����8�U�[�)�)���.8����.M�.M�����t���f�&�(�(�.�.�x�~�>�>�?�?������������u�u�������@�@��@�@�@�@�@�@s����8B�� B�Br�����list[nodes.NodeNG]r����c�����������������4�����t����������d��|�D���������������������������S�)ap��Counts the number of tokens in an args list. The Python log functions allow for special keyword arguments: func, exc_info and extra. To handle these cases correctly, we only count arguments that aren't keywords. Args: args: AST nodes that are arguments for a log format string. Returns: Number of AST nodes that aren't keywords. c��������������3���N���K����|�] }t����������|t����������j���������������������d�V����!dS�r����)r1���r����Keyword)rw����args��� r7���ry���z)_count_supplied_tokens.<locals>.<genexpr>���s3����������G�G�S� �3�� �(F�(F�G�q�G�G�G�G�G�Gr9���)r����)r����s��� r7���r����r�������s!��������G�G�D�G�G�G�G�G�Gr9����nodes.JoinedStrc�����������������>�����t����������d��|�j��������D���������������������������S�)znDetermine whether the node represents an f-string with string formatting. For example: `f'Hello %s'` c��������������3�������K����|�]G�t�����������t����������j���������������������d��j��������v�ot �����������fd�t ����������D���������������������������V����HdS�)r����c��������������3���*����K����|�] }|�j���������v�V����d�S�rm���)r����)rw����x�vals��� �r7���ry���z7str_formatting_in_f_string.<locals>.<genexpr>.<genexpr>���s)����������� P� P�A��c�i�� P� P� P� P� P� Pr9���N)r1���r���r����r����r}����MOST_COMMON_FORMATTING)rw���r����s��� @r7���ry���z-str_formatting_in_f_string.<locals>.<genexpr>���ss�����������������c�5�;�'�'���s�y��P�S� P� P� P� P�9O� P� P� P�P�P�����������r9���)r}����valuesr����s��� r7���r����r�������s4�������������;�����������r9���rN���r���rH���c�����������������J�����|�����������������������t����������|��������������������������d�S�rm���)�register_checkerr;���)rN���s��� r7����registerr�������s$������ ���N�6�2�2�3�3�3�3�3r9���)r(���r(���)r)���r*���r+���r,���r-���r,���r.���r/���r����)r����r����r.���r����)r\���r����r.���r/���)rN���r���r.���rH���)%r����� __future__r���r�����sys�typingr���r2���r���r����astroid.typingr����pylintr����pylint.checkersr ����pylint.checkers.utilsr ���� pylint.typingr����version_infor����typing_extensions�pylint.lintr���r����__annotations__r����� frozensetr����r8����BaseCheckerr;���r����r����r����r����r(���r9���r7����<module>r�����sG���� �)��(��(��"��"��"��"��"��"�� � � � �� � � � �� �� �� �� �� �� ������� �� �� �� �� �� �� �� ��*��*��*��*��*��*��������������!��!��!��!��!��!��+��+��+��+��+��+��0��0��0��0��0��0���v����������)�)�)�)�)�)���%�$�$�$�$�$�$� ������ �s>��>����@��@��@��@�F !�� !�� !����#��#;�#;�#;�<�<����VX����������,w@��w@��w@��w@��w@�X�)��w@��w@��w@�tA��A��A��A� H�� H�� H�� H� �� �� �� �4��4��4��4��4��4r9���