+
    4j/                      a  0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
Ht ^ RIHt . R)Ot ! R	 R]P                  4      t ! R
 R]4      t]! RR7       ! R R4      4       t]! 0 R*m4      tR]R&   R R lt]! RR04      tR]R&   R R lt]P4                  ! R4      tR R ltR R ltR R ltR R lt]! 0 R+m4      t R]R &   R! R" lt!R# R$ lt"R% R& lt#R' R( lt$R# ),a8  Direct-URL / VCS requirement admission for the provider.

Cloning a remote repo is one short step from arbitrary code
execution because modern Python projects build via PEP 517
backends, which run user code.  This module owns the policy types
(:class:`VcsPolicy`, :class:`VcsConfig`), the URL classifier
(:func:`split_vcs_scheme`, :func:`has_full_commit_sha`), and the
admit-or-refuse decision (:func:`admit_vcs_url`) called eagerly
during requirement ingestion.

The actual clone path lives in :mod:`nab_index.vcs` and runs only
after admission lets the URL through.
)annotationsN)	dataclass)unquoteurlsplit)FULL_GIT_SHA_REUnsupportedVcsError	VcsConfig	VcsPolicyc                  $    ] tR t^ tRtRt RtRtR# )r	   aY  Whether to honor VCS direct-URL requirements (``pkg @ git+https://...``).

Cloning a remote repo is one short step from arbitrary code execution
(modern Python projects build via PEP 517 backends, which run user
code).  Default posture is :attr:`BLOCK`; opt-in is per-protocol via
``vcs.allowed-schemes`` and per-repo via ``vcs.allowed-repos``.
blockallow N)__name__
__module____qualname____firstlineno____doc__BLOCKALLOW__static_attributes__r       k/home/user/pdf2html-billing-ledger-validate/.venv/lib/python3.14/site-packages/nab_python/_vcs_admission.pyr	   r	       s     E8Er   c                      ] tR t^6tRtRtR# )r   zA VCS / direct-URL requirement was refused by policy.

Raised eagerly during requirement ingestion; not surfaced as a
"no candidates" backtrack so the user sees a clear diagnostic.
r   N)r   r   r   r   r   r   r   r   r   r   r   6   s    r   T)frozenc                  r    ] tR t^>t$ Rt]P                  tR]R&   ]	! 4       t
R]R&   RtR]R&   RtR	]R
&   RtR# )r   zBundle of VCS opt-in knobs passed through the resolver stack.

Default is fully restrictive (``BLOCK`` policy, empty allowlists,
pin required).
r	   policyfrozenset[str]allowed_schemesztuple[str, ...]allowed_reposTboolrequire_pinr   N)r   r   r   r   r   r	   r   r   __annotations__	frozensetr   r   r    r   r   r   r   r   r   >   s7     "FI'&/kO^1%'M?'Kr   git+httpgit+gitr   _VCS_SCHEMESc                   V ^8  d   QhRR/# )   returnr   r   )formats   "r   __annotate__r*   W   s      > r   c                     \         # )zReturn the VCS URL schemes nab recognises (e.g. ``git+https``).

nab is git-only, so every entry is a ``git+`` scheme.  Exposed so
config parsing can reject an unknown ``vcs.allowed-schemes`` entry
without importing the private scheme set.
)r%   r   r   r   known_vcs_schemesr,   W   s
     r   _VCS_INSECURE_SCHEMESc                    V ^8  d   QhRRRR/# )r'   urlstrr(   ztuple[str | None, str]r   )r)   s   "r   r*   r*   d   s      # "8 r   c                z    \          F.  pV P                  V R24      '       g   K  W\        R4      R 3u # 	  RV 3# )a  Strip a recognized VCS scheme prefix.

``"git+https://example.com/r.git@v1"`` -> ``("git+https", "https://example.com/r.git@v1")``.
``"https://example.com/file.whl"``     -> ``(None,        "https://example.com/file.whl")``.

Returns ``(None, url)`` for non-VCS URLs (e.g. plain ``https://``
archives or ``file://`` paths) so the caller can refuse them
separately.  Only ``git+`` schemes are recognised; ``hg+``/``bzr+``/``svn+``
are intentionally absent so they are refused as non-VCS.
://zgit+N)r%   
startswithlen)r/   
vcs_schemes   & r   split_vcs_schemer6   d   sD     #
>>ZL,--CKM 233 # #;r   z^([^/?#]*//)[^/?#]*@c                    V ^8  d   QhRRRR/# )r'   r/   r0   r(   r   )r)   s   "r   r*   r*   z   s     2 23 23 2r   c                f    R\        V 4      P                  9  d   V # \        P                  RV 4      # )a  Drop any authority ``user[:pass]@`` / SSH ``git@`` from ``url``.

An ``allowed-repos`` prefix names a repo by scheme + host + path, not
by credentials, so both the candidate URL and the prefix are stripped
before the match. A URL with no userinfo is returned unchanged.

