All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zaproxy.zap.model.ParameterParser Maven / Gradle / Ivy

Go to download

The Zed Attack Proxy (ZAP) is an easy to use integrated penetration testing tool for finding vulnerabilities in web applications. It is designed to be used by people with a wide range of security experience and as such is ideal for developers and functional testers who are new to penetration testing. ZAP provides automated scanners as well as a set of tools that allow you to find security vulnerabilities manually.

There is a newer version: 2.7.0
Show newest version
/*
 * Zed Attack Proxy (ZAP) and its related class files.
 *
 * ZAP is an HTTP/HTTPS proxy for assessing web application security.
 *
 * Copyright 2014 The ZAP Development Team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.zaproxy.zap.model;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.URIException;
import org.parosproxy.paros.network.HtmlParameter;
import org.parosproxy.paros.network.HttpMessage;

public interface ParameterParser {

    void init(String config);

    /**
     * @deprecated 2.10.0 use #getParameters(String) This method will lose duplicated parameter
     *     names
     */
    @Deprecated
    Map getParams(HttpMessage msg, HtmlParameter.Type type);

    /**
     * Gets the parameters of the given {@code type} from the given {@code message}.
     *
     * 

The parameters are split using the key value pair separator(s) and each resulting * parameter is split into name/value pairs using key value separator(s). * *

Parameters' names and values are in decoded form, if not malformed, otherwise the original * name/value. Names and values are never {@code null}. * * @param msg the message whose parameters will be extracted from * @param type the type of parameters to extract * @return a {@code List} containing the parameters * @throws IllegalArgumentException if the {@code msg} or {@code type} is {@code null}. * @since 2.5.0 * @see #getDefaultKeyValuePairSeparator() * @see #getDefaultKeyValueSeparator() */ List getParameters(HttpMessage msg, HtmlParameter.Type type); /** * @deprecated 2.10.0 use #parseParameters(String) This method will lose duplicated parameter * names */ @Deprecated Map parse(String paramStr); /** * Parses the given {@code parameters} into a list of {@link NameValuePair}. * *

The parameters are split using the key value pair separator(s) and each resulting * parameter is split into name/value pairs using key value separator(s). * *

Parameters' names and values are in decoded form, if not malformed, otherwise the original * name/value. Names and values are never {@code null}. * * @param parameters the String of parameters to parse, might be {@code null} * @return a {@code List} containing the parameters parsed * @since 2.5.0 * @see #getDefaultKeyValuePairSeparator() * @see #getDefaultKeyValueSeparator() */ List parseParameters(String parameters); /** * Parses the given {@code parameters} into a list of {@link NameValuePair}. * *

The parameters are split using the key value pair separator(s) and each resulting * parameter is split into name/value pairs using key value separator(s). * *

Unlike {@link #parseParameters(String)} the parameters' names and values are not decoded. * This allows to rebuild the original string without (re)encoding issues. Values might be * {@code null}, when not present. * *

By default returns an empty list. * * @param parameters the String of parameters to parse, might be {@code null}. * @return a {@code List} containing the parameters parsed, never {@code null}. * @since 2.10.0 * @see #getDefaultKeyValuePairSeparator() * @see #getDefaultKeyValueSeparator() */ default List parseRawParameters(String parameters) { return Collections.emptyList(); } List getTreePath(URI uri) throws URIException; List getTreePath(HttpMessage msg) throws URIException; /** * Gets the path of the URI's ancestor found at the given depth, taking into account any context * specific configuration (e.g. structural parameters). The depth could also be seen as the * number of path elements returned. * *

A few examples (uri, depth): * *

    *
  • (http://example.org/path/to/element, 0) -> "" *
  • (http://example.org/path/to/element, 1) -> "/path" *
  • (http://example.org/path/to/element, 3) -> "/path/to/element" *
  • (http://example.org/path?page=12&data=123, 2) -> "/path?page=12", if * {@code page} is a structural parameter *
  • (http://example.org/path?page=12&data=123&type=1, 3) -> * "/path?page=12&type=1", if {@code page} and {@code type} are both structural * parameter *
* * @param uri the URI * @param depth the depth * @return the path of the ancestor * @throws URIException if an error occurred while accessing the provided uri */ String getAncestorPath(URI uri, int depth) throws URIException; String getDefaultKeyValuePairSeparator(); String getDefaultKeyValueSeparator(); String getConfig(); ParameterParser clone(); void setContext(Context context); Context getContext(); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy