public void initialize(IPathState ps) { if (!ps.has404Fingerprints() || !hasSuitablePath(ps)) { ipsCheck.initialize(ps); return; } final IInjectionModuleContext ctx = ps.createModuleContext(); final HttpUriRequest req = createRequest(ps.getPath()); ctx.submitRequest(req, this, 0); }
@Override public void runModule( HttpUriRequest request, IHttpResponse response, IInjectionModuleContext ctx) { final IPathState ps = ctx.getPathState(); if (response.isFetchFail()) { ctx.error(request, response, "Fetch failed during parent directory check"); } else if (ps.matchesPathFingerprint(response.getPageFingerprint())) { ctx.debug("Problem with parent directory behavior"); ctx.getPathState().setBadParentDirectory(); } ipsCheck.initialize(ctx.getPathState()); }
@Override public void runScript(IPathState pathState) { final IModuleContext ctx = pathState.createModuleContext(); try { final Object[] args = new Object[] {new ModuleContextJS(ctx)}; Context cx = Context.enter(); Scriptable instance = module.createInstanceScope(cx); module.runModule(cx, instance, args, pathState.toString()); } catch (WrappedException e) { logger.log( Level.WARNING, new RhinoExceptionFormatter("Wrapped exception running module script", e).toString()); } catch (RhinoException e) { logger.warning(new RhinoExceptionFormatter("Exception running module script.", e).toString()); } finally { Context.exit(); } }
@Override public void processResponse( IWebCrawler crawler, HttpUriRequest request, IHttpResponse response, Object argument) { final IInjectionModuleContext ctx = (IInjectionModuleContext) argument; final IPathState ps = ctx.getPathState(); ps.setResponse(response); ps.getPath().setVisited(true); if (response.isFetchFail()) { ctx.error(request, response, "during initial file fetch"); return; } final IPathState ps404Parent = ps.get404Parent(); boolean is404Response = ((ps404Parent == null) && response.getResponseCode() == 404) || ((ps404Parent != null) && ps404Parent.has404FingerprintMatching(response.getPageFingerprint())); if (is404Response) { ps.setPageMissing(); } else { if (response.getResponseCode() > 400) ctx.debug("Page is not accessible. http code (" + response.getResponseCode() + ")"); final IPathState pps = ps.getParentState(); if (pps == null || pps.getResponse() == null || !ps.matchesPathFingerprint(pps.getPathFingerprint())) { ctx.responseChecks(request, response); } if (ps404Parent != null && !ps.isParametric()) secondaryExtChecks.initialize(ps); if (ps.getPath().getPathType() == PathType.PATH_FILE) caseCheck.initialize(ps); } ps.unlockChildren(); if (ps.isParametric()) { parametricChecks.initialize(ps); } else { injectionChecks.initialize(ps); } }
private boolean hasSuitablePath(IPathState ps) { final IWebPath parentPath = ps.getPath().getParentPath(); return (parentPath != null && parentPath.getParentPath() != null); }