Search in sources :

Example 1 with InterfaceProvider

use of org.zaproxy.zap.extension.script.ScriptsCache.InterfaceProvider in project zaproxy by zaproxy.

the class ScriptsActiveScanner method scan.

@Override
public void scan() {
    List<ScriptWrapper> scripts = this.getActiveScripts();
    for (Iterator<ScriptWrapper> it = scripts.iterator(); it.hasNext() && !isStop(); ) {
        ScriptWrapper script = it.next();
        try {
            if (script.isEnabled()) {
                ActiveScript2 s = extension.getInterface(script, ActiveScript2.class);
                if (s != null) {
                    HttpMessage msg = this.getNewMsg();
                    logger.debug("Calling script " + script.getName() + " scanNode for " + msg.getRequestHeader().getURI());
                    s.scanNode(this, msg);
                } else {
                    scriptsNoInterface.add(script);
                }
            }
        } catch (Exception e) {
            extension.handleScriptException(script, e);
        }
    }
    if (!isStop()) {
        InterfaceProvider<ActiveScript> interfaceProvider = (scriptWrapper, targetInterface) -> {
            ActiveScript s = extension.getInterface(scriptWrapper, targetInterface);
            if (s != null) {
                return s;
            }
            if (scriptsNoInterface.contains(scriptWrapper)) {
                extension.handleFailedScriptInterface(scriptWrapper, Constant.messages.getString("ascan.scripts.interface.active.error", scriptWrapper.getName()));
            }
            return null;
        };
        cachedScripts = getExtension().createScriptsCache(Configuration.<ActiveScript>builder().setScriptType(ExtensionActiveScan.SCRIPT_TYPE_ACTIVE).setTargetInterface(ActiveScript.class).setInterfaceProvider(interfaceProvider).build());
        super.scan();
    }
    scriptsNoInterface.clear();
}
Also used : Category(org.parosproxy.paros.core.scanner.Category) Configuration(org.zaproxy.zap.extension.script.ScriptsCache.Configuration) Iterator(java.util.Iterator) AbstractAppParamPlugin(org.parosproxy.paros.core.scanner.AbstractAppParamPlugin) Set(java.util.Set) IOException(java.io.IOException) Control(org.parosproxy.paros.control.Control) AlertBuilder(org.parosproxy.paros.core.scanner.AbstractPlugin.AlertBuilder) HashSet(java.util.HashSet) CachedScript(org.zaproxy.zap.extension.script.ScriptsCache.CachedScript) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Alert(org.parosproxy.paros.core.scanner.Alert) ExtensionScript(org.zaproxy.zap.extension.script.ExtensionScript) ScriptsCache(org.zaproxy.zap.extension.script.ScriptsCache) HttpException(org.apache.commons.httpclient.HttpException) Constant(org.parosproxy.paros.Constant) InterfaceProvider(org.zaproxy.zap.extension.script.ScriptsCache.InterfaceProvider) HttpMessage(org.parosproxy.paros.network.HttpMessage) LogManager(org.apache.logging.log4j.LogManager) ScriptWrapper(org.zaproxy.zap.extension.script.ScriptWrapper) ScriptWrapper(org.zaproxy.zap.extension.script.ScriptWrapper) HttpMessage(org.parosproxy.paros.network.HttpMessage) IOException(java.io.IOException) HttpException(org.apache.commons.httpclient.HttpException)

Aggregations

IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1 HttpException (org.apache.commons.httpclient.HttpException)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 Constant (org.parosproxy.paros.Constant)1 Control (org.parosproxy.paros.control.Control)1 AbstractAppParamPlugin (org.parosproxy.paros.core.scanner.AbstractAppParamPlugin)1 AlertBuilder (org.parosproxy.paros.core.scanner.AbstractPlugin.AlertBuilder)1 Alert (org.parosproxy.paros.core.scanner.Alert)1 Category (org.parosproxy.paros.core.scanner.Category)1 HttpMessage (org.parosproxy.paros.network.HttpMessage)1 ExtensionScript (org.zaproxy.zap.extension.script.ExtensionScript)1 ScriptWrapper (org.zaproxy.zap.extension.script.ScriptWrapper)1 ScriptsCache (org.zaproxy.zap.extension.script.ScriptsCache)1 CachedScript (org.zaproxy.zap.extension.script.ScriptsCache.CachedScript)1 Configuration (org.zaproxy.zap.extension.script.ScriptsCache.Configuration)1