The cut is made on the raw string, since
:func:`urllib.parse.urlsplit` deletes every tab, CR and LF and does
not record an empty ``?``: a URL rebuilt from the parse is not the
one git is handed.
@z\1)r   netloc_AUTHORITY_USERINFO_REsubr/   s   &r   _without_userinfor>   z   s.     (3-&&&
!%%eS11r   c                    V ^8  d   QhRRRR/# )r'   	remainderr0   r(   r   )r)   s   "r   r*   r*      s     K K K Kr   c                D    RV 9   d   V P                  R4      ^ ,          # T # )zLReturn ``remainder`` without a trailing ``@<ref>``, split on the last ``@``.r9   )
rpartition)r@   s   &r   	_drop_refrC      s$    +.)+;9$Q'JJr   c                    V ^8  d   QhRRRR/# )r'   	inner_urlr0   r(   r   )r)   s   "r   r*   r*      s     / /# /# /r   c                >    \        \        V 4      P                  4      # )zuReturn the path of ``inner_url`` with any trailing ``@<ref>`` dropped.

An empty result means the URL names no repo.
)rC   r   path)rE   s   &r   
_repo_pathrH      s    
 Xi(--..r   c                    V ^8  d   QhRRRR/# )r'   rG   r0   r(   r   r   )r)   s   "r   r*   r*      s     3 3C 3D 3r   c                    \        V 4      P                  RR4      p\        P                  ! V4      pVP	                  R4      '       d!   VP	                  R4      '       g
   VR,          p\        V4      ;'       d    W!8g  # )a^  Return True if git would rewrite ``path`` before it fetches.

Git applies RFC 3986 dot-segment removal at fetch time.  ``path`` is
decoded once so an encoded ``%2e%2e`` cannot slip past, and ``\`` is
folded to ``/`` because Windows resolves it as a separator.  A trailing
``/`` is put back: RFC 3986 keeps it and :func:`posixpath.normpath`
does not.
\/)r   replace	posixpathnormpathendswithr   )rG   decoded
normaliseds   &  r   _rewritten_by_gitrS      sj     dm##D#.G##G,JZ%8%8%=%=c
=22Z22r   _REPO_BOUNDARY_CHARSc               $    V ^8  d   QhRRRRRR/# )r'   rE   r0   prefixr(   r   r   )r)   s   "r   r*   r*      s!     %+ %+C %+ %+ %+r   c                j   \        V 4      pVP                  '       d   VP                   RVP                   2MVP                  p\        V4      p\        ;QJ d3    R WDP                  R4      ^ ,          3 4       F  '       g   K   RM(	  RM$! R WDP                  R4      ^ ,          3 4       4      '       d   R# VP                  R4      pV P                  V4      '       g   R# V \        V4      R P                  R4      pV'       d   V'       d   VR,          \        9   d   R# V^ ,          \        9   # )aZ  Return True if ``inner_url`` names a repo under ``prefix``.

A bare :meth:`str.startswith` would admit a sibling repo whose URL
merely begins with an allowed entry (``.../airflow.git`` would admit
``.../airflow.git.other``).  The match here requires the prefix to end
at a path-segment boundary: the candidate must equal the prefix, the
prefix must already end in a separator, or the next candidate
character must be ``/`` (path), ``@`` (ref) or ``#`` (fragment).
Git treats the ``.git`` suffix as optional, so it is stripped from the
prefix and skipped once on the candidate before the boundary check.
Both URLs have their authority ``user[:pass]@`` / ``git@`` stripped
by the caller.

A path git would rewrite is refused first, since a ``..`` could pass
the string match while git fetches a repo outside the prefix.  The ref
is dropped before that check, off the whole post-authority remainder
rather than the path alone, matching the split :mod:`nab_index.vcs`
makes at clone time; otherwise a ``..`` in the final segment hides as
the ordinary name ``..@<ref>``.  The prefix comparison below is on the
raw URL.
?c              3  8   "   T F  p\        V4      x  K  	  R # 5iN)rS   ).0parts   & r   	<genexpr>'_repo_prefix_matches.<locals>.<genexpr>   s     
N/MtT""/Ms   TFz.gitN)r   queryrG   rC   any	partitionremovesuffixr3   r4   removeprefixrT   )rE   rV   partsr@   reporests   &&    r   _repo_prefix_matchesrh      s    , YE165::,a}-%**IYD s
NnnS6I!6L/M
Nsss
NnnS6I!6L/M
NNN  (F''S[]#008Dv/C!C7***r   c                    V ^8  d   QhRRRR/# )r'   r/   r0   r(   r   r   )r)   s   "r   r*   r*      s     , ,S ,T ,r   c                   V P                  R^4      ^ ,          pVP                  R^4      R,          pVP                  R4      ^,          pRV9  d   R# VP                  R^4      ^,          p\        \        P
                  ! V4      4      # )zReturn True if the URL pins to a 40-char hex commit hash.

Looks for ``@<sha>`` in the path component (after the authority);
ignores any ``#`` fragment.  A ``user@host`` in the authority is
left alone, matching the ref parsing in :mod:`nab_index.vcs`.
#r2   rL   r9   Fr_   )splitrb   rsplitr   r   match)r/   fragmentlessafter_schemerG   refs   &    r   has_full_commit_sharr      sz     99S!$Q'L%%eQ/3L!!#&q)D
$
++c1
a
 C%%c*++r   c                    V ^8  d   QhRRRR/# )r'   r/   r0   r(   r   r   )r)   s   "r   r*   r*      s      c &9 r   c                     \        RV  R24      # )z<Refusal for a URL whose authority ``urlsplit`` cannot parse.zrefusing malformed VCS URL
    z$
    reason: the URL does not parse.)r   r=   s   &r   _malformed_vcs_errorru      s    
