pub fn content_filter_check_generic_request_map(
    configpath: &str,
    raw: &RawRequest,
    content_filter_id: &str,
    logs: &mut Logs,
) -> (Decision, RequestInfo, Tags) {
    let mut tags = Tags::default();
    logs.debug("Content Filter inspection starts");
    let waf_profile = match with_config(configpath, logs, |_slogs, cfg| {
        cfg.content_filter_profiles.get(content_filter_id).cloned()
    }) {
        Some(Some(prof)) => prof,
        _ => {
            logs.error("Content Filter profile not found");
            return (Decision::Pass, map_request(logs, &[], &[], 25, raw), tags);
        }
    };

    if let Some(body) = raw.mbody {
        if body.len() > waf_profile.max_body_size {
            logs.error("body too large, exiting early");
            let reqinfo = map_request(logs, &waf_profile.decoding, &[], 0, raw);
            return (
                Decision::Action(body_too_large(waf_profile.max_body_size, body.len())),
                reqinfo,
                tags,
            );
        }
    }

    let reqinfo = map_request(logs, &waf_profile.decoding, &[], waf_profile.max_body_depth, raw);

    let waf_result = match HSDB.read() {
        Ok(rd) => content_filter_check(logs, &mut tags, &reqinfo, &waf_profile, rd.get(content_filter_id)),
        Err(rr) => {
            logs.error(|| format!("Could not get lock on HSDB: {}", rr));
            Ok(())
        }
    };
    logs.debug("Content Filter checks done");

    (
        match waf_result {
            Ok(()) => Decision::Pass,
            Err(wb) => Decision::Action(wb.to_action()),
        },
        reqinfo,
        tags,
    )
}
// generic entry point when the request map has already been parsed
generic entry point when the request map has already been parsed
generic entry point when the request map has already been parsed
pub fn content_filter_check_generic_request_map(
    configpath: &str,
    raw: &RawRequest,
    content_filter_id: &str,
    logs: &mut Logs,
) -> (Decision, RequestInfo, Tags) {
    let mut tags = Tags::default();
    logs.debug("Content Filter inspection starts");
    let waf_profile = match with_config(configpath, logs, |_slogs, cfg| {
        cfg.content_filter_profiles.get(content_filter_id).cloned()
    }) {
        Some(Some(prof)) => prof,
        _ => {
            logs.error("Content Filter profile not found");
            return (Decision::Pass, map_request(logs, &[], &[], 25, raw), tags);
        }
    };
    if let Some(body) = raw.mbody {
        if body.len() > waf_profile.max_body_size {
            logs.error("body too large, exiting early");
            let reqinfo = map_request(logs, &waf_profile.decoding, &[], 0, raw);
            return (
                Decision::Action(body_too_large(waf_profile.max_body_size, body.len())),
                reqinfo,
                tags,
            );
        }
    }
    let reqinfo = map_request(logs, &waf_profile.decoding, &[], waf_profile.max_body_depth, raw);
    let waf_result = match HSDB.read() {
        Ok(rd) => content_filter_check(logs, &mut tags, &reqinfo, &waf_profile, rd.get(content_filter_id)),
        Err(rr) => {
            logs.error(|| format!("Could not get lock on HSDB: {}", rr));
            Ok(())
        }
    };
    logs.debug("Content Filter checks done");
    (
        match waf_result {
            Ok(()) => Decision::Pass,
            Err(wb) => Decision::Action(wb.to_action()),
        },
        reqinfo,
        tags,
    )
}
pub fn content_filter_check_generic_request_map ( configpath : & str , raw : & RawRequest , content_filter_id : & str , logs : & mut Logs , ) -> ( Decision , RequestInfo , Tags ) { let mut tags = Tags :: default ( ) ; logs . debug ( " " ) ; let waf_profile = match with_config ( configpath , logs , | _slogs , cfg | { cfg . content_filter_profiles . get ( content_filter_id ) . cloned ( ) } ) { Some ( Some ( prof ) ) => prof , _ => { logs . error ( " " ) ; return ( Decision :: Pass , map_request ( logs , & [ ] , & [ ] , 25 , raw ) , tags ) ; } } ; if let Some ( body ) = raw . mbody { if body . len ( ) > waf_profile . max_body_size { logs . error ( " " ) ; let reqinfo = map_request ( logs , & waf_profile . decoding , & [ ] , 0 , raw ) ; return ( Decision :: Action ( body_too_large ( waf_profile . max_body_size , body . len ( ) ) ) , reqinfo , tags , ) ; } } let reqinfo = map_request ( logs , & waf_profile . decoding , & [ ] , waf_profile . max_body_depth , raw ) ; let waf_result = match HSDB . read ( ) { Ok ( rd ) => content_filter_check ( logs , & mut tags , & reqinfo , & waf_profile , rd . get ( content_filter_id ) ) , Err ( rr ) => { logs . error ( | | format ! ( " " rr ) ) ; Ok ( ( ) ) } } ; logs . debug ( " " ) ; ( match waf_result { Ok ( ( ) ) => Decision :: Pass , Err ( wb ) => Decision :: Action ( wb . to_action ( ) ) , } , reqinfo , tags , ) }
generic entry point when the request map has already been parsed
generic entry point when the request map has already been parsed
configpath
&str
raw
&RawRequest
content_filter_id
&str
logs
&mut Logs