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 Plugin. #1125

Merged
merged 25 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions include/fastdds/rtps/security/accesscontrol/AccessControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Authentication;
class SecurityException;
struct ParticipantSecurityAttributes;
struct EndpointSecurityAttributes;
class Logging;

class AccessControl
{
Expand Down Expand Up @@ -152,6 +153,25 @@ class AccessControl
const std::vector<std::string>& partitions,
EndpointSecurityAttributes& attributes,
SecurityException& exception) = 0;

bool set_logger(
Logging* logger,
SecurityException& /*exception*/)
{
logger_ = logger;
return true;
}

protected:

const Logging* get_logger()
{
return logger_;
}

private:

Logging* logger_ = nullptr;
};

} //namespace security
Expand Down
19 changes: 19 additions & 0 deletions include/fastdds/rtps/security/authentication/Authentication.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace fastrtps {
namespace rtps {
namespace security {

class Logging;

enum ValidationResult_t : uint32_t
{
VALIDATION_OK = 0,
Expand Down Expand Up @@ -225,6 +227,23 @@ class Authentication
virtual bool return_authenticated_peer_credential_token(PermissionsCredentialToken* token,
SecurityException& ex) = 0;

bool set_logger(Logging* logger,
SecurityException& /*exception*/)
{
logger_ = logger;
return true;
}

protected:

const Logging* get_logger() const
{
return logger_;
}

private:

Logging* logger_ = nullptr;
};

} //namespace security
Expand Down
21 changes: 20 additions & 1 deletion include/fastdds/rtps/security/cryptography/Cryptography.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ namespace fastrtps {
namespace rtps {
namespace security {

class Logging;

class Cryptography
{
public:

Cryptography(): m_cryptokeyexchange(nullptr), m_cryptokeyfactory(nullptr),
m_cryptotransform(nullptr) {}
m_cryptotransform(nullptr), m_logger(nullptr) {}

virtual ~Cryptography() {}

Expand All @@ -44,11 +46,28 @@ class Cryptography

CryptoTransform* cryptotransform() { return m_cryptotransform; }

bool set_logger(
Logging* logger,
SecurityException& /*exception*/)
{
m_logger = logger;
return true;
}

protected:

const Logging* get_logger()
{
return m_logger;
}

CryptoKeyExchange *m_cryptokeyexchange;
CryptoKeyFactory *m_cryptokeyfactory;
CryptoTransform *m_cryptotransform;

private:

Logging *m_logger;
};

} //namespace security
Expand Down
58 changes: 58 additions & 0 deletions include/fastdds/rtps/security/logging/BuiltinLoggingType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// 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
{
octet facility; // Set to 0x0A (10). Indicates sec/auth msgs
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_
52 changes: 52 additions & 0 deletions include/fastdds/rtps/security/logging/LogOptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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/LoggingLevel.h>

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

/**
* @brief The LogOptions struct
* @note Definition in DDS-Sec v1.1 8.6.2.1
*/
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.
LoggingLevel 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_
Loading