use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class NodeSelectDialog method showDialog.
public Target showDialog(Target defaultTarget) {
// Assume Contexts can be selected
this.getTreeContext().setVisible(true);
SiteNode siteRoot = (SiteNode) Model.getSingleton().getSession().getSiteTree().getRoot();
populateContexts((SiteNode) this.contextTree.getRoot());
if (defaultTarget != null) {
populateNode(siteRoot, (SiteNode) this.siteTree.getRoot(), defaultTarget.getStartNode());
} else {
populateNode(siteRoot, (SiteNode) this.siteTree.getRoot(), null);
}
if (selectedSiteNode != null) {
// Found the default node, select it
TreePath path = new TreePath(this.siteTree.getPathToRoot(selectedSiteNode));
this.getTreeSite().setExpandsSelectedPaths(true);
this.getTreeSite().setSelectionPath(path);
this.getTreeSite().scrollPathToVisible(path);
this.getTreeSite().expandPath(path);
} else {
// no default path, just expand the top level
TreePath path = new TreePath(this.siteTree.getPathToRoot((TreeNode) this.siteTree.getRoot()));
this.getTreeSite().expandPath(path);
}
this.setVisible(true);
// The dialog is modal so this wont return until the dialog visibility is unset
if (selectedSiteNode != null) {
return new Target(selectedSiteNode);
}
return selectedTarget;
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class SiteMapTreeCellRenderer method getTreeCellRendererComponent.
/**
* Sets custom tree node logos.
*/
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
component.removeAll();
SiteNode node = null;
if (value instanceof SiteNode) {
node = (SiteNode) value;
}
if (node != null) {
if (node.isFiltered()) {
// Hide the node
setPreferredSize(new Dimension(0, 0));
} else {
// clears the prefered size, making the node visible
setPreferredSize(null);
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
}
// folder / file icons with scope 'target' if relevant
if (node.isRoot()) {
// 'World' icon
component.add(wrap(ROOT_ICON));
} else {
OverlayIcon icon;
if (node.isDataDriven()) {
if (node.isIncludedInScope() && !node.isExcludedFromScope()) {
icon = new OverlayIcon(DATA_DRIVEN_IN_SCOPE_ICON);
} else {
icon = new OverlayIcon(DATA_DRIVEN_ICON);
}
} else if (leaf) {
if (node.isIncludedInScope() && !node.isExcludedFromScope()) {
icon = new OverlayIcon(LEAF_IN_SCOPE_ICON);
} else {
icon = new OverlayIcon(LEAF_ICON);
}
} else {
if (expanded) {
if (node.isIncludedInScope() && !node.isExcludedFromScope()) {
icon = new OverlayIcon(FOLDER_OPEN_IN_SCOPE_ICON);
} else {
icon = new OverlayIcon(FOLDER_OPEN_ICON);
}
} else {
if (node.isIncludedInScope() && !node.isExcludedFromScope()) {
icon = new OverlayIcon(FOLDER_CLOSED_IN_SCOPE_ICON);
} else {
icon = new OverlayIcon(FOLDER_CLOSED_ICON);
}
}
}
if (node.getParent().isRoot() && node.getNodeName().startsWith("https://")) {
// Add lock icon to site nodes with https
icon.add(LOCK_OVERLAY_ICON);
}
component.add(wrap(DisplayUtils.getScaledIcon(icon)));
Alert alert = node.getHighestAlert();
if (alert != null) {
component.add(wrap(alert.getIcon()));
}
for (ImageIcon ci : node.getCustomIcons()) {
component.add(wrap(DisplayUtils.getScaledIcon(ci)));
}
}
if (sel) {
component.add(wrap(node.toString(), Color.WHITE));
} else {
component.add(wrap(node.toString()));
}
for (SiteMapListener listener : listeners) {
listener.onReturnNodeRendererComponent(this, leaf, node);
}
return component;
}
return this;
}
use of org.parosproxy.paros.model.SiteNode 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.SiteNode in project zaproxy by zaproxy.
the class ExtensionHistory method purge.
public void purge(SiteMap map, SiteNode node) {
SiteNode child = null;
synchronized (map) {
while (node.getChildCount() > 0) {
try {
child = (SiteNode) node.getChildAt(0);
purge(map, child);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
if (node.isRoot()) {
return;
}
// delete reference in node
removeFromHistoryList(node.getHistoryReference());
ExtensionAlert extAlert = Control.getSingleton().getExtensionLoader().getExtension(ExtensionAlert.class);
if (node.getHistoryReference() != null) {
deleteAlertsFromExtensionAlert(extAlert, node.getHistoryReference());
node.getHistoryReference().delete();
map.removeHistoryReference(node.getHistoryReference().getHistoryId());
}
// delete past reference in node
while (node.getPastHistoryReference().size() > 0) {
HistoryReference ref = node.getPastHistoryReference().get(0);
deleteAlertsFromExtensionAlert(extAlert, ref);
removeFromHistoryList(ref);
delete(ref);
node.getPastHistoryReference().remove(0);
map.removeHistoryReference(ref.getHistoryId());
}
map.removeNodeFromParent(node);
}
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class PopupMenuHistoryReference method getSelectedHistoryReference.
private HistoryReference getSelectedHistoryReference() {
HistoryReference ref = null;
try {
switch(lastInvoker) {
case sites:
SiteNode sNode = (SiteNode) treeInvoker.getLastSelectedPathComponent();
ref = sNode.getHistoryReference();
break;
case ascan:
case history:
case bruteforce:
case search:
case fuzz:
ref = hrefsTableInvoker.getSelectedHistoryReference();
break;
case alerts:
AlertNode aNode = (AlertNode) treeInvoker.getLastSelectedPathComponent();
if (aNode.getUserObject() != null) {
Alert alert = aNode.getUserObject();
ref = alert.getHistoryRef();
}
break;
case hreftable:
ref = hrefTableInvoker.getSelectedHistoryReference();
break;
}
} catch (Exception e2) {
log.error(e2.getMessage(), e2);
}
return ref;
}
Aggregations