library/src/filesystem/BP-FilesystemRegistryPolicyCheckValidators.cc
// This will check a files stat, dirent, and filename policies and will
// return true or false based around policy matching.
This will check a files stat, dirent, and filename policies and will
return true or false based around policy matching.
This will check a files stat dirent and filename policies and will return true or false based around policy matching .
BP_BOOL BP_FSRegCheckFileAgainstCrawlPolicy
(
		P_BP_FSREG                      fs_reg,
		P_BP_FSREG_POLICIES             fs_reg_pol,
		P_BP_HASH_TABLE_KEYED_ENTRY     parent_table,
		char *                          filename,
		char *                          path,
		char *                          full_path,
		struct stat *                   file_stat,
		struct stat *                   file_lstat,
		struct dirent *                 file_dirent,
		P_BP_FSREG_FILE_POLICY_ANALYSIS policy_analysis_inout
)
{
	if(!fs_reg)
		return BP_FALSE;
	if(!fs_reg->hreg)
		return BP_FALSE;
	if(!fs_reg_pol)
		return BP_FALSE;
	if(!filename)
		return BP_FALSE;
	if(!file_stat)
		return BP_FALSE;
	if(!file_dirent)
		return BP_FALSE;
	if(!policy_analysis_inout)
		return BP_FALSE;
	BP_HASH_TABLE_ENTER_CRITICAL_SECTION(fs_reg->hreg);
	BP_BOOL symlink_check_ok   =  BP_FSRegCheckFileAgainstCrawlSymlinkPolicy     (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL hidden_check_ok    =  BP_FSRegCheckFileAgainstCrawlHiddenPolicy      (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL fifo_check_ok      =  BP_FSRegCheckFileAgainstCrawlFifoPolicy        (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL directory_check_ok =  BP_FSRegCheckFileAgainstCrawlDirectoryPolicy   (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL file_check_ok      =  BP_FSRegCheckFileAgainstCrawlFilePolicy        (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL chr_check_ok       =  BP_FSRegCheckFileAgainstCrawlChrDevicePolicy   (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL blk_check_ok       =  BP_FSRegCheckFileAgainstCrawlBlockDevicePolicy (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL sock_check_ok      =  BP_FSRegCheckFileAgainstCrawlSocketPolicy      (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL preg_check_ok      =  BP_FSRegCheckFileAgainstCrawlFilenamePregPolicy(BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL symlink_enforce_ok   = BP_FSRegEnforceFileAgainstCrawlSymlinkPolicy     (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL hidden_enforce_ok    = BP_FSRegEnforceFileAgainstCrawlHiddenPolicy      (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL fifo_enforce_ok      = BP_FSRegEnforceFileAgainstCrawlFifoPolicy        (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL directory_enforce_ok = BP_FSRegEnforceFileAgainstCrawlDirectoryPolicy   (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL file_enforce_ok      = BP_FSRegEnforceFileAgainstCrawlFilePolicy        (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL chr_enforce_ok       = BP_FSRegEnforceFileAgainstCrawlChrDevicePolicy   (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL blk_enforce_ok       = BP_FSRegEnforceFileAgainstCrawlBlockDevicePolicy (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL sock_enforce_ok      = BP_FSRegEnforceFileAgainstCrawlSocketPolicy      (BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	BP_BOOL preg_enforce_ok      = BP_FSRegEnforceFileAgainstCrawlFilenamePregPolicy(BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH);
	if
	(
		!symlink_enforce_ok   ||
		!hidden_enforce_ok    ||
		!fifo_enforce_ok      ||
		!directory_enforce_ok ||
		!file_enforce_ok      ||
		!chr_enforce_ok       ||
		!blk_enforce_ok       ||
		!sock_enforce_ok      ||
		!preg_enforce_ok
	)
	{
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(fs_reg->hreg, BP_FALSE);
	}
	BP_HASH_TABLE_LEAVE_CRITICAL_SECTION(fs_reg->hreg);
	return BP_TRUE;
}
BP_BOOL BP_FSRegCheckFileAgainstCrawlPolicy ( P_BP_FSREG fs_reg , P_BP_FSREG_POLICIES fs_reg_pol , P_BP_HASH_TABLE_KEYED_ENTRY parent_table , char * filename , char * path , char * full_path , struct stat * file_stat , struct stat * file_lstat , struct dirent * file_dirent , P_BP_FSREG_FILE_POLICY_ANALYSIS policy_analysis_inout ) { if ( ! fs_reg ) return BP_FALSE ; if ( ! fs_reg -> hreg ) return BP_FALSE ; if ( ! fs_reg_pol ) return BP_FALSE ; if ( ! filename ) return BP_FALSE ; if ( ! file_stat ) return BP_FALSE ; if ( ! file_dirent ) return BP_FALSE ; if ( ! policy_analysis_inout ) return BP_FALSE ; BP_HASH_TABLE_ENTER_CRITICAL_SECTION ( fs_reg -> hreg ) ; BP_BOOL symlink_check_ok = BP_FSRegCheckFileAgainstCrawlSymlinkPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL hidden_check_ok = BP_FSRegCheckFileAgainstCrawlHiddenPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL fifo_check_ok = BP_FSRegCheckFileAgainstCrawlFifoPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL directory_check_ok = BP_FSRegCheckFileAgainstCrawlDirectoryPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL file_check_ok = BP_FSRegCheckFileAgainstCrawlFilePolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL chr_check_ok = BP_FSRegCheckFileAgainstCrawlChrDevicePolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL blk_check_ok = BP_FSRegCheckFileAgainstCrawlBlockDevicePolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL sock_check_ok = BP_FSRegCheckFileAgainstCrawlSocketPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL preg_check_ok = BP_FSRegCheckFileAgainstCrawlFilenamePregPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL symlink_enforce_ok = BP_FSRegEnforceFileAgainstCrawlSymlinkPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL hidden_enforce_ok = BP_FSRegEnforceFileAgainstCrawlHiddenPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL fifo_enforce_ok = BP_FSRegEnforceFileAgainstCrawlFifoPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL directory_enforce_ok = BP_FSRegEnforceFileAgainstCrawlDirectoryPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL file_enforce_ok = BP_FSRegEnforceFileAgainstCrawlFilePolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL chr_enforce_ok = BP_FSRegEnforceFileAgainstCrawlChrDevicePolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL blk_enforce_ok = BP_FSRegEnforceFileAgainstCrawlBlockDevicePolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL sock_enforce_ok = BP_FSRegEnforceFileAgainstCrawlSocketPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; BP_BOOL preg_enforce_ok = BP_FSRegEnforceFileAgainstCrawlFilenamePregPolicy ( BP_FSREG_CHECK_FILE_FUNC_PARMS_PASSTHROUGH ) ; if ( ! symlink_enforce_ok || ! hidden_enforce_ok || ! fifo_enforce_ok || ! directory_enforce_ok || ! file_enforce_ok || ! chr_enforce_ok || ! blk_enforce_ok || ! sock_enforce_ok || ! preg_enforce_ok ) { BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( fs_reg -> hreg , BP_FALSE ) ; } BP_HASH_TABLE_LEAVE_CRITICAL_SECTION ( fs_reg -> hreg ) ; return BP_TRUE ; }
This will check a files stat, dirent, and filename policies and will
return true or false based around policy matching.
This will check a files stat dirent and filename policies and will return true or false based around policy matching .
// ensure we have a valid registry // enter critical section before creating new record // file_stat, // file_lstat, // file_dirent // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Generate Appropriate buffers %%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // printf("\n [+]  Running Policy Check: "); // printf("\n    Got filename: %s", filename ); // printf("\n    Got path:     %s", path     ); // printf("\n    Got fullpath: %s", full_path); // printf("\n"); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Run Policy Checks to Generate Flag Matrix %%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // run linear checks // --- Begin Cascading Exclusionary Checks ---------------- // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Run Enforcement Checks %%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // final exit checks after policy enforcement checks // run. // printf("\n One or more policy validations failed?!"); // exit critical section and return // return indicating false