*3%/TU r   c               $    V ^8  d   QhRRRRRR/# )r'   r/   r0   configr   r(   r   )r)   s   "r   r*   r*      s&     c cs cI c# cr   c                  a \        V 4      w  poVf   RV  R2p\        V4      hVP                  \        P                  J d   RV  R2p\        V4      hW!P
                  9  d^   RP                  \        VP
                  4      4      ;'       g    RpRV  R	V R
V R2pV\        9   d   VRV R2,          p\        V4      h \        S4      pTP                  R4      '       g   RT  R2p\        T4      h \        ;QJ d)    T3R lTP                   4       F  '       g   K   RM	  RM! T3R lTP                   4       4      pT'       gB   RP                  \        TP                  4      4      ;'       g    RpRT  RT 2p\        T4      hTP                  '       d#   \!        T 4      '       g   RT  R2p\        T4      hT#   \         d    \        T 4      Rhi ; i  \         d    \        T 4      Rhi ; i)zAdmit a direct-URL requirement, or raise :class:`UnsupportedVcsError`.

Returns the recognized VCS scheme on success.  Called eagerly when
ingesting root requirements with a non-empty
:attr:`Requirement.url <packaging.requirements.Requirement.url>`.
NzBrefusing direct-URL requirement (not a recognized VCS scheme)
    z
    note: nab supports git+https / git+ssh / git+http / git+file / git+git only; hg/bzr/svn and plain http(s)/file archive URLs are not supported.zrefusing VCS requirement
    z
    reason: vcs.policy is "block" (default).
    to allow: set vcs.policy = "allow" with appropriate
              vcs.allowed-schemes (and vcs.allowed-repos).z, z<empty>zrefusing VCS scheme
    z
    reason: scheme "z" not in vcs.allowed-schemes={z}.z
    note: "z4" is unauthenticated; consider an https/ssh variant.rL   z.refusing VCS URL that names no repository
    z
    reason: the URL has no repository path.
    note: everything after the final @ is the ref, so a repo URL
          looks like git+https://host/org/repo.git@<ref>.c              3  `   <"   T F#  p\        \        S4      \        V4      4      x  K%  	  R # 5irZ   )rh   r>   )r[   rV   rE   s   & r   r]    admit_vcs_url.<locals>.<genexpr>,  s6      
 / !!),.?.G  /s   +.TFzrefusing VCS repo
    zM
    reason: repo URL prefix not in vcs.allowed-repos.
    allowed prefixes: zrefusing unpinned VCS ref
    z
    reason: vcs.require-pin is true and no 40-char commit hash present.
    to allow: pin the requirement to a 40-char commit hash, or set
              vcs.require-pin = false (not recommended for reproducible installs).)r6   r   r   r	   r   r   joinsortedr-   rH   
ValueErrorru   stripra   r   r    rr   )r/   rw   schememsgallowed_str	repo_pathrepo_admittedrE   s   &&     @r   admit_vcs_urlr      sY    )-FI~% << 	 "#&&}}	'% II 	 "#&&+++iiv'='= >?LL9% ##)( +S" 	 **x (2 2C "#&&2y)	 ??3% HH 	 "#&&2 
 !..	
 
 !..	
 
 iiv';'; <=JJ% %%0M3 	 "#&&"5c":":% '' 	 "#&&Mm  2"3'T124  2"3'T12s$   G 6
G G ""G GG6)r   r   r	   >   r$   git+sshgit+filer#   	git+https>   rk   rL   r9   )%__conditional_annotations__r   
__future__r   enumrN   redataclassesr   urllib.parser   r   nab_index.vcsr   __all__Enumr	   	Exceptionr   r   r"   r%   r!   r,   r-   r6   compiler;   r>   rC   rH   rS   rT   rh   rr   ru   r   )r   s   @r   <module>r      s    #   	 ! * )		 ,)  $
 
 
  ) n  )29j2I(J ~ J& $;< 2"K
/3" (1'A n A%+P, cr   