Blame SOURCES/sos-bz1741330-openswan-to-libreswan.patch

1b1872
From b061168bdae759c88e9ef93f3620edae404e69fe Mon Sep 17 00:00:00 2001
1b1872
From: Stepan Broz <sbroz@redhat.com>
1b1872
Date: Thu, 26 Sep 2019 12:56:00 +0200
1b1872
Subject: [PATCH] [libreswan] New plugin for "libreswan" IPsec
1b1872
1b1872
The "libreswan" package is replacing "openswan" in many distributions.
1b1872
This plugin is replacing the original "openswan" plugin that it is
1b1872
based on.
1b1872
1b1872
This plugin will now run for both "libreswan" and "openswan" packages,
1b1872
or when the configuration file "/etc/ipsec.conf" is present.
1b1872
1b1872
Data collected now include configuration, current status, XFRM policy
1b1872
and state, XFRM statistics, basic information about certificates and
1b1872
the NSS database.
1b1872
1b1872
No private data (keys, certificates, secrets) are collected, authenti-
1b1872
cation and encryption keys are removed from the output of
1b1872
"ip xfrm state", and also from "ipsec barf" when running with the
1b1872
"ipsec-barf" option set.
1b1872
1b1872
Signed-off-by: Stepan Broz <sbroz@redhat.com>
1b1872
---
1b1872
 sos/plugins/{openswan.py => libreswan.py} | 37 ++++++++++++++++++-----
1b1872
 1 file changed, 30 insertions(+), 7 deletions(-)
1b1872
 rename sos/plugins/{openswan.py => libreswan.py} (50%)
1b1872
1b1872
diff --git a/sos/plugins/openswan.py b/sos/plugins/libreswan.py
1b1872
similarity index 50%
1b1872
rename from sos/plugins/openswan.py
1b1872
rename to sos/plugins/libreswan.py
1b1872
index ce5581320..717329b87 100644
1b1872
--- a/sos/plugins/openswan.py
1b1872
+++ b/sos/plugins/libreswan.py
1b1872
@@ -1,4 +1,5 @@
1b1872
 # Copyright (C) 2007 Sadique Puthen <sputhenp@redhat.com>
1b1872
+# Copyright (C) 2019 Red Hat Inc., Stepan Broz <sbroz@redhat.com>
1b1872
 
1b1872
 # This file is part of the sos project: https://github.com/sosreport/sos
1b1872
 #
1b1872
@@ -11,29 +12,38 @@
1b1872
 from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
1b1872
 
1b1872
 
1b1872
-class Openswan(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
1b1872
-    """Openswan IPsec
1b1872
+class Libreswan(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
1b1872
+    """Libreswan IPsec
1b1872
     """
1b1872
 
1b1872
-    plugin_name = 'openswan'
1b1872
-    profiles = ('network', 'security')
1b1872
+    plugin_name = 'libreswan'
1b1872
+    profiles = ('network', 'security', 'openshift')
1b1872
     option_list = [
1b1872
         ("ipsec-barf", "collect the output of the ipsec barf command",
1b1872
          "slow", False)
1b1872
     ]
1b1872
 
1b1872
     files = ('/etc/ipsec.conf',)
1b1872
-    packages = ('openswan', 'libreswan')
1b1872
+    packages = ('libreswan', 'openswan')
1b1872
 
1b1872
     def setup(self):
1b1872
         self.add_copy_spec([
1b1872
             "/etc/ipsec.conf",
1b1872
-            "/etc/ipsec.d"
1b1872
+            "/etc/ipsec.d",
1b1872
+            "/proc/net/xfrm_stat"
1b1872
         ])
1b1872
 
1b1872
         # although this is 'verification' it's normally a very quick
1b1872
         # operation so is not conditional on --verify
1b1872
-        self.add_cmd_output("ipsec verify")
1b1872
+        self.add_cmd_output([
1b1872
+            'ipsec verify',
1b1872
+            'ipsec whack --status',
1b1872
+            'ipsec whack --listall',
1b1872
+            'certutil -L -d sql:/etc/ipsec.d',
1b1872
+            'ip xfrm policy',
1b1872
+            'ip xfrm state'
1b1872
+        ])
1b1872
+
1b1872
         if self.get_option("ipsec-barf"):
1b1872
             self.add_cmd_output("ipsec barf")
1b1872
 
1b1872
@@ -44,4 +54,17 @@ def setup(self):
1b1872
             '/etc/ipsec.d/*.secrets'
1b1872
         ])
1b1872
 
1b1872
+    def postproc(self):
1b1872
+        # Remove any sensitive data.
1b1872
+        # "ip xfrm state" output contains encryption or authentication private
1b1872
+        # keys:
1b1872
+        xfrm_state_regexp = r'(aead|auth|auth-trunc|enc)' \
1b1872
+                            r'(\s.*\s)(0x[0-9a-f]+)'
1b1872
+        self.do_cmd_output_sub("state", xfrm_state_regexp,
1b1872
+                               r"\1\2********")
1b1872
+
1b1872
+        if self.get_option("ipsec-barf"):
1b1872
+            self.do_cmd_output_sub("barf", xfrm_state_regexp,
1b1872
+                                   r"\1\2********")
1b1872
+
1b1872
 # vim: set et ts=4 sw=4 :