use of org.parosproxy.paros.extension.history.ExtensionHistory in project zaproxy by zaproxy.
the class ExtensionAntiCSRF method hook.
@Override
public void hook(ExtensionHook extensionHook) {
super.hook(extensionHook);
final ExtensionHistory extensionHistory = (ExtensionHistory) Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.NAME);
if (extensionHistory != null) {
historyReferenceFactory = new HistoryReferenceFactory() {
@Override
public HistoryReference createHistoryReference(int id) {
return extensionHistory.getHistoryReference(id);
}
};
} else {
historyReferenceFactory = new HistoryReferenceFactory() {
@Override
public HistoryReference createHistoryReference(int id) throws HttpMalformedHeaderException, DatabaseException {
return new HistoryReference(id);
}
};
}
AntiCsrfToken.setHistoryReferenceFactory(historyReferenceFactory);
extensionHook.addSessionListener(this);
if (getView() != null) {
extensionHook.getHookView().addOptionPanel(getOptionsAntiCsrfPanel());
extensionHook.getHookMenu().addPopupMenuItem(this.getPopupMenuGenerateForm());
}
ExtensionPassiveScan extensionPassiveScan = (ExtensionPassiveScan) Control.getSingleton().getExtensionLoader().getExtension(ExtensionPassiveScan.NAME);
if (extensionPassiveScan != null) {
extensionPassiveScan.addPassiveScanner(antiCsrfDetectScanner);
}
AntiCsrfAPI api = new AntiCsrfAPI(this);
api.addApiOptions(getParam());
extensionHook.addApiImplementor(api);
}
use of org.parosproxy.paros.extension.history.ExtensionHistory in project zaproxy by zaproxy.
the class ExtensionAlert method refreshAlert.
private void refreshAlert(Session session) throws DatabaseException {
if (Constant.isLowMemoryOptionSet()) {
return;
}
SiteMap siteTree = this.getModel().getSession().getSiteTree();
TableAlert tableAlert = getModel().getDb().getTableAlert();
// TODO this doesnt work, but should be used when its fixed :/
//Vector<Integer> v = tableAlert.getAlertListBySession(Model.getSingleton().getSession().getSessionId());
Vector<Integer> v = tableAlert.getAlertList();
final ExtensionHistory extensionHistory = (ExtensionHistory) Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.NAME);
for (int i = 0; i < v.size(); i++) {
int alertId = v.get(i).intValue();
RecordAlert recAlert = tableAlert.read(alertId);
int historyId = recAlert.getHistoryId();
HistoryReference historyReference = null;
if (extensionHistory != null) {
historyReference = extensionHistory.getHistoryReference(historyId);
}
if (historyReference == null) {
historyReference = this.hrefs.get(Integer.valueOf(historyId));
}
Alert alert;
if (historyReference != null) {
alert = new Alert(recAlert, historyReference);
} else {
alert = new Alert(recAlert);
}
historyReference = alert.getHistoryRef();
if (historyReference != null) {
// The ref can be null if hrefs are purged
addAlertToTree(alert);
Integer key = Integer.valueOf(historyId);
if (!hrefs.containsKey(key)) {
this.hrefs.put(key, alert.getHistoryRef());
}
}
}
siteTree.nodeStructureChanged((SiteNode) siteTree.getRoot());
}
use of org.parosproxy.paros.extension.history.ExtensionHistory in project zaproxy by zaproxy.
the class AuthenticationHelper method addAuthMessageToHistory.
public static void addAuthMessageToHistory(HttpMessage msg) {
// Add message to history
try {
final HistoryReference ref = new HistoryReference(Model.getSingleton().getSession(), HistoryReference.TYPE_AUTHENTICATION, msg);
ref.addTag(HISTORY_TAG_AUTHENTICATION);
if (View.isInitialised()) {
final ExtensionHistory extHistory = Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.class);
if (extHistory != null) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
extHistory.addHistory(ref);
}
});
}
}
} catch (Exception ex) {
log.error("Cannot add authentication message to History tab.", ex);
}
}
Aggregations