Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

Scan deletion.

smicallef85fe8e13933d
diff --git a/dyn/scandelete.tmpl b/dyn/scandelete.tmpl
new file mode 100644
index 00000000..0e418c7e
--- /dev/null
+++ b/dyn/scandelete.tmpl
@@ -0,0 +1,8 @@
+<%include file="HEADER.tmpl"/>
+<div class="alert alert-warning">
+<h4>Confirm Deletion</h4>
+<br><br>
+Please confirm you wish to delete the scan '${name}'<br><br>
+<a class='btn btn-danger' href='/scandelete?id=${id}&confirm=1'>Confirm Deletion</a>
+</div>
+<%include file="FOOTER.tmpl"/>
diff --git a/dyn/scanlist.tmpl b/dyn/scanlist.tmpl
index 849fa77d..49b0d223 100644
--- a/dyn/scanlist.tmpl
+++ b/dyn/scanlist.tmpl
@@ -23,20 +23,36 @@ Loading...
<script type='text/javascript'>
sf.fetchData('/scanlist', null, function(data) {
var table = "<table class='table table-bordered table-striped'>";
- table += "<thead><tr> <th>Name</th> <th>Target</th> <th>Started</th> <th>Finished</th> <th>Status</th> <th>Events</th> </tr></thead><tbody>";
+ table += "<thead><tr> <th>Name</th> <th>Target</th> <th>Started</th> <th>Finished</th> <th>Status</th> <th>Events</th><th>Action</th> </tr></thead><tbody>";
for (var i = 0; i < data.length; i++) {
table += "<tr><td><a href=/scaninfo?id=" + data[i][0] + ">" + data[i][1] + "</a></td>";
table += "<td>" + data[i][2] + "&nbsp;&nbsp;<a target='_new' href='" + data[i][2] + "'><i class='icon-share icon-gray'></a></td>";
table += "<td>" + data[i][3] + "</td>";
- if (data[i][6] == "RUNNING") {
- table += "<td><a href=/stopscan?id=" + data[i][0] +">Abort</a></td>";
+ table += "<td>" + data[i][5] + "</td>";
+
+ if (data[i][6] == "FINISHED") {
+ status = "badge-success";
+ }
+ if (data[i][6].startsWith("ABORT")) {
+ status = "badge-warning";
+ }
+ if (data[i][6] == "RUNNING" || data[i][6] == "STARTED") {
+ status = "badge-info";
+ }
+ if (data[i][6].endsWith("FAILED")) {
+ status = "badge-important";
+ }
+ table += "<td style='text-align: center'><span class='badge " + status + "'>" + data[i][6] + "</span></td>";
+ table += "<td>" + data[i][7] + "</td>";
+ table += "<td style='text-align: center'>";
+ if (data[i][6] == "RUNNING" || data[i][6] == "STARTING" || data[i][6] == "STARTED") {
+ table += "<a href=/stopscan?id=" + data[i][0] +"><i class='icon-stop icon-gray'></a></td>";
} else {
- table += "<td>" + data[i][5] + "</td>";
+ table += "<a href=/scandelete?id=" + data[i][0] + "><i class='icon-trash icon-gray'></a></td>";
}
- table += "<td>" + data[i][6] + "</td>";
- table += "<td>" + data[i][7] + "</td></tr>";
+ table += "</tr>";
}
- table += "</tbody></table>"
+ table += "</tbody></table>";
$("#loader").fadeOut(250);
$("#mainbody").append(table);
});
diff --git a/sfdb.py b/sfdb.py
index 851a9540..a9c8dfdf 100644
--- a/sfdb.py
+++ b/sfdb.py
@@ -147,9 +147,20 @@ class SpiderFootDb:
sf.error("SQL error encountered when fetching result events: " +
e.args[0])
- # Delete a scan instance - don't need this yet
+ # Delete a scan instance
def scanInstanceDelete(self, instanceId):
- pass
+ qry1 = "DELETE FROM tbl_scan_instance WHERE guid = ?"
+ qry2 = "DELETE FROM tbl_scan_config WHERE scan_instance_id = ?"
+ qry3 = "DELETE FROM tbl_scan_results WHERE scan_instance_id = ?"
+ qvars = [instanceId]
+ try:
+ self.dbh.execute(qry1, qvars)
+ self.dbh.execute(qry2, qvars)
+ self.dbh.execute(qry3, qvars)
+ self.conn.commit()
+ except sqlite3.Error as e:
+ sf.error("SQL error encountered when deleting scan: " +
+ e.args[0])
# Store a configuration value for a scan
# To unset, simply set the optMap key value to None
diff --git a/sfwebui.py b/sfwebui.py
index d13b4ef8..62392b34 100644
--- a/sfwebui.py
+++ b/sfwebui.py
@@ -183,6 +183,21 @@ class SpiderFootWebUi:
templ = Template(filename='dyn/error.tmpl', lookup=self.lookup)
return templ.render(message=message)
+ # Delete a scan
+ def scandelete(self, id, confirm=None):
+ dbh = SpiderFootDb(self.config)
+ res = dbh.scanInstanceGet(id)
+ if res == None:
+ return self.error("Scan ID not found.")
+
+ if confirm != None:
+ dbh.scanInstanceDelete(id)
+ raise cherrypy.HTTPRedirect("/")
+ else:
+ templ = Template(filename='dyn/scandelete.tmpl', lookup=self.lookup)
+ return templ.render(id=id, name=res[0])
+ scandelete.exposed = True
+
#
# DATA PROVIDERS
#