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
57 changes: 57 additions & 0 deletions include/fastdds/rtps/security/logging/BuiltinLoggingType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2020 Canonical ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* @file BuiltinLoggingType.h
*/
#ifndef _FASTDDS_RTPS_SECURITY_LOGGING_BUILTINLOGGINGTYPE_H_
#define _FASTDDS_RTPS_SECURITY_LOGGING_BUILTINLOGGINGTYPE_H_

#include "fastdds/rtps/common/Types.h"
#include "fastdds/rtps/common/Time_t.h"
#include "fastdds/rtps/security/logging/LoggingLevel.h"
#include "fastdds/rtps/security/logging/NameValuePair.h"

#include <map>

namespace eprosima {
namespace fastrtps {
namespace rtps {
namespace security {

/**
* @brief The BuiltinLoggingType struct
*
* @note Definition in DDS-Sec v1.1 9.6
*/
struct BuiltinLoggingType final {
artivis marked this conversation as resolved.
Show resolved Hide resolved
octet facility; // Set to 0x0A (10). Indicates sec/auth msgs
Copy link

Choose a reason for hiding this comment

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

Fast RTPS seems to use four spaces for indentation. This only seems to be a single space, and elsewhere in the PR there are two. We should probably follow their established format. Try to make the code look like it was written by them.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I will take care of 'fixing' all indentations...

LoggingLevel severity;
rtps::Time_t timestamp; // Since epoch 1970-01-01 00:00:00 +0000 (UTC)
std::string hostname; // IP host name of originator
std::string hostip; // IP address of originator
std::string appname; // Identify the device or application
std::string procid; // Process name/ID for syslog system
std::string msgid; // Identify the type of message
std::string message; // Free-form message
// Note that certain string keys (SD-IDs) are reserved by IANA
std::map<std::string, NameValuePairSeq> structured_data;
};

} //namespace security
} //namespace rtps
} //namespace fastrtps
} //namespace eprosima

#endif // _FASTDDS_RTPS_SECURITY_LOGGING_BUILTINLOGGINGTYPE_H_
48 changes: 48 additions & 0 deletions include/fastdds/rtps/security/logging/EventLogLevel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2020 Canonical ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* @file EventLogLevel.h
*/
#ifndef _FASTDDS_RTPS_SECURITY_LOGGING_EVENTLOGLEVEL_H_
#define _FASTDDS_RTPS_SECURITY_LOGGING_EVENTLOGLEVEL_H_

namespace eprosima {
namespace fastrtps {
namespace rtps {
namespace security {

/**
* @brief The EventLogLevel enum
*
* @note Definition in DDS-Sec v1.1 8.6.2.1.1
Copy link

Choose a reason for hiding this comment

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

This section seems to outline the same information as 9.6, but with different names. I suspect we can remove this struct and use LoggingLevel instead, which seems to be what RTI has done. We should say something on the RTI forums or ping eProsima to make sure we're right, and to raise awareness of the error.

Copy link
Author

Choose a reason for hiding this comment

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

👍

*/
enum struct EventLogLevel : long
{
FATAL_LEVEL = 0, // security error causing a shutdown or failure of the Domain Participant
SEVERE_LEVEL, // major security error or fault
ERROR_LEVEL, // minor security error or fault
WARNING_LEVEL, // undesirable or unexpected behavior
NOTICE_LEVEL, // important security event
INFO_LEVEL, // interesting security event
DEBUG_LEVEL, // detailed information on the flow of the security events
TRACE_LEVEL // even more detailed information
};

} //namespace security
} //namespace rtps
} //namespace fastrtps
} //namespace eprosima

#endif // _FASTDDS_RTPS_SECURITY_LOGGING_EVENTLOGLEVEL_H_
51 changes: 51 additions & 0 deletions include/fastdds/rtps/security/logging/LogOptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2020 Canonical ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* @file LogOptions.h
*/
#ifndef _FASTDDS_RTPS_SECURITY_LOGGING_LOGOPTIONS_H_
#define _FASTDDS_RTPS_SECURITY_LOGGING_LOGOPTIONS_H_

#include <string>

#include "fastdds/rtps/security/logging/EventLogLevel.h"

namespace eprosima {
namespace fastrtps {
namespace rtps {
namespace security {

/**
* @brief The LogOptions struct
*/
struct LogOptions
{
//! Whether the log events should be distributed over DDS
bool distribute;

//! Level at which log messages will be logged.
//! Messages at or below the log_level are logged.
EventLogLevel event_log_level;

//! Full path to a local file
std::string log_file;
};

} //namespace security
} //namespace rtps
} //namespace fastrtps
} //namespace eprosima

#endif // _FASTDDS_RTPS_SECURITY_LOGGING_LOGOPTIONS_H_
115 changes: 115 additions & 0 deletions include/fastdds/rtps/security/logging/Logging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright 2020 Canonical ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* @file Logging.h
*/
#ifndef _FASTDDS_RTPS_SECURITY_LOGGING_LOGGING_H_
#define _FASTDDS_RTPS_SECURITY_LOGGING_LOGGING_H_

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

