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.cpp b/src/report_manager.cpp
index 9ea6026..24087c3 100644
--- a/src/report_manager.cpp
+++ b/src/report_manager.cpp
@@ -28,6 +28,10 @@
                 "MaxReports", size_t{}, sdbusplus::vtable::property_::const_,
                 [](const auto&) { return maxReports; });
             dbusIface.register_property_r(
+                "MaxReportNameLength", size_t{},
+                sdbusplus::vtable::property_::const_,
+                [](const auto&) { return maxReportNameLength; });
+            dbusIface.register_property_r(
                 "MinInterval", uint64_t{}, sdbusplus::vtable::property_::const_,
                 [](const auto&) -> uint64_t { return minInterval.count(); });
 
@@ -57,6 +61,16 @@
         reports.end());
 }
 
+void ReportManager::verifyReportNameLength(const std::string& reportName)
+{
+    if (reportName.length() > maxReportNameLength)
+    {
+        throw sdbusplus::exception::SdBusError(
+            static_cast<int>(std::errc::invalid_argument),
+            "Report name exceed maximum length");
+    }
+}
+
 void ReportManager::verifyAddReport(const std::string& reportName,
                                     const std::string& reportingType,
                                     std::chrono::milliseconds interval,
@@ -69,6 +83,8 @@
             "Reached maximal report count");
     }
 
+    verifyReportNameLength(reportName);
+
     for (const auto& report : reports)
     {
         if (report->getName() == reportName)