Add hasBeenViewed() function

This commit is contained in:
Grégory Soutadé 2014-11-27 13:07:14 +01:00
parent e0d6b5dbbc
commit 5ccc63c7ae
3 changed files with 9 additions and 4 deletions

View File

@ -79,6 +79,9 @@ class IWLA(object):
cur_time = self.meta_infos['start_analysis_time'] cur_time = self.meta_infos['start_analysis_time']
return (time.mktime(cur_time) <= time.mktime(request['time_decoded'])) return (time.mktime(cur_time) <= time.mktime(request['time_decoded']))
def hasBeenViewed(self, request):
return int(request['status']) in conf.viewed_http_codes
def _clearMeta(self): def _clearMeta(self):
self.meta_infos = { self.meta_infos = {
'last_time' : None 'last_time' : None

View File

@ -21,9 +21,11 @@ class IWLAPostAnalysisTopDownloads(IPlugin):
for (k, super_hit) in stats.items(): for (k, super_hit) in stats.items():
if super_hit['robot']: continue if super_hit['robot']: continue
for r in super_hit['requests']: for r in super_hit['requests']:
if not self.iwla.isValidForCurrentAnalysis(r) or\
not self.iwla.hasBeenViewed(r):
continue
if r['is_page']: continue if r['is_page']: continue
if not self.iwla.isValidForCurrentAnalysis(r): continue
if not int(r['status']) in viewed_http_codes: continue if not int(r['status']) in viewed_http_codes: continue

View File

@ -10,7 +10,6 @@ class IWLAPreAnalysisPageToHit(IPlugin):
def __init__(self, iwla): def __init__(self, iwla):
super(IWLAPreAnalysisPageToHit, self).__init__(iwla) super(IWLAPreAnalysisPageToHit, self).__init__(iwla)
self.API_VERSION = 1 self.API_VERSION = 1
self.conf_requires = ['viewed_http_codes']
def load(self): def load(self):
# Remove logo from indefero # Remove logo from indefero
@ -22,14 +21,15 @@ class IWLAPreAnalysisPageToHit(IPlugin):
def hook(self): def hook(self):
hits = self.iwla.getCurrentVisists() hits = self.iwla.getCurrentVisists()
viewed_http_codes = self.iwla.getConfValue('viewed_http_codes')
for (k, super_hit) in hits.items(): for (k, super_hit) in hits.items():
if super_hit['robot']: continue if super_hit['robot']: continue
for request in super_hit['requests']: for request in super_hit['requests']:
if not self.iwla.isValidForCurrentAnalysis(request) or\
not self.iwla.hasBeenViewed(request):
continue
if not request['is_page']: continue if not request['is_page']: continue
if not self.iwla.isValidForCurrentAnalysis(request): continue
uri = request['extract_request']['extract_uri'] uri = request['extract_request']['extract_uri']
for regexp in self.regexps: for regexp in self.regexps:
if regexp.match(uri): if regexp.match(uri):