
q`c           @  si   d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d   Z e d k re e   n  d S(   sE   This is designed to convert 2.x CRS ID numbering to 3.x CRS numberingi(   t   print_functionNc          C  s  t  j j t j d d  }  t  j j |   sN t j j d  t j d  n  t j	 d d  } | j
 d d d	 t d
 d d d d d | j   } t  j j | j j d   s t j j d  t j d  n  d } y= t | j j d  d  } z | j   } Wd | j   XWn! t k
 r8t j j d  n X| d k rt |  d  } z> t j |  } x( | D]  } | j | d | d  } qmWWd | j   Xn  t |  d S(   s<   Main function that contains all the logic to relabel CRS IDsi    s   IdNumbering.csvs   We were unable to locate the ID translation CSV (idNumbering.csv)             please place this is the same directory as this script
i   t   descriptions   A program that takes in an exceptions file         and renumbers all the ID to match OWASP CRS 3 numbers. Output will be directed to STDOUT.s   -fs   --filet   requiredt   actiont   storet   destt   fnamet   helps   the file to be renumberedt   utf8sp   We were unable to find the file you were trying to update the ID numbers             in, please check your path
t    s   utf-8t   rNs=   There was an error opening the file you were trying to updatet   rt(   t   ost   patht   joint   syst   isfilet   stderrt   writet   exitt   argparset   ArgumentParsert   add_argumentt   Truet
   parse_argsR   t   encodet   opent   readt   closet   IOErrort   csvt   readert   replacet   print(   t   id_translation_filet   parsert   argst   fcontentt   update_filet   id_csv_fileR   t   row(    (    sP   /etc/apache2/conf.d/modsec_vendor_configs/OWASP3/util/crs2-renumbering/update.pyt   main   s<    			!	"t   __main__(	   t   __doc__t
   __future__R    R   R   R   R   R)   t   __name__(    (    (    sP   /etc/apache2/conf.d/modsec_vendor_configs/OWASP3/util/crs2-renumbering/update.pyt   <module>   s   	+