Search in sources :

Example 6 with ExtensionHistory

use of org.parosproxy.paros.extension.history.ExtensionHistory in project zaproxy by zaproxy.

the class ExtensionAntiCSRF method hook.

@Override
public void hook(ExtensionHook extensionHook) {
    super.hook(extensionHook);
    final ExtensionHistory extensionHistory = (ExtensionHistory) Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.NAME);
    if (extensionHistory != null) {
        historyReferenceFactory = new HistoryReferenceFactory() {

            @Override
            public HistoryReference createHistoryReference(int id) {
                return extensionHistory.getHistoryReference(id);
            }
        };
    } else {
        historyReferenceFactory = new HistoryReferenceFactory() {

            @Override
            public HistoryReference createHistoryReference(int id) throws HttpMalformedHeaderException, DatabaseException {
                return new HistoryReference(id);
            }
        };
    }
    AntiCsrfToken.setHistoryReferenceFactory(historyReferenceFactory);
    extensionHook.addSessionListener(this);
    if (getView() != null) {
        extensionHook.getHookView().addOptionPanel(getOptionsAntiCsrfPanel());
        extensionHook.getHookMenu().addPopupMenuItem(this.getPopupMenuGenerateForm());
    }
    ExtensionPassiveScan extensionPassiveScan = (ExtensionPassiveScan) Control.getSingleton().getExtensionLoader().getExtension(ExtensionPassiveScan.NAME);
    if (extensionPassiveScan != null) {
        extensionPassiveScan.addPassiveScanner(antiCsrfDetectScanner);
    }
    AntiCsrfAPI api = new AntiCsrfAPI(this);
    api.addApiOptions(getParam());
    extensionHook.addApiImplementor(api);
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) ExtensionPassiveScan(org.zaproxy.zap.extension.pscan.ExtensionPassiveScan) HttpMalformedHeaderException(org.parosproxy.paros.network.HttpMalformedHeaderException) ExtensionHistory(org.parosproxy.paros.extension.history.ExtensionHistory) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 7 with ExtensionHistory

use of org.parosproxy.paros.extension.history.ExtensionHistory in project zaproxy by zaproxy.

the class ExtensionAlert method refreshAlert.

private void refreshAlert(Session session) throws DatabaseException {
    if (Constant.isLowMemoryOptionSet()) {
        return;
    }
    SiteMap siteTree = this.getModel().getSession().getSiteTree();
    TableAlert tableAlert = getModel().getDb().getTableAlert();
    // TODO this doesnt work, but should be used when its fixed :/
    //Vector<Integer> v = tableAlert.getAlertListBySession(Model.getSingleton().getSession().getSessionId());
    Vector<Integer> v = tableAlert.getAlertList();
    final ExtensionHistory extensionHistory = (ExtensionHistory) Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.NAME);
    for (int i = 0; i < v.size(); i++) {
        int alertId = v.get(i).intValue();
        RecordAlert recAlert = tableAlert.read(alertId);
        int historyId = recAlert.getHistoryId();
        HistoryReference historyReference = null;
        if (extensionHistory != null) {
            historyReference = extensionHistory.getHistoryReference(historyId);
        }
        if (historyReference == null) {
            historyReference = this.hrefs.get(Integer.valueOf(historyId));
        }
        Alert alert;
        if (historyReference != null) {
            alert = new Alert(recAlert, historyReference);
        } else {
            alert = new Alert(recAlert);
        }
        historyReference = alert.getHistoryRef();
        if (historyReference != null) {
            // The ref can be null if hrefs are purged
            addAlertToTree(alert);
            Integer key = Integer.valueOf(historyId);
            if (!hrefs.containsKey(key)) {
                this.hrefs.put(key, alert.getHistoryRef());
            }
        }
    }
    siteTree.nodeStructureChanged((SiteNode) siteTree.getRoot());
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) TableAlert(org.parosproxy.paros.db.TableAlert) SiteMap(org.parosproxy.paros.model.SiteMap) ExtensionHistory(org.parosproxy.paros.extension.history.ExtensionHistory) Alert(org.parosproxy.paros.core.scanner.Alert) RecordAlert(org.parosproxy.paros.db.RecordAlert) TableAlert(org.parosproxy.paros.db.TableAlert) RecordAlert(org.parosproxy.paros.db.RecordAlert)

Example 8 with ExtensionHistory

use of org.parosproxy.paros.extension.history.ExtensionHistory 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)

Aggregations

ExtensionHistory (org.parosproxy.paros.extension.history.ExtensionHistory)8 HistoryReference (org.parosproxy.paros.model.HistoryReference)5 IOException (java.io.IOException)2 DatabaseException (org.parosproxy.paros.db.DatabaseException)2 Session (org.parosproxy.paros.model.Session)2 SiteMap (org.parosproxy.paros.model.SiteMap)2 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)2 HttpMessage (org.parosproxy.paros.network.HttpMessage)2 UnknownHostException (java.net.UnknownHostException)1 SSLException (javax.net.ssl.SSLException)1 URIException (org.apache.commons.httpclient.URIException)1 Alert (org.parosproxy.paros.core.scanner.Alert)1 RecordAlert (org.parosproxy.paros.db.RecordAlert)1 TableAlert (org.parosproxy.paros.db.TableAlert)1 ExtensionLoader (org.parosproxy.paros.extension.ExtensionLoader)1 HtmlParameter (org.parosproxy.paros.network.HtmlParameter)1 ZapGetMethod (org.zaproxy.zap.ZapGetMethod)1 ExtensionAlert (org.zaproxy.zap.extension.alert.ExtensionAlert)1 ApiException (org.zaproxy.zap.extension.api.ApiException)1 ExtensionPassiveScan (org.zaproxy.zap.extension.pscan.ExtensionPassiveScan)1