OmniSciDB  bf83d84833
 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 718 of file DdlUtils.cpp.

References whitelisted_export_paths_, and whitelisted_import_paths_.

718  {
721 }
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 663 of file DdlUtils.cpp.

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

Referenced by CommandLineOptions::validate().

663  {
664  if (server_config_path.empty()) {
665  return;
666  }
667 
668  if (!boost::filesystem::exists(server_config_path)) {
669  throw std::runtime_error{"Configuration file at \"" + server_config_path +
670  "\" does not exist."};
671  }
672 
673  std::string import_config_key{"allowed-import-paths"};
674  std::string export_config_key{"allowed-export-paths"};
675  std::string import_config_value, export_config_value;
676 
677  namespace po = boost::program_options;
678  po::options_description desc{};
679  desc.add_options()(import_config_key.c_str(),
680  po::value<std::string>(&import_config_value));
681  desc.add_options()(export_config_key.c_str(),
682  po::value<std::string>(&export_config_value));
683  po::variables_map vm;
684  po::store(po::parse_config_file<char>(server_config_path.c_str(), desc, true), vm);
685  po::notify(vm);
686  if (vm.count(import_config_key)) {
688  import_config_key, import_config_value, whitelisted_import_paths_);
689  }
690  if (vm.count(export_config_key)) {
692  export_config_key, export_config_value, whitelisted_export_paths_);
693  }
694 }
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:640

+ 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 696 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().

698  {
699  // Skip validation if no whitelist configuration is provided.
700  if ((data_transfer_type == DataTransferType::IMPORT &&
701  whitelisted_import_paths_.empty()) ||
702  (data_transfer_type == DataTransferType::EXPORT &&
703  whitelisted_export_paths_.empty())) {
704  return;
705  }
706 
707  for (const auto& path : expanded_file_paths) {
708  if (data_transfer_type == DataTransferType::IMPORT) {
710  } else if (data_transfer_type == DataTransferType::EXPORT) {
712  } else {
713  UNREACHABLE();
714  }
715  }
716 }
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:574

+ 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: