use of org.parosproxy.paros.model.SiteMap in project zaproxy by zaproxy.
the class PopupExcludeFromProxyMenu method performAction.
@Override
public void performAction(SiteNode sn) {
try {
Session session = Model.getSingleton().getSession();
session.getExcludeFromProxyRegexs().add(new StructuralSiteNode(sn).getRegexPattern());
SiteMap map = (SiteMap) View.getSingleton().getSiteTreePanel().getTreeSite().getModel();
ExtensionHistory extHistory = Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.class);
if (extHistory != null) {
extHistory.purge(map, sn);
}
} catch (DatabaseException e) {
// Ignore
}
}
use of org.parosproxy.paros.model.SiteMap in project zaproxy by zaproxy.
the class Context method checkNode.
private boolean checkNode(SiteNode sn) {
// Loop backwards through the children TODO change for lowmem!
// log.debug("checkNode " + sn.getHierarchicNodeName()); // Useful for debugging
int origChildren = sn.getChildCount();
int movedChildren = 0;
for (SiteNode childNode : getChildren(sn)) {
if (checkNode(childNode)) {
movedChildren++;
}
}
if (this.isInContext(sn)) {
SiteMap sitesTree = this.session.getSiteTree();
HistoryReference href = sn.getHistoryReference();
try {
SiteNode sn2;
if (HttpRequestHeader.POST.equals(href.getMethod())) {
// Have to go to the db as POST data can be used in the name
sn2 = sitesTree.findNode(href.getHttpMessage());
} else {
// This is better as it doesnt require a db read
sn2 = sitesTree.findNode(href.getURI());
}
if (sn2 == null || !sn.getHierarchicNodeName().equals(sn2.getHierarchicNodeName())) {
if (!sn.isDataDriven()) {
moveNode(sitesTree, sn);
return true;
}
}
if (movedChildren > 0 && movedChildren == origChildren && sn.getChildCount() == 0) {
if (href.getHistoryType() == HistoryReference.TYPE_TEMPORARY) {
// Remove temp old node, no need to add new one in -
// that will happen when moving child nodes (if required)
deleteNode(sitesTree, sn);
return true;
}
}
// log.debug("Didnt need to move " + sn.getHierarchicNodeName()); // Useful for debugging
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
return false;
}
use of org.parosproxy.paros.model.SiteMap in project zaproxy by zaproxy.
the class ScanPanel method getSiteNode.
protected SiteNode getSiteNode(String siteName) {
SiteMap siteTree = this.getExtension().getModel().getSession().getSiteTree();
SiteNode rootNode = (SiteNode) siteTree.getRoot();
@SuppressWarnings("unchecked") Enumeration<SiteNode> en = rootNode.children();
while (en.hasMoreElements()) {
SiteNode sn = en.nextElement();
String nodeName = sn.getNodeName();
if (nodeName.toLowerCase().startsWith("https:") && !hasPort(nodeName)) {
nodeName += ":443";
}
if (nodeName.toLowerCase().startsWith("http:") && !hasPort(nodeName)) {
nodeName += ":80";
}
if (nodeName.indexOf("//") >= 0) {
nodeName = nodeName.substring(nodeName.indexOf("//") + 2);
}
if (siteName.equals(nodeName)) {
return sn;
}
}
return null;
}
use of org.parosproxy.paros.model.SiteMap 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.model.SiteMap in project zaproxy by zaproxy.
the class PopupMenuPurgeHistory method purgeHistory.
private void purgeHistory(HistoryReference ref) {
if (ref == null) {
return;
}
extension.removeFromHistoryList(ref);
ExtensionAlert extAlert = (ExtensionAlert) Control.getSingleton().getExtensionLoader().getExtension(ExtensionAlert.NAME);
if (extAlert != null) {
extAlert.deleteHistoryReferenceAlerts(ref);
}
extension.delete(ref);
SiteNode node = ref.getSiteNode();
if (node == null) {
return;
}
SiteMap map = Model.getSingleton().getSession().getSiteTree();
if (node.getHistoryReference() == ref) {
// same active Node
extension.purge(map, node);
} else {
node.getPastHistoryReference().remove(ref);
map.removeHistoryReference(ref.getHistoryId());
}
}
Aggregations