Skip to content

Commit

Permalink
fix #122 and fix #123; DFR truncation and duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
squinky86 committed Oct 18, 2023
1 parent c3a438c commit 28456b5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 1.2.7
- Fix duplicate rules in DFR (fixes #121)
- Update truncation method of DFR text (fixes #122)
- Fix duplicate rules in DFR (fixes #122)
- Update truncation method of DFR text (fixes #123)

## 1.2.6 20230807
- Update for blank column T (fixes #118)
Expand Down
59 changes: 31 additions & 28 deletions src/workerfindingsreport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ void WorkerFindingsReport::process()
assets.append(PrintCKLCheck(cc) + samples);
if (!sc.fix.trimmed().isEmpty())
{
fixes.append("\n\n-----" + sc.rule + "-----\n");
if (!fixes.isEmpty())
fixes.append("\n\n");
fixes.append("-----" + sc.rule + "-----\n");
fixes.append(sc.fix);
}
}
Expand Down Expand Up @@ -317,39 +319,40 @@ void WorkerFindingsReport::process()
if (failedChecksDup.contains(sc))
continue;
failedChecksDup.push_back(sc);
}
//calculate amount of text allowed for each entry
auto numFailure = failedChecksDup.count();
if (numFailure > 0)
{
Q_FOREACH (STIGCheck sc2, failedChecksDup)

//calculate amount of text allowed for each entry
auto numFailure = failedChecksDup.count();
if (numFailure > 0)
{
auto width = (2472 / numFailure) - (13 + sc2.rule.length());
if (technicalDesc.isEmpty())
technicalDesc = QStringLiteral("Technical Vulnerabilities:");
technicalDesc += "\n\n-----" + sc2.rule + "-----\n";
if (width > 15)
Q_FOREACH (STIGCheck sc2, failedChecksDup)
{
QString tmpVulnDisc = sc2.vulnDiscussion;
if (tmpVulnDisc.length() > width)
auto width = (2472 / numFailure) - (13 + sc2.rule.length());
if (technicalDesc.isEmpty())
technicalDesc = QStringLiteral("Technical Vulnerabilities:");
technicalDesc += "\n\n-----" + sc2.rule + "-----\n";
if (width > 15)
{
tmpVulnDisc.truncate(width - 11);
tmpVulnDisc += "(truncated)";
QString tmpVulnDisc = sc2.vulnDiscussion;
if (tmpVulnDisc.length() > width)
{
tmpVulnDisc.truncate(width - 11);
tmpVulnDisc += "(truncated)";
}
technicalDesc += tmpVulnDisc;
}
technicalDesc += tmpVulnDisc;
}
if (technicalRec.isEmpty())
technicalRec = QStringLiteral("Technical Recommendations:");
technicalRec += "\n\n-----" + sc2.rule + "-----\n";
if (width > 15)
{
QString tmpVulnFix = sc2.fix;
if (tmpVulnFix.length() > width)
if (technicalRec.isEmpty())
technicalRec = QStringLiteral("Technical Recommendations:");
technicalRec += "\n\n-----" + sc2.rule + "-----\n";
if (width > 15)
{
tmpVulnFix.truncate(width - 11);
tmpVulnFix += "(truncated)";
QString tmpVulnFix = sc2.fix;
if (tmpVulnFix.length() > width)
{
tmpVulnFix.truncate(width - 11);
tmpVulnFix += "(truncated)";
}
technicalRec += tmpVulnFix;
}
technicalRec += tmpVulnFix;
}
}
}
Expand Down

0 comments on commit 28456b5

Please sign in to comment.