Lab 17: OpenSCAP Compliance Automation

Time: 45 minutes | Level: Architect | Docker: docker run -it --rm --privileged ubuntu:22.04 bash

Overview

OpenSCAP (Security Content Automation Protocol) is the industry-standard framework for automated compliance scanning. You will install the OpenSCAP scanner, explore SCAP content (XCCDF/OVAL), run profile evaluations, generate HTML compliance reports, and produce automated remediation scripts. This lab covers the essential tools used in government, banking, and regulated-industry compliance workflows.


Step 1 — SCAP Architecture Overview

SCAP is a suite of interrelated standards:

Component
Purpose
File Type

XCCDF

Security checklists (benchmarks)

*.xml

OVAL

System state definitions

*oval*.xml

CVE

Vulnerability identifiers

CVSS

Vulnerability scoring

CPE

Platform naming

💡 Tip: XCCDF documents reference OVAL definitions. oscap evaluates the XCCDF checklist by running OVAL tests against the live system.

apt-get update -qq && apt-get install -y -qq \
  libopenscap8 openscap-utils 2>/dev/null

oscap --version

📸 Verified Output:


Step 2 — Install SCAP Security Guide Content

The SCAP Security Guide (SSG) provides pre-built XCCDF benchmarks for Ubuntu, RHEL, and more.

📸 Verified Output:

💡 Tip: The -ds.xml (DataStream) file is self-contained and preferred for automated scanning — it bundles XCCDF, OVAL, and CPE in one file.


Step 3 — Explore SCAP Content with oscap info

Before scanning, inspect available benchmarks and profiles:

📸 Verified Output:


Step 4 — Run an XCCDF Compliance Evaluation

📸 Verified Output:

💡 Tip: Exit code 2 = scan completed but some rules failed (not a tool error). Exit code 1 = tool error.


Step 5 — Parse Results & Generate Summary

📸 Verified Output:


Step 6 — Generate Remediation Script

OpenSCAP can automatically generate a remediation bash script:

📸 Verified Output:

💡 Tip: Review the remediation script before running! Some fixes may not be appropriate for your environment. Run --dry-run or test in a staging container first.


Step 7 — CVE Scanning with OVAL Definitions

OVAL definitions allow CVE-specific vulnerability scanning:

📸 Verified Output:


Step 8 — Capstone: Automated Compliance Pipeline

Build a complete compliance automation pipeline that scans, reports, and remediates:

📸 Verified Output:


Summary

Task
Command
Output

Inspect SCAP content

oscap info ssg-ubuntu2204-ds.xml

Available profiles

Run compliance scan

oscap xccdf eval --profile <id> ...

results.xml + report.html

Count pass/fail

Parse results.xml with Python

Compliance percentage

Generate remediation

oscap xccdf generate fix --fix-type bash

remediaton shell script

CVE scanning

oscap oval eval <oval-file>

Vulnerable package list

Guide document

oscap xccdf generate guide

HTML hardening guide

Last updated