Search in sources :

Example 1 with HistoryReferencesTable

use of org.zaproxy.zap.view.table.HistoryReferencesTable 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 2 with HistoryReferencesTable

use of org.zaproxy.zap.view.table.HistoryReferencesTable in project zaproxy by zaproxy.

the class ActiveScanPanel method getMessagesTable.

private HistoryReferencesTable getMessagesTable() {
    if (messagesTable == null) {
        messagesTable = new HistoryReferencesTable(EMPTY_RESULTS_MODEL);
        messagesTable.setName(MESSAGE_CONTAINER_NAME);
        messagesTable.setAutoCreateColumnsFromModel(false);
    }
    return messagesTable;
}
Also used : HistoryReferencesTable(org.zaproxy.zap.view.table.HistoryReferencesTable)

Aggregations

HistoryReferencesTable (org.zaproxy.zap.view.table.HistoryReferencesTable)2 JTree (javax.swing.JTree)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 HistoryReference (org.parosproxy.paros.model.HistoryReference)1 Session (org.parosproxy.paros.model.Session)1