Skip to content
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

Add security logging base class #1

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
435b0e4
add basic seclog classes as per dds-spec
artivis Feb 4, 2020
0e57b71
integrate logging to SecurityPluginFactory
artivis Feb 5, 2020
6f46fb9
add missing function definition
artivis Feb 5, 2020
3d902f0
add missing logic piece
artivis Feb 6, 2020
4016a45
typo
artivis Feb 6, 2020
dae5e75
add first seclog utest
artivis Feb 6, 2020
4749c9a
return if invalid log file path
artivis Feb 6, 2020
a93a5be
Logging members private & getters
artivis Feb 6, 2020
5b5f614
add set/get logger to security plugin base classes
artivis Feb 11, 2020
a8a391b
note
artivis Feb 11, 2020
3f8e054
add string_to_EventLogLevel
artivis Feb 13, 2020
1b64b11
logging integration to SecurityManager
artivis Feb 13, 2020
85507b8
add BuiltinLogging skeleton
artivis Feb 20, 2020
22cb93e
security factory create BuiltinLogging
artivis Feb 20, 2020
d4ac406
use BuiltinLogging in unit test
artivis Feb 20, 2020
171f159
change logger access in plugin bases
artivis Feb 25, 2020
017b0a3
make Logging::log const
artivis Feb 25, 2020
3af0b94
ConcurrentQueue final, fix type
artivis Feb 25, 2020
f9367d5
SecurityManager logInfo->logError
artivis Feb 25, 2020
4a9b5c4
rm inlines
artivis Feb 25, 2020
c701936
make Logging::publisher private
artivis Feb 25, 2020
a9156d5
mv BuiltinLogging -> LogTopic
artivis Feb 26, 2020
c83fd75
mv convert to base class
artivis Mar 20, 2020
c3b4c34
temporarily use EventLogLevel instead of LoggingLevel
artivis Mar 20, 2020
d585044
fix properties namespacing
artivis Mar 20, 2020
b0cdbbf
add guid & domaine id
artivis Mar 23, 2020
928ae4e
fix typo
artivis Mar 23, 2020
f57336b
add enable_logging_impl to config derived
artivis Mar 26, 2020
e7c719e
add compose_header
artivis Mar 26, 2020
406a549
cleanup and bugfix
artivis Mar 26, 2020
00def09
add initial logging to file
artivis Mar 26, 2020
4f5a801
log stamp full precision
artivis Mar 27, 2020
9bc52d7
use LoggingLevel as per sec 9.6
artivis Mar 27, 2020
aafbba0
rm EventLogLevel
artivis Mar 31, 2020
e462f19
distribute defaults to false & cleanup
artivis Mar 31, 2020
797e939
cleanup
artivis Mar 31, 2020
6bd8fc4
exception as arg
artivis Apr 1, 2020
bc3563d
add SECURITY_LOGGING macros
artivis Apr 2, 2020
230f8c8
first use of security logging macro
artivis Apr 2, 2020
e36e29c
logging header cosmetic
artivis Apr 2, 2020
a614f51
cleanup
artivis Apr 2, 2020
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
11 changes: 11 additions & 0 deletions include/fastdds/rtps/security/logging/Logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
#ifndef _FASTDDS_RTPS_SECURITY_LOGGING_LOGGING_H_
#define _FASTDDS_RTPS_SECURITY_LOGGING_LOGGING_H_

#include <limits>

#include "fastdds/rtps/security/logging/LogOptions.h"
#include "fastdds/rtps/security/logging/BuiltinLoggingType.h"
#include "fastdds/rtps/security/exceptions/SecurityException.h"
#include "fastdds/rtps/common/Guid.h"

namespace eprosima {
namespace fastrtps {
Expand Down Expand Up @@ -105,6 +108,10 @@ class Logging
*/
LoggerListener const* get_listener() const { return listener_; }

bool set_guid(const GUID_t& guid, SecurityException& exception);

bool set_domaine_id(const uint32_t id, SecurityException& exception);

protected:

/**
Expand Down Expand Up @@ -137,6 +144,10 @@ class Logging
bool options_set_ = false;

LogOptions log_options_;
GUID_t guid_;
std::string guid_str_;
uint32_t domain_id_ = std::numeric_limits<uint32_t>::max();
std::string domain_id_str_;

// DomainParticipant::create_publisher(...)
Publisher* publisher_;
Expand Down
10 changes: 8 additions & 2 deletions src/cpp/rtps/security/SecurityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ bool SecurityManager::init(

SecurityException exception;

domain_id_ = participant_->getRTPSParticipantAttributes().builtin.domainId;

const PropertyPolicy log_properties = PropertyPolicyHelper::get_properties_with_prefix(
participant_->getRTPSParticipantAttributes().properties,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused how these properties are different than the participant_properties handed to this function. Might be worth a comment here.

"dds.sec.log.builtin.DDS_LogTopic.");
Expand Down Expand Up @@ -184,6 +186,12 @@ bool SecurityManager::init(
logInfo(SECURITY, "Logging to file is not yet implemented.");
}

if (!(logging_plugin_->set_guid(participant_->getGuid(), exception) &&
logging_plugin_->set_domaine_id(domain_id_, exception)))
{
return init_logging_fail();
}

if (!( logging_plugin_->set_log_options(log_options, exception) &&
logging_plugin_->enable_logging(exception) ))
{
Expand All @@ -199,8 +207,6 @@ bool SecurityManager::init(
}
}

domain_id_ = participant_->getRTPSParticipantAttributes().builtin.domainId;

authentication_plugin_ = factory_.create_authentication_plugin(participant_properties);

if (authentication_plugin_ != nullptr)
Expand Down
46 changes: 44 additions & 2 deletions src/cpp/rtps/security/logging/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ bool Logging::convert(const EventLogLevel event_log_level,

builtin_msg.structured_data.emplace(
"DDS",
NameValuePairSeq{NameValuePair{"guid", ""},
NameValuePair{"domain_id", ""},
NameValuePairSeq{NameValuePair{"guid", guid_str_},
NameValuePair{"domain_id", domain_id_str_},
NameValuePair{"plugin_class", plugin_class},
NameValuePair{"plugin_method", plugin_method}}
);
Expand All @@ -133,6 +133,48 @@ void Logging::log_impl(const BuiltinLoggingType& /*message*/,
exception = SecurityException("Logging not implemented.");
}

bool Logging::set_guid(const GUID_t& guid, SecurityException& exception)
{
if (GUID_t::unknown() == guid)
{
exception = SecurityException("Invalid guid value.");
return false;
}
else if (GUID_t::unknown() != guid_)
{
exception = SecurityException("Guid already set.");
return false;
}

guid_ = guid;

std::stringstream ss;
ss << guid_;

guid_str_ = ss.str();

return true;
}

bool Logging::set_domaine_id(const uint32_t id, SecurityException& exception)
{
if (std::numeric_limits<uint32_t>::max() == id)
{
exception = SecurityException("Invalid domaine id value.");
return false;
}
else if (std::numeric_limits<uint32_t>::max() == domain_id_)
{
exception = SecurityException("Domaine id already set (" + std::to_string(domain_id_) + ")");
return false;
}

domain_id_ = id;
domain_id_str_ = std::to_string(domain_id_);

return true;
}

} //namespace security
} //namespace rtps
} //namespace fastrtps
Expand Down