bugfix: fix issue with reporting for previous scan results when theHarvester runs the first time/day

This commit is contained in:
Janos Zold 2018-12-19 10:15:46 +00:00
parent a24aa3e862
commit 18ff3cb05d
2 changed files with 40 additions and 35 deletions

View file

@ -135,11 +135,7 @@ def generatepluginscanstatistics(self, scanstatistics):
<tr>
'''
for i in scanstatistics:
html += '<td style="width: 156.042px;">' + str(i[0]) + "</td>"
html += '<td style="width: 156.042px;">' + str(i[1]) + "</td>"
html += '<td style="width: 157.153px;">' + str(i[2]) + "</td>"
html += '<td style="width: 157.153px;">' + str(i[3]) + "</td>"
html += '<td style="width: 157.153px;">' + str(i[4]) + "</td>"
html += '<td style="width: 156.042px;">' + str(i) + "</td>"
html +='</tr>'
html +='''
</tbody>

View file

@ -104,38 +104,47 @@ def getlatestscanresults(self,domain,previousday=False):
try:
conn = sqlite3.connect(self.db)
if previousday:
c = conn.cursor()
c.execute('''
SELECT DISTINCT(find_date)
FROM results
WHERE find_date=date('now', '-1 day') and domain=?''',(domain,))
previousscandate = c.fetchone()
c = conn.cursor()
c.execute('''
SELECT find_date, domain, source,type,resource
FROM results
WHERE find_date=? and domain=?
ORDER BY source,type
''',(previousscandate[0],domain,))
results = c.fetchall()
self.previousscanresults = results
return self.previousscanresults
try:
c = conn.cursor()
c.execute('''
SELECT DISTINCT(find_date)
FROM results
WHERE find_date=date('now', '-1 day') and domain=?''',(domain,))
previousscandate = c.fetchone()
if not previousscandate: #when theHarvester runs first time/day this query will return
self.previousscanresults = ["No results","No results","No results","No results","No results"]
else:
c = conn.cursor()
c.execute('''
SELECT find_date, domain, source,type,resource
FROM results
WHERE find_date=? and domain=?
ORDER BY source,type
''',(previousscandate[0],domain,))
results = c.fetchall()
self.previousscanresults = results
return self.previousscanresults
except Exception as e:
print("Error in getting the previous scan results from the database: " + str(e))
else:
c = conn.cursor()
c.execute('''SELECT MAX(find_date) FROM results WHERE domain=?''',(domain,))
latestscandate = c.fetchone()
c = conn.cursor()
c.execute('''
SELECT find_date, domain, source,type,resource
FROM results
WHERE find_date=? and domain=?
ORDER BY source,type
''',(latestscandate[0],domain,))
results = c.fetchall()
self.latestscanresults = results
return self.latestscanresults
try:
c = conn.cursor()
c.execute('''SELECT MAX(find_date) FROM results WHERE domain=?''',(domain,))
latestscandate = c.fetchone()
c = conn.cursor()
c.execute('''
SELECT find_date, domain, source,type,resource
FROM results
WHERE find_date=? and domain=?
ORDER BY source,type
''',(latestscandate[0],domain,))
results = c.fetchall()
self.latestscanresults = results
return self.latestscanresults
except Exception as e:
print("Error in getting the latest scan results from the database: " + str(e))
except Exception as e:
print("Error in getting the latest scan results from the database: " + str(e))
print("Error connecting to theHarvester database: " + str(e))
finally:
conn.close()