???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................3
Pi&                 @   s   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZ dZd dlmZmZmZmZmZmZ dd Zdad	d
 Zdd Zdd ZdddZdd Zdd ZdS )    )print_functionN)defaultdictzdnssec-coverage)dnskey	eventlistkeydictkeyeventkeyzoneutilsc              O   s   t | | tjd d S )N   )printsysexit)argskwargs r   /usr/lib/python3.6/coverage.pyfatal   s    
r   Tc              O   sJ   d|kr|d }|j dd nd}tr,dan|r8td | rFt| | dS )zuoutput text, adding a vertical space this is *not* the first
    first section being printed since a call to vreset()skipNTF )pop
_firstliner   )r   r   r   r   r   r   output'   s    r   c               C   s   da dS )zreset vertical spacingTN)r   r   r   r   r   vreset8   s    r   c             C   s   | j  } yt| S  tk
r$   Y nX tjd}|j| }|sJtd|  |j \}}t|}|j }|jdrx|d S |jdr|d S |jdr|d S |jd	r|d
 S |jdr|d S |jdr|d S |jdr|S td| dS )z convert a formatted time (e.g., 1y, 6mo, 15mi, etc) into seconds
    :param s: String with some text representing a time interval
    :return: Integer with the number of seconds in the time interval
    z([0-9][0-9]*)\s*([A-Za-z]*)zCannot parse %syi3moi ' wi:	 diQ hi  Zmi<   szInvalid suffix %sN)	stripint
ValueErrorrecompilematchgroupslower
startswith)r   rmnZunitr   r   r   
parse_timeA   s6    








r,   c             C   s   |}| s(t jj| s(t j|t j rt jd }|s>t jj}xB|jt jD ]2}t jj	|| }t jj|rzt j|t jrzP d}qLW |S )a1   find the location of a specified command.  if a default is supplied
    and it works, we use it; otherwise we search PATH for a match.
    :param command: string with a command to look for in the path
    :param default: default location to use
    :return: detected location for the desired command
    PATHN)
ospathisfileaccessX_OKenvirondefpathsplitpathsepjoin)ZcommanddefaultZfpathr/   Z	directoryr   r   r   set_pathk   s    $
r9   c        	   0   C   sD  t dtjjtjdd} tjtd d d}|j	dt
dddFd |j	dddt
ddd |j	ddt
ddd |j	ddt
ddd |j	ddt
ddd |j	ddd t
d!dd |j	d"d#| t
d$dd |j	d%d&t
d'd(dd) |j	d*d+d,d-d.d/ |j	d0d1d,d-d2d/ |j	d3d4d5d,d-d6d/ |j	d7d8d9tjd: |j }|jrJ|jrJtd; n*|jsZ|jrn|jrfd<nd=|_nd|_|jrt|jd>krtd? d@dA |jD |_y|jrt|j}||_W n tk
r   Y nX y|jrt|j}||_W n tk
r   Y nX y|jr(t|j}||_W n tk
r@   Y nX y<|jr||j}t|j}|dBkrnd|_ntj | |_W n tk
r   Y nX |jr|jr|S |jr*|jr*y:t|jdB |j|j}|jp|j|_|jp|j|_W n4 tk
r( } ztdC|j | W Y dd}~X nX |js@tdD dE|_|S )Gz8Read command line arguments, set global 'args' structureznamed-compilezoneZsbinz: checks future zDNSKEY coverage for a zone)descriptionzone*Nzzone(s) to checkz%(default: all zones in the directory))typenargsr8   helpz-Kr/   .z&a directory containing keys to processdir)destr8   r=   r?   metavarz-ffilenamezzone master filefile)rB   r=   r?   rC   z-mmaxttlzthe longest TTL in the zone(s)timez-dkeyttlzthe DNSKEY TTLz-rresignZ1944000z:the RRSIG refresh interval in seconds [default: 22.5 days]z-ccompilezonezpath to 'named-compilezone'z-l
checklimit0zDLength of time to check for DNSSEC coverage [default: 0 (unlimited)])rB   r=   r8   r?   rC   z-zno_ksk
store_trueFz#Only check zone-signing keys (ZSKs))rB   actionr8   r?   z-kno_zskz"Only check key-signing keys (KSKs)z-Dz--debugZ
debug_modezTurn on debugging outputz-vz	--versionversion)rO   rQ   z)ERROR: -z and -k cannot be used together.ZKSKZZSKr
   z)ERROR: -f can only be used with one zone.c             S   s4   g | ],}t |d kr,|d dkr,|dd n|qS )r
   r@   NrR   )len).0xr   r   r   
<listcomp>   s   zparse_args.<locals>.<listcomp>r   z"Unable to load zone data from %s: zWARNING: Maximum TTL value was not specified.  Using 1 week
	 (604800 seconds); re-run with the -m option to get more
	 accurate results.i:	 z5zone(s) to check(default: all zones in the directory)) r9   r.   r/   r7   r	   prefixargparseArgumentParserprogadd_argumentstrrQ   
parse_argsrP   rM   r   keytyperD   rS   r;   rF   r,   r"   rH   rI   rK   rG   r   rJ   	Exceptionr   r   )	rJ   parserr   r*   kr)   Zlimr;   er   r   r   r]      s    

 

















"r]   c           (   C   sp  t  } td yt| j| j| jd}W n2 tk
rX } ztdt|  W Y d d }~X nX x<|D ]4}|j	t
 |jr|jt
 q`|jt
| j| j  q`W t
d t  yt|}W n2 tk
r } ztdt|  W Y d d }~X nX d}| js|jd | j| jt
sXd}nJxH| jD ]>}y|j|| j| jt
s6d}W n   t
d|  Y nX qW tj|rfd	nd
 d S )Nz;PHASE 1--Loading keys to check for internal timing problems)r/   ZzonesrH   z'ERROR: Unable to build key dictionary: z9PHASE 2--Scanning future key events for coverage failuresz#ERROR: Unable to build event list: FTz&ERROR: Coverage check failed for zone r
   r   )r]   r   r   r/   r;   rH   r_   r   r\   Zcheck_prepubr   sepZcheck_postpubrF   rI   r   r   Zcoverager^   rK   r   r   )r   Zkdrb   keyZelisterrorsr;   r   r   r   main   s:    "

"
rf   )N)Z
__future__r   r.   r   rX   Zglobr#   rG   Zcalendarpprintcollectionsr   rZ   Ziscr   r   r   r   r   r	   r   r   r   r   r,   r9   r]   rf   r   r   r   r   <module>   s&    	*
x