• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

squinky86 / STIGQter / 41772281141

04 Nov 2026 04:16AM UTC coverage: 68.902% (-7.0%) from 75.946%
41772281141

push

github

squinky86
Refactor STIGQter and modernize build and update services

8082 of 13137 branches covered (61.52%)

Branch coverage included in aggregate %.

2404 of 2696 new or added lines in 30 files covered. (89.17%)

9 existing lines in 8 files now uncovered.

5914 of 7176 relevant lines covered (82.41%)

38491.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.79
/src/classification.cpp
1
/*
2
 * STIGQter - STIG fun with Qt
3
 *
4
 * Copyright © 2018–2023 Jon Hood, http://www.hoodsecurity.com/
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19

20
#include "common.h"
21
#include <QRegularExpression>
22

23
/**
24
 * @brief GetClassification
25
 * @param marking
26
 * @return The @a Classification level parsed from a free-text marking.
27
 *
28
 * Markings are free text (e.g. "CUI [Controlled by: …]" or
29
 * "TOP SECRET//SI"). A level is only recognized when the marking contains
30
 * the complete classification word (matched case-insensitively on word
31
 * boundaries) — so an incidental marking like "Storage array" does not
32
 * escalate to SECRET. The highest classification word present wins
33
 * ("TOP SECRET" is checked before "SECRET"), and "CONTROLLED" is treated
34
 * as "CUI". Markings with no recognized word are the lowest level,
35
 * @c classPublicRelease.
36
 */
37
Classification GetClassification(const QString &marking)
292 ✔
38
{
39
    const QString m = marking.toUpper();
292 ✔
40
    static const QRegularExpression reTopSecret(QStringLiteral("\\bTOP SECRET\\b"));
293 !
41
    static const QRegularExpression reSecret(QStringLiteral("\\bSECRET\\b"));
293 !
42
    static const QRegularExpression reConfidential(QStringLiteral("\\bCONFIDENTIAL\\b"));
293 !
43
    static const QRegularExpression reCUI(QStringLiteral("\\b(CUI|CONTROLLED)\\b"));
293 !
44
    static const QRegularExpression reFOUO(QStringLiteral("\\bFOUO\\b"));
293 !
45
    static const QRegularExpression reUnclassified(QStringLiteral("\\bUNCLASSIFIED\\b"));
293 !
46

47
    if (m.contains(reTopSecret))
292 !
NEW
48
        return Classification::classTopSecret;
×
49
    if (m.contains(reSecret))
292 !
NEW
50
        return Classification::classSecret;
×
51
    if (m.contains(reConfidential))
292 !
NEW
52
        return Classification::classConfidential;
×
53
    if (m.contains(reCUI))
292 ✔
54
        return Classification::classCUI;
181 ✔
55
    if (m.contains(reFOUO))
111 !
NEW
56
        return Classification::classFOUO;
×
57
    if (m.contains(reUnclassified))
111 ✔
58
        return Classification::classUnclassified;
17 ✔
59
    return Classification::classPublicRelease;
94 ✔
60
}
292 ✔
61

62
/**
63
 * @brief GetClassificationString
64
 * @param classification
65
 * @return The canonical, human-readable label for a @a Classification.
66
 */
67
QString GetClassificationString(Classification classification)
6 ✔
68
{
69
    switch (classification)
6 !
70
    {
71
    case Classification::classUnclassified:
1 ✔
72
        return QStringLiteral("UNCLASSIFIED");
1 ✔
NEW
73
    case Classification::classFOUO:
×
NEW
74
        return QStringLiteral("FOUO");
×
75
    case Classification::classCUI:
1 ✔
76
        return QStringLiteral("CUI");
1 ✔
NEW
77
    case Classification::classConfidential:
×
NEW
78
        return QStringLiteral("CONFIDENTIAL");
×
NEW
79
    case Classification::classSecret:
×
NEW
80
        return QStringLiteral("SECRET");
×
NEW
81
    case Classification::classTopSecret:
×
NEW
82
        return QStringLiteral("TOP SECRET");
×
83
    default:
4 ✔
84
        return QStringLiteral("PUBLIC RELEASE");
4 ✔
85
    }
86
}
87

88
/**
89
 * @brief GetClassificationColor
90
 * @param classification
91
 * @return The banner color for a @a Classification as a 0xRRGGBB value,
92
 * usable both by Qt (QColor/QRgb) and by libxlsxwriter (lxw_color_t).
93
 *
94
 * Colors follow the standard DoD classification banner palette.
95
 */
96
quint32 GetClassificationColor(Classification classification)
95 ✔
97
{
98
    switch (classification)
95 !
99
    {
100
    case Classification::classCUI:
88 ✔
101
        return 0x502B85; //purple
88 ✔
NEW
102
    case Classification::classConfidential:
×
NEW
103
        return 0x0033A0; //blue
×
NEW
104
    case Classification::classSecret:
×
NEW
105
        return 0xC8102E; //red
×
NEW
106
    case Classification::classTopSecret:
×
NEW
107
        return 0xFF8C00; //orange
×
108
    case Classification::classPublicRelease:
7 ✔
109
    case Classification::classUnclassified:
110
    case Classification::classFOUO:
111
    default:
112
        return 0x007A33; //green
7 ✔
113
    }
114
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc