Search in sources :

Example 31 with HistoryReference

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

the class AuthenticationHelper method addAuthMessageToHistory.

public static void addAuthMessageToHistory(HttpMessage msg) {
    // Add message to history
    try {
        final HistoryReference ref = new HistoryReference(Model.getSingleton().getSession(), HistoryReference.TYPE_AUTHENTICATION, msg);
        ref.addTag(HISTORY_TAG_AUTHENTICATION);
        if (View.isInitialised()) {
            final ExtensionHistory extHistory = Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.class);
            if (extHistory != null) {
                EventQueue.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        extHistory.addHistory(ref);
                    }
                });
            }
        }
    } catch (Exception ex) {
        log.error("Cannot add authentication message to History tab.", ex);
    }
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) ExtensionHistory(org.parosproxy.paros.extension.history.ExtensionHistory) IOException(java.io.IOException) URIException(org.apache.commons.httpclient.URIException)

Example 32 with HistoryReference

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

the class SearchResultsTable method getSelectedHistoryReferences.

@Override
public List<HistoryReference> getSelectedHistoryReferences() {
    final int[] selectedRows = getSelectedRows();
    if (selectedRows.length == 0) {
        return Collections.emptyList();
    }
    ArrayList<HistoryReference> uniqueHistoryReferences = new ArrayList<>(selectedRows.length);
    SortedSet<Integer> historyReferenceIdsAdded = new TreeSet<>();
    for (int selectedRow : selectedRows) {
        HistoryReference historyReference = getHistoryReferenceAtViewRow(selectedRow);
        if (historyReference != null) {
            Integer id = Integer.valueOf(historyReference.getHistoryId());
            if (!historyReferenceIdsAdded.contains(id)) {
                historyReferenceIdsAdded.add(id);
                uniqueHistoryReferences.add(historyReference);
            }
        }
    }
    uniqueHistoryReferences.trimToSize();
    return uniqueHistoryReferences;
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList)

Example 33 with HistoryReference

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

the class SearchResultsTableModel method createSearchResultTableEntry.

private static SearchResultTableEntry createSearchResultTableEntry(SearchResult sr, SearchResultTableEntry previousResult) {
    HistoryReference hRef = sr.getMessage().getHistoryRef();
    Integer historyId = null;
    String uri = null;
    String stringFound = null;
    if (previousResult != null) {
        Integer previousId = previousResult.getHistoryId();
        if (previousId.intValue() == hRef.getHistoryId()) {
            historyId = previousId;
        }
        if (previousResult.getStringFound().equals(sr.getStringFound())) {
            stringFound = previousResult.getStringFound();
        }
        uri = sr.getMessage().getRequestHeader().getURI().toString();
        if (previousResult.getUri().equals(uri)) {
            uri = previousResult.getUri();
        }
    }
    if (historyId == null) {
        historyId = Integer.valueOf(hRef.getHistoryId());
    }
    if (stringFound == null) {
        stringFound = sr.getStringFound();
    }
    if (uri == null) {
        uri = sr.getMessage().getRequestHeader().getURI().toString();
    }
    return new SearchResultTableEntry(hRef, historyId, hRef.getMethod(), uri, stringFound, sr);
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference)

Example 34 with HistoryReference

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

the class ExtensionHistory method getHistoryReference.

public HistoryReference getHistoryReference(int historyId) {
    HistoryReference href = historyTableModel.getHistoryReference(historyId);
    if (href != null) {
        return href;
    }
    href = (HistoryReference) historyIdToRef.get(historyId);
    if (href == null) {
        try {
            href = new HistoryReference(historyId);
            if (href.getHistoryType() != HistoryReference.TYPE_SCANNER_TEMPORARY) {
                addToMap(href);
            }
        } catch (Exception e) {
            return null;
        }
    }
    return href;
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 35 with HistoryReference

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

the class PopupMenuEmbeddedBrowser method initialize.

/**
	 * This method initializes this
	 */
private void initialize() {
    this.setText(Constant.messages.getString("history.browser.popup"));
    this.setActionCommand("");
    this.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            HistoryReference ref = null;
            if (lastInvoker == null) {
                return;
            }
            if (lastInvoker.getName().equalsIgnoreCase("ListLog")) {
                ref = extension.getSelectedHistoryReference();
                showBrowser(ref);
            } else if (lastInvoker.getName().equals("treeSite")) {
                JTree tree = (JTree) lastInvoker;
                SiteNode node = (SiteNode) tree.getLastSelectedPathComponent();
                ref = node.getHistoryReference();
                showBrowser(ref);
            }
        }
    });
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) JTree(javax.swing.JTree) SiteNode(org.parosproxy.paros.model.SiteNode)

Aggregations

HistoryReference (org.parosproxy.paros.model.HistoryReference)36 DatabaseException (org.parosproxy.paros.db.DatabaseException)11 SiteNode (org.parosproxy.paros.model.SiteNode)10 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)7 ArrayList (java.util.ArrayList)6 Alert (org.parosproxy.paros.core.scanner.Alert)6 HttpMessage (org.parosproxy.paros.network.HttpMessage)6 JTree (javax.swing.JTree)5 ExtensionHistory (org.parosproxy.paros.extension.history.ExtensionHistory)5 TreePath (javax.swing.tree.TreePath)4 IOException (java.io.IOException)3 TreeSet (java.util.TreeSet)3 Session (org.parosproxy.paros.model.Session)3 SiteMap (org.parosproxy.paros.model.SiteMap)3 Component (java.awt.Component)2 MalformedURLException (java.net.MalformedURLException)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 URIException (org.apache.commons.httpclient.URIException)2 Event (org.zaproxy.zap.eventBus.Event)2 AlertNode (org.zaproxy.zap.extension.alert.AlertNode)2