8000 [Dev] Fix `allowed_directories` crash by Tishj · Pull Request #17548 · duckdb/duckdb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Dev] Fix allowed_directories crash #17548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main/settings/custom_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ void AllowedDirectoriesSetting::SetGlobal(DatabaseInstance *db, DBConfig &config
if (!config.options.enable_external_access) {
throw InvalidInputException("Cannot change allowed_directories when enable_external_access is disabled");
}
if (!config.file_system) {
throw InvalidInputException("Cannot change/set allowed_directories before the database is started");
}
config.options.allowed_directories.clear();
auto &list = ListValue::GetChildren(input);
for (auto &val : list) {
Expand Down Expand Up @@ -226,6 +229,10 @@ void AllowedPathsSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, cons
if (!config.options.enable_external_access) {
throw InvalidInputException("Cannot change allowed_paths when enable_external_access is disabled");
}
if (!config.file_system) {
throw InvalidInputException("Cannot change/set allowed_paths before the database is started");
}

config.options.allowed_paths.clear();
auto &list = ListValue::GetChildren(input);
for (auto &val : list) {
Expand Down
23 changes: 23 additions & 0 deletions test/api/test_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ TEST_CASE("Test DB config configuration", "[api]") {
}
}

TEST_CASE("Test allowed options", "[api]") {
case_insensitive_map_t<Value> config_dict;
string option;

SECTION("allowed_directories") {
config_dict.emplace("allowed_directories", Value::LIST({Value("test")}));
option = "allowed_directories";
}
SECTION("allowed_paths") {
config_dict.emplace("allowed_paths", Value::LIST({Value("test")}));
option = "allowed_paths";
}

try {
DBConfig config(config_dict, false);
} catch (std::exception &ex) {
ErrorData error_data(ex);
REQUIRE(error_data.Type() == ExceptionType::INVALID_INPUT);
REQUIRE(error_data.RawMessage() ==
StringUtil::Format("Cannot change/set %s before the database is started", option));
}
}

TEST_CASE("Test user_agent", "[api]") {
{
// Default duckdb_api is cpp
Expand Down
Loading
0