bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESScrub Class Reference

Functions to clean/scrub input for security reasons. More...

#include <BESScrub.h>

Collaboration diagram for BESScrub:
Collaboration graph

Static Public Member Functions

Security functions
static bool command_line_arg_ok (const std::string &arg)
 sanitize command line arguments
 
static bool size_ok (unsigned int sz, unsigned int nelem)
 sanitize the size of an array. Test for integer overflow when dynamically allocating an array.
 
static bool pathname_ok (const std::string &path, bool strict)
 Does the string name a potentailly valid pathname? Test the given pathname to verfiy that it is a valid name. We define this as: Contains only printable characters; and Is less then 256 characters. If strict is true, test that the pathname consists of only letters, digits, and underscore, dash and dot characters instead of the more general case where a pathname can be composed of any printable characters.
 

Detailed Description

Functions to clean/scrub input for security reasons.

Definition at line 40 of file BESScrub.h.

Member Function Documentation

◆ command_line_arg_ok()

bool BESScrub::command_line_arg_ok ( const std::string & arg)
static

sanitize command line arguments

Test the given command line argument to protect against command injections

Parameters
argargument to check
Returns
true if ok, false otherwise

Definition at line 56 of file BESScrub.cc.

◆ pathname_ok()

bool BESScrub::pathname_ok ( const std::string & path,
bool strict )
static

Does the string name a potentailly valid pathname? Test the given pathname to verfiy that it is a valid name. We define this as: Contains only printable characters; and Is less then 256 characters. If strict is true, test that the pathname consists of only letters, digits, and underscore, dash and dot characters instead of the more general case where a pathname can be composed of any printable characters.

Note
Using this function does not guarentee that the path is valid, only that the path could be valid. The intent is foil attacks where an exploit is encoded in a string then passed to a library function. This code does not address whether the pathname references a valid resource.
Parameters
pathThe pathname to test
strictApply more restrictive tests (true by default)
Returns
true if the pathname consists of legal characters and is of legal size, false otherwise.

Definition at line 92 of file BESScrub.cc.

◆ size_ok()

bool BESScrub::size_ok ( unsigned int sz,
unsigned int nelem )
static

sanitize the size of an array. Test for integer overflow when dynamically allocating an array.

Parameters
nelemNumber of elements.
szsize of each element.
Returns
True if the nelem elements of sz size will overflow an array.

Definition at line 70 of file BESScrub.cc.


The documentation for this class was generated from the following files: