Search in sources :

Example 11 with FilterResult

use of org.zaproxy.zap.spider.filters.ParseFilter.FilterResult in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldNotFilterHttpMessageWithSvnDbRequest.

@Test
void shouldNotFilterHttpMessageWithSvnDbRequest() throws Exception {
    // Given
    DefaultParseFilter filter = createDefaultParseFilter();
    HttpMessage httpMessage = createHttpMessageWithRequestUri("/.svn/entries");
    // When
    FilterResult filterResult = filter.filtered(httpMessage);
    // Then
    assertThat(filterResult.isFiltered(), is(equalTo(false)));
}
Also used : FilterResult(org.zaproxy.zap.spider.filters.ParseFilter.FilterResult) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Example 12 with FilterResult

use of org.zaproxy.zap.spider.filters.ParseFilter.FilterResult in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldFilterHttpMessageWithResponseAboveMaxParseSize.

@Test
void shouldFilterHttpMessageWithResponseAboveMaxParseSize() throws Exception {
    // Given
    int maxParseSizeBytes = 2;
    DefaultParseFilter filter = new DefaultParseFilter(createSpiderParam(maxParseSizeBytes), resourceBundle);
    HttpMessage httpMessage = createHttpMessageWithResponseBody("ABC");
    // When
    FilterResult filterResult = filter.filtered(httpMessage);
    // Then
    assertThat(filterResult.isFiltered(), is(equalTo(true)));
    assertThat(filterResult.getReason(), is(equalTo(FILTERED_REASON_MAX_SIZE)));
}
Also used : FilterResult(org.zaproxy.zap.spider.filters.ParseFilter.FilterResult) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Example 13 with FilterResult

use of org.zaproxy.zap.spider.filters.ParseFilter.FilterResult in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldNotFilterHttpMessageWithGitRequest.

@Test
void shouldNotFilterHttpMessageWithGitRequest() throws Exception {
    // Given
    DefaultParseFilter filter = createDefaultParseFilter();
    HttpMessage httpMessage = createHttpMessageWithRequestUri("/.git/index");
    // When
    FilterResult filterResult = filter.filtered(httpMessage);
    // Then
    assertThat(filterResult.isFiltered(), is(equalTo(false)));
}
Also used : FilterResult(org.zaproxy.zap.spider.filters.ParseFilter.FilterResult) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Example 14 with FilterResult

use of org.zaproxy.zap.spider.filters.ParseFilter.FilterResult in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldFilterNullHttpMessage.

@Test
void shouldFilterNullHttpMessage() {
    // Given
    DefaultParseFilter filter = createDefaultParseFilter();
    HttpMessage httpMessage = null;
    // When
    FilterResult filterResult = filter.filtered(httpMessage);
    // Then
    assertThat(filterResult.isFiltered(), is(equalTo(true)));
    assertThat(filterResult.getReason(), is(equalTo(FILTERED_REASON_EMPTY)));
}
Also used : FilterResult(org.zaproxy.zap.spider.filters.ParseFilter.FilterResult) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Example 15 with FilterResult

use of org.zaproxy.zap.spider.filters.ParseFilter.FilterResult in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldNotFilterHttpMessageWithSitemapXmlRequestEvenWithoutContentType.

@Test
void shouldNotFilterHttpMessageWithSitemapXmlRequestEvenWithoutContentType() throws Exception {
    // Given
    DefaultParseFilter filter = createDefaultParseFilter();
    HttpMessage httpMessage = createHttpMessageWithRequestUri("/sitemap.xml");
    httpMessage.getResponseHeader().setHeader(HttpHeader.CONTENT_TYPE, "");
    // When
    FilterResult filterResult = filter.filtered(httpMessage);
    // Then
    assertThat(filterResult.isFiltered(), is(equalTo(false)));
}
Also used : FilterResult(org.zaproxy.zap.spider.filters.ParseFilter.FilterResult) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Aggregations

HttpMessage (org.parosproxy.paros.network.HttpMessage)17 FilterResult (org.zaproxy.zap.spider.filters.ParseFilter.FilterResult)17 Test (org.junit.jupiter.api.Test)16 IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 SocketException (java.net.SocketException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 UnknownHostException (java.net.UnknownHostException)1 SSLException (javax.net.ssl.SSLException)1 URIException (org.apache.commons.httpclient.URIException)1 DatabaseException (org.parosproxy.paros.db.DatabaseException)1 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)1 ParseFilter (org.zaproxy.zap.spider.filters.ParseFilter)1