Search in sources :

Example 1 with Session

use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.

the class Control method createNewSession.

/**
	 * Creates a new session and resets session related data in other components (e.g. proxy excluded URLs).
	 *
	 * @return the newly created session.
	 */
private Session createNewSession() {
    Session session = model.newSession();
    getProxy().setIgnoreList(model.getOptionsParam().getGlobalExcludeURLParam().getTokensNames());
    return session;
}
Also used : Session(org.parosproxy.paros.model.Session)

Example 2 with Session

use of org.parosproxy.paros.model.Session 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.getId());
    // 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()) {
            // Don't 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.getId()), 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 3 with Session

use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.

the class PopupMenuItemContextInclude method reCreateSubMenu.

protected void reCreateSubMenu() {
    final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
    for (ExtensionPopupMenuItem menu : subMenus) {
        mainPopupMenuItems.remove(menu);
    }
    subMenus.clear();
    Session session = Model.getSingleton().getSession();
    List<Context> contexts = session.getContexts();
    for (Context context : contexts) {
        ExtensionPopupMenuItem piicm = createPopupIncludeInContextMenu(context);
        piicm.setMenuIndex(this.getMenuIndex());
        mainPopupMenuItems.add(piicm);
        this.subMenus.add(piicm);
    }
    // Add the 'new context' menu
    ExtensionPopupMenuItem piicm = createPopupIncludeInContextMenu();
    mainPopupMenuItems.add(piicm);
    this.subMenus.add(piicm);
}
Also used : Context(org.zaproxy.zap.model.Context) ExtensionPopupMenuItem(org.parosproxy.paros.extension.ExtensionPopupMenuItem) JMenuItem(javax.swing.JMenuItem) Session(org.parosproxy.paros.model.Session)

Example 4 with Session

use of org.parosproxy.paros.model.Session 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
    }
}
Also used : StructuralSiteNode(org.zaproxy.zap.model.StructuralSiteNode) SiteMap(org.parosproxy.paros.model.SiteMap) ExtensionHistory(org.parosproxy.paros.extension.history.ExtensionHistory) DatabaseException(org.parosproxy.paros.db.DatabaseException) Session(org.parosproxy.paros.model.Session)

Example 5 with Session

use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.

the class SessionStructure method getNodeName.

private static String getNodeName(Model model, URI uri, String method, String postData) throws URIException {
    Session session = model.getSession();
    List<String> paths = getTreePath(model, uri);
    String host = getHostName(uri);
    String nodeUrl = pathsToUrl(host, paths, paths.size());
    if (postData != null) {
        String params = getParams(session, uri, postData);
        if (params.length() > 0) {
            nodeUrl = nodeUrl + " " + params;
        }
    }
    return nodeUrl;
}
Also used : Session(org.parosproxy.paros.model.Session)

Aggregations

Session (org.parosproxy.paros.model.Session)51 DatabaseException (org.parosproxy.paros.db.DatabaseException)18 Context (org.zaproxy.zap.model.Context)14 ArrayList (java.util.ArrayList)8 JMenuItem (javax.swing.JMenuItem)7 ExtensionPopupMenuItem (org.parosproxy.paros.extension.ExtensionPopupMenuItem)7 File (java.io.File)5 SiteNode (org.parosproxy.paros.model.SiteNode)5 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)5 URIException (org.apache.commons.httpclient.URIException)4 RecordStructure (org.parosproxy.paros.db.RecordStructure)4 HttpMessage (org.parosproxy.paros.network.HttpMessage)4 ApiException (org.zaproxy.zap.extension.api.ApiException)4 ApiResponseElement (org.zaproxy.zap.extension.api.ApiResponseElement)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3 JFileChooser (javax.swing.JFileChooser)3 JSONException (net.sf.json.JSONException)3 ExtensionHistory (org.parosproxy.paros.extension.history.ExtensionHistory)3