namespace eprosima {
namespace fastrtps {
namespace rtps {
namespace security {

/**
* @brief The LoggerListener class
*/
class LoggerListener
{
LoggerListener() = default;
~LoggerListener() = default;
};

/**
* @brief Base class for all security logging plugins.
*/
class Logging
{
public:
Copy link

Choose a reason for hiding this comment

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

Check other classes in Fast RTPS, make sure we're following the same format (I think these are indented).


Logging();
virtual ~Logging() = default;

/**
* @brief set_log_options
* @param log_options
* @return TRUE if successful
Copy link

Choose a reason for hiding this comment

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

Could probably flesh out the descriptions using the spec.

Copy link
Author

Choose a reason for hiding this comment

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

Will document properly once the actual implementation is done.

*/
bool set_log_options(const LogOptions& log_options, SecurityException& exception);
kyrofa marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief get_log_options
* @param log_options
* @param exception
* @return
*/
bool get_log_options(LogOptions& log_options, SecurityException& exception) const;
artivis marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief enable_logging
*/
bool enable_logging(SecurityException& exception);

/**
* @brief set_listener
* @param listener
* @return
*/
bool set_listener(LoggerListener* listener, SecurityException& exception);

/**
* @brief log
* @param log_level
* @param message
* @param category
*/
void log(const EventLogLevel event_log_level,
const std::string& message,
const std::string& category,
SecurityException& exception);

protected:

/**
* @brief log_impl
* @param message
* @param category
* @param exception
*/
virtual void log_impl(const std::string& message,
const std::string& category,
SecurityException& exception);

LoggerListener* listener_;

bool logging_enabled_ = false;
bool options_set_ = false;

LogOptions log_options_;
artivis marked this conversation as resolved.
Show resolved Hide resolved

//TODO(artivis):figure out which to use
// Publisher* publisher_; // publisher_ = DomainParticipant::create_publisher(...)
// DataWriter* data_writer_;
};

} //namespace security
} //namespace rtps
} //namespace fastrtps
} //namespace eprosima

#endif // _FASTDDS_RTPS_SECURITY_LOGGING_LOGGING_H_
48 changes: 48 additions & 0 deletions include/fastdds/rtps/security/logging/LoggingLevel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2020 Canonical ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* @file LoggingLevel.h
*/
#ifndef _FASTDDS_RTPS_SECURITY_LOGGING_LOGGINGLEVEL_H_
#define _FASTDDS_RTPS_SECURITY_LOGGING_LOGGINGLEVEL_H_

namespace eprosima {
namespace fastrtps {
namespace rtps {
namespace security {

/**
* @brief The LoggingLevel enum
*
* @note Definition in DDS-Sec v1.1 9.6
*/
enum struct LoggingLevel : long
artivis marked this conversation as resolved.
Show resolved Hide resolved
{
EMERGENCY_LEVEL, // System is unusable. Should not continue use.
ALERT_LEVEL, // Should be corrected immediately
CRITICAL_LEVEL, // A failure in primary application.
ERROR_LEVEL, // General error conditions
WARNING_LEVEL, // May indicate future error if action not taken.
NOTICE_LEVEL, // Unusual, but nor erroneous event or condition.
INFORMATIONAL_LEVEL, // Normal operational. Requires no action.
DEBUG_LEVEL
};

} //namespace security
} //namespace rtps
} //namespace fastrtps
} //namespace eprosima

#endif // _FASTDDS_RTPS_SECURITY_LOGGING_LOGGINGLEVEL_H_
46 changes: 46 additions & 0 deletions include/fastdds/rtps/security/logging/NameValuePair.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2020 Canonical ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* @file NameValuePair.h
*/
#ifndef _FASTDDS_RTPS_SECURITY_LOGGING_NAMEVALUEPAIR_H_
#define _FASTDDS_RTPS_SECURITY_LOGGING_NAMEVALUEPAIR_H_

#include <string>
#include <vector>

namespace eprosima {
namespace fastrtps {
namespace rtps {
namespace security {

/**
* @brief The NameValuePair struct
*
* @note Definition in DDS-Sec v1.1 9.6
*/
struct NameValuePair final {
std::string name;
std::string value;
};

using NameValuePairSeq = std::vector<NameValuePair>;

} //namespace security
} //namespace rtps
} //namespace fastrtps
} //namespace eprosima

#endif // _FASTDDS_RTPS_SECURITY_LOGGING_NAMEVALUEPAIR_H_
1 change: 1 addition & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ set_sources(${${PROJECT_NAME}_source_files})
set(${PROJECT_NAME}_security_source_files
rtps/security/exceptions/SecurityException.cpp
rtps/security/common/SharedSecretHandle.cpp
rtps/security/logging/Logging.cpp
rtps/security/SecurityManager.cpp
rtps/security/SecurityPluginFactory.cpp
fastrtps_deprecated/security/OpenSSLInit.cpp
Expand Down
Loading