Skip to content

Commit

Permalink
attempt 2 at removing duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
squinky86 committed Oct 26, 2023
1 parent 28456b5 commit 4e30836
Showing 1 changed file with 36 additions and 37 deletions.
73 changes: 36 additions & 37 deletions src/workerfindingsreport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ void WorkerFindingsReport::process()
QVector<STIGCheck> failedChecksDup;
for (auto j = i.value().constBegin(); j != i.value().constEnd(); j++)
{
Q_EMIT progress(-1);
if (failedCCIs.contains(*j))
{
auto failedChecks = failedCCIs.value(*j);
Expand All @@ -319,50 +320,48 @@ 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)
{
auto width = (2472 / numFailure) - (13 + sc2.rule.length());
if (technicalDesc.isEmpty())
technicalDesc = QStringLiteral("Technical Vulnerabilities:");
technicalDesc += "\n\n-----" + sc2.rule + "-----\n";
if (width > 15)
{
QString tmpVulnDisc = sc2.vulnDiscussion;
if (tmpVulnDisc.length() > width)
{
tmpVulnDisc.truncate(width - 11);
tmpVulnDisc += "(truncated)";
}
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)
{
tmpVulnFix.truncate(width - 11);
tmpVulnFix += "(truncated)";
}
technicalRec += tmpVulnFix;
}
}
}
}
}
Q_EMIT progress(-1);
if (notFirst)
preamble = preamble + QStringLiteral(",");
preamble = preamble + QStringLiteral(" ") + PrintCCI(*j);
notFirst = true;
}
for (auto sc2 = failedChecksDup.constBegin(); sc2 != failedChecksDup.constEnd(); sc2++)
{
//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)
{
QString tmpVulnDisc = sc2->vulnDiscussion;
if (tmpVulnDisc.length() > width)
{
tmpVulnDisc.truncate(width - 11);
tmpVulnDisc += "(truncated)";
}
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)
{
tmpVulnFix.truncate(width - 11);
tmpVulnFix += "(truncated)";
}
technicalRec += tmpVulnFix;
}
}
}
worksheet_write_string(wsControls, onRow, 1, preamble.toStdString().c_str(), fmtWrapped);
if (technicalDesc.isEmpty())
technicalDesc = QStringLiteral("Documentation Deficiency");
Expand Down

0 comments on commit 4e30836

Please sign in to comment.