Search in sources :

Example 51 with SpiderParam

use of org.zaproxy.zap.spider.SpiderParam in project zaproxy by zaproxy.

the class SpiderHtmlFormParserUnitTest method createSpiderHtmlFormParser.

private static SpiderHtmlFormParser createSpiderHtmlFormParser(ValueGenerator valueGenerator) {
    SpiderParam spiderOptions = createSpiderParamWithConfig();
    spiderOptions.setProcessForm(true);
    spiderOptions.setPostForm(true);
    return new SpiderHtmlFormParser(spiderOptions, valueGenerator);
}
Also used : SpiderParam(org.zaproxy.zap.spider.SpiderParam)

Example 52 with SpiderParam

use of org.zaproxy.zap.spider.SpiderParam in project zaproxy by zaproxy.

the class SpiderHtmlFormParserUnitTest method shouldParseFormAsGetIfFormHasNoMethodEvenIfPostFormProcessingIsDisabled.

@Test
void shouldParseFormAsGetIfFormHasNoMethodEvenIfPostFormProcessingIsDisabled() {
    // Given
    SpiderParam spiderOptions = createSpiderParamWithConfig();
    spiderOptions.setProcessForm(true);
    spiderOptions.setPostForm(false);
    SpiderHtmlFormParser htmlParser = new SpiderHtmlFormParser(spiderOptions, new DefaultValueGenerator());
    TestSpiderParserListener listener = createTestSpiderParserListener();
    htmlParser.addSpiderParserListener(listener);
    HttpMessage messageHtmlResponse = createMessageWith("NoMethodForm.html");
    Source source = createSource(messageHtmlResponse);
    // When
    boolean completelyParsed = htmlParser.parseResource(messageHtmlResponse, source, BASE_DEPTH);
    // Then
    assertThat(completelyParsed, is(equalTo(false)));
    assertThat(listener.getNumberOfUrlsFound(), is(equalTo(1)));
    assertThat(listener.getUrlsFound(), contains("http://example.org/?field1=Text+1&field2=Text+2&submit=Submit"));
}
Also used : DefaultValueGenerator(org.zaproxy.zap.model.DefaultValueGenerator) SpiderParam(org.zaproxy.zap.spider.SpiderParam) HttpMessage(org.parosproxy.paros.network.HttpMessage) Source(net.htmlparser.jericho.Source) Test(org.junit.jupiter.api.Test)

Example 53 with SpiderParam

use of org.zaproxy.zap.spider.SpiderParam in project zaproxy by zaproxy.

the class SpiderHtmlFormParserUnitTest method shouldNotParsePostFormIfPostFormProcessingIsDisabled.

@Test
void shouldNotParsePostFormIfPostFormProcessingIsDisabled() {
    // Given
    SpiderParam spiderOptions = createSpiderParamWithConfig();
    spiderOptions.setProcessForm(true);
    spiderOptions.setPostForm(false);
    SpiderHtmlFormParser htmlParser = new SpiderHtmlFormParser(spiderOptions, new DefaultValueGenerator());
    TestSpiderParserListener listener = createTestSpiderParserListener();
    htmlParser.addSpiderParserListener(listener);
    HttpMessage messageHtmlResponse = createMessageWith("POST", "Form.html");
    Source source = createSource(messageHtmlResponse);
    // When
    boolean completelyParsed = htmlParser.parseResource(messageHtmlResponse, source, BASE_DEPTH);
    // Then
    assertThat(completelyParsed, is(equalTo(false)));
    assertThat(listener.getNumberOfUrlsFound(), is(equalTo(0)));
}
Also used : DefaultValueGenerator(org.zaproxy.zap.model.DefaultValueGenerator) SpiderParam(org.zaproxy.zap.spider.SpiderParam) HttpMessage(org.parosproxy.paros.network.HttpMessage) Source(net.htmlparser.jericho.Source) Test(org.junit.jupiter.api.Test)

Example 54 with SpiderParam

use of org.zaproxy.zap.spider.SpiderParam in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldFailToCreateDefaultParseFilterWithNullConfigs.

@Test
void shouldFailToCreateDefaultParseFilterWithNullConfigs() {
    // Given
    SpiderParam configs = null;
    // When / Then
    assertThrows(IllegalArgumentException.class, () -> new DefaultParseFilter(configs, resourceBundle));
}
Also used : SpiderParam(org.zaproxy.zap.spider.SpiderParam) Test(org.junit.jupiter.api.Test)

Example 55 with SpiderParam

use of org.zaproxy.zap.spider.SpiderParam in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldFailToCreateDefaultParseFilterWithNullResourceBundle.

@Test
void shouldFailToCreateDefaultParseFilterWithNullResourceBundle() {
    // Given
    ResourceBundle resourceBundle = null;
    SpiderParam configs = new SpiderParam();
    // When / Then
    assertThrows(IllegalArgumentException.class, () -> new DefaultParseFilter(configs, resourceBundle));
}
Also used : SpiderParam(org.zaproxy.zap.spider.SpiderParam) ResourceBundle(java.util.ResourceBundle) Test(org.junit.jupiter.api.Test)

Aggregations

SpiderParam (org.zaproxy.zap.spider.SpiderParam)55 Test (org.junit.jupiter.api.Test)48 HttpMessage (org.parosproxy.paros.network.HttpMessage)36 Source (net.htmlparser.jericho.Source)26 DefaultValueGenerator (org.zaproxy.zap.model.DefaultValueGenerator)5 ArrayList (java.util.ArrayList)2 OptionsParam (org.parosproxy.paros.model.OptionsParam)2 ResourceBundle (java.util.ResourceBundle)1 URI (org.apache.commons.httpclient.URI)1 ScannerParam (org.parosproxy.paros.core.scanner.ScannerParam)1 ConnectionParam (org.parosproxy.paros.network.ConnectionParam)1 AlertAPI (org.zaproxy.zap.extension.alert.AlertAPI)1 AntiCsrfAPI (org.zaproxy.zap.extension.anticsrf.AntiCsrfAPI)1 AntiCsrfParam (org.zaproxy.zap.extension.anticsrf.AntiCsrfParam)1 ActiveScanAPI (org.zaproxy.zap.extension.ascan.ActiveScanAPI)1 AuthenticationAPI (org.zaproxy.zap.extension.authentication.AuthenticationAPI)1 AuthorizationAPI (org.zaproxy.zap.extension.authorization.AuthorizationAPI)1 AutoUpdateAPI (org.zaproxy.zap.extension.autoupdate.AutoUpdateAPI)1 OptionsParamCheckForUpdates (org.zaproxy.zap.extension.autoupdate.OptionsParamCheckForUpdates)1 BreakAPI (org.zaproxy.zap.extension.brk.BreakAPI)1