Hi Spacewalkers,
I have added a few completely new openscap functions to spacecmd. The
new file scap.py contains the new functions:
scap_getxccdfscandetails
scap_getxccdfscanruleresults
scap_listxccdfscans
scap_schedulexccdfscan
Can you review and add this patch upstream.
Cheers,
Gregor Grüner
From 297a9818d98864e6549429c79af983bbd75466c5 Mon Sep 17 00:00:00 2001
From: Gregor Gruener ggru...@redhat.com
Date: Mon, 5 Aug 2013 19:50:12 +0200
Subject: [PATCH] Added new scap features into spacecmd
---
spacecmd/spacecmd.spec| 11 +++-
spacecmd/src/lib/scap.py | 158 ++
spacecmd/src/lib/shell.py | 2 +-
3 files changed, 168 insertions(+), 3 deletions(-)
create mode 100644 spacecmd/src/lib/scap.py
diff --git a/spacecmd/spacecmd.spec b/spacecmd/spacecmd.spec
index ecb6b23..5b2d82d 100644
--- a/spacecmd/spacecmd.spec
+++ b/spacecmd/spacecmd.spec
@@ -64,8 +64,15 @@ touch %{buildroot}/%{python_sitelib}/spacecmd/__init__.py
%doc %{_mandir}/man1/spacecmd.1.gz
%changelog
-* Mon Aug 05 2013 Gregor Gruener ggru...@redhat.com
-- spacecmd - add new function is_monitoringenabled and list_proxies
+* Mon Aug 05 2013 Gregor Gruener ggru...@redhat.com 2.1.3-1
+- add new function scap_listxccdfscans
+- add new function scap_getxccdfscandetails
+- add new function scap_getxccdfscanruleresults
+- add new function scap_schedulexccdfscan
+
+* Mon Aug 05 2013 Gregor Gruener ggru...@redhat.com 2.1.2-1
+- add new function is_monitoringenabled
+- add new function list_proxies
* Mon Jul 22 2013 Gregor Gruener ggru...@redhat.com 2.1.1-1
- add new function custominfo_updatekey
diff --git a/spacecmd/src/lib/scap.py b/spacecmd/src/lib/scap.py
new file mode 100644
index 000..4be6512
--- /dev/null
+++ b/spacecmd/src/lib/scap.py
@@ -0,0 +1,158 @@
+#
+# Licensed under the GNU General Public License Version 3
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright 2013 Aron Parsons aronpars...@gmail.com
+# Copyright (c) 2013 Red Hat, Inc.
+#
+
+# NOTE: the 'self' variable is an instance of SpacewalkShell
+
+from optparse import Option
+from spacecmd.utils import *
+
+def help_scap_listxccdfscans(self):
+print 'scap_listxccdfscans: Return a list of finished OpenSCAP scans for given systems'
+print 'usage: scap_listxccdfscans SYSTEMS'
+
+def complete_system_scap_listxccdfscans(self, text, line, beg, end):
+return self.tab_complete_systems(text)
+
+def do_scap_listxccdfscans(self, args):
+(args, options) = parse_arguments(args)
+
+if not len(args):
+self.help_scap_listxccdfscans()
+return
+
+# use the systems listed in the SSM
+if re.match('ssm', args[0], re.I):
+systems = self.ssm.keys()
+else:
+systems = self.expand_systems(args)
+
+add_separator = False
+
+for system in sorted(systems):
+if add_separator: print self.SEPARATOR
+add_separator = True
+
+if len(systems) 1:
+print 'System: %s' % system
+print
+
+system_id = self.get_system_id(system)
+if not system_id: continue
+
+scan_list = self.client.system.scap.listXccdfScans(self.session, system_id)
+
+for s in scan_list:
+print 'XID: %d Profile: %s Path: (%s) Completed: %s' % (s['xid'], s['profile'], s['path'], s['completed'])
+
+
+
+def help_scap_getxccdfscanruleresults(self):
+print 'scap_getxccdfscanruleresults: Return a full list of RuleResults for given OpenSCAP XCCDF scan'
+print 'usage: scap_getxccdfscanruleresults XID'
+
+def do_scap_getxccdfscanruleresults(self, args):
+(args, options) = parse_arguments(args)
+
+if not len(args):
+self.help_scap_getxccdfscanruleresults()
+return
+
+add_separator = False
+
+for xid in args:
+if add_separator: print self.SEPARATOR
+add_separator = True
+
+if len(args) 1:
+print 'XID: %s' % xid
+print
+
+xid = int(xid)
+scan_results = self.client.system.scap.getXccdfScanRuleResults(self.session, xid)
+
+for s in scan_results:
+print 'IDref: %s Result: %s Idents: (%s)' % (s['idref'], s['result'], s['idents'])
+
+
+
+def help_scap_getxccdfscandetails(self):
+print