OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ddl_utils::FilePathWhitelist Class Reference

#include <DdlUtils.h>

Static Public Member Functions

static void initializeFromConfigFile (const std::string &server_config_path)
 
static void validateWhitelistedFilePath (const std::vector< std::string > &expanded_file_paths, const DataTransferType data_transfer_type)
 
static void clear ()
 

Static Private Attributes

static std::vector< std::string > whitelisted_import_paths_ {}
 
static std::vector< std::string > whitelisted_export_paths_ {}
 

Detailed Description

Definition at line 82 of file DdlUtils.h.

Member Function Documentation

void ddl_utils::FilePathWhitelist::clear ( )
static

Definition at line 716 of file DdlUtils.cpp.

References whitelisted_export_paths_, and whitelisted_import_paths_.

716  {
719 }
static std::vector< std::string > whitelisted_export_paths_
Definition: DdlUtils.h:92
static std::vector< std::string > whitelisted_import_paths_
Definition: DdlUtils.h:91
void ddl_utils::FilePathWhitelist::initializeFromConfigFile ( const std::string &  server_config_path)
static

Definition at line 661 of file DdlUtils.cpp.

References ddl_utils::set_whitelisted_paths(), whitelisted_export_paths_, and whitelisted_import_paths_.

Referenced by CommandLineOptions::validate().

661  {
662  if (server_config_path.empty()) {
663  return;
664  }
665 
666  if (!boost::filesystem::exists(server_config_path)) {
667  throw std::runtime_error{"Configuration file at \"" + server_config_path +
668  "\" does not exist."};
669  }
670 
671  std::string import_config_key{"allowed-import-paths"};
672  std::string export_config_key{"allowed-export-paths"};
673  std::string import_config_value, export_config_value;
674 
675  namespace po = boost::program_options;
676  po::options_description desc{};
677  desc.add_options()(import_config_key.c_str(),
678  po::value<std::string>(&import_config_value));
679  desc.add_options()(export_config_key.c_str(),
680  po::value<std::string>(&export_config_value));
681  po::variables_map vm;
682  po::store(po::parse_config_file<char>(server_config_path.c_str(), desc, true), vm);
683  po::notify(vm);
684  if (vm.count(import_config_key)) {
686  import_config_key, import_config_value, whitelisted_import_paths_);
687  }
688  if (vm.count(export_config_key)) {
690  export_config_key, export_config_value, whitelisted_export_paths_);
691  }
692 }
static std::vector< std::string > whitelisted_export_paths_
Definition: DdlUtils.h:92
static std::vector< std::string > whitelisted_import_paths_
Definition: DdlUtils.h:91
void set_whitelisted_paths(const std::string &config_key, const std::string &config_value, std::vector< std::string > &whitelisted_paths)
Definition: DdlUtils.cpp:638

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ddl_utils::FilePathWhitelist::validateWhitelistedFilePath ( const std::vector< std::string > &  expanded_file_paths,
const DataTransferType  data_transfer_type 
)
static

Definition at line 694 of file DdlUtils.cpp.

References ddl_utils::EXPORT, ddl_utils::IMPORT, UNREACHABLE, ddl_utils::validate_expanded_file_path(), whitelisted_export_paths_, and whitelisted_import_paths_.

Referenced by ddl_utils::validate_allowed_file_path().

696  {
697  // Skip validation if no whitelist configuration is provided.
698  if ((data_transfer_type == DataTransferType::IMPORT &&
699  whitelisted_import_paths_.empty()) ||
700  (data_transfer_type == DataTransferType::EXPORT &&
701  whitelisted_export_paths_.empty())) {
702  return;
703  }
704 
705  for (const auto& path : expanded_file_paths) {
706  if (data_transfer_type == DataTransferType::IMPORT) {
708  } else if (data_transfer_type == DataTransferType::EXPORT) {
710  } else {
711  UNREACHABLE();
712  }
713  }
714 }
static std::vector< std::string > whitelisted_export_paths_
Definition: DdlUtils.h:92
#define UNREACHABLE()
Definition: Logger.h:241
static std::vector< std::string > whitelisted_import_paths_
Definition: DdlUtils.h:91
void validate_expanded_file_path(const std::string &file_path, const std::vector< std::string > &whitelisted_root_paths)
Definition: DdlUtils.cpp:572

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

std::vector< std::string > ddl_utils::FilePathWhitelist::whitelisted_export_paths_ {}
staticprivate

Definition at line 92 of file DdlUtils.h.

Referenced by clear(), initializeFromConfigFile(), and validateWhitelistedFilePath().

std::vector< std::string > ddl_utils::FilePathWhitelist::whitelisted_import_paths_ {}
staticprivate

Definition at line 91 of file DdlUtils.h.

Referenced by clear(), initializeFromConfigFile(), and validateWhitelistedFilePath().


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