Skip to content

Commit

Permalink
Validate YAML tags on parsing
Browse files Browse the repository at this point in the history
Signed-off-by: tempate <[email protected]>
  • Loading branch information
Tempate committed Apr 11, 2024
1 parent 94c3ff1 commit 35cebcf
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion ddsrecorder_yaml/src/cpp/replayer/YamlReaderConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <ddspipe_yaml/yaml_configuration_tags.hpp>
#include <ddspipe_yaml/Yaml.hpp>
#include <ddspipe_yaml/YamlManager.hpp>
#include <ddspipe_yaml/YamlValidator.hpp>

#include <ddsrecorder_yaml/replayer/yaml_configuration_tags.hpp>
#include <ddsrecorder_yaml/replayer/YamlReaderConfiguration.hpp>
Expand Down Expand Up @@ -67,6 +68,13 @@ void ReplayerConfiguration::load_ddsreplayer_configuration_(
{
YamlReaderVersion version = LATEST;

const std::set<TagType> 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))
Expand Down Expand Up @@ -165,6 +173,16 @@ void ReplayerConfiguration::load_replay_configuration_(
const Yaml& yml,
const YamlReaderVersion& version)
{
const std::set<TagType> 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))
{
Expand Down Expand Up @@ -214,6 +232,13 @@ void ReplayerConfiguration::load_specs_configuration_(
const Yaml& yml,
const YamlReaderVersion& version)
{
const std::set<TagType> 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))
{
Expand All @@ -224,7 +249,7 @@ void ReplayerConfiguration::load_specs_configuration_(
// Get optional Topic QoS
if (YamlReader::is_tag_present(yml, SPECS_QOS_TAG))
{
YamlReader::fill<TopicQoS>(topic_qos, YamlReader::get_value_in_tag(yml, SPECS_QOS_TAG), version);
topic_qos = YamlReader::get<TopicQoS>(yml, SPECS_QOS_TAG, version);
TopicQoS::default_topic_qos.set_value(topic_qos);
}

Expand All @@ -248,6 +273,17 @@ void ReplayerConfiguration::load_dds_configuration_(
const Yaml& yml,
const YamlReaderVersion& version)
{
const std::set<TagType> 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))
{
Expand Down

0 comments on commit 35cebcf

Please sign in to comment.