use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class SpiderThread method addSeeds.
/**
* Adds the initial seeds, with following constraints:
* <ul>
* <li>If a {@link #scanContext context} is provided:
* <ul>
* <li>{@link #startURI Start URI}, if in context;</li>
* <li>{@link #startNode Start node}, if in context;</li>
* <li>All nodes in the context;</li>
* </ul>
* </li>
* <li>If spidering just in {@link #justScanInScope scope}:
* <ul>
* <li>Start URI, if in scope;</li>
* <li>Start node, if in scope;</li>
* <li>All nodes in scope;</li>
* </ul>
* </li>
* <li>If there's no context/scope restriction:
* <ul>
* <li>Start URI;</li>
* <li>Start node, also:
* <ul>
* <li>Child nodes, if {@link #scanChildren spidering "recursively"}.</li>
* </ul>
* </ul>
* </li>
* </ul>
*
* @see #addStartSeeds()
*/
private void addSeeds() {
addStartSeeds();
List<SiteNode> nodesInScope = Collections.emptyList();
if (this.scanContext != null) {
log.debug("Adding seed for Scan of all in context " + scanContext.getName());
nodesInScope = this.scanContext.getNodesInContextFromSiteTree();
} else if (justScanInScope) {
log.debug("Adding seed for Scan of all in scope.");
nodesInScope = Model.getSingleton().getSession().getNodesInScopeFromSiteTree();
}
if (!nodesInScope.isEmpty()) {
for (SiteNode node : nodesInScope) {
addSeed(node);
}
}
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class PopupMenuItemContextDataDrivenNode method performAction.
@Override
public void performAction(SiteNode sn) {
Session session = Model.getSingleton().getSession();
SessionDialog sessionDialog = View.getSingleton().getSessionDialog();
sessionDialog.recreateUISharedContexts(session);
Context uiSharedContext = sessionDialog.getUISharedContext(context.getIndex());
// We want to form a regex expression like:
// https://www.example.com/(aa/bb/cc/)(.+?)(/.*)
StringBuilder sb = new StringBuilder();
SiteNode parent = sn.getParent();
while (!parent.getParent().isRoot()) {
sb.insert(0, "/");
if (parent.isDataDriven()) {
// Dont want these in their own regex group
sb.insert(0, ".+?");
} else {
sb.insert(0, parent.getCleanNodeName());
}
parent = parent.getParent();
}
sb.insert(0, "/(");
sb.insert(0, parent.getCleanNodeName());
sb.append(")(.+?)(/.*)");
Pattern p = Pattern.compile(sb.toString());
uiSharedContext.addDataDrivenNodes(new StructuralNodeModifier(StructuralNodeModifier.Type.DataDrivenNode, p, uiSharedContext.getDefaultDDNName()));
// Show the session dialog without recreating UI Shared contexts
View.getSingleton().showSessionDialog(session, ContextStructurePanel.getPanelName(context.getIndex()), false);
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class Context method moveNode.
private void moveNode(SiteMap sitesTree, SiteNode sn) {
List<Alert> alerts = sn.getAlerts();
// And delete the old one
deleteNode(sitesTree, sn);
// Add into the right place
SiteNode sn2 = sitesTree.addPath(sn.getHistoryReference());
log.debug("Moved node " + sn.getHierarchicNodeName() + " to " + sn2.getHierarchicNodeName());
// And sort out the alerts
for (Alert alert : alerts) {
sn2.addAlert(alert);
}
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class MaxChildrenFetchFilter method checkFilter.
@Override
public FetchStatus checkFilter(URI uri) {
log.debug("Checking: " + uri);
SiteNode parent = model.getSession().getSiteTree().findClosestParent(uri);
if (parent != null) {
if (maxChildren > 0 && parent.getChildCount() > maxChildren) {
return FetchStatus.USER_RULES;
}
}
return FetchStatus.VALID;
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class ExtensionParams method sessionChangedEventHandler.
private void sessionChangedEventHandler(Session session) {
// Clear all scans
siteParamsMap = new HashMap<>();
if (getView() != null) {
this.getParamsPanel().reset();
}
if (session == null) {
// Closedown
return;
}
// Repopulate
SiteNode root = (SiteNode) session.getSiteTree().getRoot();
@SuppressWarnings("unchecked") Enumeration<SiteNode> en = root.children();
while (en.hasMoreElements()) {
String site = en.nextElement().getNodeName();
if (site.indexOf("//") >= 0) {
site = site.substring(site.indexOf("//") + 2);
}
if (getView() != null) {
this.getParamsPanel().addSite(site);
}
}
try {
List<RecordParam> params = Model.getSingleton().getDb().getTableParam().getAll();
for (RecordParam param : params) {
SiteParameters sps = this.getSiteParameters(param.getSite());
sps.addParam(param.getSite(), param);
}
} catch (DatabaseException e) {
logger.error(e.getMessage(), e);
}
}
Aggregations