U
    @†6^	  ã                   @   s0   d dl Z d dlmZmZmZ G dd„ deƒZdS )é    N)Ú
SpiderFootÚSpiderFootPluginÚSpiderFootEventc                   @   s>   e Zd ZdZi ZdZeƒ fdd„Zdd„ Zdd„ Z	d	d
„ Z
dS )Ú
sfp_cookiez_Cookies:Footprint,Investigate,Passive:Crawling and Scanning::Extract Cookies from HTTP headers.Nc                 C   s4   || _ |  ¡ | _t| ¡ ƒD ]}|| | j|< qd S )N)ÚsfÚtempStorageÚresultsÚlistÚkeysÚopts)ÚselfÚsfcÚuserOptsÚopt© r   ú5/var/www/spiderfoot.crq.systems/modules/sfp_cookie.pyÚsetup   s    
zsfp_cookie.setupc                 C   s   dgS )NZWEBSERVER_HTTPHEADERSr   ©r   r   r   r   ÚwatchedEvents    s    zsfp_cookie.watchedEventsc                 C   s   dgS )NÚTARGET_WEB_COOKIEr   r   r   r   r   ÚproducedEvents&   s    zsfp_cookie.producedEventsc           	   
   C   sì   |j }|j}|j}|j}| j d| d | ¡ || jkr>d S d| j|< |  ¡  | j 	|¡¡sn| j d¡ d S zt
 |¡}|d krˆW d S W n6 tk
rÀ } z| j dd¡ W Y ¢d S d }~X Y nX d|krètd|d | j|ƒ}|  |¡ d S )	NzReceived event, z, from Tz+Not collecting cookies from external sites.zBReceived HTTP headers from another module in an unexpected format.Fz
set-cookier   )Ú	eventTypeÚmoduleÚdataÚactualSourcer   Údebugr   Ú	getTargetÚmatchesÚurlFQDNÚjsonÚloadsÚBaseExceptionÚerrorr   Ú__name__ÚnotifyListeners)	r   ÚeventÚ	eventNameÚsrcModuleNameÚ	eventDataÚeventSourceZjdataÚeÚevtr   r   r   ÚhandleEvent*   s0    




 ÿzsfp_cookie.handleEvent)r#   Ú
__module__Ú__qualname__Ú__doc__r   r   Údictr   r   r   r,   r   r   r   r   r      s   r   )r   Úsflibr   r   r   r   r   r   r   r   Ú<module>   s   