ElasticBurp: open/create index depending on existence

Fixes appearance of error message when new index is created or on
initialization when index already exists.
This commit is contained in:
Thomas Patzke 2017-02-08 21:29:43 +01:00
parent d764a5ef0a
commit 2c2ba15326
2 changed files with 7 additions and 8 deletions

View file

@ -57,13 +57,12 @@ class BurpExtender(IBurpExtender, IHttpListener, IContextMenuFactory, ITab):
try:
print("Connecting to '%s', index '%s'" % (self.confESHost, self.confESIndex))
res = connections.create_connection(hosts=[self.confESHost])
idx = Index(self.confESIndex)
idx.doc_type(DocHTTPRequestResponse)
DocHTTPRequestResponse.init()
try:
idx.create()
except:
pass
self.idx = Index(self.confESIndex)
self.idx.doc_type(DocHTTPRequestResponse)
if self.idx.exists():
self.idx.open()
else:
self.idx.create()
except Exception as e:
JOptionPane.showMessageDialog(self.panel, "<html><p style='width: 300px'>Error while initializing ElasticSearch: %s</p></html>" % (str(e)), "Error", JOptionPane.ERROR_MESSAGE)
@ -72,6 +71,7 @@ class BurpExtender(IBurpExtender, IHttpListener, IContextMenuFactory, ITab):
return "ElasticBurp"
def applyConfigUI(self, event):
#self.idx.close()
self.confESHost = self.uiESHost.getText()
self.confESIndex = self.uiESIndex.getText()
self.confBurpTools = (self.uiCBSuite.isSelected() and IBurpExtenderCallbacks.TOOL_SUITE) | (self.uiCBTarget.isSelected() and IBurpExtenderCallbacks.TOOL_TARGET) | (self.uiCBProxy.isSelected() and IBurpExtenderCallbacks.TOOL_PROXY) | (self.uiCBSpider.isSelected() and IBurpExtenderCallbacks.TOOL_SPIDER) | (self.uiCBScanner.isSelected() and IBurpExtenderCallbacks.TOOL_SCANNER) | (self.uiCBIntruder.isSelected() and IBurpExtenderCallbacks.TOOL_INTRUDER) | (self.uiCBRepeater.isSelected() and IBurpExtenderCallbacks.TOOL_REPEATER) | (self.uiCBSequencer.isSelected() and IBurpExtenderCallbacks.TOOL_SEQUENCER) | (self.uiCBExtender.isSelected() and IBurpExtenderCallbacks.TOOL_EXTENDER)

View file

@ -40,7 +40,6 @@ identifierAnalyzer = analyzer("identifier",
class DocHTTPRequestResponse(DocType):
class Meta:
#index = "wase"
doc_type = 'HTTPRequestResponse'
timestamp = Date()