From 5073eb653cd9d83408cc5217348332ab4bbdec5b Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 22 Jan 2024 15:10:49 +0100 Subject: [PATCH] Validate YAML tags on parsing Signed-off-by: tempate --- .../cpp/replayer/YamlReaderConfiguration.cpp | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/ddsrecorder_yaml/src/cpp/replayer/YamlReaderConfiguration.cpp b/ddsrecorder_yaml/src/cpp/replayer/YamlReaderConfiguration.cpp index e1fa94b28..46df4de6c 100644 --- a/ddsrecorder_yaml/src/cpp/replayer/YamlReaderConfiguration.cpp +++ b/ddsrecorder_yaml/src/cpp/replayer/YamlReaderConfiguration.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -64,6 +65,13 @@ void ReplayerConfiguration::load_ddsreplayer_configuration_( { YamlReaderVersion version = LATEST; + const std::set tags{ + REPLAYER_REPLAY_TAG, + SPECS_TAG, + REPLAYER_DDS_TAG}; + + YamlValidator::validate_tags(yml, tags); + ///// // Get optional Replayer configuration options if (YamlReader::is_tag_present(yml, REPLAYER_REPLAY_TAG)) @@ -148,6 +156,16 @@ void ReplayerConfiguration::load_replay_configuration_( const Yaml& yml, const YamlReaderVersion& version) { + const std::set tags{ + REPLAYER_REPLAY_INPUT_TAG, + REPLAYER_REPLAY_BEGIN_TAG, + REPLAYER_REPLAY_END_TAG, + REPLAYER_REPLAY_RATE_TAG, + REPLAYER_REPLAY_START_TIME_TAG, + REPLAYER_REPLAY_TYPES_TAG}; + + YamlValidator::validate_tags(yml, tags); + // Get optional input_file if (YamlReader::is_tag_present(yml, REPLAYER_REPLAY_INPUT_TAG)) { @@ -197,6 +215,13 @@ void ReplayerConfiguration::load_specs_configuration_( const Yaml& yml, const YamlReaderVersion& version) { + const std::set tags{ + NUMBER_THREADS_TAG, + SPECS_QOS_TAG, + WAIT_ALL_ACKED_TIMEOUT_TAG}; + + YamlValidator::validate_tags(yml, tags); + // Get number of threads if (YamlReader::is_tag_present(yml, NUMBER_THREADS_TAG)) { @@ -207,7 +232,7 @@ void ReplayerConfiguration::load_specs_configuration_( // Get optional Topic QoS if (YamlReader::is_tag_present(yml, SPECS_QOS_TAG)) { - YamlReader::fill(topic_qos, YamlReader::get_value_in_tag(yml, SPECS_QOS_TAG), version); + topic_qos = YamlReader::get(yml, SPECS_QOS_TAG, version); TopicQoS::default_topic_qos.set_value(topic_qos); } @@ -223,6 +248,17 @@ void ReplayerConfiguration::load_dds_configuration_( const Yaml& yml, const YamlReaderVersion& version) { + const std::set tags{ + DOMAIN_ID_TAG, + WHITELIST_INTERFACES_TAG, + TRANSPORT_DESCRIPTORS_TRANSPORT_TAG, + IGNORE_PARTICIPANT_FLAGS_TAG, + ALLOWLIST_TAG, + BLOCKLIST_TAG, + TOPICS_TAG}; + + YamlValidator::validate_tags(yml, tags); + // Get optional DDS domain if (YamlReader::is_tag_present(yml, DOMAIN_ID_TAG)) {