U
    @6^5                     @   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                   @   sZ   e Zd ZdZddddZddddZdZdZdZe	 fd	d
Z
dd Zdd Zdd ZdS )	sfp_nameszjName Extractor:Footprint,Passive:Real World:errorprone:Attempt to identify human names in fetched content.K   T)	algolimitemailtonamefilterjscsszA value between 0-100 to tune the sensitivity of the name finder. Less than 40 will give you a lot of junk, over 50 and you'll probably miss things but will have less false positives.zJConvert e-mail addresses in the form of firstname.surname@target to names?zFilter out names that originated from CSS/JS content. Enabling this avoids detection of popular Javascript and web framework author names.Nc                 C   sT   || _ |  | _t| j  | _t| j  | _t|	 D ]}|| | j
|< q<d S )N)sftempStorageresultsset	dictwordsd	dictnamesnlistkeysopts)selfsfcuserOptsopt r   4/var/www/spiderfoot.crq.systems/modules/sfp_names.pysetup&   s    
zsfp_names.setupc                 C   s   ddddddgS )NTARGET_WEB_CONTENT	EMAILADDRDOMAIN_WHOISNETBLOCK_WHOISRAW_RIR_DATARAW_FILE_META_DATAr   r   r   r   r   watchedEvents1   s      zsfp_names.watchedEventsc                 C   s   dgS )N
HUMAN_NAMEr   r"   r   r   r   producedEvents9   s    zsfp_names.producedEventsc                 C   s  |j }|j}|j}| jd| d |  |dkrj|j}|d k	rj| jd rjd|ksZd|krj| jd d S |dkr4| jd	 r4d
|dd kr4t|t	krd
tt	j|dd d
}n*d
tt	j|dd d
}t	|}td|rd S td|| j|}|jr |j|_nd|_| | d S td}t||}	|	D ]}
d}d}|
d  }|t|d  dksN|t|d  dkrqN|
d dd}|d}|
d  dd}|d}|| jkr|| jkr| jd| d | d  |d7 }d}n| j|d | d  || jkr>|d7 }t|dksZt|dkrb|d8 }|s|| jkr|| jkr|d 8 }|| jkr|| jkr|d!8 }|
d d | }| jd"| d# t	|  || jd$ krNtd|| j|}|jr|j|_nd|_| | qNd S )%NzReceived event, z, from r   r	   z.jsz.cssz!Ignoring web content from CSS/JS.r   r   .@r    z[0-9]*r$   Unknownux   ([A-Z][a-z�������������]+)\s+.?.?\s?([A-Z][�������������a-zA-Z'\-]+)F   '   z's zPBoth first and second names are not in the dictionary, so high chance of name: (:z).r   Tz was found or z was found in dictionary.2      (   zName of z has score: r   )	eventTypemoduledatar
   debugactualSourcer   splittypestrjoinmap
capitalizerematchr   __name__moduleDataSourcenotifyListenerscompilefindalllowerlenreplacerstripr   r   )r   event	eventNamesrcModuleName	eventDataurlnameevtrxmrpZ	notindictfirstZ
secondOrigsecondr   r   r   handleEvent=   st    $"



,


zsfp_names.handleEvent)r?   
__module____qualname____doc__r   optdescsr   r   r   dictr   r#   r%   rU   r   r   r   r   r      s    r   )r=   sflibr   r   r   r   r   r   r   r   <module>   s   