Skip to content

Commit

Permalink
Thunder::SetConfiguration jsonrpc: validate json config before setting (
Browse files Browse the repository at this point in the history
#1615)

* Thunder::SetConfiguration jsonrpc: validate json config before setting

* JSON:Variant: parsing updates

---------

Co-authored-by: Pierre Wielders <[email protected]>
  • Loading branch information
HaseenaSainul and pwielders authored Jun 12, 2024
1 parent 9d6a510 commit 2419474
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Source/Thunder/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,21 @@ namespace Plugin {
ASSERT(_pluginServer != nullptr);

if (_pluginServer->Services().FromIdentifier(callsign, service) == Core::ERROR_NONE) {
result = service->ConfigLine(configuration);
Core::JSON::Variant config;
Core::OptionalType<Core::JSON::Error> error;
config.FromString(configuration, error);
result = Core::ERROR_INCOMPLETE_CONFIG;
if (error.IsSet() == true) {
SYSLOG(Logging::ParsingError, (_T("Parsing failed with %s"), ErrorDisplayMessage(error.Value()).c_str()));
} else if (config.IsValid() != true) {
SYSLOG(Logging::ParsingError, (_T("Given configuration is not valid")));
} else {
result = service->ConfigLine(configuration);

// Normalise return code
if (result != Core::ERROR_NONE) {
result = Core::ERROR_GENERAL;
// Normalise return code
if (result != Core::ERROR_NONE) {
result = Core::ERROR_GENERAL;
}
}
}

Expand Down

0 comments on commit 2419474

Please sign in to comment.