Search in sources :

Example 26 with Session

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

the class SessionExcludeFromSpiderPanel method initParam.

@Override
public void initParam(Object obj) {
    Session session = (Session) obj;
    regexesPanel.setRegexes(session.getExcludeFromSpiderRegexs());
    regexesPanel.setRemoveWithoutConfirmation(!Model.getSingleton().getOptionsParam().getViewParam().isConfirmRemoveSpiderExcludeRegex());
}
Also used : Session(org.parosproxy.paros.model.Session)

Example 27 with Session

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

the class HttpPanelSender method persistAndShowMessage.

private void persistAndShowMessage(HttpMessage httpMessage) {
    if (!EventQueue.isDispatchThread()) {
        EventQueue.invokeLater(() -> persistAndShowMessage(httpMessage));
        return;
    }
    try {
        Session session = Model.getSingleton().getSession();
        HistoryReference ref = new HistoryReference(session, HistoryReference.TYPE_ZAP_USER, httpMessage);
        final ExtensionHistory extHistory = getHistoryExtension();
        if (extHistory != null) {
            extHistory.addHistory(ref);
        }
        SessionStructure.addPath(Model.getSingleton(), ref, httpMessage);
    } catch (HttpMalformedHeaderException | DatabaseException e) {
        logger.warn("Failed to persist message sent:", e);
    }
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) HttpMalformedHeaderException(org.parosproxy.paros.network.HttpMalformedHeaderException) ExtensionHistory(org.parosproxy.paros.extension.history.ExtensionHistory) DatabaseException(org.parosproxy.paros.db.DatabaseException) Session(org.parosproxy.paros.model.Session)

Example 28 with Session

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

the class PopupMenuHistoryReference method isEnableForComponent.

@Override
public boolean isEnableForComponent(Component invoker) {
    boolean display = false;
    if (invoker.getName() == null) {
        return false;
    }
    if (invoker.getName().equals("History Table")) {
        this.lastInvoker = Invoker.history;
        this.hrefsTableInvoker = (HistoryReferencesTable) invoker;
        this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
        display = true;
    } else if (invoker instanceof JTree && invoker.getName().equals("treeSite")) {
        this.lastInvoker = Invoker.sites;
        this.treeInvoker = (JTree) invoker;
        this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
        display = true;
    } else if (invoker.getName().equals("treeAlert")) {
        this.lastInvoker = Invoker.alerts;
        this.treeInvoker = (JTree) invoker;
        JTree tree = (JTree) invoker;
        if (tree.getLastSelectedPathComponent() != null) {
            if (tree.getSelectionCount() > 1) {
                // Note - the Alerts tree only supports single selections
                this.setEnabled(false);
            } else {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
                if (!node.isRoot() && node.getUserObject() != null) {
                    this.setEnabled(isEnabledForHistoryReference(getSelectedHistoryReferences().get(0)));
                } else {
                    this.setEnabled(false);
                }
            }
        }
        display = true;
    } else if (invoker.getName().equals(SearchPanel.HTTP_MESSAGE_CONTAINER_NAME)) {
        this.lastInvoker = Invoker.search;
        this.hrefsTableInvoker = (HistoryReferencesTable) invoker;
        this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
        display = true;
    } else if (invoker.getName().equals(ActiveScanPanel.MESSAGE_CONTAINER_NAME)) {
        this.lastInvoker = Invoker.ascan;
        this.hrefsTableInvoker = (HistoryReferencesTable) invoker;
        this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
        display = true;
    } else if (invoker.getName().equals("HttpFuzzerResultsContentPanel")) {
        this.lastInvoker = Invoker.fuzz;
        this.hrefsTableInvoker = (HistoryReferencesTable) invoker;
        this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
        display = true;
    } else if (invoker.getName().equals("ForcedBrowseMessageContainer")) {
        this.lastInvoker = Invoker.bruteforce;
        this.hrefsTableInvoker = (HistoryReferencesTable) invoker;
        this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
        display = true;
    } else if (invoker instanceof HistoryReferencesTable) {
        this.lastInvoker = Invoker.hreftable;
        this.hrefTableInvoker = (HistoryReferencesTable) invoker;
        this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
        display = true;
    } else {
    // Only enable this while testing
    /*
        	log.debug("Popup " + this.getName() + 
        			" not enabled for panel " + invoker.getName() + 
        			" class " + invoker.getClass().getName());
        	*/
    }
    if (display) {
        if (this.isEnabled() && !this.isSafe() && Control.getSingleton().getMode().equals(Mode.protect)) {
            boolean inScope = true;
            Session session = Model.getSingleton().getSession();
            for (HistoryReference href : getSelectedHistoryReferences()) {
                if (!session.isInScope(href)) {
                    inScope = false;
                    break;
                }
            }
            if (!inScope) {
                // Not safe and not in scope while in protected mode
                this.setEnabled(false);
            }
        }
        return this.isEnableForInvoker(lastInvoker);
    }
    return false;
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) JTree(javax.swing.JTree) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) HistoryReferencesTable(org.zaproxy.zap.view.table.HistoryReferencesTable) Session(org.parosproxy.paros.model.Session)

Example 29 with Session

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

the class SessionStructure method getNodeName.

private static String getNodeName(long sessionId, URI uri, String method, String postData) throws URIException {
    Session session = Model.getSingleton().getSession();
    List<String> paths = session.getTreePath(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)

Example 30 with Session

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

the class Control method newSession.

public Session newSession() throws Exception {
    log.info("New Session");
    closeSessionAndCreateAndOpenUntitledDb();
    final Session session = createNewSession();
    getExtensionLoader().databaseOpen(model.getDb());
    getExtensionLoader().sessionChangedAllPlugin(session);
    if (hasView()) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                view.getSiteTreePanel().getTreeSite().setModel(session.getSiteTree());
                view.getSiteTreePanel().reloadContextTree();
            }
        });
        // refresh display
        view.getOutputPanel().clear();
    }
    try {
        model.getDb().getTableSession().insert(session.getSessionId(), session.getSessionName());
    } catch (DatabaseException e) {
        log.error(e.getMessage(), e);
    }
    return session;
}
Also used : DatabaseException(org.parosproxy.paros.db.DatabaseException) 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