Search in sources :

Example 1 with VariantFactory

use of org.zaproxy.zap.extension.ascan.VariantFactory in project zaproxy by zaproxy.

the class SessionStructureUnitTest method setUp.

@BeforeEach
void setUp() throws Exception {
    WithConfigsTest.setUpConstantMessages();
    factory = new VariantFactory();
    model = mock(Model.class);
    session = new Session(model);
    given(model.getSession()).willReturn(session);
    given(model.getVariantFactory()).willReturn(factory);
    Control.initSingletonForTesting(model);
    msg = new HttpMessage();
}
Also used : VariantFactory(org.zaproxy.zap.extension.ascan.VariantFactory) Model(org.parosproxy.paros.model.Model) HttpMessage(org.parosproxy.paros.network.HttpMessage) Session(org.parosproxy.paros.model.Session) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with VariantFactory

use of org.zaproxy.zap.extension.ascan.VariantFactory in project zaproxy by zaproxy.

the class AbstractAppParamPlugin method scan.

@Override
public void scan() {
    VariantFactory factory = Model.getSingleton().getVariantFactory();
    listVariant = factory.createVariants(this.getParent().getScannerParam(), this.getBaseMsg());
    if (listVariant.isEmpty()) {
        getParent().pluginSkipped(this, Constant.messages.getString("ascan.progress.label.skipped.reason.noinputvectors"));
        return;
    }
    for (int i = 0; i < listVariant.size() && !isStop(); i++) {
        HttpMessage msg = getNewMsg();
        // ZAP: Removed unnecessary cast.
        variant = listVariant.get(i);
        try {
            variant.setMessage(msg);
            this.scan(this.variant.getParamList());
        } catch (Exception e) {
            logger.error("Error occurred while scanning with variant " + variant.getClass().getCanonicalName(), e);
        }
        // ZAP: Implement pause and resume
        while (getParent().isPaused() && !isStop()) {
            Util.sleep(500);
        }
    }
}
Also used : VariantFactory(org.zaproxy.zap.extension.ascan.VariantFactory) HttpMessage(org.parosproxy.paros.network.HttpMessage)

Example 3 with VariantFactory

use of org.zaproxy.zap.extension.ascan.VariantFactory in project zaproxy by zaproxy.

the class SiteMapUnitTest method setup.

@BeforeEach
void setup() throws Exception {
    Session session = mock(Session.class);
    StandardParameterParser spp = new StandardParameterParser();
    given(session.getUrlParamParser(any(String.class))).willReturn(spp);
    sessionId = 1234L;
    given(session.getSessionId()).willReturn(sessionId);
    tableHistory = mock(TableHistory.class);
    given(tableHistory.write(eq(sessionId), eq(HistoryReference.TYPE_TEMPORARY), any(HttpMessage.class))).willReturn(mock(RecordHistory.class));
    HistoryReference.setTableHistory(tableHistory);
    tableAlert = mock(TableAlert.class);
    given(tableAlert.getAlertsBySourceHistoryId(anyInt())).willReturn(Collections.emptyList());
    HistoryReference.setTableAlert(tableAlert);
    Model model = mock(Model.class);
    Control.initSingletonForTesting(model);
    given(model.getSession()).willReturn(session);
    factory = new VariantFactory();
    given(model.getVariantFactory()).willReturn(factory);
    rootNode = new SiteNode(null, -1, "Root Node");
    siteMap = new SiteMap(rootNode, model);
}
Also used : VariantFactory(org.zaproxy.zap.extension.ascan.VariantFactory) TableAlert(org.parosproxy.paros.db.TableAlert) StandardParameterParser(org.zaproxy.zap.model.StandardParameterParser) TableHistory(org.parosproxy.paros.db.TableHistory) HttpMessage(org.parosproxy.paros.network.HttpMessage) RecordHistory(org.parosproxy.paros.db.RecordHistory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with VariantFactory

use of org.zaproxy.zap.extension.ascan.VariantFactory in project zaproxy by zaproxy.

the class SessionUnitTest method setUp.

@BeforeEach
void setUp() throws Exception {
    factory = new VariantFactory();
    Model model = mock(Model.class);
    given(model.getVariantFactory()).willReturn(factory);
    Control.initSingletonForTesting(model);
    session = new Session(model);
    given(model.getSession()).willReturn(session);
}
Also used : VariantFactory(org.zaproxy.zap.extension.ascan.VariantFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

VariantFactory (org.zaproxy.zap.extension.ascan.VariantFactory)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 HttpMessage (org.parosproxy.paros.network.HttpMessage)3 RecordHistory (org.parosproxy.paros.db.RecordHistory)1 TableAlert (org.parosproxy.paros.db.TableAlert)1 TableHistory (org.parosproxy.paros.db.TableHistory)1 Model (org.parosproxy.paros.model.Model)1 Session (org.parosproxy.paros.model.Session)1 StandardParameterParser (org.zaproxy.zap.model.StandardParameterParser)1