Filter by domain name

This commit is contained in:
Grégory Soutadé 2014-12-17 21:06:48 +01:00
parent 14c1686d98
commit 50fb09104e

View File

@ -124,6 +124,7 @@ class IWLA(object):
self.http_request_extracted = re.compile(r'(?P<http_method>\S+) (?P<http_uri>\S+) (?P<http_version>\S+)') self.http_request_extracted = re.compile(r'(?P<http_method>\S+) (?P<http_uri>\S+) (?P<http_version>\S+)')
self.log_re = re.compile(self.log_format_extracted) self.log_re = re.compile(self.log_format_extracted)
self.uri_re = re.compile(r'(?P<extract_uri>[^\?]+)(\?(?P<extract_parameters>.+))?') self.uri_re = re.compile(r'(?P<extract_uri>[^\?]+)(\?(?P<extract_parameters>.+))?')
self.domain_name_re = re.compile(r'.*%s' % conf.domain_name)
self.plugins = [(conf.PRE_HOOK_DIRECTORY , conf.pre_analysis_hooks), self.plugins = [(conf.PRE_HOOK_DIRECTORY , conf.pre_analysis_hooks),
(conf.POST_HOOK_DIRECTORY , conf.post_analysis_hooks), (conf.POST_HOOK_DIRECTORY , conf.post_analysis_hooks),
(conf.DISPLAY_HOOK_DIRECTORY , conf.display_hooks)] (conf.DISPLAY_HOOK_DIRECTORY , conf.display_hooks)]
@ -582,6 +583,9 @@ class IWLA(object):
self.current_analysis['days_stats'][cur_time.tm_mday] = stats self.current_analysis['days_stats'][cur_time.tm_mday] = stats
def _newHit(self, hit): def _newHit(self, hit):
if not self.domain_name_re.match(hit['server_name']):
return False
t = self._decodeTime(hit) t = self._decodeTime(hit)
cur_time = self.meta_infos['last_time'] cur_time = self.meta_infos['last_time']
@ -609,7 +613,7 @@ class IWLA(object):
for k in hit.keys(): for k in hit.keys():
if hit[k] == '-' or hit[k] == '*': if hit[k] == '-' or hit[k] == '*':
hit[k] = '' hit[k] = ''
self._appendHit(hit) self._appendHit(hit)
return True return True
@ -637,8 +641,7 @@ class IWLA(object):
groups = self.log_re.match(l) groups = self.log_re.match(l)
if groups: if groups:
if not self._newHit(groups.groupdict()): self._newHit(groups.groupdict())
continue
else: else:
self.logger.warning("No match for %s" % (l)) self.logger.warning("No match for %s" % (l))
#break #break