[PATCH 13/13] remediation + OVAL for sshd_enable_warning_banner

Shawn Wells shawn.d.wells at gmail.com
Sat Sep 7 19:23:36 UTC 2013


-------------- next part --------------
>From 841ba81777fe7089a31e16ca07f249264648cced Mon Sep 17 00:00:00 2001
From: Shawn Wells <shawn at redhat.com>
Date: Sat, 7 Sep 2013 12:47:15 -0400
Subject: [PATCH 13/13] remediation + OVAL for sshd_enable_warning_banner
 - Updated OVAL namings to match XCCDF
 - filename --> filepath
 - added remediation

Remediation testing:
[root at rhel6 checks]# ./testcheck.py sshd_enable_warning_banner.xml
Evaluating with OVAL tempfile : /tmp/sshd_enable_warning_bannerdDNEzj.xml
Writing results to : /tmp/sshd_enable_warning_bannerdDNEzj.xml-results
Definition oval:scap-security-guide.testing:def:176: true
Definition oval:scap-security-guide.testing:def:127: false
Definition oval:scap-security-guide.testing:def:125: false
Evaluation done.
[root at rhel6 checks]# vim /etc/ssh/sshd_config
[root at rhel6 checks]# ./testcheck.py sshd_enable_warning_banner.xml
Evaluating with OVAL tempfile : /tmp/sshd_enable_warning_banner8h0nEu.xml
Writing results to : /tmp/sshd_enable_warning_banner8h0nEu.xml-results
Definition oval:scap-security-guide.testing:def:176: false
Definition oval:scap-security-guide.testing:def:127: false
Definition oval:scap-security-guide.testing:def:125: false
Evaluation done.
---
 RHEL6/input/checks/sshd_banner_set.xml             |   31 --------------------
 RHEL6/input/checks/sshd_enable_warning_banner.xml  |   30 +++++++++++++++++++
 .../input/fixes/bash/sshd_enable_warning_banner.sh |    5 +++
 RHEL6/input/services/ssh.xml                       |    2 +-
 4 files changed, 36 insertions(+), 32 deletions(-)
 delete mode 100644 RHEL6/input/checks/sshd_banner_set.xml
 create mode 100644 RHEL6/input/checks/sshd_enable_warning_banner.xml
 create mode 100644 RHEL6/input/fixes/bash/sshd_enable_warning_banner.sh

diff --git a/RHEL6/input/checks/sshd_banner_set.xml b/RHEL6/input/checks/sshd_banner_set.xml
deleted file mode 100644
index fca2781..0000000
--- a/RHEL6/input/checks/sshd_banner_set.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<def-group>
-  <definition class="compliance" id="sshd_banner_set" version="1">
-    <metadata>
-      <title>Enable a Warning Banner</title>
-      <affected family="unix">
-        <platform>Red Hat Enterprise Linux 6</platform>
-      </affected>
-      <description>SSH warning banner should be enabled (and dependencies are
-      met)</description>
-      <reference source="MED" ref_id="20130813" ref_url="test_attestation" />
-    </metadata>
-    <criteria comment="SSH is not being used or conditions are met"
-    operator="OR">
-      <extend_definition comment="sshd service is disabled"
-      definition_ref="service_sshd_disabled" />
-      <criterion comment="Check Banner in /etc/ssh/sshd_config"
-      test_ref="test_sshd_banner_set" />
-    </criteria>
-  </definition>
-  <ind:textfilecontent54_test check="all" check_existence="all_exist"
-  comment="Tests the value of the Banner[\s]+/etc/issue setting in the /etc/ssh/sshd_config file"
-  id="test_sshd_banner_set" version="1">
-    <ind:object object_ref="obj_sshd_banner_set" />
-  </ind:textfilecontent54_test>
-  <ind:textfilecontent54_object id="obj_sshd_banner_set" version="1">
-    <ind:path>/etc/ssh</ind:path>
-    <ind:filename>sshd_config</ind:filename>
-    <ind:pattern operation="pattern match">^[\s]*(?i)Banner(?-i)[\s]+/etc/issue[\s]*$</ind:pattern>
-    <ind:instance datatype="int">1</ind:instance>
-  </ind:textfilecontent54_object>
-</def-group>
diff --git a/RHEL6/input/checks/sshd_enable_warning_banner.xml b/RHEL6/input/checks/sshd_enable_warning_banner.xml
new file mode 100644
index 0000000..9e4fa8a
--- /dev/null
+++ b/RHEL6/input/checks/sshd_enable_warning_banner.xml
@@ -0,0 +1,30 @@
+<def-group>
+  <definition class="compliance" id="sshd_enable_warning_banner" version="1">
+    <metadata>
+      <title>Enable a Warning Banner</title>
+      <affected family="unix">
+        <platform>Red Hat Enterprise Linux 6</platform>
+      </affected>
+      <description>SSH warning banner should be enabled (and dependencies are
+      met)</description>
+      <reference source="MED" ref_id="20130813" ref_url="test_attestation" />
+    </metadata>
+    <criteria comment="SSH is not being used or conditions are met"
+    operator="OR">
+      <extend_definition comment="sshd service is disabled"
+      definition_ref="service_sshd_disabled" />
+      <criterion comment="Check Banner in /etc/ssh/sshd_config"
+      test_ref="test_sshd_banner_set" />
+    </criteria>
+  </definition>
+  <ind:textfilecontent54_test check="all" check_existence="all_exist"
+  comment="Tests the value of the Banner[\s]+/etc/issue setting in the /etc/ssh/sshd_config file"
+  id="test_sshd_banner_set" version="1">
+    <ind:object object_ref="obj_sshd_banner_set" />
+  </ind:textfilecontent54_test>
+  <ind:textfilecontent54_object id="obj_sshd_banner_set" version="1">
+    <ind:filepath>/etc/ssh/sshd_config</ind:filepath>
+    <ind:pattern operation="pattern match">^[\s]*(?i)Banner(?-i)[\s]+/etc/issue[\s]*$</ind:pattern>
+    <ind:instance datatype="int">1</ind:instance>
+  </ind:textfilecontent54_object>
+</def-group>
diff --git a/RHEL6/input/fixes/bash/sshd_enable_warning_banner.sh b/RHEL6/input/fixes/bash/sshd_enable_warning_banner.sh
new file mode 100644
index 0000000..b1ad28f
--- /dev/null
+++ b/RHEL6/input/fixes/bash/sshd_enable_warning_banner.sh
@@ -0,0 +1,5 @@
+grep -q ^Banner /etc/ssh/sshd_config && \
+  sed -i "s/Banner.*/Banner \/etc\/issue/g" /etc/ssh/sshd_config
+if ! [ $? -eq 0 ]; then
+    echo "Banner /etc/issue" >> /etc/ssh/sshd_config
+fi
diff --git a/RHEL6/input/services/ssh.xml b/RHEL6/input/services/ssh.xml
index b468f15..d010c7b 100644
--- a/RHEL6/input/services/ssh.xml
+++ b/RHEL6/input/services/ssh.xml
@@ -311,7 +311,7 @@ whose ownership should not be obvious should ensure usage of a banner that does
 not provide easy attribution.
 </rationale>
 <ident cce="27112-2" />
-<oval id="sshd_banner_set" />
+<oval id="sshd_enable_warning_banner" />
 <ref disa="48" />
 <tested by="DS" on="20121024"/>
 </Rule>
-- 
1.7.1



More information about the scap-security-guide mailing list