Search in sources :

Example 16 with SiteNode

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);
        }
    }
}
Also used : SiteNode(org.parosproxy.paros.model.SiteNode)

Example 17 with SiteNode

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);
}
Also used : Context(org.zaproxy.zap.model.Context) Pattern(java.util.regex.Pattern) StructuralNodeModifier(org.zaproxy.zap.model.StructuralNodeModifier) SessionDialog(org.parosproxy.paros.view.SessionDialog) Session(org.parosproxy.paros.model.Session) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 18 with SiteNode

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);
    }
}
Also used : Alert(org.parosproxy.paros.core.scanner.Alert) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 19 with SiteNode

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;
}
Also used : SiteNode(org.parosproxy.paros.model.SiteNode)

Example 20 with SiteNode

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);
    }
}
Also used : RecordParam(org.parosproxy.paros.db.RecordParam) DatabaseException(org.parosproxy.paros.db.DatabaseException) SiteNode(org.parosproxy.paros.model.SiteNode)

Aggregations

SiteNode (org.parosproxy.paros.model.SiteNode)53 DatabaseException (org.parosproxy.paros.db.DatabaseException)10 HistoryReference (org.parosproxy.paros.model.HistoryReference)10 JTree (javax.swing.JTree)9 Target (org.zaproxy.zap.model.Target)8 SiteMap (org.parosproxy.paros.model.SiteMap)7 ArrayList (java.util.ArrayList)6 TreePath (javax.swing.tree.TreePath)6 Alert (org.parosproxy.paros.core.scanner.Alert)6 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)4 Context (org.zaproxy.zap.model.Context)4 StructuralSiteNode (org.zaproxy.zap.model.StructuralSiteNode)4 IOException (java.io.IOException)3 InvalidParameterException (java.security.InvalidParameterException)3 List (java.util.List)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3 ImageIcon (javax.swing.ImageIcon)3 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)3 URIException (org.apache.commons.httpclient.URIException)3 Session (org.parosproxy.paros.model.Session)3