Skip to content

Commit 601e5f9

Browse files
committed
Add new test /scanning/disa-stig-viewer-results
The new test verifies that results generated by OpenSCAP using the `--stig-viewer` option are compatible with the DISA STIG Viewer. This commit also extends the `/static-checks/rule-identifiers` test to verify all rules from the STIG profile contain `stigref` references which are used when results are imported into the DISA STIG Viewer.
1 parent 093a3e8 commit 601e5f9

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

conf/waivers/productization

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,20 @@
4040

4141
# RHEL10 - No official RHEL10 STIG benchmark yet
4242
/static-checks/rule-identifiers/stig/stigid/.*
43+
/static-checks/rule-identifiers/stig/stigref/.*
44+
/scanning/disa-stig-viewer-results
4345
rhel == 10
4446
# RHEL8 https://github.com/ComplianceAsCode/content/issues/12422
4547
/static-checks/rule-identifiers/ospp/ospp/.*
4648
rhel == 8
49+
# https://github.com/ComplianceAsCode/content/issues/14359
50+
/static-checks/rule-identifiers/stig/stigref/enable_authselect
51+
rhel == 8 or rhel == 9
52+
/static-checks/rule-identifiers/stig/stigref/configure_kerberos_crypto_policy
53+
/static-checks/rule-identifiers/stig/stigref/file_permissions_etc_audit_auditd
54+
/static-checks/rule-identifiers/stig/stigref/file_sshd_50_redhat_exists
55+
/static-checks/rule-identifiers/stig/stigref/sshd_include_crypto_policy
56+
rhel == 9
4757

4858
# bz1825810 or maybe bz1929805
4959
# can be reproduced mostly reliably (95%) both via anaconda and oscap CLI,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
summary: Run oscap scan with STIG profile and verify results compatible with DISA STIG Viewer
2+
description: |-
3+
Verify that results generated by OpenSCAP using the `--stig-viewer`
4+
option are compatible with the DISA STIG Viewer.
5+
test: $CONTEST_PYTHON -m lib.runtest ./test.py
6+
result: custom
7+
environment+:
8+
PYTHONPATH: ../..
9+
duration: 30m
10+
require+:
11+
- openscap-scanner
12+
adjust+:
13+
- when: arch != x86_64
14+
enabled: false
15+
because: the test is not architecture-specific, one is enough
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/python3
2+
3+
import re
4+
import subprocess
5+
6+
from lib import util, results
7+
8+
proc = util.subprocess_run(
9+
['oscap', 'xccdf', 'eval', '--profile', 'stig', '--progress',
10+
'--stig-viewer', 'stig_results.xml', util.get_datastream()],
11+
stderr=subprocess.STDOUT)
12+
if proc.returncode not in [0,2]:
13+
raise RuntimeError("oscap failed unexpectedly")
14+
results.add_log('stig_results.xml')
15+
16+
# parse stig_results.xml and count STIG results
17+
with open('stig_results.xml') as f:
18+
stig_content = f.read()
19+
stig_results_count = len(re.findall(r'<rule-result\s+idref="SV-', stig_content))
20+
21+
note = f'number of rules with STIG Viewer reference: {stig_results_count}'
22+
if stig_results_count > 0:
23+
results.report_and_exit('pass', note=note)
24+
else:
25+
results.report_and_exit('fail', note=note)

static-checks/rule-identifiers/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Associations between profiles and reference names
1616
profile_reference_names = {
1717
'bsi': ['bsi'],
18-
'stig': ['stigid', 'os-srg'],
18+
'stig': ['stigid', 'os-srg', 'stigref'],
1919
'ospp': ['ospp'],
2020
'cis': ['cis'],
2121
'anssi_bp28_high': ['anssi'],

0 commit comments

Comments
 (0)