Team Ai
Apppublic

Yash030/claude-code-proxy

sourceHugging Faceupdated 5mo agoView on Hugging Face
2likes
egress.cpython-314.pyc25 linesDownload Raw Back to __pycache__
1+
2�Ej:
���Rt^RIHt^RIt^RIt^RIHt^RIHt]!RRR7!RR44t	!R	R3]44tRRltR
Rlt
RRltRRltR#)z>Egress policy for user-controlled web_fetch URLs (SSRF guard).)�annotationsN)�	dataclass)�urlparseT)�frozen�slotsc�0�]tRt^t$RtR]R&R]R&RtR#)�WebFetchEgressPolicyz0Egress rules for user-influenced web_fetch URLs.�bool�allow_private_network_targetszfrozenset[str]�allowed_schemes�N)�__name__�5__module__�__qualname__�__firstlineno__�__doc__�__annotations__�__static_attributes__r��<C:\Users\yashw\.claude\temp-hf-clone\api\web_tools\egress.pyrrs��:�#'�'�#�#rrc��]tRt^tRtRtR#)�WebFetchEgressViolationzFRaised when a web_fetch URL is rejected by egress policy (SSRF guard).rN)r
rrrrrrrrrrs��Prrc��V^8�dQhRR/#)��return�intr)�formats"r�__annotate__rs��C�C�S�Crc��VPe
VP#VP;'gRP4R8XdR#^P#)N��httpsi�)�port�scheme�lower)�parseds&r�
_port_for_urlr%s=��
�{�{���{�{���=�=�&�&�B�-�-�/�7�:�3�B��Brc�$�V^8�dQhRRRRRR/#)r�host�strr!rr�list[tuple]r)rs"rrrs!����s��#��+�rc��\P!W\P\PR7# \dp\RT:RT24ThRp?ii;i))�type�protozCould not resolve host z: N)�socket�getaddrinfo�SOCK_STREAM�IPPROTO_TCP�OSErrorr)r'r!�excs&& r�_stream_getaddrinfo_or_raiser3s_����!�!��V�/�/�v�7I�7I�6�	7����%�%�d�X�R��u�5�8��	���s�47�A�A�Ac�$�V^8�dQhRRRRRR/#)r�urlr(�policyrrr)r)rs"rrr(s$��6�6�	�6�*�6��6rc�~�\V4pVP;'gRP4pW1P9d\	RV:R24hVP9pVeVR8Xd\	R4h\
V4pVP'd\WE4#VP4pVR8XgVPR4'd\	R4hVPR	4'd\	R104h\P!V4pVe.VP'g\	RV:R24h\WE4#\WE4pVFJEvr�V11^,p\P!V4pTP'dK9\	RT:R
TR24h	V# \dRpL�i;i \dKqi;i)a.Resolve and validate a URL for web_fetch, returning getaddrinfo rows for pinning.12 13Each HTTP connect pins to only these `getaddrinfo` results so a malicious DNS14server cannot rebind to a disallowed address between resolution and the TCP15connect (used by :func:`api.web_tools.outbound._run_web_fetch`).16rzURL scheme z is not allowed for web_fetchNz!web_fetch URL must include a host�	localhostz17.localhostz/localhost targets are not allowed for web_fetchz.localz..local hostnames are not allowed for web_fetchzNon-public IP host zHost z# resolves to a non-public address (�))rr"r#rr�hostnamer%r18r3�endswith�	ipaddress�19ip_address�20ValueError�	is_global)
r5r6r$r"r'r!�21host_lower�	parsed_ip�infos�_�sockaddr�addr�resolveds
&&           r�)get_validated_stream_addrinfos_for_egressrG(s����c�]�F��m�m�!�!�r�
(�
(�
*�F�
�+�+�+�%��&��#@�A�22�	23��?�?�D��|�t�r�z�%�&I�J�J��� �D�
�+�+�+�+�D�7�7�����J��[� �J�$7�$7��$E�$E�%�&W�X�X����8�$�$�%�&V�W�W���(�(��.�	����"�"�"�)�%�d�X�-J�K��
�,�D�7�7�(��4�E������{��	� �+�+�D�1�H��!�!�!�)���x�B�8�*�A�N��
���L��+���	����	��	�s$�6F�F-�
F*�)F*�-F<�;F<c�$�V^8�dQhRRRRRR/#)rr5r(r6rr�Noner)rs"rrras"��;�;�#�;�/C�;��;rc��\W4R#)zFValidate ``url`` (scheme, host, and resolved addresses) for web_fetch.N)rG)r5r6s&&r�enforce_web_fetch_egressrKas24��-�c�:r)r�25__future__rr<r-�dataclassesr�urllib.parserrr>rr%r3rGrKrrr�<module>rOs[��D�"��
�!�!��$�d�#�$�$�$�$�Q�j�Q�C��6�r;r