library/src/network/httpd/BP-HTTPdRequestHandlerParameterFilters.cc
// Run a specific check against a var.  Requires an already looked up filter and variable.
Run a specific check against a var.  Requires an already looked up filter and variable.
Run a specific check against a var . Requires an already looked up filter and variable .
BP_BOOL BP_HTTPdRequestHandlerFilterCheckVarAgainstFilter
(
		P_BP_HTTPD_REQUEST_VAR                      var,
		P_BP_HTTPD_REQUEST_HANDLER_PARAMETER_FILTER filter
)
{
	if(!filter)
		return BP_FALSE;
	if(!filter->key)
		return BP_FALSE;
	if(!filter->filter)
		return BP_FALSE;
	if(!var)
		return BP_FALSE;
	if(!var->name)
		return BP_FALSE;
	if(!BP_StringIsReasonablePrintableString(var->name, bpstrlen(var->name), BP_FALSE, BP_FALSE))
		return BP_FALSE;
	if(!var->type)
		return BP_FALSE;
	if(var->type == BP_HTTPD_REQUEST_VAR_TYPE_POST_DATA)
	{
		if(!var->data)
			return BP_FALSE;
		if(!var->data_size)
			return BP_FALSE;
		if(!filter->filter((void *) filter, var, var->name, var->data, var->data_size))
		{
			return BP_FALSE;
		}
	}
	if(var->type == BP_HTTPD_REQUEST_VAR_TYPE_GET)
	{
		if(!var->data)
			return BP_FALSE;
		if(!var->data_size)
			return BP_FALSE;
		if(!filter->filter((void *) filter, var, var->name, var->data, var->data_size))
		{
			return BP_FALSE;
		}
	}
	if(var->type == BP_HTTPD_REQUEST_VAR_TYPE_COOKIE)
	{
		if(!var->data)
			return BP_FALSE;
		if(!var->data_size)
			return BP_FALSE;
		if(!filter->filter((void *) filter, var, var->name, var->data, var->data_size))
		{
			return BP_FALSE;
		}
	}
	if(var->type == BP_HTTPD_REQUEST_VAR_TYPE_HEADER)
	{
		if(!var->data)
			return BP_FALSE;
		if(!var->data_size)
			return BP_FALSE;
		if(!filter->filter((void *) filter, var, var->name, var->data, var->data_size))
		{
			return BP_FALSE;
		}
	}
	if(var->type == BP_HTTPD_REQUEST_VAR_TYPE_POST_TMPFILE)
	{
	}
	return BP_TRUE;
}
BP_BOOL BP_HTTPdRequestHandlerFilterCheckVarAgainstFilter ( P_BP_HTTPD_REQUEST_VAR var , P_BP_HTTPD_REQUEST_HANDLER_PARAMETER_FILTER filter ) { if ( ! filter ) return BP_FALSE ; if ( ! filter -> key ) return BP_FALSE ; if ( ! filter -> filter ) return BP_FALSE ; if ( ! var ) return BP_FALSE ; if ( ! var -> name ) return BP_FALSE ; if ( ! BP_StringIsReasonablePrintableString ( var -> name , bpstrlen ( var -> name ) , BP_FALSE , BP_FALSE ) ) return BP_FALSE ; if ( ! var -> type ) return BP_FALSE ; if ( var -> type == BP_HTTPD_REQUEST_VAR_TYPE_POST_DATA ) { if ( ! var -> data ) return BP_FALSE ; if ( ! var -> data_size ) return BP_FALSE ; if ( ! filter -> filter ( ( void * ) filter , var , var -> name , var -> data , var -> data_size ) ) { return BP_FALSE ; } } if ( var -> type == BP_HTTPD_REQUEST_VAR_TYPE_GET ) { if ( ! var -> data ) return BP_FALSE ; if ( ! var -> data_size ) return BP_FALSE ; if ( ! filter -> filter ( ( void * ) filter , var , var -> name , var -> data , var -> data_size ) ) { return BP_FALSE ; } } if ( var -> type == BP_HTTPD_REQUEST_VAR_TYPE_COOKIE ) { if ( ! var -> data ) return BP_FALSE ; if ( ! var -> data_size ) return BP_FALSE ; if ( ! filter -> filter ( ( void * ) filter , var , var -> name , var -> data , var -> data_size ) ) { return BP_FALSE ; } } if ( var -> type == BP_HTTPD_REQUEST_VAR_TYPE_HEADER ) { if ( ! var -> data ) return BP_FALSE ; if ( ! var -> data_size ) return BP_FALSE ; if ( ! filter -> filter ( ( void * ) filter , var , var -> name , var -> data , var -> data_size ) ) { return BP_FALSE ; } } if ( var -> type == BP_HTTPD_REQUEST_VAR_TYPE_POST_TMPFILE ) { } return BP_TRUE ; }
Run a specific check against a var.
Run a specific check against a var .
// run basic filter checks // run basic var checks (don't run data checks yet; data checks are run after type is // actualized) // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Check Var Data Against Fitler %%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Note: The following could probably be implemented in an if/or/case but instead was implemented //       in long-form if clauses so that each type could be modified in the future with custom //       behaviors per type.  This results in a small code duplication, but it's fine as a price //       to keep var behaviors conceptually/organizationally contained. // post data // ensure we have data to filter // run filter // return false if the filter fails // http get data // ensure we have data to filter // run filter // return false if the filter fails // cookie data // ensure we have data to filter // run filter // return false if the filter fails // header data // ensure we have data to filter // run filter // return false if the filter fails // --- todo ---- // tmpfile type // todo: implement post tmpfile filter checks (must be done with iterative //       filters due to requests not being stored in memory) // return indicating success if all passes check OK