Skip to content

Commit

Permalink
refactoring Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
isayan committed Mar 14, 2021
1 parent f5a73e4 commit cc6b5e2
Show file tree
Hide file tree
Showing 42 changed files with 527 additions and 548 deletions.
Binary file modified libs/BurpExtensionCommons-v0.4.4.0.jar
Binary file not shown.
Binary file modified release/YaguraExtender-v2.2.jar
Binary file not shown.
35 changes: 17 additions & 18 deletions src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public BurpExtender() {
prop.store(bout, "");
LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(bout.toByteArray()));
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
JsonUtil.registerTypeHierarchyAdapter(MatchItem.class, new XMatchItemAdapter());
}
Expand Down Expand Up @@ -197,8 +197,8 @@ public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {
callbacks.setExtensionName(String.format("%s v%s", BUNDLE.getString("projname"), BUNDLE.getString("version")));
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
logger.log(Level.SEVERE, null, e);
public void uncaughtException(Thread t, Throwable ex) {
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
});

Expand All @@ -208,9 +208,9 @@ public void uncaughtException(Thread t, Throwable e) {
Config.loadFromJson(CONFIG_FILE, this.option);
}
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
} catch (RuntimeException ex) {
logger.log(Level.WARNING, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}

try {
Expand All @@ -219,7 +219,7 @@ public void uncaughtException(Thread t, Throwable e) {
this.setLogDir(mkLogDir(this.option.getLoggingProperty().getBaseDir(), this.option.getLoggingProperty().getLogDirFormat()));
}
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}

callbacks.registerHttpListener(this);
Expand Down Expand Up @@ -379,9 +379,9 @@ protected synchronized void writeProxyMessage(
}
} catch (IOException ex) {
getCallbacks().issueAlert(ex.getMessage());
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}
// ログを出力したら消す
Expand Down Expand Up @@ -445,9 +445,9 @@ protected synchronized void writeToolMessage(
}
}
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}

Expand Down Expand Up @@ -579,7 +579,7 @@ private void matchAlertMessage(String toolName, boolean messageIsRequest, IHttpR
}
}
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}
}
Expand Down Expand Up @@ -733,9 +733,9 @@ protected void applyOptionProperty() {
try {
Config.saveToJson(CONFIG_FILE, this.option);
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}

Expand Down Expand Up @@ -785,7 +785,7 @@ public void sendToMessageInfoCopy(IContextMenuInvocation contextMenu, IHttpReque
buff.append("\r\n");
}
} catch (ParseException ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
SwingUtil.systemClipboardCopy(buff.toString());
}
Expand Down Expand Up @@ -854,7 +854,7 @@ public void sendToAddHostIncludeToScope(IContextMenuInvocation contextMenu, IHtt
BurpExtender.getCallbacks().includeInScope(new URL(HttpUtil.toURL(url.getProtocol(), url.getHost(), url.getPort())));
}
} catch (MalformedURLException ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}

Expand All @@ -872,14 +872,13 @@ public void sendToAddHostToExcludeScope(IContextMenuInvocation contextMenu, IHtt
BurpExtender.getCallbacks().excludeFromScope(new URL(HttpUtil.toURL(url.getProtocol(), url.getHost(), url.getPort())));
}
} catch (MalformedURLException ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}

public void sendToAddToExcludeScope(IContextMenuInvocation contextMenu, IHttpRequestResponse[] messageInfoList) {
for (IHttpRequestResponse messageInfo : messageInfoList) {
IRequestInfo reqInfo = BurpExtender.getHelpers().analyzeRequest(messageInfo);
BurpExtender.getCallbacks().excludeFromScope(reqInfo.getUrl());
BurpExtender.getCallbacks().excludeFromScope(BurpExtender.getHelpers().getURL(messageInfo));
}
}

Expand Down
Loading

0 comments on commit cc6b5e2

Please sign in to comment.