Search in sources :

Example 81 with URI

use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.

the class FilterLogGetQuery method onHttpRequestSend.

@Override
public void onHttpRequestSend(HttpMessage httpMessage) {
    HttpRequestHeader reqHeader = httpMessage.getRequestHeader();
    if (reqHeader != null && reqHeader.isText() && !reqHeader.isImage()) {
        if (reqHeader.getMethod().equalsIgnoreCase(HttpRequestHeader.GET)) {
            try {
                URI uri = reqHeader.getURI();
                // ZAP: Removed unused variable (int pos).
                String firstline;
                URI newURI = (URI) uri.clone();
                String query = newURI.getQuery();
                if (query != null) {
                    newURI.setQuery(null);
                    firstline = newURI.toString();
                    // ZAP: Added type arguments.
                    Hashtable<String, String> param = parseParameter(query);
                    writeLogFile(firstline, param);
                } else {
                    firstline = uri.toString();
                    writeLogFile(firstline, null);
                }
            } catch (Exception aa) {
                logger.error(aa.getMessage(), aa);
            }
        }
    }
}
Also used : HttpRequestHeader(org.parosproxy.paros.network.HttpRequestHeader) URI(org.apache.commons.httpclient.URI) IOException(java.io.IOException)

Example 82 with URI

use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.

the class VariantODataIdQuery method setMessage.

@Override
public void setMessage(HttpMessage msg) {
    URI uri = msg.getRequestHeader().getURI();
    parse(uri);
}
Also used : URI(org.apache.commons.httpclient.URI)

Example 83 with URI

use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.

the class VariantURLPath method setParameter.

/**
     *
     * @param msg
     * @param originalPair
     * @param name
     * @param value
     * @param escaped
     * @return
     */
private String setParameter(HttpMessage msg, NameValuePair originalPair, String name, String value, boolean escaped) {
    try {
        URI uri = msg.getRequestHeader().getURI();
        String[] paths = msg.getRequestHeader().getURI().getPath().toString().split("/");
        if (originalPair.getPosition() < paths.length) {
            String encodedValue = (escaped) ? value : getEscapedValue(value);
            paths[originalPair.getPosition()] = encodedValue;
            String path = StringUtils.join(paths, "/");
            try {
                uri.setEscapedPath(path);
            } catch (URIException e) {
                // Looks like it wasnt escaped after all
                uri.setPath(path);
            }
        }
    } catch (URIException e) {
        logger.error(e.getMessage(), e);
    }
    return value;
}
Also used : URIException(org.apache.commons.httpclient.URIException) URI(org.apache.commons.httpclient.URI)

Example 84 with URI

use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.

the class PopupMenuShowAlerts method isButtonEnabledForHistoryReference.

@Override
public boolean isButtonEnabledForHistoryReference(HistoryReference href) {
    List<Alert> alerts;
    if (href.getSiteNode() != null) {
        alerts = href.getSiteNode().getAlerts();
    } else {
        alerts = href.getAlerts();
    }
    URI hrefURI = href.getURI();
    List<PopupMenuShowAlert> alertList = new ArrayList<>(alerts.size());
    for (Alert alert : alerts) {
        // Just show ones for this node
        if (hrefURI != null && !alert.getUri().equals(hrefURI.toString())) {
            continue;
        }
        final PopupMenuShowAlert menuItem = new PopupMenuShowAlert(alert.getName(), alert);
        menuItem.setIcon(alert.getIcon());
        alertList.add(menuItem);
    }
    Collections.sort(alertList);
    for (PopupMenuShowAlert pmsa : alertList) {
        this.add(pmsa);
    }
    return (alertList.size() > 0);
}
Also used : ArrayList(java.util.ArrayList) Alert(org.parosproxy.paros.core.scanner.Alert) URI(org.apache.commons.httpclient.URI)

Example 85 with URI

use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.

the class Spider method addSeed.

/* SPIDER Related */
/**
	 * Adds a new seed for the Spider.
	 * 
	 * @param msg the message used for seed. The request URI is used from the Request Header
	 */
public void addSeed(HttpMessage msg) {
    URI uri = msg.getRequestHeader().getURI();
    addSeed(uri);
}
Also used : URI(org.apache.commons.httpclient.URI)

Aggregations

URI (org.apache.commons.httpclient.URI)129 Test (org.junit.Test)72 FetchStatus (org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus)33 URIException (org.apache.commons.httpclient.URIException)28 HttpMessage (org.parosproxy.paros.network.HttpMessage)10 ArrayList (java.util.ArrayList)9 HttpRequestHeader (org.parosproxy.paros.network.HttpRequestHeader)8 DatabaseException (org.parosproxy.paros.db.DatabaseException)7 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)6 HandleParametersOption (org.zaproxy.zap.spider.SpiderParam.HandleParametersOption)6 IOException (java.io.IOException)5 Header (org.apache.commons.httpclient.Header)4 InvalidParameterException (java.security.InvalidParameterException)3 Matcher (java.util.regex.Matcher)3 Pattern (java.util.regex.Pattern)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3 JSONException (net.sf.json.JSONException)3 StructuralNode (org.zaproxy.zap.model.StructuralNode)3 File (java.io.File)2 List (java.util.List)2