diff --git a/CHANGES.md b/CHANGES.md index fad0701..0d7e919 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/src/workerfindingsreport.cpp b/src/workerfindingsreport.cpp index 0d702e7..431ef1e 100755 --- a/src/workerfindingsreport.cpp +++ b/src/workerfindingsreport.cpp @@ -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); } } @@ -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; } } }