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();
}
Aggregations