Add limit for report name length
Added limit for report name length, parametrized with
max-report-name-length option, because we cannot
remove reports with too long report name.
Tested:
- Confirmed that report with name length equal to 4096
cannot be generated via bmcweb (POST
redfish/v1/TelemetryService/MetricReportDefinitions
fails with code 500)
- Confirmed that report with name length equal to 4095
can be generated and removed via bmcweb
- Added unit-test that test that report with name
length equal to max-report-name-length + 1 cannot
be generated
- Added unit-test that test that report with name
length equal to max-report-name-length can
be generated
Change-Id: I6868320f831079af903f3624d1beff648059e351
Signed-off-by: Karol Niczyj <karol.niczyj@intel.com>
diff --git a/src/report_manager.hpp b/src/report_manager.hpp
index bb4d395..e66a614 100644
--- a/src/report_manager.hpp
+++ b/src/report_manager.hpp
@@ -5,6 +5,8 @@
#include "interfaces/report_factory.hpp"
#include "interfaces/report_manager.hpp"
+#include <systemd/sd-bus-protocol.h>
+
#include <sdbusplus/asio/object_server.hpp>
#include <chrono>
@@ -36,6 +38,7 @@
std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface;
std::vector<std::unique_ptr<interfaces::Report>> reports;
+ void verifyReportNameLength(const std::string& reportName);
void verifyAddReport(const std::string& reportName,
const std::string& reportingType,
std::chrono::milliseconds interval,
@@ -57,6 +60,8 @@
public:
static constexpr size_t maxReports{TELEMETRY_MAX_REPORTS};
static constexpr size_t maxReadingParams{TELEMETRY_MAX_READING_PARAMS};
+ static constexpr size_t maxReportNameLength{
+ TELEMETRY_MAX_REPORT_NAME_LENGTH};
static constexpr std::chrono::milliseconds minInterval{
TELEMETRY_MIN_INTERVAL};
static constexpr const char* reportManagerIfaceName =