shell bypass 403

Cubjrnet7 Shell


name : safeyaml.cpython-39.opt-1.pyc
a

'�Dgm(�@s�ddlZddlmZddlmZddlmZmZmZm	Z	ddl
Z
ddlmZe�
e�ZGdd�d�Zdd	�Zeed
�dd�Zeeeeed
�dd�ZGdd�de
j�ZGdd�de
jj�Ze�d�e	eeeeffd�dd��Ze�d�ddd��ZdS)�N)�defaultdict)�chain)�Any�Dict�List�Tuple)�performancec@s2eZdZeejejd�dd�Zdd�Zdd�ZdS)	�SchemaPathMarks��path�
start_mark�end_markcCs||_||_||_dS�Nr
)�selfrrr
�r�6/usr/lib/python3.9/site-packages/cloudinit/safeyaml.py�__init__szSchemaPathMarks.__init__cCsp|jj|jjks |jj|jjkr$dS|jj|jjkrH|jj|jjkrHdS|jj|jjkrl|jj|jjkrldSdS)z;Return whether other start/end marks are within self marks.FT)r�liner
�column�r�otherrrr�__contains__s ������zSchemaPathMarks.__contains__cCs@|jj|jjko>|jj|jjko>|jj|jjko>|jj|jjkSr)rrrr
rrrr�__eq__/s���zSchemaPathMarks.__eq__N)	�__name__�
__module__�__qualname__�str�yamlZMarkrrrrrrrr	sr	cCs0|ddd�D]}||vr||ks|SqdS)N���r)Z
child_mark�marks�markrrr�_find_closest_parent8s
r!)�
line_markscCs\|D]R}t||�}|r|j�dd�\}}|j|jksB|j�|j�s|j�||jd�|_qdS)zP
    Update any SchemaPathMarks.path for items not under the proper parent.
    �.�N)r!r�rsplit�
startswith�replace)r"r �parentZpath_prefixZ	_path_idxrrr�_reparent_schema_mark_children?s
�r))�new_markr�returncCsbg}d}|D]8}||vr$|�|�q||vr:d}|�|�|�|�q|rTt|�n
|�|�|S)a=Insert new_mark into marks, ordering ancestors first.

    Reparent existing SchemaPathMarks.path when new_mark is a parent of
    an existing mark item.

    Because schema processing is depth first, leaf/child mappings and
    sequences may be processed for SchemaPathMarks before their parents.
    This leads to SchemaPathMarks.path of 'grandchildren' being incorrectly
    parented by the root dictionary instead of an intermediary parents below
    root.

    Walk through the list of existing marks and reparent marks that are
    contained within the new_mark.
    FT)�appendr))r*r�	new_marksZreparent_pathsr rrr�_add_mark_and_reparent_marksNs



r.csPeZdZdZ�fdd�Zdd�Zd
�fdd�	Zd�fd	d
�	Z�fdd�Z�Z	S)�_CustomSafeLoaderWithMarksa�A loader which provides line and column start and end marks for YAML.

    If the YAML loaded represents a dictionary, get_single_data will inject
    a top-level "schemamarks" key in that dictionary which can be used at
    call-sites to process YAML paths schemamark metadata when annotating
    YAML files for errors.

    The schemamarks key is dictionary where each key is a dot-delimited path
    into the YAML object. Each dot represents an element that is nested under
    a parent and list items are represented with the format
    `<parent>.<list-index>`.

    The values in schemamarks will be the line number in the original content
    where YAML element begins to aid in annotation when encountering schema
    errors.

    The example YAML shows expected schemamarks for both dicts and lists:

      one: val1
      two:
        subtwo: val2
      three: [val3, val4]

    schemamarks == {
        "one": 1, "two": 2, "two.subtwo": 3, "three": 4, "three.0": 4,
        "three.1": 4
    }
    cst��|�tt�|_dSr)�superrr�list�schemamarks_by_line)r�stream��	__class__rrr�s�z#_CustomSafeLoaderWithMarks.__init__cCs�|jj|jvrb|j|jjd}|j|jjdd�D]}||vr6||vr6|}q6||vrb|jdSt|j��dd�D]8\}}|ddd�D] }||vr�|j�d�Sq�qtdS)Nrr$r#T)�reverser�)rrr2r�sorted�items)r�nodeZmost_specific_markZ	path_markZ	_line_num�schema_marksr rrr�_get_nested_path_prefix�s(���

�z2_CustomSafeLoaderWithMarks._get_nested_path_prefixFcsrt�j||d�}|�|�}|jD]L\}}|�|j��}|jj}t||j|j�}	|j|}
t	|	|
�}||j|<q |S)N��deep)
r0�construct_mappingr<�valuerrr	r
r2r.)rr:r>�mapping�nested_path_prefixZkey_nodeZ
value_node�
node_key_path�line_numr*r;r-r4rrr?�s

�

z,_CustomSafeLoaderWithMarks.construct_mappingc

st�j|dd�}|�|�}t|j�D]�\}}|jj}|�|��}t||j|j�}	||j	vrh|	g|j	|<q$||jjkr�|j	|}
t
|	|
�}||j	|<q$t||jj�D]b}||j	vr�|j	|}
t
|	|
�}||kr�|
dj|kr�|�
dt||
dj|
dj��||j	|<q�q$|S)NTr=rr)r0�construct_sequencer<�	enumerater@rrr	r
r2r.�ranger�insert)
rr:r>ZsequencerB�indexZ
sequence_itemrDrCr*r;r-Z
inner_liner4rrrE�sL

�

��

�����z-_CustomSafeLoaderWithMarks.construct_sequencecs8t���}t|t�r4tdd�t|j���D��|d<|S)NcSsg|]}|j|jjdf�qS)r$)rrr)�.0�vrrr�
<listcomp>�s�z>_CustomSafeLoaderWithMarks.get_single_data.<locals>.<listcomp>�schemamarks)r0�get_single_data�
isinstance�dictrr2�values�r�datar4rrrN�s

��z*_CustomSafeLoaderWithMarks.get_single_data)F)F)
rrr�__doc__rr<r?rErN�
__classcell__rrr4rr/qs*r/c@seZdZdZdd�ZdS)�NoAliasSafeDumperz>A class which avoids constructing anchors/aliases on yaml dumpcCsdS)NTrrRrrr�ignore_aliases�sz NoAliasSafeDumper.ignore_aliasesN)rrrrTrWrrrrrV�srVzLoading yaml)r+cCs0tj|td�}t|t�si}n
|�d�}||fS)a�Perform YAML SafeLoad and track start and end marks during parse.

    JSON schema errors come with an encoded object path such as:
        <key1>.<key2>.<list_item_index>

    YAML loader needs to preserve a mapping of schema path to line and column
    marks to annotate original content with JSON schema error marks for the
    command:
        cloud-init devel schema --annotate


    )�LoaderrM)r�loadr/rOrP�pop)Zblob�resultrMrrr�load_with_marks�s


r\zDumping yamlTFc	Cs$tj|dd||d|rtntjjd�S)z%Return data in nicely formatted yaml.�
�F)Z
line_break�indent�explicit_start�explicit_endZdefault_flow_styleZDumper)r�dumprV�dumper�
SafeDumper)�objr`raZnoaliasrrr�dumpss�rf)TTF)Zlogging�collectionsr�	itertoolsr�typingrrrrrZ	cloudinitrZ	getLoggerrZLOGr	r!r)r.Z
SafeLoaderr/rcrdrVZtimedr�intr\rfrrrr�<module>s$
"�#} 

© 2025 Cubjrnet7