Skip to content

Commit

Permalink
Add relative rule uid to report modules (#167)
Browse files Browse the repository at this point in the history
Signed-off-by: romanodanilo <[email protected]>
  • Loading branch information
romanodanilo authored and hoangtungdinh committed Oct 10, 2024
1 parent 295aca7 commit 6c0505a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,12 @@ void cCheckerWidget::ShowDetails(cIssue *const itemToShow) const
}

ssDetails << itemToShow->GetIssueLevelStr().c_str() << " | " << itemToShow->GetDescription().c_str();
if (itemToShow->GetRuleUID() != "")
{
ssDetails << "\nruleUID: ";
ssDetails << itemToShow->GetRuleUID().c_str();
}

// Add extended informations to description if present
std::stringstream extended_info_stream;
if (itemToShow->HasLocations())
Expand Down
50 changes: 43 additions & 7 deletions src/report_modules/report_module_text/src/report_format_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ void WriteResults(const char *file, cResultContainer *ptrResultContainer)
std::list<cIssue *> issues;
std::list<cRule *> rules;
std::list<cMetadata *> metadata;
std::set<std::string> violated_rules;
std::set<std::string> info_violated_rules;
std::set<std::string> warning_violated_rules;
std::set<std::string> error_violated_rules;
std::set<std::string> addressed_rules;

if (outFile.is_open())
Expand Down Expand Up @@ -344,10 +346,28 @@ void WriteResults(const char *file, cResultContainer *ptrResultContainer)
ss << "\n " << mapIssueLevelToString[(*it_Issue)->GetIssueLevel()]
<< (*it_Issue)->GetDescription();

if ((*it_Issue)->GetRuleUID() != "")
{
ss << "\n "
<< "ruleUID: " << (*it_Issue)->GetRuleUID();
}

PrintExtendedInformationIntoStream((*it_Issue), &ss);
if ((*it_Issue)->GetRuleUID() != "")
{
violated_rules.insert((*it_Issue)->GetRuleUID());
eIssueLevel current_issue_level = (*it_Issue)->GetIssueLevel();
if (current_issue_level == eIssueLevel::INFO_LVL)
{
info_violated_rules.insert((*it_Issue)->GetRuleUID());
}
if (current_issue_level == eIssueLevel::WARNING_LVL)
{
warning_violated_rules.insert((*it_Issue)->GetRuleUID());
}
if (current_issue_level == eIssueLevel::ERROR_LVL)
{
error_violated_rules.insert((*it_Issue)->GetRuleUID());
}
}
if ((*it_Issue)->HasDomainSpecificInfo())
{
Expand Down Expand Up @@ -408,10 +428,24 @@ void WriteResults(const char *file, cResultContainer *ptrResultContainer)
ss << "\n\t-> Addressed RuleUID: " << str << "\n";
}

ss << "\nTotal number of violated rules: " << violated_rules.size();
for (const auto &str : violated_rules)
int total_number_of_violated_rules =
info_violated_rules.size() + warning_violated_rules.size() + error_violated_rules.size();
ss << "\nTotal number of violated rules: " << total_number_of_violated_rules << "\n";

ss << "\nInfo violated rules: " << info_violated_rules.size();
for (const auto &str : info_violated_rules)
{
ss << "\n\t-> Violated RuleUID: " << str << "\n";
ss << "\n\t-> Info violation RuleUID: " << str;
}
ss << "\nWarning violated rules: " << warning_violated_rules.size();
for (const auto &str : warning_violated_rules)
{
ss << "\n\t-> Warning violation RuleUID: " << str;
}
ss << "\nError violated rules: " << error_violated_rules.size();
for (const auto &str : error_violated_rules)
{
ss << "\n\t-> Error violation RuleUID: " << str;
}

ss << "\n" << BASIC_SEPARATOR_LINE << "\n";
Expand Down Expand Up @@ -465,8 +499,10 @@ void PrintExtendedInformationIntoStream(cIssue *issue, std::stringstream *ssStre
{
for (const auto location : issue->GetLocationsContainer())
{
*ssStream << "\n " << location->GetDescription();

if (location->GetDescription() != "")
{
*ssStream << "\n " << location->GetDescription();
}
std::list<cExtendedInformation *> extendedInfos = location->GetExtendedInformations();

for (std::list<cExtendedInformation *>::iterator extIt = extendedInfos.begin(); extIt != extendedInfos.end();
Expand Down

0 comments on commit 6c0505a

Please sign in to comment.