Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

oscap

OpenSCAP: check RHEL systems and images against security profiles (CIS, DISA STIG, PCI-DSS, ANSSI) and generate fixes.

Niveau
DevSecOps-service
Groep
Beveiligingsscans en hardening
Root nodig
Ja
Pakket
openscap-scanner

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

oscap evaluates SCAP content: the SCAP Security Guide package (scap-security-guide) ships data streams with profiles for each RHEL version. A scan gives an HTML report with pass/fail per rule and can create remediation as a Bash script, an Ansible playbook or a blueprint for image builder. oscap-podman scans container images; the RHEL installer can apply a profile at install time.

This is the Red Hat way to show compliance to auditors.

Zo schrijf je het

oscap xccdf eval --profile PROFILE [--results FILE] [--report FILE] DATASTREAM
oscap info DATASTREAM

Belangrijkste delen

Commands

info FILE
List profiles in a data stream.
xccdf eval
Run a scan.
xccdf generate fix
Make a remediation script/playbook.
xccdf generate guide
Make a guide (all rules of a profile).
oval eval
Run OVAL checks (e.g. CVE data).
oscap-podman IMAGE xccdf eval …
Scan a container image.

Opties 7

Meest gebruikt

Flags

--profile ID
Profile (e.g. xccdf_org.ssgproject.content_profile_cis).
--results FILE.xml
ARF/XCCDF results.
--report FILE.html
HTML report.
--remediate
Fix while scanning (careful!).
--fix-type bash|ansible|blueprint
Kind of fix (generate fix).
--rule ID
Only one rule.
--tailoring-file FILE
Your changes to a profile.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1Install and list the profiles

    dnf install -y openscap-scanner scap-security-guide
    oscap info /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml | grep -i "profile" | head -30
  2. 2Scan against CIS Level 1 Server

    oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis_server_l1 --results results.xml --report report.html /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
  3. 3Count failed rules

    grep -c 'result>fail<' results.xml
    xmllint --xpath "count(//*[local-name()='rule-result'][*[local-name()='result']='fail'])" results.xml
  4. 4Make an Ansible playbook with the fixes

    oscap xccdf generate fix --fix-type ansible --profile xccdf_org.ssgproject.content_profile_cis_server_l1 --output cis-fix.yml /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
    ansible-playbook -i inventory.ini cis-fix.yml --check
  5. 5Fixes only for the failed rules

    oscap xccdf generate fix --fix-type bash --result-id xccdf_org.open-scap_testresult_xccdf_org.ssgproject.content_profile_cis_server_l1 --output fix-failed.sh results.xml
  6. 6Check one rule only

    oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis_server_l1 --rule xccdf_org.ssgproject.content_rule_sshd_disable_root_login /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
  7. 7Scan a container image

    oscap-podman registry.access.redhat.com/ubi9/ubi:latest xccdf eval --profile xccdf_org.ssgproject.content_profile_cis_server_l1 --report ubi9.html /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
  8. 8Check for known CVEs (Red Hat OVAL)

    curl -sO https://security.access.redhat.com/data/oval/v2/RHEL9/rhel-9.oval.xml.bz2 && bunzip2 rhel-9.oval.xml.bz2
    oscap oval eval --report cve-report.html rhel-9.oval.xml
  9. 9Use the graphical workbench to tailor a profile

    dnf install -y scap-workbench
  10. 10Apply a profile at install time (kickstart)

    cat ks.cfg
    %addon com_redhat_oscap
        content-type = scap-security-guide
        profile = xccdf_org.ssgproject.content_profile_cis_server_l1
    %end

Let op

  • --remediate changes the system at once (SSH, passwords, mounts) — test on a copy first.
  • Profiles are long; tailor them (skip rules that do not fit) and document why.

Bestanden

/usr/share/xml/scap/ssg/content/
Data streams (ssg-rhel9-ds.xml, ssg-rhel10-ds.xml).

Tips om te onthouden

  • Run the scan in CI on the golden image; keep the HTML reports as evidence for audits.

Exitcodes

0All rules passed.
1Error.
2At least one rule failed (or unknown).